* Removed send script from OS Manager (it's a nonsense, after a few

tests..)
* Some typos fixes
This commit is contained in:
Adolfo Gómez García 2014-12-07 21:35:13 +01:00
parent bda104d94e
commit 903664b7c5
11 changed files with 57 additions and 48 deletions

View File

@ -1,3 +1,4 @@
build
.idea
*_enterprise*
/samples/

View File

@ -446,28 +446,6 @@ class UserServiceManager(object):
UserServiceOpChecker.makeUnique(uService, ui, state)
return False
def manageOsManagerPreConnection(self, uService, user):
'''
Sends, if the user service has os manager and the os manager "wants" to send an pre-script to actor
the script to the Service
If fails, it will silently ignore it, but probably connection will not success
This is so right now to keep compatibility with previos xmlrpc actor..
@return: Nothing
'''
logger.debug('Managing specific OS Manager data before connection')
if uService.needsOsManager() is False:
logger.debug('No os manager for service, finishing')
return
osm = uService.getOsManager()
instanceOsManager = osm.getInstance()
script = instanceOsManager.preAccessScript(uService, user)
if script is None:
logger.debug('OS Manager does not provides a pre access script')
logger.debug('Pre access script: {}'.format(script))
return self.sendScript(uService, script)
def sendScript(self, uService, script):
'''
If allowed, send script to user service

View File

@ -36,7 +36,7 @@ from django.utils.translation import ugettext_noop as _
from uds.core.util.State import State
from uds.core import Module
__updated__ = '2014-12-04'
__updated__ = '2014-12-07'
STORAGE_KEY = 'osmk'
@ -126,14 +126,6 @@ class OSManager(Module):
'''
return None
def preAccessScript(self, userService, user):
'''
This gives us the chance to include "customized" initialization for any os manager for an specifyc user & service on assignation to an user
such as "include" in allowed user list, etc...
Both values are db objects
'''
return None
@classmethod
def transformsUserOrPasswordForService(cls):
'''

View File

@ -141,6 +141,15 @@ class Transport(Module):
'''
return {'protocol': protocols.NONE, 'username': '', 'password': '', 'domain': ''}
def preAccessScript(self, userService, user):
'''
This gives us the chance to include "customized" initialization for any transport for an specifyc user & service on assignation to an user
such as "include" in allowed user list, etc...
Both values are db objects
'''
return None
def renderForHtml(self, userService, idUserService, idTransport, ip, os, user, password):
'''
Requests the html rendering of connector for the destination ip, (dbUser) and password

View File

@ -38,7 +38,6 @@ class WinDomainOsManager(WindowsOsManager):
# Inherits base "onLogout"
onLogout = WindowsOsManager.onLogout
idle = WindowsOsManager.idle
addToRemoteGroup = WindowsOsManager.addToRemoteGroup
def __init__(self, environment, values):
super(WinDomainOsManager, self).__init__(environment, values)

View File

@ -34,7 +34,6 @@ class WinRandomPassManager(WindowsOsManager):
# Inherits base "onLogout"
onLogout = WindowsOsManager.onLogout
idle = WindowsOsManager.idle
addToRemoteGroup = WindowsOsManager.addToRemoteGroup
def __init__(self, environment, values):
super(WinRandomPassManager, self).__init__(environment, values)

View File

@ -23,6 +23,39 @@ import logging
logger = logging.getLogger(__name__)
# Base script for allowing RDP access
baseScript = '''from __future__ import unicode_literals
import win32security
import win32net
from udsactor.httpserver import scriptsOnLogout
# Well known SSID for Remote Desktop Users
REMOTE_USERS_SID = 'S-1-5-32-555'
user = '{user}'
p = win32security.GetBinarySid(REMOTE_USERS_SID)
groupName = win32security.LookupAccountSid(None, p)[0]
useraAlreadyInGroup = False
resumeHandle = 0
while True:
users, total, resumeHandle = win32net.NetLocalGroupGetMembers(None, groupName, 1, resumeHandle, 32768)
if user in [u['name'] for u in users]:
useraAlreadyInGroup = True
break
if resumeHandle == 0:
break
if useraAlreadyInGroup is False:
try:
userSSID = win32security.LookupAccountName(None, user)[0]
win32net.NetLocalGroupAddMembers(None, groupName, 0, [{'sid': userSSID}])
except Exception as e:
logger.exception('Exception adding user to Remote Desktop Users: {}'.format(e))
'''
def scrambleMsg(data):
'''
@ -58,7 +91,6 @@ class WindowsOsManager(osmanagers.OSManager):
idle = gui.NumericField(label=_("Max.Idle time"), length=4, defvalue=-1, rdonly=False, order=11,
tooltip=_('Maximum idle time (in seconds) before session is automaticatlly closed to the user (<= 0 means no max idle time).'), required=True)
addToRemoteGroup = gui.CheckBoxField(label=_('Remote Desktop Groups'), order=12, tooltip=_('If checked, the conecting user will be added to Remote Desktop Users group prior to connecting'))
@staticmethod
def validateLen(length):
@ -220,11 +252,14 @@ class WindowsOsManager(osmanagers.OSManager):
def unmarshal(self, s):
data = s.split('\t')
try:
if data[0] == 'v1':
self._onLogout = data[1]
self._idle = -1
elif data[0] == 'v2':
self._onLogout, self._idle = data[1], int(data[2])
except Exception:
logger.exception('Exception unmarshalling. Some values left as default ones')
self.__setProcessUnusedMachines()

