Ejemplo n.º 1
0
    def test_asm_transfer(self):
        """
        Test creating ASM in NetworkX and transition to Neo4j
        :return:
        """
        t = fu.ExperimentTopology()
        n1 = t.add_node(name='n1', site='RENC')
        cap = fu.Capacities(core=4, ram=64, disk=500)
        n1.set_properties(capacities=cap,
                          image_type='qcow2',
                          image_ref='default_centos_8')
        n1.add_component(ctype=fu.ComponentType.SmartNIC,
                         model='ConnectX-6',
                         name='nic1')
        n2 = t.add_node(name='n2', site='RENC')
        n2.set_properties(capacities=cap,
                          image_type='qcow2',
                          image_ref='default_centos_8')
        n2.add_component(ctype=fu.ComponentType.GPU,
                         model='RTX6000',
                         name='nic2')
        slice_graph = t.serialize()

        #t.serialize(file_name='slice_graph.graphml')
        generic_graph = self.n4j_imp.import_graph_from_string(
            graph_string=slice_graph, graph_id=t.graph_model.graph_id)
        asm_graph = Neo4jASMFactory.create(generic_graph)
        node_ids = asm_graph.list_all_node_ids()
        print('ASM Node IDs')
        print(node_ids)
        node_id = next(iter(node_ids))

        # this is how you map  to BQM
        asm_graph.set_mapping(node_id=node_id,
                              to_graph_id="dead-beef",
                              to_node_id='beef-beef')
        to_graph, to_node = asm_graph.get_mapping(node_id=node_id)

        assert (to_graph == "dead-beef")
        assert (to_node == "beef-beef")

        # test creating an experiment topology as a cast of an ASM loaded into Neo4j
        neo4j_topo = fu.ExperimentTopology()
        neo4j_topo.cast(asm_graph=asm_graph)

        print(f'New topology on top of {neo4j_topo.graph_model.graph_id}')
        print(neo4j_topo.nodes)

        # set allocated capacities or labels
        # in orchestrator
        alloc_labels = fu.Labels(instance_parent="worker_node-1")
        neo4j_topo.nodes['n1'].set_properties(label_allocations=alloc_labels)
        # in AM
        provisioned_labels = fu.Labels(instance="open-stack-instance-id-123")
        neo4j_topo.nodes['n1'].set_properties(labels=provisioned_labels)
        ri = fu.ReservationInfo(reservation_id="01234",
                                reservation_state='READY')
        neo4j_topo.nodes['n1'].set_properties(reservation_info=ri)

        self.n4j_imp.delete_all_graphs()
Ejemplo n.º 2
0
    def testSerDes3(self):
        # multi-format serialization-deserialization test
        topo = f.ExperimentTopology()
        topo.add_node(name='n1', site='RENC')
        cap = f.Capacities(core=1, unit=2)
        topo.nodes['n1'].capacities = cap
        topo.nodes['n1'].add_component(ctype=f.ComponentType.SharedNIC,
                                       model='ConnectX-6',
                                       name='nic1')
        topo.add_node(name='n2', site='UKY')
        topo.nodes['n2'].add_component(ctype=f.ComponentType.SharedNIC,
                                       model='ConnectX-6',
                                       name='nic2')
        topo.add_network_service(name='s1',
                                 nstype=f.ServiceType.L2STS,
                                 interfaces=topo.interface_list)
        slice_graph = topo.serialize(fmt=f.GraphFormat.JSON_NODELINK)

        print(f'NODE_LINK {slice_graph=}')

        t1 = f.ExperimentTopology(graph_string=slice_graph)

        self.assertTrue('n1' in t1.nodes.keys())
        self.assertTrue('nic1' in t1.nodes['n1'].components.keys())
        cap1 = t1.nodes['n1'].capacities
        self.assertEqual(cap1.core, 1)
        self.assertEqual(cap1.unit, 2)

        print(f'LIST COMPONENTS of n1 {t1.nodes["n1"].components}')
        print(f'LIST COMPONENTS of n2 {t1.nodes["n2"].components}')
        self.n4j_imp.delete_all_graphs()
