From 00d87bde7e2a7f838fef4af721aa230168e54881 Mon Sep 17 00:00:00 2001 From: Saju Madhavan Date: Fri, 15 Jul 2016 01:50:20 +0530 Subject: [PATCH] Transition default VIM to API and DB operation Set the default-vim in the tacker-db and provide API to manage it. Change-Id: Ie447f13c1d30e3cf5c1756c424fe60882082c211 Partial-Bug: 1592957 --- tackerclient/tacker/v1_0/nfvo/vim.py | 16 ++++++++++++++-- tackerclient/tests/unit/vm/test_cli10_vim.py | 6 +++--- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tackerclient/tacker/v1_0/nfvo/vim.py b/tackerclient/tacker/v1_0/nfvo/vim.py index d8e005f8..21e62d1a 100644 --- a/tackerclient/tacker/v1_0/nfvo/vim.py +++ b/tackerclient/tacker/v1_0/nfvo/vim.py @@ -60,6 +60,11 @@ class CreateVIM(tackerV10.CreateCommand): parser.add_argument( '--description', help='Set a description for the VIM') + parser.add_argument( + '--is-default', + action='store_true', + default=False, + help='Set as default VIM') def args2body(self, parsed_args): body = {self.resource: {}} @@ -81,7 +86,8 @@ class CreateVIM(tackerV10.CreateCommand): 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']) + ['tenant_id', 'name', 'description', + 'is_default']) return body @@ -98,6 +104,11 @@ class UpdateVIM(tackerV10.UpdateCommand): group.add_argument( '--config', help='Specify VIM config parameters as a direct input') + parser.add_argument( + '--is-default', + action='store_true', + default=False, + help='Set as default VIM') def args2body(self, parsed_args): body = {self.resource: {}} @@ -115,7 +126,8 @@ class UpdateVIM(tackerV10.UpdateCommand): 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']) + tackerV10.update_dict(parsed_args, body[self.resource], + ['tenant_id', 'is_default']) return body diff --git a/tackerclient/tests/unit/vm/test_cli10_vim.py b/tackerclient/tests/unit/vm/test_cli10_vim.py index 99de8530..ed56e60f 100644 --- a/tackerclient/tests/unit/vm/test_cli10_vim.py +++ b/tackerclient/tests/unit/vm/test_cli10_vim.py @@ -53,7 +53,7 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base): 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} + description, 'is_default': False} self._test_create_resource(self._RESOURCE, cmd, None, my_id, args, position_names, position_values, extra_body=extra_body) @@ -69,7 +69,7 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base): ] position_names = ['auth_cred', 'vim_project', 'auth_url'] position_values = [self.auth_cred, self.vim_project, self.auth_url] - extra_body = {'type': 'openstack'} + extra_body = {'type': 'openstack', 'is_default': False} self._test_create_resource(self._RESOURCE, cmd, None, my_id, args, position_names, position_values, extra_body=extra_body) @@ -131,7 +131,7 @@ class CLITestV10VIMJSON(test_cli10.CLITestV10Base): key = 'config' value = str(update_config) extra_fields = {'vim_project': self.vim_project, 'auth_cred': - self.auth_cred} + self.auth_cred, 'is_default': False} self._test_update_resource(self._RESOURCE, cmd, my_id, [my_id, '--%s' % key, value],