mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-20 06:50:23 +03:00
Added usb support workaround for 4.0 & 4.1 of ovirt
This commit is contained in:
parent
72230c5a60
commit
5f1676e56b
@ -37,7 +37,7 @@ from uds.core.util import log
|
||||
import pickle
|
||||
import logging
|
||||
|
||||
__updated__ = '2017-03-16'
|
||||
__updated__ = '2017-03-17'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -419,6 +419,8 @@ class OVirtLinkedDeployment(UserDeployment):
|
||||
Changes the mac of the first nic
|
||||
'''
|
||||
self.service().updateMachineMac(self._vmid, self.getUniqueId())
|
||||
# Fix usb if needed
|
||||
self.service().fixUsb(self._vmid)
|
||||
|
||||
# Check methods
|
||||
def __checkCreate(self):
|
||||
|
@ -41,7 +41,7 @@ from uds.core.ui import gui
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2017-03-16'
|
||||
__updated__ = '2017-03-17'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -395,6 +395,10 @@ class OVirtLinkedService(Service):
|
||||
'''
|
||||
return self.parent().updateMachineMac(machineId, macAddres)
|
||||
|
||||
def fixUsb(self, machineId):
|
||||
if self.usb.value in ('native',):
|
||||
self.parent().fixUsb(machineId)
|
||||
|
||||
def getMacRange(self):
|
||||
'''
|
||||
Returns de selected mac range
|
||||
|
@ -45,7 +45,7 @@ from . import client
|
||||
|
||||
import logging
|
||||
|
||||
__updated__ = '2016-09-11'
|
||||
__updated__ = '2017-03-17'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -394,6 +394,9 @@ class Provider(ServiceProvider):
|
||||
'''
|
||||
return self.__getApi().updateMachineMac(machineId, macAddres)
|
||||
|
||||
def fixUsb(self, machineId):
|
||||
self.__getApi().fixUsb(machineId)
|
||||
|
||||
def getMacRange(self):
|
||||
return self.macsRange.value
|
||||
|
||||
|
@ -11,7 +11,7 @@ import threading
|
||||
import logging
|
||||
import re
|
||||
|
||||
__updated__ = '2016-09-11'
|
||||
__updated__ = '2017-03-17'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -662,6 +662,9 @@ class Client(object):
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
def fixUsb(self, machineId):
|
||||
return # No need to fix usb on 3.x releases
|
||||
|
||||
def getConsoleConnection(self, machineId):
|
||||
'''
|
||||
Gets the connetion info for the specified machine
|
||||
|
@ -6,11 +6,12 @@ Created on Nov 14, 2012
|
||||
|
||||
import ovirtsdk4 as ovirt
|
||||
|
||||
import time
|
||||
import threading
|
||||
import logging
|
||||
import six
|
||||
|
||||
__updated__ = '2017-03-16'
|
||||
__updated__ = '2017-03-17'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -66,6 +67,7 @@ class Client(object):
|
||||
try:
|
||||
cached_api_key = aKey
|
||||
cached_api = ovirt.Connection(url='https://' + self._host + '/ovirt-engine/api', username=self._username, password=self._password, timeout=self._timeout, insecure=True) # , debug=True, log=logger )
|
||||
|
||||
return cached_api
|
||||
except:
|
||||
logger.exception('Exception connection ovirt at {0}'.format(self._host))
|
||||
@ -79,6 +81,7 @@ class Client(object):
|
||||
self._password = password
|
||||
self._timeout = int(timeout)
|
||||
self._cache = cache
|
||||
self._needsUsbFix = True
|
||||
|
||||
def test(self):
|
||||
try:
|
||||
@ -458,10 +461,11 @@ class Client(object):
|
||||
|
||||
cluster = ovirt.types.Cluster(id=six.binary_type(clusterId))
|
||||
template = ovirt.types.Template(id=six.binary_type(templateId))
|
||||
# if usbType in ('native',): # Removed 'legacy', from 3.6 is not used anymore, and from 4.0 not available
|
||||
# usb = ovirt.types.Usb(enabled=True, type=ovirt.types.UsbType.NATIVE)
|
||||
# else:
|
||||
usb = ovirt.types.Usb(enabled=False)
|
||||
|
||||
if self._needsUsbFix is False and usbType in ('native',): # Removed 'legacy', from 3.6 is not used anymore, and from 4.0 not available
|
||||
usb = ovirt.types.Usb(enabled=True, type=ovirt.types.UsbType.NATIVE)
|
||||
else:
|
||||
usb = ovirt.types.Usb(enabled=False)
|
||||
|
||||
memoryPolicy = ovirt.types.MemoryPolicy(guaranteed=guaranteedMB * 1024 * 1024)
|
||||
par = ovirt.types.Vm(name=name, cluster=cluster, template=template, description=comments,
|
||||
@ -643,6 +647,21 @@ class Client(object):
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
def fixUsb(self, machineId):
|
||||
# Fix for usb support
|
||||
if self._needsUsbFix:
|
||||
try:
|
||||
lock.acquire(True)
|
||||
|
||||
api = self.__getApi()
|
||||
usb = ovirt.types.Usb(enabled=True, type=ovirt.types.UsbType.NATIVE)
|
||||
vms = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
vmu = ovirt.types.Vm(usb=usb)
|
||||
vms.update(vmu)
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
|
||||
def getConsoleConnection(self, machineId):
|
||||
'''
|
||||
Gets the connetion info for the specified machine
|
||||
|
Loading…
x
Reference in New Issue
Block a user