1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

X2Go Working on linux & Windows

This commit is contained in:
Adolfo Gómez García 2016-11-07 02:35:23 +01:00
parent 3a58e0e446
commit 82097b67f4
11 changed files with 99 additions and 74 deletions

View File

@ -46,6 +46,7 @@ from uds.core.ui.UserInterface import gui
from .user_services import AssignedService, CachedService, Groups, Transports, Publications, Changelog
from .services_pool_calendars import AccessCalendars, ActionsCalendars
from .services import Services
from uds.core.managers import userServiceManager
import logging
@ -74,10 +75,12 @@ class ServicesPools(ModelHandler):
table_title = _('Service Pools')
table_fields = [
{'name': {'title': _('Name')}},
{'parent': {'title': _('Parent Service')}},
{'state': {'title': _('status'), 'type': 'dict', 'dict': State.dictionary()}},
{'user_services_count': {'title': _('User services'), 'type': 'number'}},
{'user_services_in_preparation': {'title': _('In Preparation')}},
{'show_transports': {'title': _('Shows transports'), 'type': 'callback'}},
{'pool_group_name': {'title': _('Pool Group')}},
{'parent': {'title': _('Parent Service')}},
{'tags': {'title': _('tags'), 'visible': False}},
]
# Field from where to get "class" and prefix for that class, so this will generate "row-state-A, row-state-X, ....
@ -97,6 +100,13 @@ class ServicesPools(ModelHandler):
poolGroupName = item.servicesPoolGroup.name
if item.servicesPoolGroup.image is not None:
poolGroupThumb = item.servicesPoolGroup.image.thumb64
state = item.state
if item.isInMaintenance():
state = State.MAINTENANCE
elif userServiceManager().canInitiateServiceFromDeployedService(item) is False:
state = State.SLOWED_DOWN
val = {
'id': item.uuid,
'name': item.name,
@ -104,7 +114,7 @@ class ServicesPools(ModelHandler):
'parent': item.service.name,
'parent_type': item.service.data_type,
'comments': item.comments,
'state': item.state if item.isInMaintenance() is False else State.MAINTENANCE,
'state': state,
'thumb': item.image.thumb64 if item.image is not None else DEFAULT_THUMB_BASE64,
'service_id': item.service.uuid,
'provider_id': item.service.provider.uuid,
@ -117,6 +127,7 @@ class ServicesPools(ModelHandler):
'cache_l2_srvs': item.cache_l2_srvs,
'max_srvs': item.max_srvs,
'user_services_count': item.userServices.count(),
'user_services_in_preparation': item.userServices.filter(state=State.PREPARING).count(),
'restrained': item.isRestrained(),
'show_transports': item.show_transports,
'fallbackAccess': item.fallbackAccess,

View File

@ -51,7 +51,7 @@ import requests
import json
import logging
__updated__ = '2016-10-23'
__updated__ = '2016-11-04'
logger = logging.getLogger(__name__)

View File

@ -48,6 +48,7 @@ class State(object):
FINISHED = 'F'
BALANCING = 'H'
INACTIVE = 'I'
SLOWED_DOWN = 'J' # Only used on admin dashboard, not internal real state
CANCELING = 'K'
LAUNCHING = 'L'
REMOVING = 'M'
@ -78,7 +79,8 @@ class State(object):
FOR_EXECUTE: _('Waiting execution'),
BALANCING: _('Balancing'),
MAINTENANCE: _('In maintenance'),
WAITING_OS: _('Waiting OS')
WAITING_OS: _('Waiting OS'),
SLOWED_DOWN: _('Too many preparing services'),
}
# States that are merely for "information" to the user. They don't contain any usable instance

View File

@ -209,6 +209,8 @@
column.render = renderTextTransform(opts.dict) if opts.dict?
when "callback"
column.render = renderCallBack(v)
when "number"
column.render = $.fn.dataTable.render.number(get_format("THOUSAND_SEPARATOR"), get_format("DECIMAL_SEPARATOR"))
else
column.type = opts.type
columns.push column

View File

