fix merge conflict
This commit is contained in:
commit
e2fba18ba5
12 changed files with 75 additions and 48 deletions
|
@ -1556,9 +1556,10 @@ class Session:
|
||||||
funcs = []
|
funcs = []
|
||||||
for node_id in self.nodes:
|
for node_id in self.nodes:
|
||||||
node = self.nodes[node_id]
|
node = self.nodes[node_id]
|
||||||
if isinstance(node, CoreNodeBase):
|
if not isinstance(node, CoreNodeBase) or not node.up:
|
||||||
args = (node,)
|
continue
|
||||||
funcs.append((self.services.stop_services, args, {}))
|
args = (node,)
|
||||||
|
funcs.append((self.services.stop_services, args, {}))
|
||||||
utils.threadpool(funcs)
|
utils.threadpool(funcs)
|
||||||
|
|
||||||
# shutdown emane
|
# shutdown emane
|
||||||
|
|
|
@ -110,6 +110,8 @@ class CoreClient:
|
||||||
self.xml_dir = None
|
self.xml_dir = None
|
||||||
self.xml_file = None
|
self.xml_file = None
|
||||||
|
|
||||||
|
self.modified_service_nodes = set()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
# helpers
|
# helpers
|
||||||
self.interfaces_manager.reset()
|
self.interfaces_manager.reset()
|
||||||
|
@ -124,6 +126,7 @@ class CoreClient:
|
||||||
self.emane_config = None
|
self.emane_config = None
|
||||||
self.service_configs.clear()
|
self.service_configs.clear()
|
||||||
self.file_configs.clear()
|
self.file_configs.clear()
|
||||||
|
self.modified_service_nodes.clear()
|
||||||
for mobility_player in self.mobility_players.values():
|
for mobility_player in self.mobility_players.values():
|
||||||
mobility_player.handle_close()
|
mobility_player.handle_close()
|
||||||
self.mobility_players.clear()
|
self.mobility_players.clear()
|
||||||
|
@ -806,6 +809,9 @@ class CoreClient:
|
||||||
logging.error("unknown node: %s", node_id)
|
logging.error("unknown node: %s", node_id)
|
||||||
continue
|
continue
|
||||||
del self.canvas_nodes[node_id]
|
del self.canvas_nodes[node_id]
|
||||||
|
|
||||||
|
self.modified_service_nodes.discard(node_id)
|
||||||
|
|
||||||
if node_id in self.mobility_configs:
|
if node_id in self.mobility_configs:
|
||||||
del self.mobility_configs[node_id]
|
del self.mobility_configs[node_id]
|
||||||
if node_id in self.wlan_configs:
|
if node_id in self.wlan_configs:
|
||||||
|
@ -1046,3 +1052,6 @@ class CoreClient:
|
||||||
config = self.emane_model_configs.get(_from)
|
config = self.emane_model_configs.get(_from)
|
||||||
if config:
|
if config:
|
||||||
self.emane_model_configs[_to] = config
|
self.emane_model_configs[_to] = config
|
||||||
|
|
||||||
|
def service_been_modified(self, node_id: int) -> bool:
|
||||||
|
return node_id in self.modified_service_nodes
|
||||||
|
|
|
@ -36,8 +36,14 @@ class NodeServiceDialog(Dialog):
|
||||||
services = canvas_node.core_node.services
|
services = canvas_node.core_node.services
|
||||||
model = canvas_node.core_node.model
|
model = canvas_node.core_node.model
|
||||||
if len(services) == 0:
|
if len(services) == 0:
|
||||||
if not NodeUtils.is_custom(canvas_node.core_node.model):
|
# not custom node type and node's services haven't been modified before
|
||||||
|
if not NodeUtils.is_custom(
|
||||||
|
canvas_node.core_node.model
|
||||||
|
) and not self.app.core.service_been_modified(self.node_id):
|
||||||
services = set(self.app.core.default_services[model])
|
services = set(self.app.core.default_services[model])
|
||||||
|
# services of default type nodes were modified to be empty
|
||||||
|
elif canvas_node.core_node.id in self.app.core.modified_service_nodes:
|
||||||
|
services = set()
|
||||||
else:
|
else:
|
||||||
services = set(
|
services = set(
|
||||||
NodeUtils.get_custom_node_services(self.app.guiconfig, model)
|
NodeUtils.get_custom_node_services(self.app.guiconfig, model)
|
||||||
|
@ -141,12 +147,14 @@ class NodeServiceDialog(Dialog):
|
||||||
)
|
)
|
||||||
|
|
||||||
def click_save(self):
|
def click_save(self):
|
||||||
|
# if node is custom type or current services are not the default services then set core node services and add node to modified services node set
|
||||||
if (
|
if (
|
||||||
self.canvas_node.core_node.model not in self.app.core.default_services
|
self.canvas_node.core_node.model not in self.app.core.default_services
|
||||||
or self.current_services
|
or self.current_services
|
||||||
!= self.app.core.default_services[self.canvas_node.core_node.model]
|
!= self.app.core.default_services[self.canvas_node.core_node.model]
|
||||||
):
|
):
|
||||||
self.canvas_node.core_node.services[:] = self.current_services
|
self.canvas_node.core_node.services[:] = self.current_services
|
||||||
|
self.app.core.modified_service_nodes.add(self.canvas_node.core_node.id)
|
||||||
else:
|
else:
|
||||||
if len(self.canvas_node.core_node.services) > 0:
|
if len(self.canvas_node.core_node.services) > 0:
|
||||||
self.canvas_node.core_node.services[:] = []
|
self.canvas_node.core_node.services[:] = []
|
||||||
|
|
|
@ -854,6 +854,11 @@ class CanvasGraph(tk.Canvas):
|
||||||
node = CanvasNode(
|
node = CanvasNode(
|
||||||
self.master, scaled_x, scaled_y, copy, self.nodes[canvas_nid].image
|
self.master, scaled_x, scaled_y, copy, self.nodes[canvas_nid].image
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# add new node to modified_service_nodes set if that set contains the to_copy node
|
||||||
|
if self.app.core.service_been_modified(core_node.id):
|
||||||
|
self.app.core.modified_service_nodes.add(copy.id)
|
||||||
|
|
||||||
copy_map[canvas_nid] = node.id
|
copy_map[canvas_nid] = node.id
|
||||||
self.core.canvas_nodes[copy.id] = node
|
self.core.canvas_nodes[copy.id] = node
|
||||||
self.nodes[node.id] = node
|
self.nodes[node.id] = node
|
||||||
|
|
|
@ -89,12 +89,15 @@ class MenuAction:
|
||||||
title="Open",
|
title="Open",
|
||||||
filetypes=(("XML Files", "*.xml"), ("All Files", "*")),
|
filetypes=(("XML Files", "*.xml"), ("All Files", "*")),
|
||||||
)
|
)
|
||||||
if file_path:
|
self.open_xml_task(file_path)
|
||||||
self.app.core.xml_file = file_path
|
|
||||||
self.app.core.xml_dir = str(os.path.dirname(file_path))
|
def open_xml_task(self, filename):
|
||||||
|
if filename:
|
||||||
|
self.app.core.xml_file = filename
|
||||||
|
self.app.core.xml_dir = str(os.path.dirname(filename))
|
||||||
self.prompt_save_running_session()
|
self.prompt_save_running_session()
|
||||||
self.app.statusbar.progress_bar.start(5)
|
self.app.statusbar.progress_bar.start(5)
|
||||||
task = BackgroundTask(self.app, self.app.core.open_xml, args=(file_path,))
|
task = BackgroundTask(self.app, self.app.core.open_xml, args=(filename,))
|
||||||
task.start()
|
task.start()
|
||||||
|
|
||||||
def gui_preferences(self):
|
def gui_preferences(self):
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
@ -55,6 +57,10 @@ class Menubar(tk.Menu):
|
||||||
menu.add_command(label="Save", accelerator="Ctrl+S", command=self.save)
|
menu.add_command(label="Save", accelerator="Ctrl+S", command=self.save)
|
||||||
menu.add_command(label="Reload", underline=0, state=tk.DISABLED)
|
menu.add_command(label="Reload", underline=0, state=tk.DISABLED)
|
||||||
self.app.bind_all("<Control-s>", self.save)
|
self.app.bind_all("<Control-s>", self.save)
|
||||||
|
|
||||||
|
# some hard code values for testing
|
||||||
|
recent = tk.Menu(menu)
|
||||||
|
menu.add_cascade(label="Recent files", menu=recent)
|
||||||
menu.add_separator()
|
menu.add_separator()
|
||||||
menu.add_command(label="Export Python script...", state=tk.DISABLED)
|
menu.add_command(label="Export Python script...", state=tk.DISABLED)
|
||||||
menu.add_command(label="Execute XML or Python script...", state=tk.DISABLED)
|
menu.add_command(label="Execute XML or Python script...", state=tk.DISABLED)
|
||||||
|
@ -409,6 +415,13 @@ class Menubar(tk.Menu):
|
||||||
menu.add_command(label="About", command=self.menuaction.show_about)
|
menu.add_command(label="About", command=self.menuaction.show_about)
|
||||||
self.add_cascade(label="Help", menu=menu)
|
self.add_cascade(label="Help", menu=menu)
|
||||||
|
|
||||||
|
def open_recent_files(self, filename: str):
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
logging.debug("Open recent file %s", filename)
|
||||||
|
self.menuaction.open_xml_task(filename)
|
||||||
|
else:
|
||||||
|
logging.warning("File does not exist %s", filename)
|
||||||
|
|
||||||
def save(self, event=None):
|
def save(self, event=None):
|
||||||
xml_file = self.app.core.xml_file
|
xml_file = self.app.core.xml_file
|
||||||
if xml_file:
|
if xml_file:
|
||||||
|
|
|
@ -284,6 +284,7 @@ class CoreNodeBase(NodeBase):
|
||||||
self.config_services = {}
|
self.config_services = {}
|
||||||
self.nodedir = None
|
self.nodedir = None
|
||||||
self.tmpnodedir = False
|
self.tmpnodedir = False
|
||||||
|
self.up = False
|
||||||
|
|
||||||
def add_config_service(self, service_class: "ConfigServiceType") -> None:
|
def add_config_service(self, service_class: "ConfigServiceType") -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -503,7 +504,6 @@ class CoreNode(CoreNodeBase):
|
||||||
)
|
)
|
||||||
self.client = None
|
self.client = None
|
||||||
self.pid = None
|
self.pid = None
|
||||||
self.up = False
|
|
||||||
self.lock = threading.RLock()
|
self.lock = threading.RLock()
|
||||||
self._mounts = []
|
self._mounts = []
|
||||||
self.bootsh = bootsh
|
self.bootsh = bootsh
|
||||||
|
|
|
@ -289,7 +289,6 @@ class Rj45Node(CoreNodeBase, CoreInterface):
|
||||||
"""
|
"""
|
||||||
CoreNodeBase.__init__(self, session, _id, name, start, server)
|
CoreNodeBase.__init__(self, session, _id, name, start, server)
|
||||||
CoreInterface.__init__(self, session, self, name, mtu, server)
|
CoreInterface.__init__(self, session, self, name, mtu, server)
|
||||||
self.up = False
|
|
||||||
self.lock = threading.RLock()
|
self.lock = threading.RLock()
|
||||||
self.ifindex = None
|
self.ifindex = None
|
||||||
# the following are PyCoreNetIf attributes
|
# the following are PyCoreNetIf attributes
|
||||||
|
|
|
@ -923,20 +923,14 @@ class CoreXmlReader:
|
||||||
|
|
||||||
if link_options.unidirectional == 1 and node_set in node_sets:
|
if link_options.unidirectional == 1 and node_set in node_sets:
|
||||||
logging.info(
|
logging.info(
|
||||||
"updating link node_one(%s) node_two(%s): %s",
|
"updating link node_one(%s) node_two(%s)", node_one, node_two
|
||||||
node_one,
|
|
||||||
node_two,
|
|
||||||
link_options,
|
|
||||||
)
|
)
|
||||||
self.session.update_link(
|
self.session.update_link(
|
||||||
node_one, node_two, interface_one.id, interface_two.id, link_options
|
node_one, node_two, interface_one.id, interface_two.id, link_options
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
logging.info(
|
logging.info(
|
||||||
"adding link node_one(%s) node_two(%s): %s",
|
"adding link node_one(%s) node_two(%s)", node_one, node_two
|
||||||
node_one,
|
|
||||||
node_two,
|
|
||||||
link_options,
|
|
||||||
)
|
)
|
||||||
self.session.add_link(
|
self.session.add_link(
|
||||||
node_one, node_two, interface_one, interface_two, link_options
|
node_one, node_two, interface_one, interface_two, link_options
|
||||||
|
|
|
@ -15,18 +15,18 @@ def parse(name):
|
||||||
help="number of nodes to create in this example",
|
help="number of nodes to create in this example",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-t",
|
"-c",
|
||||||
"--time",
|
"--count",
|
||||||
type=int,
|
type=int,
|
||||||
default=DEFAULT_TIME,
|
default=DEFAULT_TIME,
|
||||||
help="example iperf run time in seconds",
|
help="number of time to ping node",
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.nodes < 2:
|
if args.nodes < 2:
|
||||||
parser.error(f"invalid min number of nodes: {args.nodes}")
|
parser.error(f"invalid min number of nodes: {args.nodes}")
|
||||||
if args.time < 1:
|
if args.count < 1:
|
||||||
parser.error(f"invalid test time: {args.time}")
|
parser.error(f"invalid ping count({args.count}), count must be greater than 0")
|
||||||
|
|
||||||
return args
|
return args
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
|
||||||
import logging
|
import logging
|
||||||
import parser
|
import time
|
||||||
|
|
||||||
|
import params
|
||||||
from core.emulator.coreemu import CoreEmu
|
from core.emulator.coreemu import CoreEmu
|
||||||
from core.emulator.emudata import IpPrefixes
|
from core.emulator.emudata import IpPrefixes
|
||||||
from core.emulator.enumerations import EventTypes, NodeTypes
|
from core.emulator.enumerations import EventTypes, NodeTypes
|
||||||
|
@ -33,14 +33,10 @@ def example(args):
|
||||||
# get nodes to run example
|
# get nodes to run example
|
||||||
first_node = session.get_node(2)
|
first_node = session.get_node(2)
|
||||||
last_node = session.get_node(args.nodes + 1)
|
last_node = session.get_node(args.nodes + 1)
|
||||||
|
|
||||||
logging.info("starting iperf server on node: %s", first_node.name)
|
|
||||||
first_node.cmd("iperf -s -D")
|
|
||||||
first_node_address = prefixes.ip4_address(first_node)
|
first_node_address = prefixes.ip4_address(first_node)
|
||||||
logging.info("node %s connecting to %s", last_node.name, first_node_address)
|
logging.info("node %s pinging %s", last_node.name, first_node_address)
|
||||||
output = last_node.cmd(f"iperf -t {args.time} -c {first_node_address}")
|
output = last_node.cmd(f"ping -c {args.count} {first_node_address}")
|
||||||
logging.info(output)
|
logging.info(output)
|
||||||
first_node.cmd("killall -9 iperf")
|
|
||||||
|
|
||||||
# shutdown session
|
# shutdown session
|
||||||
coreemu.shutdown()
|
coreemu.shutdown()
|
||||||
|
@ -48,11 +44,13 @@ def example(args):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
args = parser.parse("switch")
|
args = params.parse("switch")
|
||||||
start = datetime.datetime.now()
|
start = time.perf_counter()
|
||||||
logging.info("running switch example: nodes(%s) time(%s)", args.nodes, args.time)
|
logging.info(
|
||||||
|
"running switch example: nodes(%s) ping count(%s)", args.nodes, args.count
|
||||||
|
)
|
||||||
example(args)
|
example(args)
|
||||||
logging.info("elapsed time: %s", datetime.datetime.now() - start)
|
logging.info("elapsed time: %s", time.perf_counter() - start)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import datetime
|
|
||||||
import logging
|
import logging
|
||||||
import parser
|
import time
|
||||||
|
|
||||||
|
import params
|
||||||
from core.emulator.coreemu import CoreEmu
|
from core.emulator.coreemu import CoreEmu
|
||||||
from core.emulator.emudata import IpPrefixes, NodeOptions
|
from core.emulator.emudata import IpPrefixes, NodeOptions
|
||||||
from core.emulator.enumerations import EventTypes, NodeTypes
|
from core.emulator.enumerations import EventTypes, NodeTypes
|
||||||
|
@ -37,14 +37,10 @@ def example(args):
|
||||||
# get nodes for example run
|
# get nodes for example run
|
||||||
first_node = session.get_node(2)
|
first_node = session.get_node(2)
|
||||||
last_node = session.get_node(args.nodes + 1)
|
last_node = session.get_node(args.nodes + 1)
|
||||||
|
|
||||||
logging.info("starting iperf server on node: %s", first_node.name)
|
|
||||||
first_node.cmd("iperf -s -D")
|
|
||||||
address = prefixes.ip4_address(first_node)
|
address = prefixes.ip4_address(first_node)
|
||||||
logging.info("node %s connecting to %s", last_node.name, address)
|
logging.info("node %s pinging %s", last_node.name, address)
|
||||||
output = last_node.cmd(f"iperf -t {args.time} -c {address}")
|
output = last_node.cmd(f"ping -c {args.count} {address}")
|
||||||
logging.info(output)
|
logging.info(output)
|
||||||
first_node.cmd("killall -9 iperf")
|
|
||||||
|
|
||||||
# shutdown session
|
# shutdown session
|
||||||
coreemu.shutdown()
|
coreemu.shutdown()
|
||||||
|
@ -52,12 +48,13 @@ def example(args):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
args = parser.parse("wlan")
|
args = params.parse("wlan")
|
||||||
|
start = time.perf_counter()
|
||||||
start = datetime.datetime.now()
|
logging.info(
|
||||||
logging.info("running wlan example: nodes(%s) time(%s)", args.nodes, args.time)
|
"running wlan example: nodes(%s) ping count(%s)", args.nodes, args.count
|
||||||
|
)
|
||||||
example(args)
|
example(args)
|
||||||
logging.info("elapsed time: %s", datetime.datetime.now() - start)
|
logging.info("elapsed time: %s", time.perf_counter() - start)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue