corefx - added rj45 node, updates to dealing with session start failure
This commit is contained in:
parent
60588eabbb
commit
5f7d46aacd
8 changed files with 64 additions and 23 deletions
|
@ -170,7 +170,7 @@ public class Controller implements Initializable {
|
||||||
Platform.runLater(() -> decorator.setTitle(String.format("CORE (Session %s)", sessionId)));
|
Platform.runLater(() -> decorator.setTitle(String.format("CORE (Session %s)", sessionId)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean startSession() throws IOException {
|
public boolean startSession() {
|
||||||
// force nodes to get latest positions
|
// force nodes to get latest positions
|
||||||
networkGraph.updatePositions();
|
networkGraph.updatePositions();
|
||||||
|
|
||||||
|
@ -180,12 +180,18 @@ public class Controller implements Initializable {
|
||||||
List<Hook> hooks = hooksDialog.getHooks();
|
List<Hook> hooks = hooksDialog.getHooks();
|
||||||
|
|
||||||
// start/create session
|
// start/create session
|
||||||
|
boolean result = false;
|
||||||
progressBar.setVisible(true);
|
progressBar.setVisible(true);
|
||||||
boolean result = coreClient.start(nodes, links, hooks);
|
try {
|
||||||
progressBar.setVisible(false);
|
result = coreClient.start(nodes, links, hooks);
|
||||||
if (result) {
|
if (result) {
|
||||||
showMobilityScriptDialogs();
|
showMobilityScriptDialogs();
|
||||||
saveXmlMenuItem.setDisable(false);
|
saveXmlMenuItem.setDisable(false);
|
||||||
|
}
|
||||||
|
} catch (IOException ex) {
|
||||||
|
Toast.error("Failure Starting Session", ex);
|
||||||
|
} finally {
|
||||||
|
progressBar.setVisible(false);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class NodeType {
|
||||||
public static final int SWITCH = 4;
|
public static final int SWITCH = 4;
|
||||||
public static final int HUB = 5;
|
public static final int HUB = 5;
|
||||||
public static final int WLAN = 6;
|
public static final int WLAN = 6;
|
||||||
|
public static final int RJ45 = 7;
|
||||||
public static final int EMANE = 10;
|
public static final int EMANE = 10;
|
||||||
public static final int DOCKER = 15;
|
public static final int DOCKER = 15;
|
||||||
public static final int LXC = 16;
|
public static final int LXC = 16;
|
||||||
|
@ -35,9 +36,10 @@ public class NodeType {
|
||||||
add(new NodeType(SWITCH, "lanswitch", "Switch", "/icons/switch-100.png"));
|
add(new NodeType(SWITCH, "lanswitch", "Switch", "/icons/switch-100.png"));
|
||||||
add(new NodeType(HUB, "hub", "Hub", "/icons/hub-100.png"));
|
add(new NodeType(HUB, "hub", "Hub", "/icons/hub-100.png"));
|
||||||
add(new NodeType(WLAN, "wlan", "WLAN", "/icons/wlan-100.png"));
|
add(new NodeType(WLAN, "wlan", "WLAN", "/icons/wlan-100.png"));
|
||||||
|
add(new NodeType(RJ45, "rj45", "RJ45", "/icons/rj45-80.png"));
|
||||||
add(new NodeType(EMANE, "wlan", "EMANE", "/icons/emane-100.png"));
|
add(new NodeType(EMANE, "wlan", "EMANE", "/icons/emane-100.png"));
|
||||||
add(new NodeType(NodeType.DOCKER, null, "DockerNode", "/icons/dockernode-100.png"));
|
add(new NodeType(DOCKER, null, "DockerNode", "/icons/dockernode-100.png"));
|
||||||
add(new NodeType(NodeType.LXC, null, "LxcNode", "/icons/lxcnode-100.png"));
|
add(new NodeType(LXC, null, "LxcNode", "/icons/lxcnode-100.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,9 @@ public class CorePopupGraphMousePlugin<V, E> extends EditingPopupGraphMousePlugi
|
||||||
case NodeType.EMANE:
|
case NodeType.EMANE:
|
||||||
contextMenu = new EmaneContextMenu(controller, node);
|
contextMenu = new EmaneContextMenu(controller, node);
|
||||||
break;
|
break;
|
||||||
|
case NodeType.RJ45:
|
||||||
|
contextMenu = new Rj45ContextMenu(controller, node);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
logger.warn("no context menu for node: {}", node.getType());
|
logger.warn("no context menu for node: {}", node.getType());
|
||||||
break;
|
break;
|
||||||
|
|
21
corefx/src/main/java/com/core/graph/Rj45ContextMenu.java
Normal file
21
corefx/src/main/java/com/core/graph/Rj45ContextMenu.java
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
package com.core.graph;
|
||||||
|
|
||||||
|
import com.core.Controller;
|
||||||
|
import com.core.data.CoreNode;
|
||||||
|
import org.apache.logging.log4j.LogManager;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
|
class Rj45ContextMenu extends AbstractNodeContextMenu {
|
||||||
|
private static final Logger logger = LogManager.getLogger();
|
||||||
|
|
||||||
|
Rj45ContextMenu(Controller controller, CoreNode coreNode) {
|
||||||
|
super(controller, coreNode);
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setup() {
|
||||||
|
if (!controller.getCoreClient().isRunning()) {
|
||||||
|
addMenuItem("Delete Node", event -> controller.deleteNode(coreNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -167,6 +167,7 @@ public class GraphToolbar extends VBox {
|
||||||
addNodeType(NodeType.SWITCH, "lanswitch", devicesList);
|
addNodeType(NodeType.SWITCH, "lanswitch", devicesList);
|
||||||
addNodeType(NodeType.WLAN, "wlan", devicesList);
|
addNodeType(NodeType.WLAN, "wlan", devicesList);
|
||||||
addNodeType(NodeType.EMANE, "wlan", devicesList);
|
addNodeType(NodeType.EMANE, "wlan", devicesList);
|
||||||
|
addNodeType(NodeType.RJ45, "rj45", devicesList);
|
||||||
devicesList.getSelectionModel().selectFirst();
|
devicesList.getSelectionModel().selectFirst();
|
||||||
updateButtonValues(devicesButton, devicesList.getSelectionModel().getSelectedItem());
|
updateButtonValues(devicesButton, devicesList.getSelectionModel().getSelectedItem());
|
||||||
setupButtonSelection("Network Nodes", devicesButton, devicesList);
|
setupButtonSelection("Network Nodes", devicesButton, devicesList);
|
||||||
|
@ -237,15 +238,11 @@ public class GraphToolbar extends VBox {
|
||||||
private void startSession() {
|
private void startSession() {
|
||||||
runButton.setDisable(true);
|
runButton.setDisable(true);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
boolean result = controller.startSession();
|
||||||
boolean result = controller.startSession();
|
if (result) {
|
||||||
if (result) {
|
Toast.success("Session Started");
|
||||||
Toast.success("Session Started");
|
|
||||||
setRunButton(true);
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Toast.error("Failure Starting Session", ex);
|
|
||||||
}
|
}
|
||||||
|
setRunButton(result);
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ public class NodeDetails extends ScrollPane {
|
||||||
|
|
||||||
public void setNode(CoreNode node) {
|
public void setNode(CoreNode node) {
|
||||||
clear();
|
clear();
|
||||||
|
boolean sessionRunning = controller.getCoreClient().isRunning();
|
||||||
|
|
||||||
title.setText(node.getName());
|
title.setText(node.getName());
|
||||||
addSeparator();
|
addSeparator();
|
||||||
|
|
||||||
|
@ -54,15 +56,18 @@ public class NodeDetails extends ScrollPane {
|
||||||
addRow("Type", node.getNodeType().getDisplay(), true);
|
addRow("Type", node.getNodeType().getDisplay(), true);
|
||||||
}
|
}
|
||||||
addRow("EMANE", node.getEmane(), true);
|
addRow("EMANE", node.getEmane(), true);
|
||||||
addRow("Image", node.getImage(), true);
|
|
||||||
addRow("X", node.getPosition().getX().toString(), true);
|
addRow("X", node.getPosition().getX().toString(), true);
|
||||||
addRow("Y", node.getPosition().getY().toString(), true);
|
addRow("Y", node.getPosition().getY().toString(), true);
|
||||||
|
|
||||||
addLabel("Interfaces");
|
if (node.getType() == NodeType.DOCKER || node.getType() == NodeType.LXC) {
|
||||||
|
setContainerDetails(node, sessionRunning);
|
||||||
|
}
|
||||||
|
|
||||||
boolean firstInterface = true;
|
boolean firstInterface = true;
|
||||||
for (CoreLink link : controller.getNetworkGraph().getGraph().getIncidentEdges(node)) {
|
for (CoreLink link : controller.getNetworkGraph().getGraph().getIncidentEdges(node)) {
|
||||||
if (firstInterface) {
|
if (firstInterface) {
|
||||||
firstInterface = false;
|
firstInterface = false;
|
||||||
|
addLabel("Interfaces");
|
||||||
} else {
|
} else {
|
||||||
addSeparator();
|
addSeparator();
|
||||||
}
|
}
|
||||||
|
@ -119,6 +124,15 @@ public class NodeDetails extends ScrollPane {
|
||||||
JFXScrollPane.smoothScrolling(scrollPane);
|
JFXScrollPane.smoothScrolling(scrollPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setContainerDetails(CoreNode node, boolean sessionRunning) {
|
||||||
|
JFXTextField imageField = addRow("Image", node.getImage(), sessionRunning);
|
||||||
|
addButton("Update", event -> {
|
||||||
|
if (node.getType() == NodeType.DOCKER || node.getType() == NodeType.LXC) {
|
||||||
|
node.setImage(imageField.getText());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private void addButton(String text, EventHandler<ActionEvent> handler) {
|
private void addButton(String text, EventHandler<ActionEvent> handler) {
|
||||||
JFXButton emaneButton = new JFXButton(text);
|
JFXButton emaneButton = new JFXButton(text);
|
||||||
emaneButton.getStyleClass().add("core-button");
|
emaneButton.getStyleClass().add("core-button");
|
||||||
|
@ -147,14 +161,12 @@ public class NodeDetails extends ScrollPane {
|
||||||
addAddress("IP6", coreInterface.getIp6());
|
addAddress("IP6", coreInterface.getIp6());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRow(String labelText, String value, boolean disabled) {
|
private JFXTextField addRow(String labelText, String value, boolean disabled) {
|
||||||
if (value == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Label label = new Label(labelText);
|
Label label = new Label(labelText);
|
||||||
JFXTextField textField = new JFXTextField(value);
|
JFXTextField textField = new JFXTextField(value);
|
||||||
textField.setDisable(disabled);
|
textField.setDisable(disabled);
|
||||||
gridPane.addRow(index++, label, textField);
|
gridPane.addRow(index++, label, textField);
|
||||||
|
return textField;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAddress(String label, IPAddress ip) {
|
private void addAddress(String label, IPAddress ip) {
|
||||||
|
|
|
@ -129,7 +129,7 @@ public class NodeServicesDialog extends StageDialog {
|
||||||
|
|
||||||
Set<String> nodeServices = node.getServices();
|
Set<String> nodeServices = node.getServices();
|
||||||
if (nodeServices.isEmpty()) {
|
if (nodeServices.isEmpty()) {
|
||||||
nodeServices = getController().getDefaultServices().get(node.getModel());
|
nodeServices = getController().getDefaultServices().getOrDefault(node.getModel(), new HashSet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (List<ServiceItem> items : serviceItemGroups.values()) {
|
for (List<ServiceItem> items : serviceItemGroups.values()) {
|
||||||
|
|
BIN
corefx/src/main/resources/icons/rj45-80.png
Normal file
BIN
corefx/src/main/resources/icons/rj45-80.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 B |
Loading…
Add table
Reference in a new issue