View File

@ -39,6 +39,7 @@ import logging
logger = logging.getLogger(__name__)
class IPMachineDeployed(AutoAttributes, services.UserDeployment):
suggestedTime = 10

View File

@ -47,7 +47,7 @@ import logging
logger = logging.getLogger(__name__)
__updated__ = '2014-05-14'
__updated__ = '2014-12-07'
CACHE_TIME_FOR_SERVER = 1800
@ -171,7 +171,6 @@ class Provider(ServiceProvider):
continue
yield m
def getStorages(self, force=False):
'''
Obtains the list of storages inside XenServer.
@ -189,7 +188,6 @@ class Provider(ServiceProvider):
'''
return self.__getApi().getSRs()
def getStorageInfo(self, storageId, force=False):
'''
Obtains the storage info
@ -220,7 +218,6 @@ class Provider(ServiceProvider):
logger.debug('Task for cloneForTemplate: {0}'.format(task))
return task
def convertToTemplate(self, machineId, shadowMultiplier=4):
'''
Publish the machine (makes a template from it so we can create COWs) and returns the template id of
@ -336,7 +333,6 @@ class Provider(ServiceProvider):
'''
return self.__getApi().resumeVM(machineId, async)
def removeVM(self, machineId):
'''
Tries to delete a machine. No check is done, it is simply requested to XenServer

View File

@ -121,7 +121,7 @@ class TSNXTransport(Transport):
else:
self._tunnelServer = ''
self._tunnelCheckServer = ''
self._useEmptyCreds = ''
self._useEmptyCreds = False
self._fixedName = ''
self._fixedPassword = ''
self._listenPort = ''
@ -134,8 +134,8 @@ class TSNXTransport(Transport):
'''
Serializes the transport data so we can store it in database
'''
return str.join('\t', [ 'v1', gui.boolToStr(self._useEmptyCreds), self._fixedName, self._fixedPassword, self._listenPort,
self._connection, self._session, self._cacheDisk, self._cacheMem, self._tunnelServer, self._tunnelCheckServer ])
return str.join('\t', ['v1', gui.boolToStr(self._useEmptyCreds), self._fixedName, self._fixedPassword, self._listenPort,
self._connection, self._session, self._cacheDisk, self._cacheMem, self._tunnelServer, self._tunnelCheckServer])
def unmarshal(self, string):
data = string.split('\t')

View File

@ -276,7 +276,6 @@ def service(request, idService, idTransport):
if ip is not None:
itrans = trans.getInstance()
if itrans.isAvailableFor(ip):
UserServiceManager.manager().manageOsManagerPreConnection(ads, request.user)
log.doLog(ads, log.INFO, "User service ready, rendering transport", log.WEB)
transport = itrans.renderForHtml(ads, ads.uuid, trans.uuid, ip, request.session['OS'], request.user, webPassword(request))
return render_to_response(theme.template('show_transport.html'), {'transport': transport, 'nolang': True}, context_instance=RequestContext(request))