initial changes to mark older style services as deprecated and make configurable services the defaults for the python gui, added attribute to still allow supporting the legacy gui for time being and logic to compensate

This commit is contained in:
Blake Harnden 2021-05-07 13:10:05 -07:00
parent ca8b4f1f6e
commit ad09bd5504
12 changed files with 24 additions and 15 deletions

View file

@ -688,8 +688,8 @@ class CoreHandler(socketserver.BaseRequestHandler):
options = NodeOptions(
name=message.get_tlv(NodeTlvs.NAME.value),
model=message.get_tlv(NodeTlvs.MODEL.value),
legacy=True,
)
options.set_position(
x=message.get_tlv(NodeTlvs.X_POSITION.value),
y=message.get_tlv(NodeTlvs.Y_POSITION.value),

View file

@ -102,9 +102,9 @@ class Zebra(ConfigService):
ip4s = []
ip6s = []
for ip4 in iface.ip4s:
ip4s.append(str(ip4.ip))
ip4s.append(str(ip4))
for ip6 in iface.ip6s:
ip6s.append(str(ip6.ip))
ip6s.append(str(ip6))
ifaces.append((iface, ip4s, ip6s, iface.control))
return dict(

View file

@ -208,7 +208,7 @@ class EmaneManager:
self.node_models.clear()
else:
self.node_configs.get(node_id, {}).clear()
del self.node_models[node_id]
self.node_models.pop(node_id, None)
def deleteeventservice(self) -> None:
if self.service:

View file

@ -91,6 +91,7 @@ class NodeOptions:
server: str = None
image: str = None
emane: str = None
legacy: bool = False
def set_position(self, x: float, y: float) -> None:
"""

View file

@ -549,12 +549,16 @@ class Session:
# add services to needed nodes
if isinstance(node, (CoreNode, PhysicalNode)):
node.type = options.model
logger.debug("set node type: %s", node.type)
self.services.add_services(node, node.type, options.services)
if options.legacy or options.services:
logger.debug("set node type: %s", node.type)
self.services.add_services(node, node.type, options.services)
# add config services
config_services = options.config_services
if not options.legacy and not config_services:
config_services = self.services.default_services.get(node.type, [])
logger.info("setting node config services: %s", options.config_services)
for name in options.config_services:
for name in config_services:
service_class = self.service_manager.get_service(name)
node.add_config_service(service_class)

View file

@ -393,7 +393,7 @@ class CoreClient:
self.client.connect()
# get current core configurations services/config services
core_config = self.client.get_config()
self.emane_models = core_config.emane_models
self.emane_models = sorted(core_config.emane_models)
for service in core_config.services:
group_services = self.services.setdefault(service.group, set())
group_services.add(service.name)
@ -664,12 +664,12 @@ class CoreClient:
)
if nutils.is_custom(node):
services = nutils.get_custom_services(self.app.guiconfig, model)
node.services = set(services)
node.config_services = set(services)
# assign default services to CORE node
else:
services = self.session.default_services.get(model)
if services:
node.services = services.copy()
node.config_services = services.copy()
logger.info(
"add node(%s) to session(%s), coordinates(%s, %s)",
node.name,

View file

@ -116,7 +116,7 @@ class EmaneConfigDialog(Dialog):
self.radiovar.set(1)
self.emane_models: List[str] = [
x.split("_")[1] for x in sorted(self.app.core.emane_models)
x.split("_")[1] for x in self.app.core.emane_models
]
model = self.emane_models[0]
self.emane_model: tk.StringVar = tk.StringVar(value=model)

View file

@ -17,7 +17,7 @@ if TYPE_CHECKING:
class NodeServiceDialog(Dialog):
def __init__(self, app: "Application", node: Node) -> None:
title = f"{node.name} Services"
title = f"{node.name} Services (Deprecated)"
super().__init__(app, title)
self.node: Node = node
self.groups: Optional[ListboxScroll] = None

View file

@ -28,7 +28,7 @@ class ServiceConfigDialog(Dialog):
def __init__(
self, master: tk.BaseWidget, app: "Application", service_name: str, node: Node
) -> None:
title = f"{service_name} Service"
title = f"{service_name} Service (Deprecated)"
super().__init__(app, title, master=master)
self.core: "CoreClient" = app.core
self.node: Node = node

View file

@ -255,10 +255,12 @@ class CanvasNode:
else:
self.context.add_command(label="Configure", command=self.show_config)
if nutils.is_container(self.core_node):
self.context.add_command(label="Services", command=self.show_services)
self.context.add_command(
label="Config Services", command=self.show_config_services
)
self.context.add_command(
label="Services (Deprecated)", command=self.show_services
)
if is_emane:
self.context.add_command(
label="EMANE Config", command=self.show_emane_config

View file

@ -78,6 +78,7 @@ def global_coreemu(patcher):
def global_session(request, patcher, global_coreemu):
mkdir = not request.config.getoption("mock")
session = Session(1000, {"emane_prefix": "/usr"}, mkdir)
session.service_manager = global_coreemu.service_manager
yield session
session.shutdown()

View file

@ -702,7 +702,8 @@ class TestGrpc:
# given
client = CoreGrpcClient()
session = grpc_server.coreemu.create_session()
node = session.add_node(CoreNode)
options = NodeOptions(legacy=True)
node = session.add_node(CoreNode, options=options)
service_name = "DefaultRoute"
# then