Ejemplo n.º 1
0
    def test_register_vim_with_mandatory_params(self):
        cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None)
        name = 'my-name'
        my_id = 'my-id'

        vim_config = utils.get_file_path(
            'tests/unit/vm/samples/vim_k8s_bearer_token.yaml')
        args = [
            name,
            '--config-file',
            vim_config,
        ]
        position_names = ['auth_cred', 'vim_project', 'auth_url', 'type']
        position_values = [
            self.auth_cred, self.vim_project, self.auth_url, self.type
        ]
        extra_body = {'type': 'kubernetes', 'name': name, 'is_default': False}
        self._test_create_resource(self._RESOURCE,
                                   cmd,
                                   name,
                                   my_id,
                                   args,
                                   position_names,
                                   position_values,
                                   extra_body=extra_body)
Ejemplo n.º 2
0
 def test_register_vim_all_params(self):
     cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None)
     name = 'my-name'
     my_id = 'my-id'
     description = 'Vim Description'
     vim_config = utils.get_file_path(
         'tests/unit/vm/samples/vim_config.yaml')
     args = [
         name, '--config-file', vim_config, '--description', description
     ]
     position_names = ['auth_cred', 'vim_project', 'auth_url']
     position_values = [self.auth_cred, self.vim_project, self.auth_url]
     extra_body = {
         'type': 'openstack',
         'name': name,
         'description': description,
         'is_default': False
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                None,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body)
 def test_create_device_template_with_mandatory_params(self):
     cmd = device_template.CreateDeviceTemplate(
         test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     service_type = 'MY-SERVICE'
     device_driver = 'device-driver'
     mgmt_driver = 'mgmt-driver'
     args = [
         '--template-service-type',
         service_type,
         '--device-driver',
         device_driver,
         '--mgmt-driver',
         mgmt_driver,
     ]
     position_names = ['device_driver', 'mgmt_driver']
     position_values = [device_driver, mgmt_driver]
     extra_body = {
         'service_types': [{
             'service_type': service_type
         }],
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                None,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body)
Ejemplo n.º 4
0
 def test_register_vim_with_no_auth_url(self):
     cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     name = 'test_vim'
     description = 'Vim Description'
     vim_config = utils.get_file_path(
         'tests/unit/vm/samples/vim_config_without_auth_url.yaml')
     args = [
         name, '--config-file', vim_config, '--description', description
     ]
     position_names = ['auth_cred', 'vim_project', 'auth_url']
     position_values = [self.auth_cred, self.vim_project, self.auth_url]
     extra_body = {
         'type': 'openstack',
         'name': name,
         'description': description,
         'is_default': False
     }
     message = 'Auth URL must be specified'
     ex = self.assertRaises(exceptions.TackerClientException,
                            self._test_create_resource,
                            self._RESOURCE,
                            cmd,
                            None,
                            my_id,
                            args,
                            position_names,
                            position_values,
                            extra_body=extra_body)
     self.assertEqual(message, ex.message)
     self.assertEqual(404, ex.status_code)
 def test_create_service_instance_with_mandatory_params(self):
     cmd = service_instance.CreateServiceInstance(
         test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     service_type_id = 'service-type-id'
     service_table_id = 'service-table-id'
     device = 'my-device'
     args = [
         '--service-type-id',
         service_type_id,
         '--service-table-id',
         service_table_id,
         '--device',
         device,
     ]
     position_names = ['service_type_id', 'service_table_id']
     position_values = [service_type_id, service_table_id]
     extra_body = {
         'devices': [device],
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                None,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body)
Ejemplo n.º 6
0
    def test_create_vnf_all_params(self):
        cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
        name = 'my_name'
        my_id = 'my-id'
        vnfd_id = 'vnfd'
        vim_id = 'vim_id'
        description = 'my-description'
        region_name = 'region'
        key = 'key'
        value = 'value'

        args = [
            name, '--vnfd-id', vnfd_id, '--vim-id', vim_id, '--description',
            description, '--vim-region-name', region_name,
            '--%s' % key, value
        ]
        position_names = [
            'name', 'vnfd_id', 'vim_id', 'description', 'attributes'
        ]
        position_values = [name, vnfd_id, vim_id, description, {}]
        extra_body = {
            key: value,
            'placement_attr': {
                'region_name': region_name
            }
        }
        self._test_create_resource(self._RESOURCE,
                                   cmd,
                                   name,
                                   my_id,
                                   args,
                                   position_names,
                                   position_values,
                                   extra_body=extra_body)
Ejemplo n.º 7
0
 def test_update_vnf(self):
     cmd = vnf.UpdateVNF(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     key = 'new_key'
     value = 'new-value'
     self._test_update_resource(self._RESOURCE, cmd, my_id,
                                [my_id, '--%s' % key, value], {key: value})
Ejemplo n.º 8
0
 def test_create_vnfd_all_params(self, mo):
     cmd = vnfd.CreateVNFD(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     name = 'my-name'
     attr_key = 'vnfd'
     attr_val = 'vnfd'
     args = [name, '--vnfd-file', 'vnfd-file']
     position_names = ['name']
     position_values = [name]
     extra_body = {
         'service_types': [{
             'service_type': 'vnfd'
         }],
         'attributes': {
             attr_key: attr_val
         },
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                None,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body)
Ejemplo n.º 9
0
 def test_list_vnfds_pagenation(self):
     cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
     print(cmd)
     self._test_list_resources(self._RESOURCES,
                               cmd,
                               True,
                               template_source='onboarded')
Ejemplo n.º 10
0
    def test_create_vnffgd_with_mandatory_params(self):
        cmd = vnffgd.CreateVNFFGD(test_cli10.MyApp(sys.stdout), None)
        my_id = 'my-id'
        name = 'my-name'
        attr_key = 'vnffgd'
        attr_val = 'vnffgd'
        args = [
            name,
            '--vnffgd',
            'vnffgd',
        ]
        position_names = ['name']
        position_values = [name]
        extra_body = {
            'template': {
                attr_key: attr_val
            },
        }

        self._test_create_resource(self._RESOURCE,
                                   cmd,
                                   name,
                                   my_id,
                                   args,
                                   position_names,
                                   position_values,
                                   extra_body=extra_body)
Ejemplo n.º 11
0
 def test_create_vnffg_with_mandatory_params(self):
     cmd = vnffg.CreateVNFFG(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     vnffg_name = 'fake-vnffg'
     vnffgd_id = 'vnffgd'
     args = [
         vnffg_name,
         '--vnffgd-id',
         vnffgd_id,
     ]
     position_names = ['vnffgd_id']
     position_values = [vnffgd_id]
     extra_body = {
         'symmetrical': False,
         'name': vnffg_name,
         'attributes': {}
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                vnffg_name,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body,
                                get_client_called_count=2)
Ejemplo n.º 12
0
 def test_create_vnfd_with_mandatory_params(self, mo):
     cmd = vnfd.CreateVNFD(test_cli10.MyApp(sys.stdout), None)
     name = 'my_name'
     my_id = 'my-id'
     args = [
         name,
         '--vnfd-file',
         'vnfd-file',
     ]
     position_names = ['name']
     position_values = [name]
     extra_body = {
         'service_types': [{
             'service_type': 'vnfd'
         }],
         'attributes': {
             'vnfd': 'vnfd'
         }
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                name,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body)
    def test_create_vnffgd_all_params(self, mo):
        cmd = vnffgd.CreateVNFFGD(test_cli10.MyApp(sys.stdout), None)
        my_id = 'my-id'
        name = 'my-name'
        attr_key = 'vnffgd'
        attr_val = 'vnffgd'
        description = 'vnffgd description'
        args = [
            name,
            '--vnffgd-file',
            'vnffgd_file',
            '--description',
            description,
        ]
        position_names = ['name', 'description']
        position_values = [name, description]
        extra_body = {
            'template': {
                attr_key: attr_val
            },
        }

        self._test_create_resource(self._RESOURCE,
                                   cmd,
                                   name,
                                   my_id,
                                   args,
                                   position_names,
                                   position_values,
                                   extra_body=extra_body)
Ejemplo n.º 14
0
 def test_update_vnffg(self):
     cmd = vnffg.UpdateVNFFG(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     key = 'new_key'
     value = 'new-value'
     self._test_update_resource(self._RESOURCE,
                                cmd,
                                my_id, [my_id, '--%s' % key, value],
                                {key: value},
                                get_client_called_count=2)
 def test_update_service_instance(self):
     cmd = service_instance.UpdateServiceInstance(
         test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     key = 'new-key'
     value = 'new-value'
     self._test_update_resource(
         self._RESOURCE, cmd, my_id,
         [my_id, '--kwargs', '%s=%s' % (key, value)],
         {'kwargs': {
             key: value
         }})
Ejemplo n.º 16
0
 def test_list_vnf_resources(self):
     cmd = vnf.ListVNFResources(test_cli10.MyApp(sys.stdout), None)
     base_args = [self.test_id]
     response = [{'name': 'CP11', 'id': 'id1', 'type': 'NeutronPort'},
                 {'name': 'CP12', 'id': 'id2', 'type': 'NeutronPort'}]
     val = self._test_list_sub_resources(self._VNF_RESOURCES, 'resources',
                                         cmd, self.test_id,
                                         response_contents=response,
                                         detail=True, base_args=base_args)
     self.assertIn('id1', val)
     self.assertIn('NeutronPort', val)
     self.assertIn('CP11', val)
 def test_update_device_template(self):
     cmd = device_template.UpdateDeviceTemplate(
         test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     name = 'new-name'
     description = 'new-description'
     self._test_update_resource(
         self._RESOURCE, cmd, my_id,
         [my_id, '--name', name, '--description', description], {
             'name': name,
             'description': description
         })
Ejemplo n.º 18
0
 def test_update_vim_with_mandatory_params(self):
     cmd = vim.UpdateVIM(test_cli10.MyApp(sys.stdout), None)
     update_config = utils.get_file_path(
         'tests/unit/vm/samples/vim_config_without_auth_url.yaml')
     my_id = 'my-id'
     args = [my_id, '--config-file', str(update_config)]
     extra_fields = {
         'vim_project': self.vim_project,
         'auth_cred': self.auth_cred
     }
     self._test_update_resource(self._RESOURCE, cmd, my_id, args,
                                extra_fields)
Ejemplo n.º 19
0
 def test_create_vnf_with_vnfd_id(self):
     cmd = vnf.CreateVNF(test_cli10.MyApp(sys.stdout), None)
     name = 'my_name'
     my_id = 'my-id'
     vnfd_id = 'vnfd'
     args = [
         name,
         '--vnfd-id', vnfd_id,
     ]
     position_names = ['name', 'vnfd_id', 'attributes']
     position_values = [name, vnfd_id, {}]
     self._test_create_resource(self._RESOURCE, cmd, name, my_id,
                                args, position_names, position_values)
Ejemplo n.º 20
0
 def test_update_vim(self):
     cmd = vim.UpdateVIM(test_cli10.MyApp(sys.stdout), None)
     update_config = utils.get_file_path(
         'tests/unit/vm/samples/vim_config_without_auth_url.yaml')
     my_id = 'my-id'
     key = 'config-file'
     value = str(update_config)
     extra_fields = {
         'vim_project': self.vim_project,
         'auth_cred': self.auth_cred,
         'is_default': False
     }
     self._test_update_resource(self._RESOURCE, cmd, my_id,
                                [my_id, '--%s' % key, value], extra_fields)
Ejemplo n.º 21
0
 def test_create_vnffg_with_mandatory_params(self):
     cmd = vnffg.CreateVNFFG(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     vnffg_name = 'fake-vnffg'
     vnffgd_id = 'vnffgd'
     args = [
         vnffg_name,
         '--vnffgd-id', vnffgd_id,
     ]
     position_names = ['vnffgd_id']
     position_values = [vnffgd_id]
     extra_body = {'name': vnffg_name}
     self._test_create_resource(self._RESOURCE, cmd, vnffg_name, my_id,
                                args, position_names, position_values,
                                extra_body=extra_body)
 def test_create_device_template_all_params(self):
     cmd = device_template.CreateDeviceTemplate(
         test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     name = 'my-name'
     description = 'my-description'
     service_type = 'MY-SERVICE'
     device_driver = 'device-driver'
     mgmt_driver = 'mgmt-driver'
     attr_key = 'attr-key'
     attr_val = 'attr-val'
     args = [
         '--name',
         name,
         '--description',
         description,
         '--template-service-type',
         service_type,
         '--device-driver',
         device_driver,
         '--mgmt-driver',
         mgmt_driver,
         '--attribute',
         attr_key,
         attr_val,
     ]
     position_names = [
         'name', 'description', 'device_driver', 'mgmt_driver'
     ]
     position_values = [name, description, device_driver, mgmt_driver]
     extra_body = {
         'service_types': [{
             'service_type': service_type
         }],
         'attributes': {
             attr_key: attr_val
         },
     }
     self._test_create_resource(self._RESOURCE,
                                cmd,
                                None,
                                my_id,
                                args,
                                position_names,
                                position_values,
                                extra_body=extra_body)
Ejemplo n.º 23
0
    def test_create_vnffg_all_params(self):
        cmd = vnffg.CreateVNFFG(test_cli10.MyApp(sys.stdout), None)
        my_id = 'my-id'
        vnffgd_id = 'vnffgd'
        vnffg_name = 'fake-vnffg'
        vnf_mapping = 'VNFD1:VNF1'

        args = [
            vnffg_name,
            '--vnffgd-id', vnffgd_id,
            '--vnf-mapping', vnf_mapping,
            '--symmetrical', 'True']
        position_names = ['vnffgd_id', 'vnf_mapping', 'symmetrical']
        position_values = [vnffgd_id, {"VNFD1": "VNF1"}, 'True']
        extra_body = {'name': vnffg_name}
        self._test_create_resource(self._RESOURCE, cmd, None, my_id,
                                   args, position_names, position_values,
                                   extra_body=extra_body)
Ejemplo n.º 24
0
 def test_update_vim_all_params(self):
     cmd = vim.UpdateVIM(test_cli10.MyApp(sys.stdout), None)
     update_config = utils.get_file_path(
         'tests/unit/vm/samples/vim_config_without_auth_url.yaml')
     my_id = 'my-id'
     name = 'new_name'
     description = 'new_description'
     is_default = 'True'
     args = [
         my_id,
         '--config-file', str(update_config),
         '--name', name,
         '--description', description,
         '--is_default', is_default]
     extra_fields = {'vim_project': self.vim_project, 'auth_cred':
                     self.auth_cred, 'is_default': 'True',
                     'name': name, 'description': description}
     self._test_update_resource(self._RESOURCE, cmd, my_id, args,
                                extra_fields)
Ejemplo n.º 25
0
 def test_create_vnfd_with_empty_file(self, mo):
     cmd = vnfd.CreateVNFD(
         test_cli10.MyApp(sys.stdout), None)
     name = 'my_name'
     my_id = 'my-id'
     args = [name, '--vnfd-file', 'vnfd-file', ]
     position_names = ['name']
     position_values = [name]
     extra_body = {
         'service_types': [{'service_type': 'vnfd'}],
         'attributes': {'vnfd': 'vnfd'}
     }
     err = None
     try:
         self._test_create_resource(self._RESOURCE, cmd, name, my_id,
                                    args, position_names, position_values,
                                    extra_body=extra_body)
     except InvalidInput:
         err = True
     self.assertEqual(True, err)
Ejemplo n.º 26
0
 def test_update_vnffg(self):
     cmd = vnffg.UpdateVNFFG(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     update_vnffg = utils.get_file_path(
         'tests/unit/vm/samples/vnffg_update_file.yaml')
     vnf_mapping = 'VNFD1:VNF1'
     args = [
         my_id, '--vnf-mapping', vnf_mapping, '--vnffgd-template',
         str(update_vnffg), '--symmetrical'
     ]
     extra_fields = {
         "vnf_mapping": {
             "VNFD1": "VNF1"
         },
         "vnffgd_template": "abcxyz",
         "symmetrical": True
     }
     self._test_update_resource(self._RESOURCE,
                                cmd,
                                my_id,
                                args,
                                extra_fields,
                                get_client_called_count=2)
Ejemplo n.º 27
0
 def test_register_vim_with_false_cert_verify(self):
     cmd = vim.CreateVIM(test_cli10.MyApp(sys.stdout), None)
     name = 'my-name'
     my_id = 'my-id'
     # change cert_verify to False
     self.auth_cred = {'username': '******', 'password': '******',
                       'user_domain_name': 'user_domain_name',
                       'cert_verify': 'False'}
     description = 'Vim Description'
     vim_config = utils.get_file_path(
         'tests/unit/vm/samples/vim_config_with_false_cert_verify.yaml')
     args = [
         name,
         '--config-file', vim_config,
         '--description', description]
     position_names = ['auth_cred', 'vim_project', 'auth_url', 'type']
     position_values = [self.auth_cred, self.vim_project,
                        self.auth_url, self.type]
     extra_body = {'type': 'openstack', 'name': name,
                   'description': description, 'is_default': False}
     self._test_create_resource(self._RESOURCE, cmd, None, my_id,
                                args, position_names, position_values,
                                extra_body=extra_body)
Ejemplo n.º 28
0
 def test_list_inline_vnfds(self):
     cmd = vnfd.ListVNFD(test_cli10.MyApp(sys.stdout), None)
     self._test_list_resources(self._RESOURCES,
                               cmd,
                               True,
                               template_source='inline')
Ejemplo n.º 29
0
 def test_multi_delete_vnfd(self):
     cmd = vnfd.DeleteVNFD(test_cli10.MyApp(sys.stdout), None)
     vnfd_ids = 'my-id1 my-id2 my-id3'
     args = [vnfd_ids]
     self._test_delete_resource(self._RESOURCE, cmd, vnfd_ids, args)
Ejemplo n.º 30
0
 def test_delete_vnfd(self):
     cmd = vnfd.DeleteVNFD(test_cli10.MyApp(sys.stdout), None)
     my_id = 'my-id'
     args = [my_id]
     self._test_delete_resource(self._RESOURCE, cmd, my_id, args)