Ejemplo n.º 3
0
    def build_slice_with_compute_only(include_components: bool = False, exceed_capacities: bool = False,
                                      exceed_components: bool = False, use_hints: bool = False, no_cap: bool = False,
                                      instance_type: str = "fabric.c8.m32.d500") -> str:
        t = fu.ExperimentTopology()
        n1 = t.add_node(name='n1', site='RENC')

        n1.set_properties(image_type='qcow2', image_ref='default_centos_8')

        n2 = t.add_node(name='n2', site='RENC')
        n2.set_properties(image_type='qcow2', image_ref='default_centos_8')

        if not no_cap:
            cap = None
            if exceed_capacities:
                cap = fu.Capacities(core=33, ram=64, disk=500)
            else:
                cap = fu.Capacities(core=3, ram=61, disk=499)
            n1.set_properties(capacities=cap)
            n2.set_properties(capacities=cap)

        if include_components:
            n1.add_component(ctype=fu.ComponentType.SmartNIC, model='ConnectX-6', name='nic1')
            n2.add_component(ctype=fu.ComponentType.NVME, model='P4510', name='c1')
            n2.add_component(ctype=fu.ComponentType.GPU, model='RTX6000', name='c2')
            if exceed_components:
                n2.add_component(ctype=fu.ComponentType.GPU, model='Tesla T4', name='c3')
                n2.add_component(ctype=fu.ComponentType.SmartNIC, model='ConnectX-6', name='nic1')
                n2.add_component(ctype=fu.ComponentType.SmartNIC, model='ConnectX-5', name='nic2')

        if use_hints:
            cap_hints = fu.CapacityHints(instance_type=instance_type)
            n1.set_properties(capacity_hints=cap_hints)
            n2.set_properties(capacity_hints=cap_hints)

        return t.serialize()
Ejemplo n.º 4
0
 def setUp(self) -> None:
     self.topo = f.ExperimentTopology()
     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"])
Ejemplo n.º 5
0
    def testSerDes2(self):
        # more thorough serialization-deserialization test
        topo = f.ExperimentTopology()
        topo.add_node(name='n1', site='RENC')
        cap = f.Capacities(core=1, unit=2)
        topo.nodes['n1'].capacities = cap
        topo.nodes['n1'].add_component(ctype=f.ComponentType.SharedNIC,
                                       model='ConnectX-6',
                                       name='nic1')
        topo.add_node(name='n2', site='UKY')
        topo.nodes['n2'].add_component(ctype=f.ComponentType.SharedNIC,
                                       model='ConnectX-6',
                                       name='nic2')
        topo.add_network_service(name='s1',
                                 nstype=f.ServiceType.L2STS,
                                 interfaces=topo.interface_list)
        slice_graph = topo.serialize()
        print('\n\n\nINITIAL TOPO')
        print(topo)

        # 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 = f.ExperimentTopology(graph_string=orch_graph)

        print('\n\n\nRELOADED TOPO')
        print(t1)
        self.assertTrue('n1' in t1.nodes.keys())
        self.assertTrue('nic1' in t1.nodes['n1'].components.keys())
        cap1 = t1.nodes['n1'].capacities
        self.assertEqual(cap1.core, 1)
        self.assertEqual(cap1.unit, 2)

        print(f'LIST COMPONENTS of n1 {t1.nodes["n1"].components}')
        print(f'LIST COMPONENTS of n2 {t1.nodes["n2"].components}')
        self.n4j_imp.delete_all_graphs()
Ejemplo n.º 6
0
 def testSerDes(self):
     self.topo.add_node(name='n1', site='RENC')
     self.topo.nodes['n1'].add_component(ctype=f.ComponentType.SharedNIC,
                                         model='ConnectX-6',
                                         name='nic1')
     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())
