cosmetic changes
This commit is contained in:
parent
746d3a33d9
commit
010957966b
2 changed files with 18 additions and 35 deletions
17
plugin.py
17
plugin.py
|
@ -197,23 +197,6 @@ def vmstop(vm_id):
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
def vmshutdown(vm_id):
|
|
||||||
""" graceful stop """
|
|
||||||
slave_id, vm_type = grid.query_vm(vm_id)
|
|
||||||
proxobject = auth(slave_id)
|
|
||||||
vm_type = vm_type.lower()
|
|
||||||
slave_name = proxobject.cluster.status.get()[0]['name']
|
|
||||||
ioconfig.logger.info('slave[%s]> acpi shutdown sent to %s %s' % (slave_name, vm_type, vm_id))
|
|
||||||
|
|
||||||
if vm_type == 'kvm':
|
|
||||||
result = proxobject.nodes(slave_name).qemu(vm_id).status.shutdown.post()
|
|
||||||
if vm_type == 'lxc':
|
|
||||||
result = proxobject.nodes(slave_name).lxc(vm_id).status.shutdown.post()
|
|
||||||
#ioconfig.logger.info('slave[{}]> {}'.format(slave_name, result))
|
|
||||||
response = { 'status':'SHUTDOWN', 'vmid':vm_id }
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
def vmsuspend(vm_id):
|
def vmsuspend(vm_id):
|
||||||
""" suspend machine """
|
""" suspend machine """
|
||||||
slave_id, vm_type = grid.query_vm(vm_id)
|
slave_id, vm_type = grid.query_vm(vm_id)
|
||||||
|
|
|
@ -163,7 +163,7 @@ class CreateResource(object):
|
||||||
def on_post(self, req, resp):
|
def on_post(self, req, resp):
|
||||||
"""Create a cluster node, returns array of: status, vmid, pass, ipv4, """
|
"""Create a cluster node, returns array of: status, vmid, pass, ipv4, """
|
||||||
logger.info('grid> create ' + str(req.params))
|
logger.info('grid> create ' + str(req.params))
|
||||||
resp.status, response = selector('create', req)
|
resp.status, response = selector('vmcreate', req)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class StatusResource(object):
|
class StatusResource(object):
|
||||||
|
@ -171,7 +171,7 @@ class StatusResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" check vm status """
|
""" check vm status """
|
||||||
logger.info('grid> status ' + str(vmid))
|
logger.info('grid> status ' + str(vmid))
|
||||||
resp.status, response = selector('status', req, vmid)
|
resp.status, response = selector('vmstatus', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class DeleteResource(object):
|
class DeleteResource(object):
|
||||||
|
@ -179,7 +179,7 @@ class DeleteResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" delete machine completely"""
|
""" delete machine completely"""
|
||||||
logger.info('grid> delete ' + str(vmid))
|
logger.info('grid> delete ' + str(vmid))
|
||||||
resp.status, response = selector('delete', req, vmid)
|
resp.status, response = selector('vmdelete', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class SuspendResource(object):
|
class SuspendResource(object):
|
||||||
|
@ -187,7 +187,7 @@ class SuspendResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" Temporary suspend the instance """
|
""" Temporary suspend the instance """
|
||||||
logger.info('grid> suspend ' + str(vmid))
|
logger.info('grid> suspend ' + str(vmid))
|
||||||
resp.status, response = selector('suspend', req, vmid)
|
resp.status, response = selector('vmsuspend', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class ResumeResource(object):
|
class ResumeResource(object):
|
||||||
|
@ -195,7 +195,7 @@ class ResumeResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" Unuspend the instance """
|
""" Unuspend the instance """
|
||||||
logger.info('grid> resume ' + str(vmid))
|
logger.info('grid> resume ' + str(vmid))
|
||||||
resp.status, response = selector('resume', req, vmid)
|
resp.status, response = selector('vmresume', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class StartResource(object):
|
class StartResource(object):
|
||||||
|
@ -203,7 +203,7 @@ class StartResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" Start the instance """
|
""" Start the instance """
|
||||||
logger.info('grid> start ' + str(vmid))
|
logger.info('grid> start ' + str(vmid))
|
||||||
resp.status, response = selector('start', req, vmid)
|
resp.status, response = selector('vmstart', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class ShutdownResource(object):
|
class ShutdownResource(object):
|
||||||
|
@ -211,7 +211,7 @@ class ShutdownResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" ACPI Shutdown the instance """
|
""" ACPI Shutdown the instance """
|
||||||
logger.info('grid> shutdown ' + str(vmid))
|
logger.info('grid> shutdown ' + str(vmid))
|
||||||
resp.status, response = selector('shutdown', req, vmid)
|
resp.status, response = selector('vmshutdown', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class StopResource(object):
|
class StopResource(object):
|
||||||
|
@ -219,7 +219,7 @@ class StopResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" Stop the instance """
|
""" Stop the instance """
|
||||||
logger.info('grid> stop ' + str(vmid))
|
logger.info('grid> stop ' + str(vmid))
|
||||||
resp.status, response = selector('stop', req, vmid)
|
resp.status, response = selector('vmstop', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
class VNCResource(object):
|
class VNCResource(object):
|
||||||
|
@ -227,7 +227,7 @@ class VNCResource(object):
|
||||||
def on_post(self, req, resp, vmid):
|
def on_post(self, req, resp, vmid):
|
||||||
""" Create a VNC link to the instance """
|
""" Create a VNC link to the instance """
|
||||||
logger.info('grid> vnc ' + str(vmid))
|
logger.info('grid> vnc ' + str(vmid))
|
||||||
resp.status, response = selector('vnc', req, vmid)
|
resp.status, response = selector('vmvnc', req, vmid)
|
||||||
req.context['result'] = response
|
req.context['result'] = response
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -246,31 +246,31 @@ res_checkin = CheckInResource()
|
||||||
api.add_route('/checkin', res_checkin)
|
api.add_route('/checkin', res_checkin)
|
||||||
|
|
||||||
res_create = CreateResource()
|
res_create = CreateResource()
|
||||||
api.add_route('/create', res_create)
|
api.add_route('/vmcreate', res_create)
|
||||||
|
|
||||||
res_status = StatusResource()
|
res_status = StatusResource()
|
||||||
api.add_route('/status/{vmid}', res_status)
|
api.add_route('/vmstatus/{vmid}', res_status)
|
||||||
|
|
||||||
res_delete = DeleteResource()
|
res_delete = DeleteResource()
|
||||||
api.add_route('/delete/{vmid}', res_delete)
|
api.add_route('/vmdelete/{vmid}', res_delete)
|
||||||
|
|
||||||
res_suspend = SuspendResource()
|
res_suspend = SuspendResource()
|
||||||
api.add_route('/suspend/{vmid}', res_suspend)
|
api.add_route('/vmsuspend/{vmid}', res_suspend)
|
||||||
|
|
||||||
res_resume = ResumeResource()
|
res_resume = ResumeResource()
|
||||||
api.add_route('/resume/{vmid}', res_resume)
|
api.add_route('/vmresume/{vmid}', res_resume)
|
||||||
|
|
||||||
res_start = StartResource()
|
res_start = StartResource()
|
||||||
api.add_route('/start/{vmid}', res_start)
|
api.add_route('/vmstart/{vmid}', res_start)
|
||||||
|
|
||||||
res_shutdown = ShutdownResource()
|
res_shutdown = ShutdownResource()
|
||||||
api.add_route('/shutdown/{vmid}', res_shutdown)
|
api.add_route('/vmshutdown/{vmid}', res_shutdown)
|
||||||
|
|
||||||
res_stop = StopResource()
|
res_stop = StopResource()
|
||||||
api.add_route('/stop/{vmid}', res_stop)
|
api.add_route('/vmstop/{vmid}', res_stop)
|
||||||
|
|
||||||
res_vnc = VNCResource()
|
res_vnc = VNCResource()
|
||||||
api.add_route('/vnc/{vmid}', res_vnc)
|
api.add_route('/vmvnc/{vmid}', res_vnc)
|
||||||
|
|
||||||
#display motd
|
#display motd
|
||||||
welcome()
|
welcome()
|
||||||
|
|
Loading…
Reference in a new issue