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)));
|
||||
}
|
||||
|
||||
public boolean startSession() throws IOException {
|
||||
public boolean startSession() {
|
||||
// force nodes to get latest positions
|
||||
networkGraph.updatePositions();
|
||||
|
||||
|
@ -180,13 +180,19 @@ public class Controller implements Initializable {
|
|||
List<Hook> hooks = hooksDialog.getHooks();
|
||||
|
||||
// start/create session
|
||||
boolean result = false;
|
||||
progressBar.setVisible(true);
|
||||
boolean result = coreClient.start(nodes, links, hooks);
|
||||
progressBar.setVisible(false);
|
||||
try {
|
||||
result = coreClient.start(nodes, links, hooks);
|
||||
if (result) {
|
||||
showMobilityScriptDialogs();
|
||||
saveXmlMenuItem.setDisable(false);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Toast.error("Failure Starting Session", ex);
|
||||
} finally {
|
||||
progressBar.setVisible(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ public class NodeType {
|
|||
public static final int SWITCH = 4;
|
||||
public static final int HUB = 5;
|
||||
public static final int WLAN = 6;
|
||||
public static final int RJ45 = 7;
|
||||
public static final int EMANE = 10;
|
||||
public static final int DOCKER = 15;
|
||||
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(HUB, "hub", "Hub", "/icons/hub-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(NodeType.DOCKER, null, "DockerNode", "/icons/dockernode-100.png"));
|
||||
add(new NodeType(NodeType.LXC, null, "LxcNode", "/icons/lxcnode-100.png"));
|
||||
add(new NodeType(DOCKER, null, "DockerNode", "/icons/dockernode-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:
|
||||
contextMenu = new EmaneContextMenu(controller, node);
|
||||
break;
|
||||
case NodeType.RJ45:
|
||||
contextMenu = new Rj45ContextMenu(controller, node);
|
||||
break;
|
||||
default:
|
||||
logger.warn("no context menu for node: {}", node.getType());
|
||||
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.WLAN, "wlan", devicesList);
|
||||
addNodeType(NodeType.EMANE, "wlan", devicesList);
|
||||
addNodeType(NodeType.RJ45, "rj45", devicesList);
|
||||
devicesList.getSelectionModel().selectFirst();
|
||||
updateButtonValues(devicesButton, devicesList.getSelectionModel().getSelectedItem());
|
||||
setupButtonSelection("Network Nodes", devicesButton, devicesList);
|
||||
|
@ -237,15 +238,11 @@ public class GraphToolbar extends VBox {
|
|||
private void startSession() {
|
||||
runButton.setDisable(true);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
boolean result = controller.startSession();
|
||||
if (result) {
|
||||
Toast.success("Session Started");
|
||||
setRunButton(true);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Toast.error("Failure Starting Session", ex);
|
||||
}
|
||||
setRunButton(result);
|
||||
}).start();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,8 @@ public class NodeDetails extends ScrollPane {
|
|||
|
||||
public void setNode(CoreNode node) {
|
||||
clear();
|
||||
boolean sessionRunning = controller.getCoreClient().isRunning();
|
||||
|
||||
title.setText(node.getName());
|
||||
addSeparator();
|
||||
|
||||
|
@ -54,15 +56,18 @@ public class NodeDetails extends ScrollPane {
|
|||
addRow("Type", node.getNodeType().getDisplay(), true);
|
||||
}
|
||||
addRow("EMANE", node.getEmane(), true);
|
||||
addRow("Image", node.getImage(), true);
|
||||
addRow("X", node.getPosition().getX().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;
|
||||
for (CoreLink link : controller.getNetworkGraph().getGraph().getIncidentEdges(node)) {
|
||||
if (firstInterface) {
|
||||
firstInterface = false;
|
||||
addLabel("Interfaces");
|
||||
} else {
|
||||
addSeparator();
|
||||
}
|
||||
|
@ -119,6 +124,15 @@ public class NodeDetails extends 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) {
|
||||
JFXButton emaneButton = new JFXButton(text);
|
||||
emaneButton.getStyleClass().add("core-button");
|
||||
|
@ -147,14 +161,12 @@ public class NodeDetails extends ScrollPane {
|
|||
addAddress("IP6", coreInterface.getIp6());
|
||||
}
|
||||
|
||||
private void addRow(String labelText, String value, boolean disabled) {
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
private JFXTextField addRow(String labelText, String value, boolean disabled) {
|
||||
Label label = new Label(labelText);
|
||||
JFXTextField textField = new JFXTextField(value);
|
||||
textField.setDisable(disabled);
|
||||
gridPane.addRow(index++, label, textField);
|
||||
return textField;
|
||||
}
|
||||
|
||||
private void addAddress(String label, IPAddress ip) {
|
||||
|
|
|
@ -129,7 +129,7 @@ public class NodeServicesDialog extends StageDialog {
|
|||
|
||||
Set<String> nodeServices = node.getServices();
|
||||
if (nodeServices.isEmpty()) {
|
||||
nodeServices = getController().getDefaultServices().get(node.getModel());
|
||||
nodeServices = getController().getDefaultServices().getOrDefault(node.getModel(), new HashSet<>());
|
||||
}
|
||||
|
||||
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