Ejemplo n.º 7
0
    def build_2_site_ptp_slice_sriov() -> str:
        """
        2-site for PTP service between two shared card ports
        """
        t = fu.ExperimentTopology()
        n1 = t.add_node(name='n1', site='RENC', ntype=fu.NodeType.VM)
        n2 = t.add_node(name='n2', site='UKY')

        cap = fu.Capacities(core=2, ram=8, disk=100)
        n1.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')
        n2.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')

        n1.add_component(model_type=fu.ComponentModelType.SharedNIC_ConnectX_6, name='n1-nic1')
        n2.add_component(model_type=fu.ComponentModelType.SharedNIC_ConnectX_6, name='n2-nic1')
        n2.add_component(ctype=fu.ComponentType.NVME, model='P4510', name='c1')

        t.add_network_service(name='ptp1', nstype=fu.ServiceType.L2PTP,
                              interfaces=[n1.interface_list[0], n2.interface_list[0]])

        return t.serialize()
Ejemplo n.º 8
0
    def build_slice() -> str:
        t = fu.ExperimentTopology()
        n1 = t.add_node(name='n1', site='RENC', ntype=fu.NodeType.VM)
        n2 = t.add_node(name='n2', site='RENC')
        n3 = t.add_node(name='n3', site='RENC')

        cap = fu.Capacities(core=2, ram=8, disk=100)
        n1.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')
        n2.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')
        n3.set_properties(capacities=cap, image_type='qcow2', image_ref='default_centos_8')

        n1.add_component(model_type=fu.ComponentModelType.SharedNIC_ConnectX_6, name='n1-nic1')

        n2.add_component(model_type=fu.ComponentModelType.SmartNIC_ConnectX_6, name='n2-nic1')
        n2.add_component(ctype=fu.ComponentType.NVME, model='P4510', name='c1')

        n3.add_component(model_type=fu.ComponentModelType.SmartNIC_ConnectX_5, name='n3-nic1')

        t.add_network_service(name='bridge1', nstype=fu.ServiceType.L2Bridge, interfaces=t.interface_list)

        return t.serialize()
Ejemplo n.º 9
0
 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}')
    def testNodeAndServiceSlivers(self):
        t = f.ExperimentTopology()
        t.add_node(name='n1', site='RENC')
        t.nodes['n1'].capacities = f.Capacities(core=1)
        t.nodes['n1'].add_component(name='c1',
                                    ctype=f.ComponentType.SmartNIC,
                                    model='ConnectX-6')
        d = ABCPropertyGraph.sliver_to_dict(t.nodes['n1'].get_sliver())
        t.add_node(name='n2', site='RENC')
        t.nodes['n2'].add_component(name='c2',
                                    ctype=f.ComponentType.SmartNIC,
                                    model='ConnectX-6')
        t.nodes['n2'].add_component(name='c3',
                                    ctype=f.ComponentType.NVME,
                                    model='P4510')
        t.add_network_service(name='s1',
                              nstype=f.ServiceType.L2Bridge,
                              interfaces=t.interface_list)
        jns = JSONSliver.sliver_to_json(t.nodes['n1'].get_sliver())
        ns1 = JSONSliver.node_sliver_from_json(jns)
        jns = JSONSliver.sliver_to_json(t.nodes['n2'].get_sliver())
        ns2 = JSONSliver.node_sliver_from_json(jns)
        ness = JSONSliver.sliver_to_json(t.network_services['s1'].get_sliver())
        nss1 = JSONSliver.network_service_sliver_from_json(ness)

        self.assertEqual(ns1.capacities.core, 1)
        self.assertEqual(len(ns1.attached_components_info.list_devices()), 1)
        self.assertEqual(len(ns2.attached_components_info.list_devices()), 2)
        self.assertEqual(len(nss1.interface_info.list_interfaces()), 4)
        inames = [
            i.resource_name for i in nss1.interface_info.list_interfaces()
        ]
        self.assertTrue('n2-c2-p1' in inames)
        self.assertEqual(
            ns1.attached_components_info.list_devices()
            [0].network_service_info.list_services()
            [0].interface_info.list_interfaces()[0].capacities.bw, 100)
Ejemplo n.º 11
0
def load(file_name: str):

    t = fu.ExperimentTopology()
    t.load(file_name=file_name)
    return t