vmremove phase 2

This commit is contained in:
deflax 2017-09-25 17:55:01 +03:00
parent 45dccc8119
commit 47a7ae2cbf
2 changed files with 6 additions and 4 deletions

View file

@ -9,6 +9,7 @@ import re
import datetime
import random
import netaddr
import os
#import local packages
import utils

View file

@ -64,8 +64,8 @@ def vmcreate(req):
except:
vm_pass = 'datapoint'
#slave_name = str(grid.query_happiness(region_id, weight)) #TODO: provide weight parameters here and calculate route
#slave_name = 'lexx'
slave_name = 'warrior'
slave_name = 'lexx'
#slave_name = 'warrior'
vm_id = random.randint(1000, 9999)
cubeid = int(time.time() * 10000 * 10000)
deploy = { 'cube': int(cubeid),
@ -129,7 +129,7 @@ def vmcreate(req):
def vmremove(cubeid):
""" terminate a vm """
slave_name, vm_type, vm_id, vmhost, vmowner = grid.queryvm(cubeid)
slave_name, vm_type, vm_id, vm_host, vm_owner = grid.queryvm(cubeid)
proxobject = auth(slave_name)
ioconfig.logger.info('%s[%s]> deleting %s %s (%s)' % (vm_owner, slave_name, vm_type, vm_id, vm_host))
if vm_type == 'kvm':
@ -137,7 +137,8 @@ def vmremove(cubeid):
if vm_type == 'lxc':
result = proxobject.nodes(slave_name).lxc(vm_id).delete()
grid.deletedb(cubeid)
return result
response = { 'status':'DELETE', 'cube': cubeid, 'hostname': vm_name }
return response
def vmstatus(cubeid):