(rest) - added broadcast for links,configs,exceptions,files and fixed edit node (gui) - added handling of broadcast links, different rendering for wireless links, removal of wirelesss links on stop
This commit is contained in:
parent
e7a56cc3ad
commit
f062e2868d
11 changed files with 307 additions and 44 deletions
|
@ -20,6 +20,8 @@ public interface ICoreClient {
|
||||||
|
|
||||||
boolean start() throws IOException;
|
boolean start() throws IOException;
|
||||||
|
|
||||||
|
boolean stop() throws IOException;
|
||||||
|
|
||||||
void updateState(SessionState state);
|
void updateState(SessionState state);
|
||||||
|
|
||||||
boolean setState(SessionState state) throws IOException;
|
boolean setState(SessionState state) throws IOException;
|
||||||
|
@ -56,6 +58,8 @@ public interface ICoreClient {
|
||||||
|
|
||||||
boolean createNode(CoreNode node) throws IOException;
|
boolean createNode(CoreNode node) throws IOException;
|
||||||
|
|
||||||
|
boolean editNode(CoreNode node) throws IOException;
|
||||||
|
|
||||||
boolean deleteNode(CoreNode node) throws IOException;
|
boolean deleteNode(CoreNode node) throws IOException;
|
||||||
|
|
||||||
boolean createLink(CoreLink link) throws IOException;
|
boolean createLink(CoreLink link) throws IOException;
|
||||||
|
|
|
@ -15,6 +15,7 @@ import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class CoreRestClient implements ICoreClient {
|
public class CoreRestClient implements ICoreClient {
|
||||||
|
@ -55,6 +56,10 @@ public class CoreRestClient implements ICoreClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CoreLink link : session.getLinks()) {
|
for (CoreLink link : session.getLinks()) {
|
||||||
|
if (link.getInterfaceOne() != null || link.getInterfaceTwo() != null) {
|
||||||
|
link.setType(LinkTypes.WIRED.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
networkGraph.addLink(link);
|
networkGraph.addLink(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,6 +162,17 @@ public class CoreRestClient implements ICoreClient {
|
||||||
return setState(SessionState.INSTANTIATION);
|
return setState(SessionState.INSTANTIATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean stop() throws IOException {
|
||||||
|
List<CoreLink> wirelessLinks = networkGraph.getGraph().getEdges().stream()
|
||||||
|
.filter(CoreLink::isWireless)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
wirelessLinks.forEach(networkGraph::removeWirelessLink);
|
||||||
|
networkGraph.getGraphViewer().repaint();
|
||||||
|
|
||||||
|
return setState(SessionState.SHUTDOWN);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateState(SessionState state) {
|
public void updateState(SessionState state) {
|
||||||
sessionState = state;
|
sessionState = state;
|
||||||
|
@ -292,6 +308,12 @@ public class CoreRestClient implements ICoreClient {
|
||||||
return WebUtils.postJson(url, node);
|
return WebUtils.postJson(url, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean editNode(CoreNode node) throws IOException {
|
||||||
|
String url = getUrl(String.format("sessions/%s/nodes/%s", sessionId, node.getId()));
|
||||||
|
return WebUtils.putJson(url, node);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteNode(CoreNode node) throws IOException {
|
public boolean deleteNode(CoreNode node) throws IOException {
|
||||||
String url = getUrl(String.format("/sessions/%s/nodes/%s", sessionId, node.getId()));
|
String url = getUrl(String.format("/sessions/%s/nodes/%s", sessionId, node.getId()));
|
||||||
|
|
|
@ -20,6 +20,9 @@ public class CoreLink {
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private boolean visible = true;
|
private boolean visible = true;
|
||||||
|
|
||||||
|
@JsonProperty("message_type")
|
||||||
|
private Integer messageType;
|
||||||
|
|
||||||
private Integer type = 1;
|
private Integer type = 1;
|
||||||
|
|
||||||
@JsonProperty("node_one")
|
@JsonProperty("node_one")
|
||||||
|
@ -41,4 +44,8 @@ public class CoreLink {
|
||||||
this.weight = (float) id;
|
this.weight = (float) id;
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWireless() {
|
||||||
|
return interfaceOne == null && interfaceTwo == null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
31
corefx/src/main/java/com/core/data/LinkTypes.java
Normal file
31
corefx/src/main/java/com/core/data/LinkTypes.java
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package com.core.data;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum LinkTypes {
|
||||||
|
WIRELESS(0),
|
||||||
|
WIRED(1);
|
||||||
|
|
||||||
|
private static final Map<Integer, LinkTypes> LOOKUP = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (LinkTypes state : LinkTypes.values()) {
|
||||||
|
LOOKUP.put(state.getValue(), state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
LinkTypes(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LinkTypes get(int value) {
|
||||||
|
return LOOKUP.get(value);
|
||||||
|
}
|
||||||
|
}
|
36
corefx/src/main/java/com/core/data/MessageFlags.java
Normal file
36
corefx/src/main/java/com/core/data/MessageFlags.java
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
package com.core.data;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public enum MessageFlags {
|
||||||
|
ADD(1),
|
||||||
|
DELETE(2),
|
||||||
|
CRI(4),
|
||||||
|
LOCAL(8),
|
||||||
|
STRING(16),
|
||||||
|
TEXT(32),
|
||||||
|
TTY(64);
|
||||||
|
|
||||||
|
private static final Map<Integer, MessageFlags> LOOKUP = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (MessageFlags state : MessageFlags.values()) {
|
||||||
|
LOOKUP.put(state.getValue(), state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
|
||||||
|
MessageFlags(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getValue() {
|
||||||
|
return this.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MessageFlags get(int value) {
|
||||||
|
return LOOKUP.get(value);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,7 @@
|
||||||
package com.core.graph;
|
package com.core.graph;
|
||||||
|
|
||||||
import com.core.Controller;
|
import com.core.Controller;
|
||||||
import com.core.data.CoreInterface;
|
import com.core.data.*;
|
||||||
import com.core.data.CoreLink;
|
|
||||||
import com.core.data.CoreNode;
|
|
||||||
import com.core.data.NodeType;
|
|
||||||
import com.core.ui.Toast;
|
import com.core.ui.Toast;
|
||||||
import com.core.utils.IconUtils;
|
import com.core.utils.IconUtils;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -20,6 +17,7 @@ import edu.uci.ics.jung.visualization.annotations.AnnotationControls;
|
||||||
import edu.uci.ics.jung.visualization.control.EditingModalGraphMouse;
|
import edu.uci.ics.jung.visualization.control.EditingModalGraphMouse;
|
||||||
import edu.uci.ics.jung.visualization.control.GraphMouseListener;
|
import edu.uci.ics.jung.visualization.control.GraphMouseListener;
|
||||||
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
|
import edu.uci.ics.jung.visualization.control.ModalGraphMouse;
|
||||||
|
import edu.uci.ics.jung.visualization.decorators.EdgeShape;
|
||||||
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
import edu.uci.ics.jung.visualization.renderers.Renderer;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.apache.commons.net.util.SubnetUtils;
|
import org.apache.commons.net.util.SubnetUtils;
|
||||||
|
@ -30,7 +28,6 @@ import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.geom.Ellipse2D;
|
import java.awt.geom.Ellipse2D;
|
||||||
import java.awt.geom.Rectangle2D;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -90,9 +87,25 @@ public class NetworkGraph {
|
||||||
});
|
});
|
||||||
|
|
||||||
// edge render properties
|
// edge render properties
|
||||||
renderContext.setEdgeStrokeTransformer(edge -> new BasicStroke(1));
|
renderContext.setEdgeStrokeTransformer(edge -> {
|
||||||
renderContext.setEdgeShapeTransformer(edge -> new Rectangle2D.Float(0, 0, 1, 10));
|
LinkTypes linkType = LinkTypes.get(edge.getType());
|
||||||
renderContext.setEdgeFillPaintTransformer(edge -> Color.BLACK);
|
if (LinkTypes.WIRELESS == linkType) {
|
||||||
|
float[] dash = {15.0f};
|
||||||
|
return new BasicStroke(5, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND,
|
||||||
|
0, dash, 0);
|
||||||
|
} else {
|
||||||
|
return new BasicStroke(5);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
renderContext.setEdgeShapeTransformer(EdgeShape.line(graph));
|
||||||
|
renderContext.setEdgeDrawPaintTransformer(edge -> {
|
||||||
|
LinkTypes linkType = LinkTypes.get(edge.getType());
|
||||||
|
if (LinkTypes.WIRELESS == linkType) {
|
||||||
|
return Color.BLUE;
|
||||||
|
} else {
|
||||||
|
return Color.BLACK;
|
||||||
|
}
|
||||||
|
});
|
||||||
renderContext.setEdgeIncludePredicate(predicate -> predicate.element.isVisible());
|
renderContext.setEdgeIncludePredicate(predicate -> predicate.element.isVisible());
|
||||||
|
|
||||||
graphViewer.setVertexToolTipTransformer(renderContext.getVertexLabelTransformer());
|
graphViewer.setVertexToolTipTransformer(renderContext.getVertexLabelTransformer());
|
||||||
|
@ -144,6 +157,15 @@ public class NetworkGraph {
|
||||||
logger.debug("graph moved node({}): {},{}", node.getName(), x, y);
|
logger.debug("graph moved node({}): {},{}", node.getName(), x, y);
|
||||||
node.getPosition().setX(x);
|
node.getPosition().setX(x);
|
||||||
node.getPosition().setY(y);
|
node.getPosition().setY(y);
|
||||||
|
|
||||||
|
// upate node when session is active
|
||||||
|
if (controller.getCoreClient().isRunning()) {
|
||||||
|
try {
|
||||||
|
controller.getCoreClient().editNode(node);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.error("failed to update node location");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -224,7 +246,7 @@ public class NetworkGraph {
|
||||||
link.setInterfaceTwo(interfaceTwo);
|
link.setInterfaceTwo(interfaceTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isVisible = !isWirelessLink(nodeOne, nodeTwo);
|
boolean isVisible = !checkForWirelessNode(nodeOne, nodeTwo);
|
||||||
link.setVisible(isVisible);
|
link.setVisible(isVisible);
|
||||||
|
|
||||||
logger.info("adding user created edge: {}", link);
|
logger.info("adding user created edge: {}", link);
|
||||||
|
@ -342,7 +364,7 @@ public class NetworkGraph {
|
||||||
return node.getType() == NodeType.EMANE || node.getType() == NodeType.WLAN;
|
return node.getType() == NodeType.EMANE || node.getType() == NodeType.WLAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isWirelessLink(CoreNode nodeOne, CoreNode nodeTwo) {
|
private boolean checkForWirelessNode(CoreNode nodeOne, CoreNode nodeTwo) {
|
||||||
boolean result = isWirelessNode(nodeOne);
|
boolean result = isWirelessNode(nodeOne);
|
||||||
return result || isWirelessNode(nodeTwo);
|
return result || isWirelessNode(nodeTwo);
|
||||||
}
|
}
|
||||||
|
@ -363,12 +385,23 @@ public class NetworkGraph {
|
||||||
CoreNode nodeOne = nodeMap.get(link.getNodeOne());
|
CoreNode nodeOne = nodeMap.get(link.getNodeOne());
|
||||||
CoreNode nodeTwo = nodeMap.get(link.getNodeTwo());
|
CoreNode nodeTwo = nodeMap.get(link.getNodeTwo());
|
||||||
|
|
||||||
boolean isVisible = !isWirelessLink(nodeOne, nodeTwo);
|
boolean isVisible = !checkForWirelessNode(nodeOne, nodeTwo);
|
||||||
link.setVisible(isVisible);
|
link.setVisible(isVisible);
|
||||||
|
|
||||||
graph.addEdge(link, nodeOne, nodeTwo);
|
graph.addEdge(link, nodeOne, nodeTwo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeWirelessLink(CoreLink link) {
|
||||||
|
logger.info("deleting link: {}", link);
|
||||||
|
CoreNode nodeOne = nodeMap.get(link.getNodeOne());
|
||||||
|
CoreNode nodeTwo = nodeMap.get(link.getNodeTwo());
|
||||||
|
|
||||||
|
CoreLink existingLink = graph.findEdge(nodeOne, nodeTwo);
|
||||||
|
if (existingLink != null) {
|
||||||
|
graph.removeEdge(existingLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void removeLink(CoreLink link) {
|
public void removeLink(CoreLink link) {
|
||||||
graphViewer.getPickedEdgeState().pick(link, false);
|
graphViewer.getPickedEdgeState().pick(link, false);
|
||||||
graph.removeEdge(link);
|
graph.removeEdge(link);
|
||||||
|
|
|
@ -2,7 +2,6 @@ package com.core.ui;
|
||||||
|
|
||||||
import com.core.Controller;
|
import com.core.Controller;
|
||||||
import com.core.data.NodeType;
|
import com.core.data.NodeType;
|
||||||
import com.core.data.SessionState;
|
|
||||||
import com.core.utils.IconUtils;
|
import com.core.utils.IconUtils;
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXListView;
|
import com.jfoenix.controls.JFXListView;
|
||||||
|
@ -266,7 +265,7 @@ public class GraphToolbar extends VBox {
|
||||||
|
|
||||||
private void stopSession() {
|
private void stopSession() {
|
||||||
try {
|
try {
|
||||||
boolean result = controller.getCoreClient().setState(SessionState.SHUTDOWN);
|
boolean result = controller.getCoreClient().stop();
|
||||||
if (result) {
|
if (result) {
|
||||||
controller.sessionStopped();
|
controller.sessionStopped();
|
||||||
Toast.success("Session Stopped");
|
Toast.success("Session Stopped");
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
package com.core.websocket;
|
package com.core.websocket;
|
||||||
|
|
||||||
import com.core.Controller;
|
import com.core.Controller;
|
||||||
import com.core.data.CoreEvent;
|
import com.core.data.*;
|
||||||
import com.core.data.CoreNode;
|
|
||||||
import com.core.data.SessionState;
|
|
||||||
import com.core.utils.JsonUtils;
|
import com.core.utils.JsonUtils;
|
||||||
import io.socket.client.IO;
|
import io.socket.client.IO;
|
||||||
import io.socket.client.Socket;
|
import io.socket.client.Socket;
|
||||||
|
@ -27,7 +25,16 @@ public class CoreWebSocket {
|
||||||
socket.on(Socket.EVENT_CONNECT, args -> {
|
socket.on(Socket.EVENT_CONNECT, args -> {
|
||||||
logger.info("connected to web socket");
|
logger.info("connected to web socket");
|
||||||
});
|
});
|
||||||
socket.on("node", args -> {
|
socket.on("node", this::handleNodes);
|
||||||
|
socket.on("event", this::handleEvents);
|
||||||
|
socket.on("config", this::handleConfigs);
|
||||||
|
socket.on("link", this::handleLinks);
|
||||||
|
socket.on(Socket.EVENT_DISCONNECT, args -> {
|
||||||
|
logger.info("disconnected from web socket");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleNodes(Object... args) {
|
||||||
for (Object arg : args) {
|
for (Object arg : args) {
|
||||||
try {
|
try {
|
||||||
CoreNode node = JsonUtils.read(arg.toString(), CoreNode.class);
|
CoreNode node = JsonUtils.read(arg.toString(), CoreNode.class);
|
||||||
|
@ -37,12 +44,13 @@ public class CoreWebSocket {
|
||||||
logger.error("error getting core node", ex);
|
logger.error("error getting core node", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
socket.on("event", args -> {
|
|
||||||
|
private void handleEvents(Object... args) {
|
||||||
for (Object arg : args) {
|
for (Object arg : args) {
|
||||||
try {
|
try {
|
||||||
CoreEvent event = JsonUtils.read(arg.toString(), CoreEvent.class);
|
CoreEvent event = JsonUtils.read(arg.toString(), CoreEvent.class);
|
||||||
logger.info("core event: {}", event);
|
logger.info("handling broadcast event: {}", event);
|
||||||
SessionState state = SessionState.get(event.getEventType().getValue());
|
SessionState state = SessionState.get(event.getEventType().getValue());
|
||||||
if (state != null) {
|
if (state != null) {
|
||||||
logger.info("event updating session state: {}", state);
|
logger.info("event updating session state: {}", state);
|
||||||
|
@ -52,10 +60,32 @@ public class CoreWebSocket {
|
||||||
logger.error("error getting core event", ex);
|
logger.error("error getting core event", ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
socket.on(Socket.EVENT_DISCONNECT, args -> {
|
|
||||||
logger.info("disconnected from web socket");
|
private void handleLinks(Object... args) {
|
||||||
});
|
for (Object arg : args) {
|
||||||
|
try {
|
||||||
|
CoreLink link = JsonUtils.read(arg.toString(), CoreLink.class);
|
||||||
|
logger.info("handling broadcast link: {}", link);
|
||||||
|
MessageFlags flag = MessageFlags.get(link.getMessageType());
|
||||||
|
if (MessageFlags.DELETE == flag) {
|
||||||
|
logger.info("delete");
|
||||||
|
controller.getNetworkGraph().removeWirelessLink(link);
|
||||||
|
} else if (MessageFlags.ADD == flag) {
|
||||||
|
link.setLoaded(true);
|
||||||
|
controller.getNetworkGraph().addLink(link);
|
||||||
|
}
|
||||||
|
controller.getNetworkGraph().getGraphViewer().repaint();
|
||||||
|
} catch (IOException ex) {
|
||||||
|
logger.error("error handling broadcast link", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleConfigs(Object... args) {
|
||||||
|
for (Object arg : args) {
|
||||||
|
logger.info("handling broadcast config: {}", arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
|
|
|
@ -56,8 +56,9 @@ def edit_node(session_id, node_id):
|
||||||
data = request.get_json() or {}
|
data = request.get_json() or {}
|
||||||
|
|
||||||
node_options = NodeOptions()
|
node_options = NodeOptions()
|
||||||
x = data.get("x")
|
node_position = data["position"]
|
||||||
y = data.get("y")
|
x = node_position["x"]
|
||||||
|
y = node_position["y"]
|
||||||
node_options.set_position(x, y)
|
node_options.set_position(x, y)
|
||||||
lat = data.get("lat")
|
lat = data.get("lat")
|
||||||
lon = data.get("lon")
|
lon = data.get("lon")
|
||||||
|
|
|
@ -39,6 +39,10 @@ def create_session():
|
||||||
# add handlers
|
# add handlers
|
||||||
session.event_handlers.append(websocket_routes.broadcast_event)
|
session.event_handlers.append(websocket_routes.broadcast_event)
|
||||||
session.node_handlers.append(websocket_routes.broadcast_node)
|
session.node_handlers.append(websocket_routes.broadcast_node)
|
||||||
|
session.config_handlers.append(websocket_routes.broadcast_config)
|
||||||
|
session.link_handlers.append(websocket_routes.broadcast_link)
|
||||||
|
session.exception_handlers.append(websocket_routes.broadcast_exception)
|
||||||
|
session.file_handlers.append(websocket_routes.broadtcast_file)
|
||||||
|
|
||||||
response_data = jsonify(
|
response_data = jsonify(
|
||||||
id=session.session_id,
|
id=session.session_id,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from flask_socketio import SocketIO
|
from flask_socketio import SocketIO
|
||||||
|
|
||||||
|
import core_utils
|
||||||
from core import logger
|
from core import logger
|
||||||
|
|
||||||
socketio = None
|
socketio = None
|
||||||
|
@ -18,6 +19,101 @@ def register(app):
|
||||||
logger.info("websocket client disconnected")
|
logger.info("websocket client disconnected")
|
||||||
|
|
||||||
|
|
||||||
|
def broadtcast_file(file_data):
|
||||||
|
socketio.emit("file", {
|
||||||
|
"message_type": file_data.message_type,
|
||||||
|
"node": file_data.node,
|
||||||
|
"name": file_data.name,
|
||||||
|
"mode": file_data.mode,
|
||||||
|
"number": file_data.number,
|
||||||
|
"type": file_data.type,
|
||||||
|
"source": file_data.source,
|
||||||
|
"session": file_data.session,
|
||||||
|
"data": file_data.data,
|
||||||
|
"compressed_data": file_data.compressed_data
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def broadcast_exception(exception_data):
|
||||||
|
socketio.emit("exception", {
|
||||||
|
"node": exception_data.node,
|
||||||
|
"session": exception_data.session,
|
||||||
|
"level": exception_data.level,
|
||||||
|
"source": exception_data.source,
|
||||||
|
"date": exception_data.date,
|
||||||
|
"text": exception_data.text,
|
||||||
|
"opaque": exception_data.opaque
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def broadcast_link(link_data):
|
||||||
|
logger.info("broadcasting link")
|
||||||
|
interface_one = None
|
||||||
|
if link_data.interface1_id is not None:
|
||||||
|
interface_one = {
|
||||||
|
"id": link_data.interface1_id,
|
||||||
|
"name": link_data.interface1_name,
|
||||||
|
"mac": core_utils.convert_value(link_data.interface1_mac),
|
||||||
|
"ip4": core_utils.convert_value(link_data.interface1_ip4),
|
||||||
|
"ip4mask": link_data.interface1_ip4_mask,
|
||||||
|
"ip6": core_utils.convert_value(link_data.interface1_ip6),
|
||||||
|
"ip6mask": link_data.interface1_ip6_mask,
|
||||||
|
}
|
||||||
|
|
||||||
|
interface_two = None
|
||||||
|
if link_data.interface2_id is not None:
|
||||||
|
interface_two = {
|
||||||
|
"id": link_data.interface2_id,
|
||||||
|
"name": link_data.interface2_name,
|
||||||
|
"mac": core_utils.convert_value(link_data.interface2_mac),
|
||||||
|
"ip4": core_utils.convert_value(link_data.interface2_ip4),
|
||||||
|
"ip4mask": link_data.interface2_ip4_mask,
|
||||||
|
"ip6": core_utils.convert_value(link_data.interface2_ip6),
|
||||||
|
"ip6mask": link_data.interface2_ip6_mask,
|
||||||
|
}
|
||||||
|
|
||||||
|
socketio.emit("link", {
|
||||||
|
"message_type": link_data.message_type,
|
||||||
|
"type": link_data.link_type,
|
||||||
|
"node_one": link_data.node1_id,
|
||||||
|
"node_two": link_data.node2_id,
|
||||||
|
"interface_one": interface_one,
|
||||||
|
"interface_two": interface_two,
|
||||||
|
"options": {
|
||||||
|
"opaque": link_data.opaque,
|
||||||
|
"jitter": link_data.jitter,
|
||||||
|
"key": link_data.key,
|
||||||
|
"mburst": link_data.mburst,
|
||||||
|
"mer": link_data.mer,
|
||||||
|
"per": link_data.per,
|
||||||
|
"bandwidth": link_data.bandwidth,
|
||||||
|
"burst": link_data.burst,
|
||||||
|
"delay": link_data.delay,
|
||||||
|
"dup": link_data.dup,
|
||||||
|
"unidirectional": link_data.unidirectional
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
def broadcast_config(config_data):
|
||||||
|
socketio.emit("config", {
|
||||||
|
"message_type": config_data.message_type,
|
||||||
|
"node": config_data.node,
|
||||||
|
"object": config_data.object,
|
||||||
|
"type": config_data.type,
|
||||||
|
"data_types": config_data.data_types,
|
||||||
|
"data_values": config_data.data_values,
|
||||||
|
"captions": config_data.captions,
|
||||||
|
"bitmap": config_data.bitmap,
|
||||||
|
"possible_values": config_data.possible_values,
|
||||||
|
"groups": config_data.groups,
|
||||||
|
"session": config_data.session,
|
||||||
|
"interface_number": config_data.interface_number,
|
||||||
|
"network_id": config_data.network_id,
|
||||||
|
"opaque": config_data.opaque
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
def broadcast_event(event):
|
def broadcast_event(event):
|
||||||
socketio.emit("event", {
|
socketio.emit("event", {
|
||||||
"node": event.node,
|
"node": event.node,
|
||||||
|
|
Loading…
Add table
Reference in a new issue