Allow modification of a VM profile
And fix some bugs around this. Fixes #76
This commit is contained in:
@ -478,12 +478,17 @@ def get_vm_meta(vm):
|
||||
|
||||
return retdata, retcode
|
||||
|
||||
def update_vm_meta(vm, limit, selector, autostart):
|
||||
def update_vm_meta(vm, limit, selector, autostart, provisioner_profile):
|
||||
"""
|
||||
Update metadata of a VM.
|
||||
"""
|
||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||
retflag, retdata = pvc_vm.modify_vm_metadata(zk_conn, vm, limit, selector, bool(strtobool(autostart)))
|
||||
if autostart is not None:
|
||||
try:
|
||||
autostart = bool(strtobool(autostart))
|
||||
except:
|
||||
autostart = False
|
||||
retflag, retdata = pvc_vm.modify_vm_metadata(zk_conn, vm, limit, selector, autostart, provisioner_profile)
|
||||
pvc_common.stopZKConnection(zk_conn)
|
||||
|
||||
if retflag:
|
||||
|
@ -1165,6 +1165,7 @@ class API_VM_Metadata(Resource):
|
||||
{ 'name': 'limit' },
|
||||
{ 'name': 'selector', 'choices': ('mem', 'vcpus', 'load', 'vms'), 'helptext': "A valid selector must be specified" },
|
||||
{ 'name': 'autostart' },
|
||||
{ 'name': 'profile' },
|
||||
])
|
||||
@Authenticator
|
||||
def post(self, vm, reqargs):
|
||||
@ -1194,6 +1195,11 @@ class API_VM_Metadata(Resource):
|
||||
type: boolean
|
||||
required: false
|
||||
description: Whether to autostart the VM when its node returns to ready domain state
|
||||
- in: query
|
||||
name: profile
|
||||
type: string
|
||||
required: false
|
||||
description: The PVC provisioner profile for the VM
|
||||
responses:
|
||||
200:
|
||||
description: OK
|
||||
@ -1210,7 +1216,8 @@ class API_VM_Metadata(Resource):
|
||||
vm,
|
||||
reqargs.get('limit', None),
|
||||
reqargs.get('selector', None),
|
||||
reqargs.get('autostart', None)
|
||||
reqargs.get('autostart', None),
|
||||
reqargs.get('profile', None)
|
||||
)
|
||||
api.add_resource(API_VM_Metadata, '/vm/<vm>/meta')
|
||||
|
||||
|
Reference in New Issue
Block a user