Merge "Usability improvements of vim-update options"
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
import yaml
|
||||
|
||||
from oslo_utils import strutils
|
||||
|
||||
from tackerclient.common import exceptions
|
||||
from tackerclient.tacker import v1_0 as tackerV10
|
||||
from tackerclient.tacker.v1_0.nfvo import vim_utils
|
||||
@@ -89,12 +91,19 @@ class UpdateVIM(tackerV10.UpdateCommand):
|
||||
def add_known_arguments(self, parser):
|
||||
parser.add_argument(
|
||||
'--config-file',
|
||||
required=True,
|
||||
help='Specify VIM specific config parameters in a file')
|
||||
parser.add_argument(
|
||||
'--name',
|
||||
help='New name for the VIM')
|
||||
parser.add_argument(
|
||||
'--description',
|
||||
help='New description for the VIM')
|
||||
parser.add_argument(
|
||||
'--is-default',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Set as default VIM')
|
||||
type=strutils.bool_from_string,
|
||||
metavar='{True,False}',
|
||||
help='Indicate whether the VIM is used as default')
|
||||
|
||||
def args2body(self, parsed_args):
|
||||
body = {self.resource: {}}
|
||||
@@ -110,7 +119,8 @@ class UpdateVIM(tackerV10.UpdateCommand):
|
||||
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'])
|
||||
['tenant_id', 'name', 'description',
|
||||
'is_default'])
|
||||
return body
|
||||
|
||||
|
||||
|
||||
@@ -124,18 +124,37 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base):
|
||||
self._test_show_resource(self._RESOURCE, cmd, self.test_id,
|
||||
args, ['id', 'name'])
|
||||
|
||||
def test_update_vim(self):
|
||||
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'
|
||||
key = 'config-file'
|
||||
value = str(update_config)
|
||||
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': False}
|
||||
self._test_update_resource(self._RESOURCE, cmd, my_id, [my_id,
|
||||
'--%s' %
|
||||
key, value],
|
||||
self.auth_cred, 'is_default': 'True',
|
||||
'name': name, 'description': description}
|
||||
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_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_delete_vim(self):
|
||||
|
||||
Reference in New Issue
Block a user