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_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_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)
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)
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_k8s_bearer_token_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)
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)
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)
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_k8s_bearer_token.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': 'kubernetes', '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_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_k8s_bearer_token_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)
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_config.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': 'openstack', 'name': name, 'is_default': False} self._test_create_resource(self._RESOURCE, cmd, name, my_id, args, position_names, position_values, extra_body=extra_body)
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)
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)
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_k8s_bearer_token_without_auth_url.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': 'kubernetes', '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)