vmremove phase 2
This commit is contained in:
parent
45dccc8119
commit
47a7ae2cbf
2 changed files with 6 additions and 4 deletions
1
grid.py
1
grid.py
|
@ -9,6 +9,7 @@ import re
|
||||||
import datetime
|
import datetime
|
||||||
import random
|
import random
|
||||||
import netaddr
|
import netaddr
|
||||||
|
import os
|
||||||
|
|
||||||
#import local packages
|
#import local packages
|
||||||
import utils
|
import utils
|
||||||
|
|
|
@ -64,8 +64,8 @@ def vmcreate(req):
|
||||||
except:
|
except:
|
||||||
vm_pass = 'datapoint'
|
vm_pass = 'datapoint'
|
||||||
#slave_name = str(grid.query_happiness(region_id, weight)) #TODO: provide weight parameters here and calculate route
|
#slave_name = str(grid.query_happiness(region_id, weight)) #TODO: provide weight parameters here and calculate route
|
||||||
#slave_name = 'lexx'
|
slave_name = 'lexx'
|
||||||
slave_name = 'warrior'
|
#slave_name = 'warrior'
|
||||||
vm_id = random.randint(1000, 9999)
|
vm_id = random.randint(1000, 9999)
|
||||||
cubeid = int(time.time() * 10000 * 10000)
|
cubeid = int(time.time() * 10000 * 10000)
|
||||||
deploy = { 'cube': int(cubeid),
|
deploy = { 'cube': int(cubeid),
|
||||||
|
@ -129,7 +129,7 @@ def vmcreate(req):
|
||||||
|
|
||||||
def vmremove(cubeid):
|
def vmremove(cubeid):
|
||||||
""" terminate a vm """
|
""" 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)
|
proxobject = auth(slave_name)
|
||||||
ioconfig.logger.info('%s[%s]> deleting %s %s (%s)' % (vm_owner, slave_name, vm_type, vm_id, vm_host))
|
ioconfig.logger.info('%s[%s]> deleting %s %s (%s)' % (vm_owner, slave_name, vm_type, vm_id, vm_host))
|
||||||
if vm_type == 'kvm':
|
if vm_type == 'kvm':
|
||||||
|
@ -137,7 +137,8 @@ def vmremove(cubeid):
|
||||||
if vm_type == 'lxc':
|
if vm_type == 'lxc':
|
||||||
result = proxobject.nodes(slave_name).lxc(vm_id).delete()
|
result = proxobject.nodes(slave_name).lxc(vm_id).delete()
|
||||||
grid.deletedb(cubeid)
|
grid.deletedb(cubeid)
|
||||||
return result
|
response = { 'status':'DELETE', 'cube': cubeid, 'hostname': vm_name }
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
def vmstatus(cubeid):
|
def vmstatus(cubeid):
|
||||||
|
|
Loading…
Reference in a new issue