VNF scaling: CLI and python client

vnf-scale --vnf-name <vnf-name> --vnf-id <vnf-id>
          --scaling-policy-name <policy-name>
          --scaling-type <type>

implements:  blueprint #vnf-scaling
depends-on: Ib8cdd1295460e617806eec173e4d4ed8f35e6642

Change-Id: If88273efad41eaff466895ad7dbba6a8de31d119
This commit is contained in:
Kanagaraj Manickam 2016-07-04 20:40:59 +05:30
parent 885b53b6d0
commit 94ccf2ded8
3 changed files with 61 additions and 0 deletions

View File

@ -115,6 +115,7 @@ COMMAND_V1 = {
'vnf-delete': vnf.DeleteVNF,
'vnf-list': vnf.ListVNF,
'vnf-show': vnf.ShowVNF,
'vnf-scale': vnf.ScaleVNF,
# 'vnf-config-create'
# 'vnf-config-push'

View File

@ -143,3 +143,58 @@ class DeleteVNF(tackerV10.DeleteCommand):
"""Delete a given VNF."""
resource = _VNF
class ScaleVNF(tackerV10.TackerCommand):
"""Scale a VNF."""
api = 'nfv-orchestration'
resource = None
log = None
def get_parser(self, prog_name):
parser = super(ScaleVNF, self).get_parser(prog_name)
self.add_known_arguments(parser)
return parser
def run(self, parsed_args):
tacker_client = self.get_client()
tacker_client.format = parsed_args.request_format
body = self.args2body(parsed_args)
obj_creator = getattr(tacker_client,
"scale_vnf")
obj_creator(body["scale"].pop('vnf_id'), body)
def add_known_arguments(self, parser):
vnf_group = parser.add_mutually_exclusive_group(required=True)
vnf_group.add_argument(
'--vnf-id',
help='VNF ID')
vnf_group.add_argument(
'--vnf-name',
help='VNF name')
parser.add_argument(
'--scaling-policy-name',
help='VNF policy name used to scale')
parser.add_argument(
'--scaling-type',
help='VNF scaling type, it could be either "out" or "in"')
def args2body(self, parsed_args):
args = {}
body = {"scale": args}
if parsed_args.vnf_name:
tacker_client = self.get_client()
tacker_client.format = parsed_args.request_format
_id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
'vnf',
parsed_args.
vnf_name)
parsed_args.vnf_id = _id
args['vnf_id'] = parsed_args.vnf_id
args['type'] = parsed_args.scaling_type
args['policy'] = parsed_args.scaling_policy_name
return body

View File

@ -338,6 +338,7 @@ class Client(ClientBase):
vnfd_path = '/vnfds/%s'
vnfs_path = '/vnfs'
vnf_path = '/vnfs/%s'
vnf_scale_path = '/vnfs/%s/actions'
vims_path = '/vims'
vim_path = '/vims/%s'
@ -417,6 +418,10 @@ class Client(ClientBase):
def update_vnf(self, vnf, body=None):
return self.put(self.vnf_path % vnf, body=body)
@APIParamsCall
def scale_vnf(self, vnf, body=None):
return self.post(self.vnf_scale_path % vnf, body=body)
@APIParamsCall
def show_vim(self, vim, **_params):
return self.get(self.vim_path % vim, params=_params)