"""
__author__ = "Alfonso Tierno, Gerardo Garcia, Pablo Montes"
__date__ = "$09-oct-2014 09:09:48$"
-__version__ = "0.4.22-r532"
-version_date = "Oct 2017"
+__version__ = "0.4.23-r533"
+version_date = "May 2018"
from argcomplete.completers import FilesCompleter
import os
tenant = _get_tenant()
toact = _get_item_uuid("instances", args.name, tenant=tenant)
action={}
- action[ args.action ] = args.param
+ action[ args.action ] = yaml.safe_load(args.param)
if args.vnf:
action["vnfs"] = args.vnf
if args.vm:
logger.debug("openmano response: %s", mano_response.text )
result = 0 if mano_response.status_code==200 else mano_response.status_code
content = mano_response.json()
- #print json.dumps(content, indent=4)
+ # print json.dumps(content, indent=4)
if mano_response.status_code == 200:
if args.verbose:
print yaml.safe_dump(content, indent=4, default_flow_style=False)
return result
- for uuid,c in content.iteritems():
- print ("{:38} {:20} {:20}".format(uuid, c['name'], c['description']))
+ if "instance_action_id" in content:
+ print("instance_action_id={}".format(content["instance_action_id"]))
+ else:
+ for uuid,c in content.iteritems():
+ print ("{:38} {:20} {:20}".format(uuid, c.get('name'), c.get('description')))
else:
print content['error']['description']
return result
instance_scenario_action_parser = subparsers.add_parser('instance-scenario-action', parents=[parent_parser], help="invoke an action over part or the whole scenario instance")
instance_scenario_action_parser.add_argument("name", action="store", help="name or uuid of the scenario instance")
instance_scenario_action_parser.add_argument("action", action="store", type=str, \
- choices=["start","pause","resume","shutoff","shutdown","forceOff","rebuild","reboot", "console", "add_public_key"],\
+ choices=["start","pause","resume","shutoff","shutdown","forceOff","rebuild","reboot", "console", "add_public_key","vdu-scaling"],\
help="action to send")
- instance_scenario_action_parser.add_argument("param", nargs='?', help="addional param of the action. e.g. console type (novnc, ...), reboot type (TODO)")
+ instance_scenario_action_parser.add_argument("param", nargs='?', help="addional param of the action. e.g. console: novnc; reboot: type; vdu-scaling: '[{vdu-id: xxx, type: create|delete, count: 1}]'")
instance_scenario_action_parser.add_argument("--vnf", action="append", help="VNF to act on (can use several entries)")
instance_scenario_action_parser.add_argument("--vm", action="append", help="VM to act on (can use several entries)")
instance_scenario_action_parser.set_defaults(func=instance_scenario_action)