fabric-testbed / InformationModel

FABRIC Information Model library
MIT License
7 stars 1 forks source link

Nodes[c].components returns empty #80

Closed ibaldin closed 3 years ago

ibaldin commented 3 years ago

Issue: Nodes in ExperimentTopology have empty components when topology is built from a graph_string or file Scenario: • Create ExperimentTopology as “topology” object • Add Nodes and attach components to each nodes • Serialize the topology as a file • Reload the topology from the saved file as “topology2” object • topology2.nodes[“n1”].components returns an empty dictionary Possible solution: File: networkx_mixin.py Function: NetworkXMixin::_get_first_neighbors_via line 128 the if statement uses an incorrect constant NetworkXMixin.NETWORKX_LABEL which is defined as Class Passing label instead in the following statement fixes the issue. if graph.edges[(real_node, n)].get(NetworkXMixin.NETWORKX_LABEL, None) != rel:

ibaldin commented 3 years ago

So I ran the following test:

    def testSerDes1(self):
        # more thorough serialization-deserialization test
        self.topo.add_node(name='n1', site='RENC')
        self.topo.nodes['n1'].add_component(ctype=f.ComponentType.SharedNIC, model='ConnectX-6', name='nic1')
        self.topo.add_node(name='n2', site='UKY')
        self.topo.nodes['n2'].add_component(ctype=f.ComponentType.SharedNIC, model='ConnectX-6', name='nic1')
        self.topo.add_network_service(name='s1', nstype=f.ServiceType.L2STS, interfaces=self.topo.interface_list)
        gs = self.topo.serialize()
        self.topo.graph_model.importer.delete_all_graphs()
        t1 = f.ExperimentTopology(graph_string=gs)
        self.assertEqual(t1.graph_model.graph_id, self.topo.graph_model.graph_id)
        self.assertTrue('n1' in t1.nodes.keys())
        self.assertTrue('nic1' in t1.nodes['n1'].components.keys())
        print(f'LIST COMPONENTS of n1 {t1.nodes["n1"].components}')
        print(f'LIST COMPONENTS of n2 {t1.nodes["n2"].components}')

and I got this output:

LIST COMPONENTS of n1 {'nic1': {'details': 'Mellanox ConnectX-6 VPI MCX653 dual port 100Gbps', 'model': 'ConnectX-6', 'name': 'nic1', 'type': 'SharedNIC'}}
LIST COMPONENTS of n2 {'nic1': {'details': 'Mellanox ConnectX-6 VPI MCX653 dual port 100Gbps', 'model': 'ConnectX-6', 'name': 'nic1', 'type': 'SharedNIC'}}

which seems correct. Sorry, I'm not understanding this @kthare10

kthare10 commented 3 years ago

I think the missing piece is that Orchestrator loads the Experiment Topology and converts into Neo4jASM. It then sends out the serialized Neo4JASM back to the user. Following test captures the failure, I am observing:

    def testSerDes1(self):
        # more thorough serialization-deserialization test
        topo = fu.ExperimentTopology()
        topo.add_node(name='n1', site='RENC')
        topo.nodes['n1'].add_component(ctype=fu.ComponentType.SharedNIC, model='ConnectX-6', name='nic1')
        topo.add_node(name='n2', site='UKY')
        topo.nodes['n2'].add_component(ctype=fu.ComponentType.SharedNIC, model='ConnectX-6', name='nic1')
        topo.add_network_service(name='s1', nstype=fu.ServiceType.L2STS, interfaces=topo.interface_list)
        slice_graph = topo.serialize()

        # Import it in the neo4j as ASM
        generic_graph = self.n4j_imp.import_graph_from_string(graph_string=slice_graph)
        asm_graph = Neo4jASMFactory.create(generic_graph)

        # Serialize ASM
        orch_graph = asm_graph.serialize_graph()

        # Reload Experiment topology from serialized ASM
        t1 = fu.ExperimentTopology(graph_string=orch_graph)

        self.assertTrue('n1' in t1.nodes.keys())
        self.assertTrue('nic1' in t1.nodes['n1'].components.keys())
        print(f'LIST COMPONENTS of n1 {t1.nodes["n1"].components}')
        print(f'LIST COMPONENTS of n2 {t1.nodes["n2"].components}')
ibaldin commented 3 years ago

Ah, I'm wondering if the other issue with capacities is also because of some difference in Neo4j vs. NetworkX. I will investigate.