Exemplo n.º 1
0
    def add_vrouter(self):
        gsc_obj = self._global_system_config_obj

        if self._args.ip_fabric_subnet:
            ip_subnet, mask = self._args.ip_fabric_subnet.split('/')
            so = SubnetType(ip_subnet, int(mask))
            sl = gsc_obj.get_ip_fabric_subnets()
            if sl is None:
                gsc_obj.set_ip_fabric_subnets(SubnetListType([so]))
                self._vnc_lib.global_system_config_update(gsc_obj)
            elif so not in sl.subnet:
                sl.subnet.append(so)
                gsc_obj.set_ip_fabric_subnets(sl)
                self._vnc_lib.global_system_config_update(gsc_obj)

        vrouter_obj = VirtualRouter(
            self._args.host_name,
            gsc_obj,
            virtual_router_ip_address=self._args.host_ip)
        vrouter_exists = True

        try:
            vrouter_obj = self._vnc_lib.virtual_router_read(
                fq_name=vrouter_obj.get_fq_name())
        except NoIdError:
            vrouter_exists = False

        if self._args.sub_cluster_name:
            sub_cluster_obj = SubCluster(self._args.sub_cluster_name)
            try:
                sub_cluster_obj = self._vnc_lib.sub_cluster_read(
                    fq_name=sub_cluster_obj.get_fq_name())
            except NoIdError:
                raise RuntimeError("Sub cluster has to be provisioned first")
            vrouter_obj.add_sub_cluster(sub_cluster_obj)

        # Configure router type
        if self._args.router_type:
            vrouter_obj.set_virtual_router_type(self._args.router_type)
        if self._args.dpdk_enabled:
            vrouter_obj.set_virtual_router_dpdk_enabled(True)
        else:
            vrouter_obj.set_virtual_router_dpdk_enabled(False)

        # Configure sirov physical networks
        if self._args.sriov_physnets:
            vrouter_obj.set_virtual_router_sriov_physical_networks(
                self._args.sriov_physnets)
        if vrouter_exists:
            self.vrouter_fq_name = vrouter_obj.get_fq_name()
            self._vnc_lib.virtual_router_update(vrouter_obj)
        else:
            try:
                self.vrouter_fq_name = vrouter_obj.get_fq_name()
                self._vnc_lib.virtual_router_create(vrouter_obj)
            except RefsExistError:
                print("Already created!")
Exemplo n.º 2
0
    def test_ibgp_auto_mesh_sub(self):
        config_db.GlobalSystemConfigST.ibgp_auto_mesh = True
        self.assertEqual(config_db.GlobalSystemConfigST.get_ibgp_auto_mesh(),
                         True, "ibgp_auto_mesh_toggle_test")
        # create subcluster
        sub_cluster_obj = SubCluster('test-host', sub_cluster_asn=64513)

        self._vnc_lib.sub_cluster_create(sub_cluster_obj)
        sub_cluster_obj = self._vnc_lib.sub_cluster_read(
            fq_name=sub_cluster_obj.get_fq_name())
        # create router1
        r1_name = self.id() + 'router1'
        router1 = self.create_bgp_router_sub(
            r1_name,
            'contrail',
            asn=64513,
            router_type='external-control-node',
            sub_cluster=sub_cluster_obj)
        # create router2
        r2_name = self.id() + 'router2'
        router2 = self.create_bgp_router_sub(
            r2_name,
            'contrail',
            asn=64513,
            router_type='external-control-node',
            sub_cluster=sub_cluster_obj)
        # create router3
        r3_name = self.id() + 'router3'
        router3 = self.create_bgp_router(r3_name, 'contrail')
        # create router4
        r4_name = self.id() + 'router4'
        router4 = self.create_bgp_router(r4_name, 'contrail')

        self.check_bgp_peering(router3, router4, 1)
        self.check_bgp_peering(router1, router2, 1)

        self._vnc_lib.bgp_router_delete(id=router1.uuid)
        self._vnc_lib.bgp_router_delete(id=router2.uuid)
        self._vnc_lib.bgp_router_delete(id=router3.uuid)
        self._vnc_lib.bgp_router_delete(id=router4.uuid)
        self._vnc_lib.sub_cluster_delete(id=sub_cluster_obj.uuid)
        gevent.sleep(1)
Exemplo n.º 3
0
    def test_ibgp_auto_mesh_sub(self):
        config_db.GlobalSystemConfigST.ibgp_auto_mesh = True
        self.assertEqual(config_db.GlobalSystemConfigST.get_ibgp_auto_mesh(),
                         True, "ibgp_auto_mesh_toggle_test")
        # create subcluster
        sub_cluster_obj = SubCluster('test-host', sub_cluster_asn=64513)

        self._vnc_lib.sub_cluster_create(sub_cluster_obj)
        sub_cluster_obj = self._vnc_lib.sub_cluster_read(
                fq_name=sub_cluster_obj.get_fq_name())
        # create router1
        r1_name = self.id() + 'router1'
        router1 = self.create_bgp_router_sub(r1_name, 'contrail', asn=64513,
                                             router_type='external-control-node',
                                             sub_cluster=sub_cluster_obj)
        # create router2
        r2_name = self.id() + 'router2'
        router2 = self.create_bgp_router_sub(r2_name, 'contrail', asn=64513,
                                             router_type='external-control-node',
                                             sub_cluster=sub_cluster_obj)
        # create router3
        r3_name = self.id() + 'router3'
        router3 = self.create_bgp_router(r3_name, 'contrail')
        # create router4
        r4_name = self.id() + 'router4'
        router4 = self.create_bgp_router(r4_name, 'contrail')

        self.check_bgp_peering(router3, router4, 1)
        self.check_bgp_peering(router1, router2, 1)


        self._vnc_lib.bgp_router_delete(id=router1.uuid)
        self._vnc_lib.bgp_router_delete(id=router2.uuid)
        self._vnc_lib.bgp_router_delete(id=router3.uuid)
        self._vnc_lib.bgp_router_delete(id=router4.uuid)
        self._vnc_lib.sub_cluster_delete(id=sub_cluster_obj.uuid)
        gevent.sleep(1)