@ -46,7 +46,7 @@ import logging
import random
import string
__updated__ = '2016-11-02'
__updated__ = '2016-11-07'
logger = logging.getLogger(__name__)
@ -81,23 +81,27 @@ class TX2GOTransport(BaseX2GOTransport):
raise BaseX2GOTransport.ValidationException(_('Must use HOST:PORT in Tunnel Server Field'))
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
prefs = user.prefs('nx')
priv, pub = self.getAndPushKey('user', userService)
prefs = user.prefs('rdp')
prefs = user.prefs('nx')
ci = self.getConnectionInfo(userService, user, password)
username = ci['username']
width, height = CommonPrefs.getWidthHeight(prefs)
logger.debug('')
xf = x2gofile.getTemplate(
pack=self.pack.value,
quality=self.quality.value,
sound=self.sound.isTrue(),
soundSystem=self.sound.value,
windowManager=self.desktopType.value,
exports=self.exports.isTrue())
exports=self.exports.isTrue(),
width=width,
height=height
)
tunpass = ''.join(random.choice(string.letters + string.digits) for _i in range(12))
tunuser = TicketStore.create(tunpass)

View File

@ -40,7 +40,7 @@ from . import x2gofile
import logging
__updated__ = '2016-10-24'
__updated__ = '2016-11-07'
logger = logging.getLogger(__name__)
@ -66,23 +66,25 @@ class X2GOTransport(BaseX2GOTransport):
quality = BaseX2GOTransport.quality
def getUDSTransportScript(self, userService, transport, ip, os, user, password, request):
prefs = user.prefs('nx')
priv, pub = self.getAndPushKey('user', userService)
prefs = user.prefs('rdp')
prefs = user.prefs('nx')
ci = self.getConnectionInfo(userService, user, password)
username = ci['username']
width, height = CommonPrefs.getWidthHeight(prefs)
xf = x2gofile.getTemplate(
pack=self.pack.value,
quality=self.quality.value,
sound=self.sound.isTrue(),
soundSystem=self.sound.value,
windowManager=self.desktopType.value,
exports=self.exports.isTrue())
exports=self.exports.isTrue(),
width=width,
height=height
)
# data
data = {

View File

@ -3,25 +3,27 @@
from __future__ import unicode_literals
# pylint: disable=import-error, no-name-in-module
from PyQt4 import QtCore, QtGui
import os
import subprocess
from uds import tools # @UnresolvedImport
executable = tools.findApp('remote-viewer')
if executable is None:
raise Exception('''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
<p>
Please, install appropriate package for your Linux system. (probably named something like <b>remote-viewer</b>)
</p>
''')
rsaPubKey = '''{m.rsa_key}'''
theFile = '''{m.r.as_file}'''
import six
keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(export='/:1;', keyFile=keyFile.replace('\\', '/'), ip='{m.ip}', port='22')
filename = tools.saveTempFile(theFile)
subprocess.Popen([executable, filename])
# HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session
# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)
executable = tools.findApp('x2goclient')
if executable is None:
raise Exception('''<p>You must have installed latest X2GO Client in order to connect to this UDS service.</p>
<p>Please, install the required packages for your platform</p>''')
subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
# tools.addFileToUnlink(filename)
# tools.addFileToUnlink(keyFile)
# QtGui.QMessageBox.critical(parent, 'Notice', executable + ' -- ' + keyFile + ', ' + filename, QtGui.QMessageBox.Ok) # @UndefinedVariable

View File

@ -2,47 +2,35 @@
# Saved as .py for easier editing
from __future__ import unicode_literals
# pylint: disable=import-error, no-name-in-module, undefined-variable
import subprocess
# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable
from uds import tools # @UnresolvedImport
from PyQt4 import QtCore, QtGui
import os
import subprocess
from uds.forward import forward # @UnresolvedImport
executable = tools.findApp('remote-viewer')
from uds import tools # @UnresolvedImport
if executable is None:
raise Exception('''<p>You need to have installed virt-viewer to connect to this UDS service.</p>
<p>
Please, install appropriate package for your system.
</p>
<p>
Please, install appropriate package for your Linux system. (probably named something like <b>virt-viewer</b>)
</p>
''')
import six
forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 22)
if {m.port} != -1: # @UndefinedVariable
forwardThread1, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', {m.port}) # @UndefinedVariable
if forwardThread.status == 2:
raise Exception('Unable to open tunnel')
if forwardThread1.status == 2:
raise Exception('Unable to open tunnel')
else:
port = -1
if {m.secure_port} != -1: # @UndefinedVariable
forwardThread2, secure_port = forwardThread1.clone('{m.ip}', {m.secure_port}) # @UndefinedVariable
if forwardThread2.status == 2:
raise Exception('Unable to open tunnel')
else:
secure_port = -1
theFile = '''{m.r.as_file}'''.format(
secure_port=secure_port,
port=port
)
tools.addTaskToWait(forwardThread)
keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(export='/:1;', keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port)
filename = tools.saveTempFile(theFile)
# HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session
subprocess.Popen([executable, filename])
executable = tools.findApp('x2goclient')
if executable is None:
raise Exception('''<p>You must have installed latest X2GO Client in order to connect to this UDS service.</p>
<p>Please, install the required packages for your platform</p>''')
subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)

