Пример #1
0
 def test_args2body_kubernetes_vim_bearer(self):
     config_param = {'bearer_token': sentinel.bearer_token,
                     'ssl_ca_cert': "None",
                     'project_name': sentinel.prj_name,
                     'type': 'kubernetes'}
     vim = {}
     auth_cred = config_param.copy()
     auth_cred.pop('project_name')
     auth_cred.pop('type')
     expected_vim = {'auth_cred': auth_cred,
                     'vim_project':
                         {'name': sentinel.prj_name},
                     'type': 'kubernetes'}
     vim_utils.args2body_vim(config_param.copy(), vim)
     self.assertEqual(expected_vim, vim)
Пример #2
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     config_param = None
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         config_param = yaml.load(config_yaml)
     vim_obj = body[self.resource]
     if config_param is not None:
         vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(
         parsed_args, body[self.resource],
         ['tenant_id', 'name', 'description', 'is_default'])
     return body
Пример #3
0
 def test_args2body_kubernetes_vim(self):
     config_param = {'username': sentinel.usrname1,
                     'password': sentinel.password1,
                     'ssl_ca_cert': 'abcxyz',
                     'project_name': sentinel.prj_name,
                     'type': 'kubernetes'}
     vim = {}
     auth_cred = config_param.copy()
     auth_cred.pop('project_name')
     auth_cred.pop('type')
     expected_vim = {'auth_cred': auth_cred,
                     'vim_project':
                         {'name': sentinel.prj_name},
                     'type': 'kubernetes'}
     vim_utils.args2body_vim(config_param.copy(), vim)
     self.assertEqual(expected_vim, vim)
Пример #4
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         config_param = yaml.load(config_yaml)
     if 'auth_url' in config_param:
         raise exceptions.TackerClientException(message='Auth URL cannot '
                                                'be updated',
                                                status_code=404)
     vim_obj = body[self.resource]
     vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'is_default'])
     return body
Пример #5
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             vim_config = f.read()
             config_param = yaml.load(vim_config, Loader=yaml.SafeLoader)
     vim_obj = body[self.resource]
     try:
         auth_url = config_param.pop('auth_url')
     except KeyError:
         raise exceptions.TackerClientException(message='Auth URL must be '
                                                'specified',
                                                status_code=404)
     vim_obj['auth_url'] = vim_utils.validate_auth_url(auth_url).geturl()
     vim_obj['type'] = config_param.pop('type', 'openstack')
     vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(
         parsed_args, body[self.resource],
         ['tenant_id', 'name', 'description', 'is_default'])
     return body
Пример #6
0
 def test_args2body_vim(self):
     config_param = {'project_name': sentinel.prj_name,
                     'username': sentinel.usrname1,
                     'password': sentinel.password1,
                     'project_domain_name': sentinel.prj_domain_name1,
                     'user_domain_name': sentinel.user_domain.name,
                     'cert_verify': 'True',
                     'type': 'openstack'}
     vim = {}
     auth_cred = config_param.copy()
     auth_cred.pop('project_name')
     auth_cred.pop('project_domain_name')
     auth_cred.pop('type')
     expected_vim = {'auth_cred': auth_cred,
                     'vim_project':
                         {'name': sentinel.prj_name,
                          'project_domain_name': sentinel.prj_domain_name1},
                     'type': 'openstack'}
     vim_utils.args2body_vim(config_param.copy(), vim)
     self.assertEqual(expected_vim, vim)
Пример #7
0
 def args2body(self, parsed_args):
     body = {_VIM: {}}
     config_param = None
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         try:
             config_param = yaml.load(config_yaml)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
     vim_obj = body[_VIM]
     if config_param is not None:
         vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(parsed_args, body[_VIM],
                           ['tenant_id', 'name', 'description',
                            'is_default'])
     # type attribute is read-only, it can't be updated, so remove it
     # in update method
     body[_VIM].pop('type', None)
     return body
Пример #8
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     config_param = None
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         try:
             config_param = yaml.load(config_yaml)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
     vim_obj = body[self.resource]
     if config_param is not None:
         vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(
         parsed_args, body[self.resource],
         ['tenant_id', 'name', 'description', 'is_default'])
     # type attribute is read-only, it can't be updated, so remove it
     # in update method
     body['vim'].pop('type', None)
     return body
Пример #9
0
 def args2body(self, parsed_args):
     body = {_VIM: {}}
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             vim_config = f.read()
             try:
                 config_param = yaml.load(vim_config,
                                          Loader=yaml.SafeLoader)
             except yaml.YAMLError as e:
                 raise exceptions.InvalidInput(e)
     vim_obj = body[_VIM]
     try:
         auth_url = config_param.pop('auth_url')
     except KeyError:
         raise exceptions.TackerClientException(message='Auth URL must be '
                                                        'specified',
                                                status_code=404)
     vim_obj['auth_url'] = vim_utils.validate_auth_url(auth_url).geturl()
     vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(parsed_args, body[_VIM],
                           ['tenant_id', 'name', 'description',
                            'is_default'])
     return body
Пример #10
0
 def test_args2body_vim(self):
     config_param = {
         'project_id': sentinel.prj_id1,
         'username': sentinel.usrname1,
         'password': sentinel.password1,
         'project_domain_name': sentinel.prj_domain_name1,
         'user_domain_name': sentinel.user_domain.name,
     }
     vim = {}
     auth_cred = config_param.copy()
     auth_cred.pop('project_id')
     auth_cred.pop('project_domain_name')
     auth_cred.update({'user_id': ''})
     expected_vim = {
         'auth_cred': auth_cred,
         'vim_project': {
             'id': sentinel.prj_id1,
             'name': '',
             'project_domain_name': sentinel.prj_domain_name1
         }
     }
     vim_utils.args2body_vim(config_param.copy(), vim)
     self.assertEqual(expected_vim, vim)