update_vnf: support config as yaml file

Change-Id: I8f594a35f0e9b6478f0b0292196bd99f3c6dacfa
This commit is contained in:
Isaku Yamahata 2015-05-13 03:43:55 -07:00
parent 584bb05ae9
commit 85598f7855
3 changed files with 16 additions and 22 deletions

View File

@ -123,6 +123,7 @@ COMMAND_V1 = {
'vnfd-show': vnfd.ShowVNFD,
'vnf-create': vnf.CreateVNF,
'vnf-update': vnf.UpdateVNF,
'vnf-delete': vnf.DeleteVNF,
'vnf-list': vnf.ListVNF,
'vnf-show': vnf.ShowVNF,

View File

@ -19,8 +19,6 @@
#
# @author: Isaku Yamahata, Intel
from tackerclient.common import exceptions
from tackerclient.openstack.common.gettextutils import _
from tackerclient.tacker import v1_0 as tackerV10
@ -80,25 +78,20 @@ class UpdateVNF(tackerV10.UpdateCommand):
def add_known_arguments(self, parser):
parser.add_argument(
'--configs',
metavar='<key>=<value>',
action='append',
dest='configs',
default=[],
help='vnf specific config')
'--config-file',
help='specify config yaml file')
parser.add_argument(
'--config',
help='specify config yaml file')
def args2body(self, parsed_args):
body = {self.resource: {}}
if parsed_args.configs:
try:
configs = dict(key_value.split('=', 1)
for key_value in parsed_args.attributes)
except ValueError:
msg = (_('invalid argument for --configs %s') %
parsed_args.configs)
raise exceptions.TackerCLIError(msg)
if configs:
body[self.resource]['configs'] = configs
if parsed_args.config_file:
with open(parsed_args.config_file) as f:
config_yaml = f.read()
body[self.resource]['config'] = config_yaml
if parsed_args.config:
body[self.resource]['config'] = parsed_args.config
tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
return body

View File

@ -480,9 +480,9 @@ class Client(ClientBase):
@APIParamsCall
def update_vnf(self, vnf, body=None):
args = body[self._VNF]
args_ = {'tenant_id': args['tenant_id']}
if 'configs' in args:
args_['attributes'] = args['configs']
body_ = {self._DEVICE: body[self._VNF]}
args_ = {}
if 'config' in args:
args_['attributes'] = {'config': args['config']}
body_ = {self._DEVICE: args_}
ret = self.update_device(vnf, body_)
return {self._VNF: ret[self._DEVICE]}