View File

@ -4,7 +4,6 @@ from __future__ import unicode_literals
# pylint: disable=import-error, no-name-in-module
from PyQt4 import QtCore, QtGui
import win32crypt # @UnresolvedImport
import os
import subprocess
@ -13,7 +12,7 @@ from uds import tools # @UnresolvedImport
import six
keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(exports='c:\\', keyFile=keyFile.replace('\\', '/'), ip='{m.ip}', port='22')
theFile = '''{m.xf}'''.format(export='c:\\', keyFile=keyFile.replace('\\', '/'), ip='{m.ip}', port='22')
filename = tools.saveTempFile(theFile)
x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient'
@ -24,7 +23,7 @@ if executable is None:
# C:\Program Files (x86)\\x2goclient>x2goclient.exe --session-conf=c:/temp/sessions --session=UDS/test-session --close-disconnect --hide --no-menu
subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu'])
subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
# tools.addFileToUnlink(filename)
# tools.addFileToUnlink(keyFile)

View File

@ -5,7 +5,6 @@ from __future__ import unicode_literals
# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable
from PyQt4 import QtCore, QtGui
import win32crypt # @UnresolvedImport
import os
import subprocess
from uds.forward import forward # @UnresolvedImport
@ -14,7 +13,7 @@ from uds import tools # @UnresolvedImport
import six
forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 3389)
forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 22)
if forwardThread.status == 2:
raise Exception('Unable to open tunnel')
@ -22,7 +21,7 @@ if forwardThread.status == 2:
tools.addTaskToWait(forwardThread)
keyFile = tools.saveTempFile('''{m.key}''')
theFile = '''{m.xf}'''.format(exports='c:\\', keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port)
theFile = '''{m.xf}'''.format(export='c:\\', keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port)
filename = tools.saveTempFile(theFile)
x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient'
@ -31,6 +30,6 @@ if executable is None:
raise Exception('''<p>You must have installed latest X2GO Client in default program file folder in order to connect to this UDS service.</p>
<p>You can download it for windows from <a href="http://wiki.x2go.org/doku.php">X2Go Site</a>.</p>''')
subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu'])
subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
# QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)

View File

@ -43,14 +43,14 @@ fstunnel=true
iconvto=UTF-8
iconvfrom=ISO8859-1
useiconv=false
fullscreen=false
fullscreen={fullscreen}
multidisp=false
display=1
maxdim=false
rdpclient=rdesktop
directrdpsettings=
width=800
height=600
width={width}
height={height}
dpi=96
setdpi=true
xinerama=false
@ -94,7 +94,23 @@ sshproxyautologin=false
sshproxykrblogin=false
'''
def getTemplate(pack, quality, sound, soundSystem, windowManager, exports):
def getTemplate(pack, quality, sound, soundSystem, windowManager, exports, width, height):
trueFalse = lambda(x): 'true' if x else 'false'
export = 'export="{{export}}"' if exports else ''
return template.format(pack=pack, quality=quality, sound=trueFalse(sound), soundSystem=soundSystem, windowManager=windowManager, export=export)
export = 'export="{export}"' if exports else ''
if width == -1 or height == -1:
width = 800
height = 600
fullscreen = 'true'
else:
fullscreen = 'false'
return template.format(
pack=pack,
quality=quality,
sound=trueFalse(sound),
soundSystem=soundSystem,
windowManager=windowManager,
export=export,
width=width,
height=height,
fullscreen=fullscreen
)