mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-03 01:17:56 +03:00
More test over oVirt, and added "Memory for Virtual Machine" and "Physical memory guaranteed" as parameters on oVirtService
This commit is contained in:
parent
06bdc36645
commit
d6b65a7e88
@ -765,6 +765,9 @@ class UserInterface(object):
|
|||||||
|
|
||||||
# Set all values to defaults ones
|
# Set all values to defaults ones
|
||||||
for k in self._gui.iterkeys():
|
for k in self._gui.iterkeys():
|
||||||
|
if self._gui[k].isType(gui.InputField.HIDDEN_TYPE): # Do not fills the value of hidden fields, those will not be deserialized
|
||||||
|
continue
|
||||||
|
|
||||||
self._gui[k].value = self._gui[k].defValue
|
self._gui[k].value = self._gui[k].defValue
|
||||||
|
|
||||||
for txt in values.decode('zip').split('\002'):
|
for txt in values.decode('zip').split('\002'):
|
||||||
|
@ -29,10 +29,10 @@ class oVirtHelpers(object):
|
|||||||
res = []
|
res = []
|
||||||
# Get storages for that datacenter
|
# Get storages for that datacenter
|
||||||
for storage in provider.getDatacenterInfo(ci['datacenter_id'])['storage']:
|
for storage in provider.getDatacenterInfo(ci['datacenter_id'])['storage']:
|
||||||
if storage['active'] is True and storage['type'] == 'data':
|
if storage['type'] == 'data':
|
||||||
space, free = storage['available']/1024/1024/1024, (storage['available']-storage['used'])/1024/1024/1024
|
space, free = storage['available']/1024/1024/1024, (storage['available']-storage['used'])/1024/1024/1024
|
||||||
|
|
||||||
res.append( {'id': storage['id'], 'text': "%s (%4.2f Gb/%4.2f Gb)" % (storage['name'], space, free ) })
|
res.append( {'id': storage['id'], 'text': "%s (%4.2f Gb/%4.2f Gb) %s" % (storage['name'], space, free, storage['active'] and '(ok)' or '(disabled)' ) })
|
||||||
data = [{
|
data = [{
|
||||||
'name' : 'datastore', 'values' : res
|
'name' : 'datastore', 'values' : res
|
||||||
}]
|
}]
|
||||||
|
@ -52,9 +52,9 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
#: Recheck every five seconds by default (for task methods)
|
#: Recheck every six seconds by default (for task methods)
|
||||||
suggestedTime = 5
|
suggestedTime = 6
|
||||||
|
|
||||||
def initialize(self):
|
def initialize(self):
|
||||||
self._name = ''
|
self._name = ''
|
||||||
self._ip = ''
|
self._ip = ''
|
||||||
@ -74,7 +74,6 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
'''
|
'''
|
||||||
Does nothing here also, all data are keeped at environment storage
|
Does nothing here also, all data are keeped at environment storage
|
||||||
'''
|
'''
|
||||||
logger.debug('Data: {0}'.format(str_))
|
|
||||||
vals = str_.split('\1')
|
vals = str_.split('\1')
|
||||||
if vals[0] == 'v1':
|
if vals[0] == 'v1':
|
||||||
self._name, self._ip, self._mac, self._vmid, self._reason, queue = vals[1:]
|
self._name, self._ip, self._mac, self._vmid, self._reason, queue = vals[1:]
|
||||||
@ -245,7 +244,7 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
|
|
||||||
def __pushBackOp(self, op):
|
def __pushBackOp(self, op):
|
||||||
self._queue.append(op)
|
self._queue.append(op)
|
||||||
|
|
||||||
def __error(self, reason):
|
def __error(self, reason):
|
||||||
'''
|
'''
|
||||||
Internal method to set object as error state
|
Internal method to set object as error state
|
||||||
@ -347,7 +346,7 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
if state == 'up': # Already started, return
|
if state == 'up': # Already started, return
|
||||||
return
|
return
|
||||||
|
|
||||||
if state != 'down':
|
if state != 'down' and state != 'suspended':
|
||||||
self.__pushFrontOp(opRetry) # Will call "check Retry", that will finish inmediatly and again call this one
|
self.__pushFrontOp(opRetry) # Will call "check Retry", that will finish inmediatly and again call this one
|
||||||
else:
|
else:
|
||||||
self.service().startMachine(self._vmid)
|
self.service().startMachine(self._vmid)
|
||||||
@ -365,7 +364,7 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if state != 'up' and state != 'suspended':
|
if state != 'up' and state != 'suspended':
|
||||||
self.__pushBackOp(opRetry) # Will call "check Retry", that will finish inmediatly and again call this one
|
self.__pushFrontOp(opRetry) # Will call "check Retry", that will finish inmediatly and again call this one
|
||||||
else:
|
else:
|
||||||
self.service().stopMachine(self._vmid)
|
self.service().stopMachine(self._vmid)
|
||||||
|
|
||||||
@ -382,7 +381,7 @@ class OVirtLinkedDeployment(UserDeployment):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if state != 'up':
|
if state != 'up':
|
||||||
self.__pushBackOp(opRetry) # Remember here, the return State.FINISH will make this retry be "poped" right ar return
|
self.__pushFrontOp(opRetry) # Remember here, the return State.FINISH will make this retry be "poped" right ar return
|
||||||
else:
|
else:
|
||||||
self.service().suspendMachine(self._vmid)
|
self.service().suspendMachine(self._vmid)
|
||||||
|
|
||||||
|
@ -148,14 +148,20 @@ class OVirtLinkedService(Service):
|
|||||||
'''
|
'''
|
||||||
Loads required values inside
|
Loads required values inside
|
||||||
'''
|
'''
|
||||||
self.ov.value = self.parent().serialize()
|
|
||||||
self.ev.value = self.parent().env().key()
|
|
||||||
|
|
||||||
|
# Here we have to use "default values", cause values aren't used at form initialization
|
||||||
|
# This is that value is always '', so if we want to change something, we have to do it
|
||||||
|
# at defValue
|
||||||
|
self.ov.defValue = self.parent().serialize()
|
||||||
|
self.ev.defValue = self.parent().env().key()
|
||||||
|
|
||||||
machines = self.parent().getMachines()
|
machines = self.parent().getMachines()
|
||||||
vals = []
|
vals = []
|
||||||
for m in machines:
|
for m in machines:
|
||||||
vals.append( gui.choiceItem( m['id'], m['name'] ))
|
vals.append( gui.choiceItem( m['id'], m['name'] ))
|
||||||
|
|
||||||
|
# This is not the same case, values is not the "value" of the field, but
|
||||||
|
# the list of values shown because this is a "ChoiceField"
|
||||||
self.machine.setValues(vals)
|
self.machine.setValues(vals)
|
||||||
|
|
||||||
clusters = self.parent().getClusters()
|
clusters = self.parent().getClusters()
|
||||||
@ -207,12 +213,16 @@ class OVirtLinkedService(Service):
|
|||||||
name: Name (sanitized) of the machine
|
name: Name (sanitized) of the machine
|
||||||
comments: Comments for machine
|
comments: Comments for machine
|
||||||
templateId: Id of the template to deploy from
|
templateId: Id of the template to deploy from
|
||||||
|
displayType: 'vnc' or 'spice'. Display to use ad oVirt admin interface
|
||||||
|
memoryMB: Memory requested for machine, in MB
|
||||||
|
guaranteedMB: Minimum memory guaranteed for this machine
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Id of the machine being created form template
|
Id of the machine being created form template
|
||||||
'''
|
'''
|
||||||
logger.debug('Deploying from template {0} machine {1}'.format(templateId, name))
|
logger.debug('Deploying from template {0} machine {1}'.format(templateId, name))
|
||||||
return self.parent().deployFromTemplate(name, comments, templateId, self.cluster.value, self.display.value)
|
return self.parent().deployFromTemplate(name, comments, templateId, self.cluster.value,
|
||||||
|
self.display.value, int(self.memory.value), int(self.memoryGuaranteed.value))
|
||||||
|
|
||||||
def removeTemplate(self, templateId):
|
def removeTemplate(self, templateId):
|
||||||
'''
|
'''
|
||||||
|
@ -291,7 +291,7 @@ class Provider(ServiceProvider):
|
|||||||
'''
|
'''
|
||||||
return self.__getApi().removeTemplate(templateId)
|
return self.__getApi().removeTemplate(templateId)
|
||||||
|
|
||||||
def deployFromTemplate(self, name, comments, templateId, clusterId, displayType):
|
def deployFromTemplate(self, name, comments, templateId, clusterId, displayType, memoryMB, guaranteedMB):
|
||||||
'''
|
'''
|
||||||
Deploys a virtual machine on selected cluster from selected template
|
Deploys a virtual machine on selected cluster from selected template
|
||||||
|
|
||||||
@ -300,11 +300,14 @@ class Provider(ServiceProvider):
|
|||||||
comments: Comments for machine
|
comments: Comments for machine
|
||||||
templateId: Id of the template to deploy from
|
templateId: Id of the template to deploy from
|
||||||
clusterId: Id of the cluster to deploy to
|
clusterId: Id of the cluster to deploy to
|
||||||
|
displayType: 'vnc' or 'spice'. Display to use ad oVirt admin interface
|
||||||
|
memoryMB: Memory requested for machine, in MB
|
||||||
|
guaranteedMB: Minimum memory guaranteed for this machine
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Id of the machine being created form template
|
Id of the machine being created form template
|
||||||
'''
|
'''
|
||||||
return self.__getApi().deployFromTemplate(name, comments, templateId, clusterId, displayType)
|
return self.__getApi().deployFromTemplate(name, comments, templateId, clusterId, displayType, memoryMB, guaranteedMB)
|
||||||
|
|
||||||
def startMachine(self, machineId):
|
def startMachine(self, machineId):
|
||||||
'''
|
'''
|
||||||
|
@ -257,9 +257,14 @@ class Client(object):
|
|||||||
d = api.datacenters.get(id=datacenterId)
|
d = api.datacenters.get(id=datacenterId)
|
||||||
storage = []
|
storage = []
|
||||||
for dd in d.storagedomains.list():
|
for dd in d.storagedomains.list():
|
||||||
|
try:
|
||||||
|
active = dd.get_status().get_state()
|
||||||
|
except:
|
||||||
|
active = 'inactive'
|
||||||
|
|
||||||
storage.append( { 'id' : dd.get_id(), 'name' : dd.get_name(), 'type' : dd.get_type(),
|
storage.append( { 'id' : dd.get_id(), 'name' : dd.get_name(), 'type' : dd.get_type(),
|
||||||
'available' : dd.get_available(), 'used' : dd.get_used(),
|
'available' : dd.get_available(), 'used' : dd.get_used(),
|
||||||
'active' : dd.get_status().get_state() == 'active' } )
|
'active' : active == 'active' } )
|
||||||
|
|
||||||
|
|
||||||
res = { 'name' : d.get_name(), 'id' : d.get_id(), 'storage_type' : d.get_storage_type(),
|
res = { 'name' : d.get_name(), 'id' : d.get_id(), 'storage_type' : d.get_storage_type(),
|
||||||
@ -401,7 +406,7 @@ class Client(object):
|
|||||||
finally:
|
finally:
|
||||||
lock.release()
|
lock.release()
|
||||||
|
|
||||||
def deployFromTemplate(self, name, comments, templateId, clusterId, displayType):
|
def deployFromTemplate(self, name, comments, templateId, clusterId, displayType, memoryMB, guaranteedMB):
|
||||||
'''
|
'''
|
||||||
Deploys a virtual machine on selected cluster from selected template
|
Deploys a virtual machine on selected cluster from selected template
|
||||||
|
|
||||||
@ -410,10 +415,15 @@ class Client(object):
|
|||||||
comments: Comments for machine
|
comments: Comments for machine
|
||||||
templateId: Id of the template to deploy from
|
templateId: Id of the template to deploy from
|
||||||
clusterId: Id of the cluster to deploy to
|
clusterId: Id of the cluster to deploy to
|
||||||
|
displayType: 'vnc' or 'spice'. Display to use ad oVirt admin interface
|
||||||
|
memoryMB: Memory requested for machine, in MB
|
||||||
|
guaranteedMB: Minimum memory guaranteed for this machine
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Id of the machine being created form template
|
Id of the machine being created form template
|
||||||
'''
|
'''
|
||||||
|
logger.debug('Deploying machine with name "{0}" from template {1} at cluster {2} with display {3}, memory {4} and guaranteed {5}'.format(
|
||||||
|
name, templateId, clusterId, displayType, memoryMB, guaranteedMB))
|
||||||
try:
|
try:
|
||||||
lock.acquire(True)
|
lock.acquire(True)
|
||||||
|
|
||||||
@ -425,7 +435,9 @@ class Client(object):
|
|||||||
template = params.Template(id=templateId)
|
template = params.Template(id=templateId)
|
||||||
display = params.Display(type_=displayType)
|
display = params.Display(type_=displayType)
|
||||||
|
|
||||||
par = params.VM(name=name, cluster=cluster, template=template, description=comments, display=display)
|
memoryPolicy = params.MemoryPolicy(guaranteed=guaranteedMB*1024*1024)
|
||||||
|
par = params.VM(name=name, cluster=cluster, template=template, description=comments,
|
||||||
|
display=display, type_='desktop', memory=memoryMB*1024*1024, memory_policy=memoryPolicy)
|
||||||
|
|
||||||
return api.vms.add(par).get_id()
|
return api.vms.add(par).get_id()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user