def _create_qos_queues(self):
     name = data_utils.rand_name('test-rbac-qos-queue')
     if rbac_base.get_contail_version() < 5:
         fq_name = [name]
     else:
         fq_name = ['default-global-system-config',
                    "default-global-qos-config", name]
     qos_queue = self.qos_client.create_qos_queues(
         fq_name=fq_name)['qos-queue']
     self.addCleanup(self._try_delete_resource,
                     self._delete_qos_queue,
                     qos_queue['uuid'])
     return qos_queue
Beispiel #2
0
 def _create_config_node(self):
     config_node_ip_address = self._random_ip_generator()
     display_name = data_utils.rand_name('config_node')
     if rbac_base.get_contail_version() < 5:
         fq_name = [display_name]
     else:
         fq_name = ['default-global-system-config', display_name]
     config_node = self.config_client.create_config_nodes(
         config_node_ip_address=config_node_ip_address,
         display_name=display_name, fq_name=fq_name)
     config_node_id = config_node['config-node']['uuid']
     if config_node_id:
         self.addCleanup(self._try_delete_resource,
                         self.config_client.delete_config_node,
                         config_node_id)
     return config_node
Beispiel #3
0
 def test_show_global_system_config(self):
     if rbac_base.get_contail_version() < 5:
         new_config = self._create_global_system_config()
         with self.rbac_utils.override_role(self):
             self.config_client.show_global_system_config(
                 new_config['uuid'])
     else:
         resp, resp_body = self.config_client.list_global_system_configs()
         # There must exist just one global system config in Contrail
         # verion > 4.x. There may be more than one in other versions
         # which is bug fixed in later releases.
         body = json.loads(resp_body)['global-system-configs']
         self.assertGreater(len(body), 0,
                            msg="No global system config exists. "
                                "There must exists "
                                "default-global-sytem-config "
                                "at least by default")
         for gsc in body:
             if gsc['fq_name'][0] == 'default-global-system-config':
                 with self.rbac_utils.override_role(self):
                     self.config_client.show_global_system_config(
                         gsc['uuid'])
class GlobalSystemConfigTest(rbac_base.BaseContrailTest):
    """Test class to test config node objects using RBAC roles"""
    def _create_global_system_config(self):
        config_name = data_utils.rand_name('test-config')
        parent_type = 'config-root'
        config_fq_name = [config_name]
        new_config = \
            self.config_client.create_global_system_configs(
                parent_type=parent_type,
                display_name=config_name,
                fq_name=config_fq_name)['global-system-config']
        self.addCleanup(self._try_delete_resource,
                        (self.config_client.delete_global_system_config),
                        new_config['uuid'])
        return new_config

    @rbac_rule_validation.action(service="Contrail",
                                 rules=["list_global_system_configs"])
    @idempotent_id('d1d189a7-14c1-49c5-b180-cd42ed2ca123')
    def test_list_global_system_configs(self):
        """test method for list global system config service objects"""
        with self.rbac_utils.override_role(self):
            self.config_client.list_global_system_configs()

    @testtools.skipUnless(rbac_base.get_contail_version() < 5,
                          'Not supported in OpenContrail versions >= 5')
    @rbac_rule_validation.action(service="Contrail",
                                 rules=["create_global_system_configs"])
    @idempotent_id('e0ba6a20-3e28-47ac-bf95-9a848fcee49a')
    def test_create_global_system_configs(self):
        """test method for create global system config service objects"""
        with self.rbac_utils.override_role(self):
            self._create_global_system_config()

    @rbac_rule_validation.action(service="Contrail",
                                 rules=["show_global_system_config"])
    @idempotent_id('4b9f9131-cb34-4b7d-9d06-c6aca85cce3a')
    def test_show_global_system_config(self):
        if rbac_base.get_contail_version() < 5:
            new_config = self._create_global_system_config()
            with self.rbac_utils.override_role(self):
                self.config_client.show_global_system_config(
                    new_config['uuid'])
        else:
            resp, resp_body = self.config_client.list_global_system_configs()
            # There must exist just one global system config in Contrail
            # verion > 4.x. There may be more than one in other versions
            # which is bug fixed in later releases.
            body = json.loads(resp_body)['global-system-configs']
            self.assertGreater(len(body),
                               0,
                               msg="No global system config exists. "
                               "There must exists "
                               "default-global-sytem-config "
                               "at least by default")
            for gsc in body:
                if gsc['fq_name'][0] == 'default-global-system-config':
                    with self.rbac_utils.override_role(self):
                        self.config_client.show_global_system_config(
                            gsc['uuid'])

    @testtools.skipUnless(rbac_base.get_contail_version() < 5,
                          'Not supported in OpenContrail versions >= 5')
    @rbac_rule_validation.action(service="Contrail",
                                 rules=["update_global_system_config"])
    @idempotent_id('4f90dc83-da59-45a4-8ab6-b387bd6c2df4')
    def test_update_global_system_config(self):
        """test method for update global system config service objects"""
        new_config = self._create_global_system_config()
        update_name = data_utils.rand_name('test')
        with self.rbac_utils.override_role(self):
            self.config_client.update_global_system_config(
                new_config['uuid'], display_name=update_name)

    @testtools.skipUnless(rbac_base.get_contail_version() < 5,
                          'Not supported in OpenContrail versions >= 5')
    @rbac_rule_validation.action(service="Contrail",
                                 rules=["delete_global_system_config"])
    @idempotent_id('fce1653c-e657-4a1e-8ced-7e02d297d6c9')
    def test_delete_global_system_config(self):
        """test method for delete global system config service objects"""
        new_config = self._create_global_system_config()
        with self.rbac_utils.override_role(self):
            self.config_client.delete_global_system_config(new_config['uuid'])