def test_update_global_asn_with_valid_4_byte(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # First, enable 4byte AS flag.
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        # Read back the GSC
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        self.assertEqual(True, gsc.enable_4byte_as)

        # Update global ASN to a 4 byte value
        gsc.autonomous_system = 700000
        self.api.global_system_config_update(gsc)

        # Read back the GSC
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        self.assertEqual(700000, gsc.autonomous_system)

        # Set the DEFAULT ASN and enable_4byte_as flag back to default as in
        # CI, the order of test cases can change
        gsc.autonomous_system = self.DEFAULT_ASN
        self.api.global_system_config_update(gsc)

        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
    def test_update_4_byte_asn_range_check(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # First, enable 4byte AS flag.
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        # Update ASN to greater than 0xFFffFFff
        gsc.autonomous_system = 0x1FFFFFFFF
        self.assertRaises(BadRequest, self.api.global_system_config_update,
                          gsc)

        # Set enable_4byte_as flag back to default
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
Exemplo n.º 3
0
    def test_update_both_global_asn_and_asn_flag(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # First, enable 4byte AS flag.
        gsc.enable_4byte_as = True
        gsc.autonomous_system = 61450
        self.api.global_system_config_update(gsc)
    def test_bgp_router_update_with_invalid_4_byte_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        # Enable 4 byte ASN flag in GSC
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        rt_inst_obj = self.api.routing_instance_read(fq_name=[
            'default-domain', 'default-project', 'ip-fabric', '__default__'
        ])
        bgp_router_params = BgpRouterParams(router_type='control-node',
                                            autonomous_system=64512,
                                            local_autonomous_system=64500)
        bgp_router_obj = BgpRouter(name='bgprouter1',
                                   parent_obj=rt_inst_obj,
                                   bgp_router_parameters=bgp_router_params)
        bgp_router_uuid = self.api.bgp_router_create(bgp_router_obj)

        # Read back the bgp_router object
        bgp_router_obj = self.api.bgp_router_read(id=bgp_router_uuid)

        # update asn numbers to invalid 4 byte value
        new_bgp_router_params = BgpRouterParams(
            router_type='control-node',
            autonomous_system=0x1FFFFFFFFF,
            local_autonomous_system=0x1FFFFFFFFF)
        bgp_router_obj.set_bgp_router_parameters(new_bgp_router_params)

        self.assertRaises(BadRequest, self.api.bgp_router_update,
                          bgp_router_obj)

        # Now delete the bgp router object and disable 4 byte ASN flag
        self.api.bgp_router_delete(id=bgp_router_uuid)
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
    def test_cannot_update_global_asn_if_used_by_user(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        gsc.autonomous_system = self.NEW_ASN
        with mock.patch.object(self._api_server._db_conn, 'dbe_list',
                               return_value=(True, self.FAKE_VN_LIST, None)):
            self.assertRaises(BadRequest, self.api.global_system_config_update,
                              gsc)
    def test_create_vn_with_configured_rt_in_system_range(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        vn = VirtualNetwork('%s-vn' % self.id())
        rt_name = 'target:%d:%d' % (gsc.autonomous_system,
                                    BGP_RTGT_MIN_ID + 1000)
        vn.set_route_target_list(RouteTargetList([rt_name]))

        self.assertRaises(BadRequest, self.api.virtual_network_create, vn)
Exemplo n.º 7
0
    def test_update_global_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        self.assertEqual(self.DEFAULT_ASN, gsc.autonomous_system)
        gsc.autonomous_system = self.NEW_ASN
        gsc = self.api.global_system_config_update(gsc)
        self.assertEqual(self.NEW_ASN,
                         GlobalSystemConfigServer._autonomous_system)
Exemplo n.º 8
0
    def tearDown(self, *args, **kwargs):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        gsc.autonomous_system = self.DEFAULT_ASN
        gsc.enable_4byte_as = False

        self.api.global_system_config_update(gsc)
        self._api_server._global_asn = None

        test_case.ApiServerTestCase.tearDown(self)
Exemplo n.º 9
0
    def test_update_global_asn_with_valid_4_byte(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # First, enable 4byte AS flag.
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        # Read back the GSC
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        self.assertEqual(True, gsc.enable_4byte_as)

        # Update global ASN to a 4 byte value
        gsc.autonomous_system = 700000
        self.api.global_system_config_update(gsc)

        # Read back the GSC
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        self.assertEqual(700000, gsc.autonomous_system)
    def test_update_both_global_asn_and_asn_flag(self):
        # For simplicity, we don't allow update of both autonomous_system
        # and enable_4byte_as in the same request.
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # First, enable 4byte AS flag.
        gsc.enable_4byte_as = True
        gsc.autonomous_system = 61450
        self.assertRaises(BadRequest, self.api.global_system_config_update,
                          gsc)
Exemplo n.º 11
0
    def test_can_update_global_asn_if_not_used_by_user(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        gsc.enable_4byte_as = False

        tests = [
            {'autonomous_system': self.NEW_ASN + 10,
             'mock_return_value': (True, self.FAKE_VN_LIST, None)},
            {'autonomous_system': self.NEW_ASN + 2,
             'mock_return_value': (True, self.FAKE_LR_LIST, None)},
        ]
        for t in tests:
            with mock.patch.object(self._api_server._db_conn, 'dbe_list',
                                   return_value=t['mock_return_value']):
                gsc.autonomous_system = t['autonomous_system']
                self.api.global_system_config_update(gsc)

            gsc = self.api.global_system_config_read(
                GlobalSystemConfig().fq_name)
            self.assertEqual(gsc.autonomous_system, t['autonomous_system'])
Exemplo n.º 12
0
    def test_control_node_zone(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        cnz = []
        for i in range(2):
            cnz_name = "cnz-" + str(i)
            cnz.append(ControlNodeZone(name=cnz_name, parent_obj=gsc))
            self.api.control_node_zone_create(cnz[i])

        rt_inst_obj = self.api.routing_instance_read(fq_name=[
            'default-domain', 'default-project', 'ip-fabric', '__default__'
        ])
        bgp_router_params = BgpRouterParams(router_type='control-node')

        # create bgp_rotuer with two control-node-zones
        bgp_router_obj = BgpRouter(name='bgprouter',
                                   parent_obj=rt_inst_obj,
                                   bgp_router_parameters=bgp_router_params)
        bgp_router_obj.add_control_node_zone(cnz[0])
        bgp_router_obj.add_control_node_zone(cnz[1])
        try:
            self.api.bgp_router_create(bgp_router_obj)
        except BadRequest:
            pass

        # update bgp_router with two control-node-zones
        bgp_router_obj = BgpRouter(name='bgprouter',
                                   parent_obj=rt_inst_obj,
                                   bgp_router_parameters=bgp_router_params)
        bgp_router_uuid = self.api.bgp_router_create(bgp_router_obj)
        bgp_router_obj.add_control_node_zone(cnz[0])
        bgp_router_obj.add_control_node_zone(cnz[1])
        try:
            self.api.bgp_router_update(bgp_router_obj)
        except BadRequest:
            self.api.bgp_router_delete(id=bgp_router_uuid)

        # update bgp_router with same control-node-zone
        bgp_router_obj = BgpRouter(name='bgprouter',
                                   parent_obj=rt_inst_obj,
                                   bgp_router_parameters=bgp_router_params)
        bgp_router_obj.add_control_node_zone(cnz[0])
        bgp_router_uuid = self.api.bgp_router_create(bgp_router_obj)
        bgp_router_obj = self.api.bgp_router_read(id=bgp_router_uuid)
        bgp_router_obj.add_control_node_zone(cnz[0])
        self.api.bgp_router_update(bgp_router_obj)

        # update bgp_router with new control-node-zone
        bgp_router_obj.add_control_node_zone(cnz[1])
        try:
            self.api.bgp_router_update(bgp_router_obj)
        except BadRequest:
            self.api.bgp_router_delete(id=bgp_router_uuid)

        for i in range(2):
            self.api.control_node_zone_delete(fq_name=cnz[i].fq_name)
Exemplo n.º 13
0
    def test_update_asn_if_any_rt_uses_4_byte(self):
        """
        Test scenario.

        1. Set enable_4byte_as to true
        2. Create RT with 4 bytes ASN
        3. Set enable_4byte_as to false
        4. Change global ASN to different 2 bytes numbers
        """
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # Set enable_4byte_as to True
        gsc.enable_4byte_as = True
        gsc.autonomous_system = self.ASN_4_BYTES
        self.api.global_system_config_update(gsc)

        # reread gsc
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        self.assertEqual(gsc.enable_4byte_as, True)

        # create VN and RT with 4bytes ASN
        vn = VirtualNetwork('%s-vn' % self.id())
        rt_name = 'target:%d:%d' % (self.ASN_4_BYTES, 1000)
        vn.set_route_target_list(RouteTargetList([rt_name]))
        self.api.virtual_network_create(vn)

        # Set enable_4byte_as to false
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
        # Change global ASN to 2 bytes numbers (must be in separate step)
        gsc.autonomous_system = self.NEW_ASN
        self.api.global_system_config_update(gsc)

        # reread gsc to confirm change
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        self.assertEqual(gsc.autonomous_system, self.NEW_ASN)

        # cleanup
        self.api.virtual_network_delete(id=vn.uuid)
        gsc.autonomous_system = self.DEFAULT_ASN
        self.api.global_system_config_update(gsc)
    def test_update_both_global_asn_and_asn_flag(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        # First, enable 4byte AS flag.
        gsc.enable_4byte_as = True
        gsc.autonomous_system = 61450
        self.api.global_system_config_update(gsc)

        # Set the enable_4_byte back to false
        gsc.enable_4byte_as = False
        gsc.autonomous_system = self.DEFAULT_ASN
        self.api.global_system_config_update(gsc)
Exemplo n.º 15
0
    def test_bgpaas_create_with_invalid_4_byte_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        # Enable 4 byte ASN flag in GSC
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        proj = self.api.project_read(
            fq_name=["default-domain", "default-project"])
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        # Set a invalid ASN and create bgpaas object
        bgpaas_obj.autonomous_system = 0x1FFFFFFFF
        self.assertRaises(BadRequest, self.api.bgp_as_a_service_create,
                          bgpaas_obj)

        # Finally, disable 4 byte ASN flag
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
Exemplo n.º 16
0
    def test_bgpaas_create_with_valid_4_byte_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        # Enable 4 byte ASN flag in GSC
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        proj = self.api.project_read(
            fq_name=["default-domain", "default-project"])
        bgpaas_obj = BgpAsAService(name='bgpaas',
                                   parent_obj=proj)
        # Set a valid ASN and create bgpaas object
        bgpaas_obj.autonomous_system = 700000
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)

        # Now delete the bgpaas object and disable 4 byte ASN flag
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
Exemplo n.º 17
0
    def test_asn_change_when_zk_rt_missing(self):
        vn_obj = self.create_virtual_network('vn_for_asn' + self.id(),
                                             '10.0.0.0/24')
        ri_fq_name = vn_obj.fq_name + [vn_obj.fq_name[-1]]
        rt_obj = self.wait_for_route_target(vn_obj)
        rt_id_str = "%(#)010d" % {
            '#': int(rt_obj.get_fq_name_str().split(':')[-1])
        }
        db_checker = db_manage.DatabaseChecker(
            *db_manage._parse_args('check --cluster_id %s' % self._cluster_id))
        path = '%s%s%s' % (self._cluster_id, db_checker.BASE_RTGT_ID_ZK_PATH,
                           rt_id_str)
        self.assertEqual(
            db_checker._zk_client.get(path)[0], ':'.join(ri_fq_name))
        with db_checker._zk_client.patch_path(path):
            errors = db_checker.check_route_targets_id()
            error_types = [type(x) for x in errors]
            self.assertIn(db_manage.SchemaRTgtIdExtraError, error_types)
            self.assertIn(db_manage.ConfigRTgtIdExtraError, error_types)

            free_rt_orig = SchemaTransformerDB.free_route_target

            # Flag to be used to check free_route_target function failure
            has_test_failed = [False]

            def mock_free_rt(*args, **kwargs):
                try:
                    return free_rt_orig(*args, **kwargs)
                except Exception:
                    has_test_failed[0] = True

            SchemaTransformerDB.free_route_target = mock_free_rt
            gsc = self._vnc_lib.global_system_config_read(
                GlobalSystemConfig().fq_name)

            gsc.enable_4byte_as = True
            gsc.autonomous_system = 81000
            self._vnc_lib.global_system_config_update(gsc)

            # Wait for Schema_tranformer to process ASN change
            gevent.sleep(10)
            SchemaTransformerDB.free_route_target = free_rt_orig
            if has_test_failed[0]:
                self.fail("free_route_target failed in schema transformer")
Exemplo n.º 18
0
    def setUpClass(cls, *args, **kwargs):
        super(TestSubClusterBase, cls).setUpClass(*args, **kwargs)

        cls._gsc = cls._vnc_lib.global_system_config_read(
            GlobalSystemConfig().fq_name)

        if hasattr(cls, '_global_asn') and cls._global_asn:
            cls._gsc.set_autonomous_system(cls._global_asn)
            if cls._global_asn > 0xFFFF:
                cls._gsc.enable_4byte_as = True
            cls._vnc_lib.global_system_config_update(cls._gsc)
        else:
            cls._global_asn = cls._gsc.get_autonomous_system()

        # Create a pool of 10 sub-cluster IDs to use for the tests
        start = 42
        if cls._global_asn <= 0xFFFF:
            start += 1 << 16
        cls._id_range = set(range(start, start + 10))
Exemplo n.º 19
0
    def test_bgpaas_update_with_valid_4_byte_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        # Enable 4 byte ASN flag in GSC
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        # Create bgpaas object with ASN 64512
        bgpaas_uuid, bgpaas_obj = self.create_bgpaas()

        # Update ASN with a valid 4 byte value
        bgpaas_obj.autonomous_system = 700000
        self.api.bgp_as_a_service_update(bgpaas_obj)

        # Disable 4 byte ASN flag
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)

        # Finally, delete the bgpaas object
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
Exemplo n.º 20
0
    def test_bgpaas_update_with_valid_4_byte_local_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        # Enable 4 byte ASN flag in GSC
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        # Create bgpaas object with ASN 64512 and Local ASN 64500
        bgpaas_uuid, bgpaas_obj = self.create_bgpaas_with_local_asn()

        # Update Local ASN with a valid value
        bgp_session_attr = BgpSessionAttributes(local_autonomous_system=700002)
        bgpaas_obj.set_bgpaas_session_attributes(bgp_session_attr)
        self.api.bgp_as_a_service_update(bgpaas_obj)

        # Disable 4 byte ASN flag
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)

        # Finally, delete the bgpaas object
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)
Exemplo n.º 21
0
    def test_bgp_router_create_with_invalid_4_byte_asn(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        # Enable 4 byte ASN flag in GSC
        gsc.enable_4byte_as = True
        self.api.global_system_config_update(gsc)

        rt_inst_obj = self.api.routing_instance_read(fq_name=[
            'default-domain', 'default-project', 'ip-fabric', '__default__'
        ])
        bgp_router_params = BgpRouterParams(router_type='control-node',
                                            autonomous_system=0x1FFFFFFFF,
                                            local_autonomous_system=700000)
        bgp_router_obj = BgpRouter(name='bgprouter1',
                                   parent_obj=rt_inst_obj,
                                   bgp_router_parameters=bgp_router_params)
        self.assertRaises(BadRequest, self.api.bgp_router_create,
                          bgp_router_obj)

        # Now disable 4 byte ASN flag
        gsc.enable_4byte_as = False
        self.api.global_system_config_update(gsc)
Exemplo n.º 22
0
    def test_cannot_update_global_asn_if_used_by_user(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)

        tests = [
            {'autonomous_system': self.NEW_ASN,
             'mock_return_value': (True, self.FAKE_VN_LIST, None),
             'expected_rt_count': 6},
            {'autonomous_system': self.NEW_ASN + 1,
             'mock_return_value': (True, self.FAKE_VN_LIST, None),
             'expected_rt_count': 1},
            {'autonomous_system': self.NEW_ASN + 2,
             'mock_return_value': (True, self.FAKE_VN_LIST, None),
             'expected_rt_count': 1},
            {'autonomous_system': self.NEW_ASN,
             'mock_return_value': (True, self.FAKE_LR_LIST, None),
             'expected_rt_count': 2},
            {'autonomous_system': self.NEW_ASN + 1,
             'mock_return_value': (True, self.FAKE_LR_LIST, None),
             'expected_rt_count': 1},
        ]
        for t in tests:
            gsc.autonomous_system = t['autonomous_system']
            with mock.patch.object(self._api_server._db_conn, 'dbe_list',
                                   return_value=t['mock_return_value']):
                try:
                    self.api.global_system_config_update(gsc)
                except Exception as exc:
                    self.assertIsInstance(exc, BadRequest)
                    self.assertEqual(exc.status_code, 400)
                    # The first line of exception is a generic message.
                    # The remaining lines are list of Route Targets
                    # that are invalid.
                    # We want to count all invalid Route Targets,
                    # so we start with the second element of the list.
                    existing_rt = exc.content.split('\t')[1:]
                    self.assertEqual(len(existing_rt), t['expected_rt_count'])
Exemplo n.º 23
0
    def test_control_node_zone(self):
        gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
        cnz = []
        for i in range(2):
            cnz_name = "cnz-" + str(i)
            cnz.append(ControlNodeZone(name=cnz_name, parent_obj=gsc))
            self.api.control_node_zone_create(cnz[i])

        proj = self.api.project_read(
            fq_name=["default-domain", "default-project"])
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        primary_attr = BGPaaSControlNodeZoneAttributes("primary")
        secondary_attr = BGPaaSControlNodeZoneAttributes("secondary")

        # create bgpaas with two control-node-zones as "primary"
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        bgpaas_obj.add_control_node_zone(cnz[1], primary_attr)
        try:
            self.api.bgp_as_a_service_create(bgpaas_obj)
        except BadRequest:
            pass

        # create bgpaas with two control-node-zones as "secondary"
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        bgpaas_obj.add_control_node_zone(cnz[1], secondary_attr)
        try:
            self.api.bgp_as_a_service_create(bgpaas_obj)
        except BadRequest:
            pass

        # update bgpaas with two control-node-zones as "primary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        bgpaas_obj.add_control_node_zone(cnz[1], primary_attr)
        try:
            self.api.bgp_as_a_service_update(bgpaas_obj)
        except BadRequest:
            self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with two control-node-zones as "secondary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        bgpaas_obj.add_control_node_zone(cnz[1], secondary_attr)
        try:
            self.api.bgp_as_a_service_update(bgpaas_obj)
        except BadRequest:
            self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with same control-node-zone as "primary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        self.api.bgp_as_a_service_update(bgpaas_obj)
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with same control-node-zone as "secondary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        self.api.bgp_as_a_service_update(bgpaas_obj)
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with new control-node-zone as "primary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[1], primary_attr)
        try:
            self.api.bgp_as_a_service_update(bgpaas_obj)
        except BadRequest:
            self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with same control-node-zone as "secondary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        self.api.bgp_as_a_service_update(bgpaas_obj)
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with same control-node-zone as "primary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[0], primary_attr)
        self.api.bgp_as_a_service_update(bgpaas_obj)
        self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        # update bgpaas with new control-node-zone as "secondary"
        bgpaas_obj = BgpAsAService(name='bgpaas', parent_obj=proj)
        bgpaas_obj.add_control_node_zone(cnz[0], secondary_attr)
        bgpaas_uuid = self.api.bgp_as_a_service_create(bgpaas_obj)
        bgpaas_obj = self.api.bgp_as_a_service_read(id=bgpaas_uuid)
        bgpaas_obj.add_control_node_zone(cnz[1], secondary_attr)
        try:
            self.api.bgp_as_a_service_update(bgpaas_obj)
        except BadRequest:
            self.api.bgp_as_a_service_delete(id=bgpaas_uuid)

        for i in range(2):
            self.api.control_node_zone_delete(fq_name=cnz[i].fq_name)
Exemplo n.º 24
0
 def setUp(self):
     super(TestFlowNode, self).setUp()
     self.gsc = self.api.global_system_config_read(
         GlobalSystemConfig().fq_name)
Exemplo n.º 25
0
 def test_only_one_global_system_config_can_exists(self):
     gsc = GlobalSystemConfig('gsc-%s' % self.id())
     self.assertRaises(BadRequest, self.api.global_system_config_create,
                       gsc)
Exemplo n.º 26
0
 def setUp(self, **kwargs):
     super(TestInPlaceUpgradeR2002, self).setUp()
     gsc_fq_name = GlobalSystemConfig().fq_name
     self.gsc = self.api.global_system_config_read(gsc_fq_name)
Exemplo n.º 27
0
 def test_update_2_byte_asn_range_check(self):
     gsc = self.api.global_system_config_read(GlobalSystemConfig().fq_name)
     gsc.autonomous_system = 70000
     self.assertRaises(BadRequest, self.api.global_system_config_update,
                       gsc)