Usability improvements of vim-update options

Tacker CLI does not support updating name and description of VIM.
This patch introduces --name and --description options to vim-update.

Also, existing --is-default option's behavior can be improved.
Currently is_default attribute will be set to False when --is-default
is ommited, and will be set to True when --is-default is specified.
So even a user, who wants to update attributes other than is_default,
needs to be aware of current is_default setting. This patch will make
the behavior of --is-default option clearer like below:

 1.When --is-default True is specified, it'll be set to True.
 2.When --is-default False is specified, it'll be set to False.
 3.When --is-default is ommited, it will stay as-is.

In addition, --config-file should be a required option because both
server and client expect it to be given when updating VIM.

Change-Id: Ic19fb6b0efb48bc3486f94836be4f2ff35f8c84b
Partial-Bug: 1637360
This commit is contained in:
Naoya Harada 2016-11-01 20:39:43 +09:00
parent 8a5679c4b0
commit b45904f7a1
2 changed files with 40 additions and 11 deletions
tackerclient
tacker/v1_0/nfvo
tests/unit/vm

@ -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):