From 4196883bfbe884aa9e57acf0db2ced27d020acc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Sat, 4 Jun 2016 20:02:34 +0200 Subject: [PATCH] Fixed Timings on uds Actor Fixed oVirt to allow USB Configuration on service (for spice). Defaults to not allow. --- actors/src/UDSActorUser.py | 2 +- .../uds/services/OVirt/OVirtLinkedService.py | 19 ++++++++++++++++--- .../src/uds/services/OVirt/OVirtProvider.py | 6 +++--- .../uds/services/OVirt/client/oVirtClient.py | 17 +++++++++++------ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/actors/src/UDSActorUser.py b/actors/src/UDSActorUser.py index d819b131..c7178948 100644 --- a/actors/src/UDSActorUser.py +++ b/actors/src/UDSActorUser.py @@ -242,7 +242,7 @@ class UDSSystemTray(QtGui.QSystemTrayIcon): idleTime = operations.getIdleDuration() remainingTime = self.maxIdleTime - idleTime - if remainingTime > 300: # Reset show Warning dialog if we have more than 5 minutes left + if remainingTime > 120: # Reset show Warning dialog if we have more than 5 minutes left self.showIdleWarn = True logger.debug('User has been idle for: {}'.format(idleTime)) diff --git a/server/src/uds/services/OVirt/OVirtLinkedService.py b/server/src/uds/services/OVirt/OVirtLinkedService.py index f6d35390..2e49996a 100644 --- a/server/src/uds/services/OVirt/OVirtLinkedService.py +++ b/server/src/uds/services/OVirt/OVirtLinkedService.py @@ -41,7 +41,7 @@ from uds.core.ui import gui import logging -__updated__ = '2016-03-09' +__updated__ = '2016-06-04' logger = logging.getLogger(__name__) @@ -163,10 +163,23 @@ class OVirtLinkedService(Service): required=True ) + usb = gui.ChoiceField( + label=_('USB'), + rdonly=False, + order=9, + tooltip=_('Enable usb redirection for SPICE'), + values=[ + gui.choiceItem('disabled', 'disabled'), + gui.choiceItem('native', 'native'), + gui.choiceItem('legacy', 'legacy') + ], + defvalue='1' # Default value is the ID of the choicefield + ) + display = gui.ChoiceField( label=_('Display'), rdonly=False, - order=8, + order=9, tooltip=_('Display type (only for administration purposes)'), values=[ gui.choiceItem('spice', 'Spice'), @@ -290,7 +303,7 @@ class OVirtLinkedService(Service): logger.debug('Deploying from template {0} machine {1}'.format(templateId, name)) self.datastoreHasSpace() return self.parent().deployFromTemplate(name, comments, templateId, self.cluster.value, - self.display.value, int(self.memory.value), int(self.memoryGuaranteed.value)) + self.display.value, self.usb.value, int(self.memory.value), int(self.memoryGuaranteed.value)) def removeTemplate(self, templateId): ''' diff --git a/server/src/uds/services/OVirt/OVirtProvider.py b/server/src/uds/services/OVirt/OVirtProvider.py index 0afe54d5..53e2c162 100644 --- a/server/src/uds/services/OVirt/OVirtProvider.py +++ b/server/src/uds/services/OVirt/OVirtProvider.py @@ -45,7 +45,7 @@ from .client import oVirtClient import logging -__updated__ = '2016-04-25' +__updated__ = '2016-06-04' logger = logging.getLogger(__name__) @@ -310,7 +310,7 @@ class Provider(ServiceProvider): ''' return self.__getApi().removeTemplate(templateId) - def deployFromTemplate(self, name, comments, templateId, clusterId, displayType, memoryMB, guaranteedMB): + def deployFromTemplate(self, name, comments, templateId, clusterId, displayType, usbType, memoryMB, guaranteedMB): ''' Deploys a virtual machine on selected cluster from selected template @@ -326,7 +326,7 @@ class Provider(ServiceProvider): Returns: Id of the machine being created form template ''' - return self.__getApi().deployFromTemplate(name, comments, templateId, clusterId, displayType, memoryMB, guaranteedMB) + return self.__getApi().deployFromTemplate(name, comments, templateId, clusterId, displayType, usbType, memoryMB, guaranteedMB) def startMachine(self, machineId): ''' diff --git a/server/src/uds/services/OVirt/client/oVirtClient.py b/server/src/uds/services/OVirt/client/oVirtClient.py index b05cdd07..b60b6275 100644 --- a/server/src/uds/services/OVirt/client/oVirtClient.py +++ b/server/src/uds/services/OVirt/client/oVirtClient.py @@ -11,7 +11,7 @@ import threading import logging import re -__updated__ = '2016-04-07' +__updated__ = '2016-06-04' logger = logging.getLogger(__name__) @@ -142,7 +142,7 @@ class Client(object): res = [] for vm in vms: - res.append({'name': vm.get_name(), 'id': vm.get_id(), 'cluster_id': vm.get_cluster().get_id()}) + res.append({'name': vm.get_name(), 'id': vm.get_id(), 'cluster_id': vm.get_cluster().get_id(), 'usb': (vm.get_usb().get_enabled(), vm.get_usb().get_type()) }) self._cache.put(vmsKey, res, Client.CACHE_TIME_LOW) @@ -444,7 +444,7 @@ class Client(object): finally: lock.release() - def deployFromTemplate(self, name, comments, templateId, clusterId, displayType, memoryMB, guaranteedMB): + def deployFromTemplate(self, name, comments, templateId, clusterId, displayType, usbType, memoryMB, guaranteedMB): ''' Deploys a virtual machine on selected cluster from selected template @@ -460,8 +460,8 @@ class Client(object): Returns: 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)) + logger.debug('Deploying machine with name "{0}" from template {1} at cluster {2} with display {3} and usb {4}, memory {5} and guaranteed {6}'.format( + name, templateId, clusterId, displayType, usbType, memoryMB, guaranteedMB)) try: lock.acquire(True) @@ -472,10 +472,15 @@ class Client(object): cluster = params.Cluster(id=clusterId) template = params.Template(id=templateId) display = params.Display(type_=displayType) + if usbType in ('native', 'legacy'): + usb = params.Usb(enabled=True, type_=usbType) + else: + usb = params.Usb(enabled=False) memoryPolicy = params.MemoryPolicy(guaranteed=guaranteedMB * 1024 * 1024) par = params.VM(name=name, cluster=cluster, template=template, description=comments, - type_='desktop', memory=memoryMB * 1024 * 1024, memory_policy=memoryPolicy) # display=display, + type_='desktop', memory=memoryMB * 1024 * 1024, memory_policy=memoryPolicy, + usb=usb) # display=display, return api.vms.add(par).get_id()