allow choosing local host machine interface for rj45 node
This commit is contained in:
parent
615b989102
commit
c402ce5284
3 changed files with 33 additions and 2 deletions
|
@ -702,10 +702,17 @@ class CoreClient:
|
|||
emane = None
|
||||
if node_type == core_pb2.NodeType.EMANE:
|
||||
emane = self.emane_models[0]
|
||||
name = f"EMANE{node_id}"
|
||||
elif node_type == core_pb2.NodeType.WIRELESS_LAN:
|
||||
name = f"WLAN{node_id}"
|
||||
elif node_type in [core_pb2.NodeType.RJ45, core_pb2.NodeType.TUNNEL]:
|
||||
name = "UNASSIGNED"
|
||||
else:
|
||||
name = f"n{node_id}"
|
||||
node = core_pb2.Node(
|
||||
id=node_id,
|
||||
type=node_type,
|
||||
name=f"n{node_id}",
|
||||
name=name,
|
||||
model=model,
|
||||
position=position,
|
||||
image=image,
|
||||
|
|
|
@ -10,7 +10,7 @@ from core.gui.dialogs.emaneconfig import EmaneModelDialog
|
|||
from core.gui.images import Images
|
||||
from core.gui.nodeutils import NodeUtils
|
||||
from core.gui.themes import FRAME_PAD, PADX, PADY
|
||||
from core.gui.widgets import image_chooser
|
||||
from core.gui.widgets import ListboxScroll, image_chooser
|
||||
|
||||
|
||||
def mac_auto(is_auto, entry):
|
||||
|
@ -131,6 +131,18 @@ class NodeConfigDialog(Dialog):
|
|||
combobox.grid(row=row, column=1, sticky="ew")
|
||||
row += 1
|
||||
|
||||
if NodeUtils.is_rj45_node(self.node.type):
|
||||
response = self.app.core.client.get_interfaces()
|
||||
logging.debug("host machine available interfaces: %s", response)
|
||||
interfaces = ListboxScroll(frame)
|
||||
interfaces.grid(
|
||||
row=row, column=0, columnspan=2, sticky="ew", padx=PADX, pady=PADY
|
||||
)
|
||||
for inf in sorted(response.interfaces[:]):
|
||||
interfaces.listbox.insert(tk.END, inf)
|
||||
row += 1
|
||||
interfaces.listbox.bind("<<ListboxSelect>>", self.interface_select)
|
||||
|
||||
# interfaces
|
||||
if self.canvas_node.interfaces:
|
||||
self.draw_interfaces()
|
||||
|
@ -235,3 +247,10 @@ class NodeConfigDialog(Dialog):
|
|||
# redraw
|
||||
self.canvas_node.redraw()
|
||||
self.destroy()
|
||||
|
||||
def interface_select(self, event):
|
||||
listbox = event.widget
|
||||
cur = listbox.curselection()
|
||||
if cur:
|
||||
interface = listbox.get(cur[0])
|
||||
self.name.set(interface)
|
||||
|
|
|
@ -47,6 +47,7 @@ class NodeUtils:
|
|||
CONTAINER_NODES = {NodeType.DEFAULT, NodeType.DOCKER, NodeType.LXC}
|
||||
IMAGE_NODES = {NodeType.DOCKER, NodeType.LXC}
|
||||
WIRELESS_NODES = {NodeType.WIRELESS_LAN, NodeType.EMANE}
|
||||
RJ45_NODES = {NodeType.RJ45}
|
||||
IGNORE_NODES = {NodeType.CONTROL_NET, NodeType.PEER_TO_PEER}
|
||||
NODE_MODELS = {"router", "host", "PC", "mdr", "prouter"}
|
||||
ANTENNA_ICON = None
|
||||
|
@ -71,6 +72,10 @@ class NodeUtils:
|
|||
def is_wireless_node(cls, node_type):
|
||||
return node_type in cls.WIRELESS_NODES
|
||||
|
||||
@classmethod
|
||||
def is_rj45_node(cls, node_type):
|
||||
return node_type in cls.RJ45_NODES
|
||||
|
||||
@classmethod
|
||||
def node_icon(cls, node_type, model):
|
||||
if model == "":
|
||||
|
|
Loading…
Reference in a new issue