@dataclasses.dataclass
class TopologyDiffTuple:
nodes: set[Node]
components: set[Component]
services: set[NetworkService]
interfaces: set[Interface]
@dataclasses.dataclass
class TopologyDiff:
added: TopologyDiffTuple
removed: TopologyDiffTuple
Note that both topologies (topoA and topoB) must be loaded into Neo4j. Remember that all ModelElement objects (Node, Component, Interface, NetworkService) are shallow and build their innards by querying the underlying backend (Neo4j in this case) when properties are needed. Both graphs topoA and topoB must therefore be present, otherwise only names and GUIDs of the elements will be known.
Creating them can be done thusly:
self.n4j_imp = Neo4jGraphImporter(url=self.neo4j["url"], user=self.neo4j["user"],
pswd=self.neo4j["pass"],
import_host_dir=self.neo4j["import_host_dir"],
import_dir=self.neo4j["import_dir"])
self.topoB = f.ExperimentTopology(importer=self.n4j_imp)
new_id = str(uuid.uuid4())
# if you need to override graph id use new_graph_id, otherwise parameter is optional
self.topoB.load(graph_string=graph_A_string, new_graph_id=new_id)
Also now the code allows to dynamically connect/disconnect interfaces from services, not just passing them in the constructor (although that is still valid):
Also now substrate models can be validated, not just experiment topology objects.
NOTE: NetworkService objects continue to have site property, however it is no longer set in the constructor (because it may not be possible) by default. Instead the validate() call sets it. Also NetworkService constructor does allow explicitly setting the site property if needed and validate() call checks that it was set correctly based on the interfaces that were connected to the service.
Diffying topologies works.
where diffres is a
TopologyDiff
dataclass:Note that both topologies (topoA and topoB) must be loaded into Neo4j. Remember that all ModelElement objects (Node, Component, Interface, NetworkService) are shallow and build their innards by querying the underlying backend (Neo4j in this case) when properties are needed. Both graphs topoA and topoB must therefore be present, otherwise only names and GUIDs of the elements will be known.
Creating them can be done thusly:
Also now the code allows to dynamically connect/disconnect interfaces from services, not just passing them in the constructor (although that is still valid):
Similarly you can disconnect:
Also now substrate models can be validated, not just experiment topology objects.
NOTE: NetworkService objects continue to have
site
property, however it is no longer set in the constructor (because it may not be possible) by default. Instead thevalidate()
call sets it. Also NetworkService constructor does allow explicitly setting thesite
property if needed andvalidate()
call checks that it was set correctly based on the interfaces that were connected to the service.