mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-27 06:50:25 +03:00
Merge remote-tracking branch 'origin/v2.1'
This commit is contained in:
commit
cdac261561
@ -36,6 +36,7 @@ from udsactor import operations
|
||||
from udsactor.service import CommonService
|
||||
from udsactor.service import initCfg
|
||||
from udsactor.service import IPC_PORT
|
||||
|
||||
from udsactor import ipc
|
||||
|
||||
from udsactor.log import logger
|
||||
@ -58,6 +59,8 @@ except Exception: # Platform may not include prctl, so in case it's not availab
|
||||
|
||||
|
||||
class UDSActorSvc(Daemon, CommonService):
|
||||
rebootMachineAfterOp = False
|
||||
|
||||
def __init__(self, args=None):
|
||||
Daemon.__init__(self, '/var/run/udsa.pid')
|
||||
CommonService.__init__(self)
|
||||
@ -67,6 +70,12 @@ class UDSActorSvc(Daemon, CommonService):
|
||||
Renames the computer, and optionally sets a password for an user
|
||||
before this
|
||||
'''
|
||||
hostName = operations.getComputerName()
|
||||
|
||||
if hostName.lower() == name.lower():
|
||||
logger.info('Computer name is already {}'.format(hostName))
|
||||
self.setReady()
|
||||
return
|
||||
|
||||
# Check for password change request for an user
|
||||
if user is not None:
|
||||
@ -80,13 +89,28 @@ class UDSActorSvc(Daemon, CommonService):
|
||||
'Could not change password for user {} (maybe invalid current password is configured at broker): {} '.format(user, unicode(e)))
|
||||
|
||||
renamer.rename(name)
|
||||
self.setReady()
|
||||
|
||||
if self.rebootMachineAfterOp is False:
|
||||
self.setReady()
|
||||
else:
|
||||
logger.info('Rebooting computer to activate new name {}'.format(name))
|
||||
self.reboot()
|
||||
|
||||
|
||||
def joinDomain(self, name, domain, ou, account, password):
|
||||
logger.fatal('Join domain is not supported on linux platforms right now')
|
||||
|
||||
def run(self):
|
||||
initCfg()
|
||||
cfg = initCfg() # Gets a local copy of config to get "reboot"
|
||||
|
||||
logger.debug('CFG: {}'.format(cfg))
|
||||
|
||||
if cfg is not None:
|
||||
self.rebootMachineAfterOp = cfg.get('reboot', False)
|
||||
else:
|
||||
self.rebootMachineAfterOp = False
|
||||
|
||||
logger.info('Reboot after is {}'.format(self.rebootMachineAfterOp))
|
||||
|
||||
logger.debug('Running Daemon')
|
||||
set_proctitle('UDSActorDaemon')
|
||||
|
@ -78,3 +78,6 @@ def writeConfig(data):
|
||||
cfg.write(f)
|
||||
|
||||
os.chmod(CONFIGFILE, 0o0600)
|
||||
|
||||
def useOldJoinSystem():
|
||||
return False
|
||||
|
@ -71,6 +71,8 @@ def initCfg():
|
||||
cfg = None
|
||||
break
|
||||
|
||||
return cfg
|
||||
|
||||
|
||||
class CommonService(object):
|
||||
def __init__(self):
|
||||
|
@ -43,6 +43,7 @@ import servicemanager # @UnresolvedImport, pylint: disable=import-error
|
||||
import os
|
||||
|
||||
from udsactor import operations
|
||||
from udsactor import store
|
||||
from udsactor.service import CommonService
|
||||
from udsactor.service import initCfg
|
||||
|
||||
@ -113,7 +114,7 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
|
||||
|
||||
operations.renameComputer(name)
|
||||
# Reboot just after renaming
|
||||
logger.info('Rebooting computer got activate new name {}'.format(name))
|
||||
logger.info('Rebooting computer to activate new name {}'.format(name))
|
||||
self.reboot()
|
||||
|
||||
def oneStepJoin(self, name, domain, ou, account, password):
|
||||
@ -158,12 +159,15 @@ class UDSActorSvc(win32serviceutil.ServiceFramework, CommonService):
|
||||
ver = ver[0] * 10 + ver[1]
|
||||
logger.debug('Starting joining domain {} with name {} (detected operating version: {})'.format(
|
||||
domain, name, ver))
|
||||
# If file c:\compat.bin exists, joind domain in two steps instead one
|
||||
|
||||
# Accepts one step joinDomain, also remember XP is no more supported by
|
||||
# microsoft, but this also must works with it because will do a "multi
|
||||
# step" join
|
||||
if ver >= 60:
|
||||
if ver >= 60 and store.useOldJoinSystem() is False:
|
||||
self.oneStepJoin(name, domain, ou, account, password)
|
||||
else:
|
||||
logger.info('Using multiple step join because configuration requests to do so')
|
||||
self.multiStepJoin(name, domain, ou, account, password)
|
||||
|
||||
def preConnect(self, user, protocol):
|
||||
|
@ -82,7 +82,6 @@ def readConfig():
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def writeConfig(data, fixPermissions=True):
|
||||
try:
|
||||
key = wreg.OpenKey(baseKey, path, 0, wreg.KEY_ALL_ACCESS) # @UndefinedVariable
|
||||
@ -93,3 +92,16 @@ def writeConfig(data, fixPermissions=True):
|
||||
|
||||
wreg.SetValueEx(key, "", 0, wreg.REG_BINARY, encoder(cPickle.dumps(data))) # @UndefinedVariable
|
||||
wreg.CloseKey(key) # @UndefinedVariable
|
||||
|
||||
def useOldJoinSystem():
|
||||
try:
|
||||
key = wreg.OpenKey(baseKey, 'Software\\UDSEnterpriseActor', 0, wreg.KEY_QUERY_VALUE) # @UndefinedVariable
|
||||
try:
|
||||
data, _ = wreg.QueryValueEx(key, 'join') # @UndefinedVariable
|
||||
except Exception:
|
||||
data = ''
|
||||
wreg.CloseKey(key) # @UndefinedVariable
|
||||
except:
|
||||
data = ''
|
||||
|
||||
return data == 'old'
|
||||
|
@ -355,5 +355,5 @@ class Changelog(DetailHandler):
|
||||
return [
|
||||
{'revision': {'title': _('Revision'), 'type': 'numeric', 'width': '6em'}},
|
||||
{'stamp': {'title': _('Publish date'), 'type': 'datetime'}},
|
||||
{'log': {'title': _('State')}},
|
||||
{'log': {'title': _('Comment')}},
|
||||
]
|
||||
|
@ -118,7 +118,7 @@ class TaskManager(object):
|
||||
thread = DelayedTaskThread()
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
time.sleep(1)
|
||||
time.sleep(0.5)
|
||||
|
||||
signal.signal(signal.SIGTERM, TaskManager.sigTerm)
|
||||
|
||||
|
@ -34,6 +34,6 @@ from __future__ import unicode_literals
|
||||
|
||||
# Helper to acommodate all unique generators in one place
|
||||
|
||||
from .UniqueGIDGenerator import UniqueGIDGenerator
|
||||
from .UniqueMacGenerator import UniqueMacGenerator
|
||||
from .UniqueNameGenerator import UniqueNameGenerator
|
||||
from .UniqueGIDGenerator import UniqueGIDGenerator # @UnusedImport
|
||||
from .UniqueMacGenerator import UniqueMacGenerator # @UnusedImport
|
||||
from .UniqueNameGenerator import UniqueNameGenerator # @UnusedImport
|
||||
|
@ -5,13 +5,12 @@ Created on Nov 14, 2012
|
||||
'''
|
||||
|
||||
import ovirtsdk4 as ovirt
|
||||
import ovirtsdk4.types
|
||||
|
||||
import threading
|
||||
import logging
|
||||
import re
|
||||
import six
|
||||
|
||||
__updated__ = '2016-09-11'
|
||||
__updated__ = '2017-03-03'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -224,7 +223,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
c = api.system_service().clusters_service().service(clusterId).get()
|
||||
c = api.system_service().clusters_service().service(six.binary_type(clusterId)).get()
|
||||
|
||||
dc = c.data_center
|
||||
|
||||
@ -274,7 +273,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
datacenter_service = api.system_service().data_centers_service().service(datacenterId)
|
||||
datacenter_service = api.system_service().data_centers_service().service(six.binary_type(datacenterId))
|
||||
d = datacenter_service.get()
|
||||
|
||||
storage = []
|
||||
@ -328,7 +327,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
dd = api.system_service().storage_domains_service().service(storageId).get()
|
||||
dd = api.system_service().storage_domains_service().service(six.binary_type(storageId)).get()
|
||||
|
||||
res = {
|
||||
'id': dd.id,
|
||||
@ -368,9 +367,9 @@ class Client(object):
|
||||
# cluster = ov.clusters_service().service('00000002-0002-0002-0002-0000000002e4') # .get()
|
||||
# vm = ov.vms_service().service('e7ff4e00-b175-4e80-9c1f-e50a5e76d347') # .get()
|
||||
|
||||
vms = api.system_service().vms_service().service(machineId)
|
||||
vms = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
|
||||
cluster = api.system_service().clusters_service().service(clusterId).get()
|
||||
cluster = api.system_service().clusters_service().service(six.binary_type(clusterId)).get()
|
||||
vm = vms.get()
|
||||
|
||||
if vm is None:
|
||||
@ -422,7 +421,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
template = api.system_service().templates_service().service(templateId).get()
|
||||
template = api.system_service().templates_service().service(six.binary_type(templateId)).get()
|
||||
|
||||
if template is None:
|
||||
return 'removed'
|
||||
@ -457,8 +456,8 @@ class Client(object):
|
||||
|
||||
logger.debug('Deploying machine {0}'.format(name))
|
||||
|
||||
cluster = ovirt.types.Cluster(id=clusterId)
|
||||
template = ovirt.types.Template(id=templateId)
|
||||
cluster = ovirt.types.Cluster(id=six.binary_type(clusterId))
|
||||
template = ovirt.types.Template(id=six.binary_type(templateId))
|
||||
if usbType in ('native', 'legacy'):
|
||||
usb = ovirt.types.Usb(enabled=True, type=ovirt.types.UsbType.NATIVE if usbType == 'native' else ovirt.types.UsbType.LEGACY)
|
||||
else:
|
||||
@ -485,7 +484,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
api.system_service().templates_service().service(templateId).remove()
|
||||
api.system_service().templates_service().service(six.binary_type(templateId)).remove()
|
||||
# This returns nothing, if it fails it raises an exception
|
||||
finally:
|
||||
lock.release()
|
||||
@ -511,7 +510,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
vm = api.system_service().vms_service().service(machineId).get()
|
||||
vm = api.system_service().vms_service().service(six.binary_type(machineId)).get()
|
||||
|
||||
if vm is None or vm.status is None:
|
||||
return 'unknown'
|
||||
@ -538,7 +537,7 @@ class Client(object):
|
||||
api = self.__getApi()
|
||||
|
||||
|
||||
vmService = api.system_service().vms_service().service(machineId)
|
||||
vmService = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
|
||||
if vmService.get() is None:
|
||||
raise Exception('Machine not found')
|
||||
@ -562,7 +561,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
vmService = api.system_service().vms_service().service(machineId)
|
||||
vmService = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
|
||||
if vmService.get() is None:
|
||||
raise Exception('Machine not found')
|
||||
@ -586,7 +585,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
vmService = api.system_service().vms_service().service(machineId)
|
||||
vmService = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
|
||||
if vmService.get() is None:
|
||||
raise Exception('Machine not found')
|
||||
@ -610,7 +609,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
vmService = api.system_service().vms_service().service(machineId)
|
||||
vmService = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
|
||||
if vmService.get() is None:
|
||||
raise Exception('Machine not found')
|
||||
@ -629,7 +628,7 @@ class Client(object):
|
||||
|
||||
api = self.__getApi()
|
||||
|
||||
vmService = api.system_service().vms_service().service(machineId)
|
||||
vmService = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
|
||||
if vmService.get() is None:
|
||||
raise Exception('Machine not found')
|
||||
@ -652,7 +651,7 @@ class Client(object):
|
||||
lock.acquire(True)
|
||||
api = self.__getApi()
|
||||
|
||||
vmService = api.system_service().vms_service().service(machineId)
|
||||
vmService = api.system_service().vms_service().service(six.binary_type(machineId))
|
||||
vm = vmService.get()
|
||||
|
||||
if vm is None:
|
||||
|
@ -39,7 +39,7 @@ from . import on
|
||||
import pickle
|
||||
import logging
|
||||
|
||||
__updated__ = '2016-07-11'
|
||||
__updated__ = '2017-02-28'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -224,7 +224,7 @@ class LiveDeployment(UserDeployment):
|
||||
state = self.service().getMachineState(self._vmid)
|
||||
|
||||
# If we want to check an state and machine does not exists (except in case that we whant to check this)
|
||||
if state == on.VmState.UNKNOWN:
|
||||
if state in [on.VmState.UNKNOWN, on.VmState.DONE]:
|
||||
return self.__error('Machine not found')
|
||||
|
||||
ret = State.RUNNING
|
||||
@ -500,7 +500,7 @@ class LiveDeployment(UserDeployment):
|
||||
if op == opError:
|
||||
return self.__error('Machine is already in error state!')
|
||||
|
||||
if op == opFinish or op == opWait:
|
||||
if op in [opFinish, opWait, opStart, opCreate]:
|
||||
self._queue = [opRemove, opFinish]
|
||||
return self.__executeQueue()
|
||||
|
||||
|
@ -38,7 +38,7 @@ from defusedxml import minidom
|
||||
# Python bindings for OpenNebula
|
||||
from .common import sanitizeName
|
||||
|
||||
__updated__ = '2016-07-27'
|
||||
__updated__ = '2017-03-03'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -113,7 +113,7 @@ def create(api, fromTemplateId, name, toDataStore):
|
||||
|
||||
return six.text_type(templateId)
|
||||
except Exception as e:
|
||||
logger.error('Creating template on OpenNebula: {}'.format(e))
|
||||
logger.exception('Creating template on OpenNebula: {}'.format(e))
|
||||
try:
|
||||
api.deleteTemplate(templateId) # Try to remove created template in case of fail
|
||||
except Exception:
|
||||
@ -155,7 +155,7 @@ def remove(api, templateId):
|
||||
|
||||
api.deleteTemplate(templateId) # api.call('template.delete', int(templateId))
|
||||
except Exception as e:
|
||||
logger.error('Creating template on OpenNebula: {}'.format(e))
|
||||
logger.error('Removing template on OpenNebula: {}'.format(e))
|
||||
|
||||
def deployFrom(api, templateId, name):
|
||||
'''
|
||||
|
@ -39,7 +39,7 @@ from defusedxml import minidom
|
||||
# Python bindings for OpenNebula
|
||||
from .common import VmState
|
||||
|
||||
__updated__ = '2017-01-26'
|
||||
__updated__ = '2017-03-03'
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@ -157,11 +157,15 @@ def getNetInfo(api, machineId, networkId=None):
|
||||
md = minidom.parseString(api.VMInfo(machineId)[1])
|
||||
node = md
|
||||
|
||||
for nic in md.getElementsByTagName('NIC'):
|
||||
netId = nic.getElementsByTagName('NETWORK_ID')[0].childNodes[0].data
|
||||
if networkId is None or int(netId) == int(networkId):
|
||||
node = nic
|
||||
break
|
||||
try:
|
||||
for nic in md.getElementsByTagName('NIC'):
|
||||
netId = nic.getElementsByTagName('NETWORK_ID')[0].childNodes[0].data
|
||||
if networkId is None or int(netId) == int(networkId):
|
||||
node = nic
|
||||
break
|
||||
except Exception:
|
||||
raise Exception('No network interface found on template. Please, add a network and republish.')
|
||||
|
||||
logger.debug(node.toxml())
|
||||
|
||||
# Default, returns first MAC found (or raise an exception if there is no MAC)
|
||||
@ -187,7 +191,7 @@ def getDisplayConnection(api, machineId):
|
||||
type_ = graphics.getElementsByTagName('TYPE')[0].childNodes[0].data
|
||||
port = graphics.getElementsByTagName('PORT')[0].childNodes[0].data
|
||||
try:
|
||||
passwd = graphics.getElementsByTagName('PASSWD').childNodes[0].data
|
||||
passwd = graphics.getElementsByTagName('PASSWD')[0].childNodes[0].data
|
||||
except Exception:
|
||||
passwd = ''
|
||||
|
||||
|
@ -44,7 +44,7 @@ from uds.services.OVirt.OVirtProvider import Provider as oVirtProvider
|
||||
import logging
|
||||
import os
|
||||
|
||||
__updated__ = '2016-05-27'
|
||||
__updated__ = '2017-02-21'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -85,7 +85,7 @@ class BaseSpiceTransport(Transport):
|
||||
multiline=4,
|
||||
label=_('Certificate'),
|
||||
tooltip=_('Server certificate (public), can be found on your ovirt engine, probably at /etc/pki/ovirt-engine/certs/ca.der (Use the contents of this file).'),
|
||||
required=True
|
||||
required=False
|
||||
)
|
||||
fullScreen = gui.CheckBoxField(
|
||||
order=5,
|
||||
|
@ -8,7 +8,7 @@ import six
|
||||
import os
|
||||
|
||||
|
||||
__updated__ = '2016-05-27'
|
||||
__updated__ = '2017-02-21'
|
||||
|
||||
|
||||
TEMPLATE = '''[virt-viewer]
|
||||
@ -29,7 +29,7 @@ ca={ca}
|
||||
toggle-fullscreen=shift+f11
|
||||
release-cursor=shift+f12
|
||||
secure-attention=ctrl+alt+end
|
||||
secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard
|
||||
{secure_channel}
|
||||
'''
|
||||
|
||||
|
||||
@ -81,6 +81,7 @@ class RemoteViewerFile(object):
|
||||
smartcard=smartcard,
|
||||
usb_auto_share=usb_auto_share,
|
||||
delete_file=delete_file,
|
||||
host_subject=self.host_subject,
|
||||
ca=ca
|
||||
host_subject=self.host_subject if self.tls_port != -1 else '',
|
||||
ca=ca if self.tls_port != -1 else '',
|
||||
secure_channel='secure-channels=main;inputs;cursor;playback;record;display;usbredir;smartcard' if self.tls_port != -1 else ''
|
||||
)
|
||||
|
@ -51,7 +51,7 @@ import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
__updated__ = '2017-02-02'
|
||||
__updated__ = '2017-02-27'
|
||||
|
||||
|
||||
def about(request):
|
||||
|
Loading…
x
Reference in New Issue
Block a user