The branch, uccsoutput has been updated via 8130c9d12e3447fda3064b4b3f1ba0aef1015341 (commit) via 00fb61c3429809f7511f7bda5667a77facd96918 (commit) via e341bd86111730b2919697a74ac18d759d2a9e74 (commit) via c9c92dbff6b4e9ee872eb738121dbd51da94d329 (commit) via 1734e9987eebeaf7574c42c28b92f010fb827008 (commit) via cd9500b7a1d12cd973af7726dbead83b79bc8581 (commit) via 890debb62b31a29ed482d392e7d276c5d9936d90 (commit) from aea8e30472982caf3be18c73e3175becfc6d6b4a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8130c9d12e3447fda3064b4b3f1ba0aef1015341 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Apr 7 10:08:09 2013 +0200 Fix wrong usage of session option »cmd«, has to be »command«. commit 00fb61c3429809f7511f7bda5667a77facd96918 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Apr 6 14:01:40 2013 +0200 add test that checks profile completion from hard-coded defaults commit e341bd86111730b2919697a74ac18d759d2a9e74 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Apr 6 13:39:43 2013 +0200 Add cmd and directrdp session profile parameters to defaults. commit c9c92dbff6b4e9ee872eb738121dbd51da94d329 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Apr 6 13:37:33 2013 +0200 sbin/x2gobroker: import UCCS web frontend commit 1734e9987eebeaf7574c42c28b92f010fb827008 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Apr 6 13:36:38 2013 +0200 fix x2gobroker/web/uccs.py commit cd9500b7a1d12cd973af7726dbead83b79bc8581 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Apr 6 13:26:27 2013 +0200 new parameter in default profile commit 890debb62b31a29ed482d392e7d276c5d9936d90 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sat Apr 6 13:03:58 2013 +0200 move UCCS JSON classes into separate file ----------------------------------------------------------------------- Summary of changes: debian/changelog | 5 +- etc/broker/x2gobroker-sessionprofiles.conf | 3 +- sbin/x2gobroker | 1 + x2gobroker/brokers/zeroconf_broker.py | 7 +- x2gobroker/defaults.py | 3 +- x2gobroker/tests/test_broker_base.py | 4 +- x2gobroker/tests/test_broker_inifile.py | 142 +++++++++++++--- x2gobroker/tests/test_broker_zeroconf.py | 4 + x2gobroker/uccsjson.py | 241 ++++++++++++++++++++++++++++ x2gobroker/web/uccs.py | 93 ++--------- 10 files changed, 387 insertions(+), 116 deletions(-) create mode 100644 x2gobroker/uccsjson.py The diff of changes is: diff --git a/debian/changelog b/debian/changelog index b460d0d..be2985b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,7 +1,8 @@ x2gobroker (0.0.1.1-0~x2go1) UNRELEASED; urgency=low - * New upstream version (0.0.1.0): - - Continue development... + * New upstream version (0.0.1.1): + - Add command and directrdp session profile parameters to defaults. + - Fix wrong usage of session option »cmd«, has to be »command«. -- Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Sun, 10 Mar 2013 13:00:32 +0100 diff --git a/etc/broker/x2gobroker-sessionprofiles.conf b/etc/broker/x2gobroker-sessionprofiles.conf index 2f0caea..8d060ec 100644 --- a/etc/broker/x2gobroker-sessionprofiles.conf +++ b/etc/broker/x2gobroker-sessionprofiles.conf @@ -29,6 +29,7 @@ [DEFAULT] +command=TERMINAL defsndport=true useiconv=false iconvfrom=UTF-8 @@ -52,7 +53,7 @@ applications=TERMINAL,WWWBROWSER,MAILCLIENT,OFFICE multidisp=false sshproxyport=22 sound=true -rootless=false +rootless=true iconvto=UTF-8 soundtunnel=true dpi=96 diff --git a/sbin/x2gobroker b/sbin/x2gobroker index 05678ab..894b3c0 100755 --- a/sbin/x2gobroker +++ b/sbin/x2gobroker @@ -110,6 +110,7 @@ if __name__ == "__main__": # import classes serving the different web.py URLs import x2gobroker.web.plain +import x2gobroker.web.uccs #import x2gobroker.web.json #import x2gobroker.web.html import x2gobroker.web.extras diff --git a/x2gobroker/brokers/zeroconf_broker.py b/x2gobroker/brokers/zeroconf_broker.py index 5970659..6cb83ad 100644 --- a/x2gobroker/brokers/zeroconf_broker.py +++ b/x2gobroker/brokers/zeroconf_broker.py @@ -36,7 +36,7 @@ class X2GoBroker(base.X2GoBroker): def list_profiles(self, username): - list_of_profiles = { + _list_of_profiles = { uuid.uuid4(): { 'user': u'', 'defsndport': True, @@ -74,6 +74,11 @@ class X2GoBroker(base.X2GoBroker): 'pack': u'16m-jpeg', }, } + list_of_profiles = {} + for profile_id in _list_of_profiles.keys(): + profile = self.get_profile_defaults() + profile.update(_list_of_profiles[profile_id]) + list_of_profiles[profile_id] = profile return list_of_profiles def select_session(self, profile_id, username=None): diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py index 8a930dc..9e61d83 100644 --- a/x2gobroker/defaults.py +++ b/x2gobroker/defaults.py @@ -161,6 +161,7 @@ X2GOBROKER_CONFIG_DEFAULTS = { # defaults for X2Go Sessino Broker session profiles file X2GOBROKER_SESSIONPROFILE_DEFAULTS = { u'DEFAULT': { + u'command': u'TERMINAL', u'defsndport': True, u'useiconv': False, u'iconvfrom': u'UTF-8', @@ -184,7 +185,7 @@ X2GOBROKER_SESSIONPROFILE_DEFAULTS = { u'multidisp': False, u'sshproxyport': 22, u'sound': True, - u'rootless': False, + u'rootless': True, u'iconvto': u'UTF-8', u'soundtunnel': True, u'dpi': 96, diff --git a/x2gobroker/tests/test_broker_base.py b/x2gobroker/tests/test_broker_base.py index 0bda18e..1371724 100644 --- a/x2gobroker/tests/test_broker_base.py +++ b/x2gobroker/tests/test_broker_base.py @@ -274,6 +274,7 @@ check-credentials = false def test_getdefaultprofile(self): base_backend = self._init_base_backend() _expected_profile = { + 'command': 'TERMINAL', 'defsndport': True, 'useiconv': False, 'iconvfrom': 'UTF-8', @@ -297,7 +298,7 @@ check-credentials = false 'multidisp': False, 'sshproxyport': 22, 'sound': True, - 'rootless': False, + 'rootless': True, 'iconvto': 'UTF-8', 'soundtunnel': True, 'dpi': 96, @@ -306,6 +307,7 @@ check-credentials = false 'pack': '16m-jpeg', 'user': '', 'host': [u'localhost'], + 'directrdp': False, } _profile = base_backend.get_profile_defaults() self.assertEqual(len(_expected_profile.keys()), len(_profile.keys())) diff --git a/x2gobroker/tests/test_broker_inifile.py b/x2gobroker/tests/test_broker_inifile.py index 35b4289..6bc62f8 100644 --- a/x2gobroker/tests/test_broker_inifile.py +++ b/x2gobroker/tests/test_broker_inifile.py @@ -47,6 +47,96 @@ class TestX2GoBrokerBackendInifile(unittest.TestCase): for _profile_id in _profile_ids: self.assertTrue( ( 'default' not in inifile_backend.get_profile(_profile_id).keys() ) ) + # TEST COMPLETION OF DEFAULTS FROM CODE IN defaults.py + + def test_getprofilecompletion(self): + _session_profiles = """ +[DEFAULT] +exports = +fullscreen = false +width = 800 +height = 600 +applications = TERMINAL, WWWBROWSER + +[testprofile] +user = foo +command = GNOME + +""" + tf = tempfile.NamedTemporaryFile() + print >> tf, _session_profiles + tf.seek(0) + inifile_backend = inifile.X2GoBroker(profile_config_file=tf.name) + _expected_defaults = copy.deepcopy(x2gobroker.defaults.X2GOBROKER_SESSIONPROFILE_DEFAULTS['DEFAULT']) + for key in copy.deepcopy(_expected_defaults).keys(): + if key.startswith('acl-'): + del _expected_defaults[key] + _expected_defaults.update( { + u'exports': '', + u'fullscreen': False, + u'width': 800, + u'height': 600, + u'applications': ['TERMINAL','WWWBROWSER',], + u'user': 'foo', + u'command': 'GNOME', + } ) + # just testing the directrdp hard-coded defaults + _expected_defaults.update( { + u'directrdp': False, + } ) + _expected_profile = copy.deepcopy(_expected_defaults) + _profile = inifile_backend.get_profile('testprofile') + print _expected_defaults + for key in _expected_profile.keys(): + self.assertTrue( ( key in _profile.keys() ) ) + for key in _profile.keys(): + self.assertTrue( ( key in _expected_profile.keys() and _profile[key] == _expected_profile[key] ) ) + + # TEST COMPLETION OF DEFAULTS FROM CODE IN defaults.py + + def test_getprofilecompletion(self): + _session_profiles = """ +[DEFAULT] +exports = +fullscreen = false +width = 800 +height = 600 +applications = TERMINAL, WWWBROWSER + +[testprofile] +user = foo +command = GNOME + +""" + tf = tempfile.NamedTemporaryFile() + print >> tf, _session_profiles + tf.seek(0) + inifile_backend = inifile.X2GoBroker(profile_config_file=tf.name) + _expected_defaults = copy.deepcopy(x2gobroker.defaults.X2GOBROKER_SESSIONPROFILE_DEFAULTS['DEFAULT']) + for key in copy.deepcopy(_expected_defaults).keys(): + if key.startswith('acl-'): + del _expected_defaults[key] + _expected_defaults.update( { + u'exports': '', + u'fullscreen': False, + u'width': 800, + u'height': 600, + u'applications': ['TERMINAL','WWWBROWSER',], + u'user': 'foo', + u'command': 'GNOME', + } ) + # just testing the directrdp hard-coded defaults + _expected_defaults.update( { + u'directrdp': False, + } ) + _expected_profile = copy.deepcopy(_expected_defaults) + _profile = inifile_backend.get_profile('testprofile') + for key in _expected_profile.keys(): + self.assertTrue( ( key in _profile.keys() ) ) + for key in _profile.keys(): + self.assertTrue( ( key in _expected_profile.keys() and _profile[key] == _expected_profile[key] ) ) + + ### TEST SESSION PROFILES: get_profile_defaults() def test_getprofiledefaults(self): @@ -74,16 +164,16 @@ applications = TERMINAL, WWWBROWSER [testprofile1] user = foo -cmd = GNOME +command = GNOME [testprofile2] user = bar -cmd = KDE +command = KDE fullscreen = true [testprofile3] user = bar -cmd = KDE +command = KDE fullscreen = true acl-users-deny = ALL acl-users-allow = foo,bar @@ -102,23 +192,23 @@ acl-users-order = deny-allow u'fullscreen': False, u'width': 800, u'height': 600, - u'applications': ['TERMINAL','WWWBROWSER',] + u'applications': ['TERMINAL','WWWBROWSER',], } ) _expected_profile1 = copy.deepcopy(_expected_defaults) _expected_profile1.update({ u'user': 'foo', - u'cmd': 'GNOME', + u'command': 'GNOME', }) _expected_profile2 = copy.deepcopy(_expected_defaults) _expected_profile2.update({ u'user': 'bar', - u'cmd': 'KDE', + u'command': 'KDE', u'fullscreen': True, }) _expected_profile3 = copy.deepcopy(_expected_defaults) _expected_profile3.update({ u'user': 'bar', - u'cmd': 'KDE', + u'command': 'KDE', u'fullscreen': True, }) _profile1 = inifile_backend.get_profile('testprofile1') @@ -154,16 +244,16 @@ acl-clients-allow = 10.0.0.0/16,10.1.0.0/16,admin-1.intern,admin-2.intern [testprofile1] user = foo -cmd = GNOME +command = GNOME [testprofile2] user = foo -cmd = GNOME +command = GNOME acl-clients-deny = 10.0.2.0/24,ALL [testprofile3] user = bar -cmd = KDE +command = KDE fullscreen = true acl-users-deny = ALL acl-users-allow = foo,bar @@ -223,15 +313,15 @@ applications = TERMINAL, WWWBROWSER [testprofile1] user = -cmd = GNOME +command = GNOME [testprofile2] user = -cmd = XFCE +command = XFCE [testprofile3] user = -cmd = KDE +command = KDE fullscreen = true """ tf = tempfile.NamedTemporaryFile() @@ -273,21 +363,21 @@ acl-groups-order = deny-allow [testprofile1] user = -cmd = GNOME +command = GNOME acl-users-allow = flip acl-users-deny = ALL acl-users-order = deny-allow [testprofile2] user = -cmd = XFCE +command = XFCE acl-users-allow = thekla acl-users-deny = ALL acl-users-order = deny-allow [testprofile3] user = -cmd = KDE +command = KDE fullscreen = true acl-users-deny = willi acl-users-order = deny-allow @@ -302,40 +392,40 @@ acl-users-order = deny-allow list_of_profile_ids = list_of_profiles.keys() list_of_profile_ids.sort() self.assertEqual(list_of_profile_ids, ['testprofile1']) - self.assertEqual(list_of_profiles['testprofile1']['cmd'], 'GNOME') + self.assertEqual(list_of_profiles['testprofile1']['command'], 'GNOME') username_m = 'maja' list_of_profiles = inifile_backend.list_profiles(username_m) list_of_profile_ids = list_of_profiles.keys() list_of_profile_ids.sort() self.assertEqual(list_of_profile_ids, ['testprofile1', 'testprofile2', 'testprofile3']) - self.assertEqual(list_of_profiles['testprofile1']['cmd'], 'GNOME') - self.assertEqual(list_of_profiles['testprofile2']['cmd'], 'XFCE') - self.assertEqual(list_of_profiles['testprofile3']['cmd'], 'KDE') + self.assertEqual(list_of_profiles['testprofile1']['command'], 'GNOME') + self.assertEqual(list_of_profiles['testprofile2']['command'], 'XFCE') + self.assertEqual(list_of_profiles['testprofile3']['command'], 'KDE') username_k = 'kassandra' list_of_profiles = inifile_backend.list_profiles(username_k) list_of_profile_ids = list_of_profiles.keys() list_of_profile_ids.sort() self.assertEqual(list_of_profile_ids, ['testprofile1', 'testprofile2', 'testprofile3']) - self.assertEqual(list_of_profiles['testprofile1']['cmd'], 'GNOME') - self.assertEqual(list_of_profiles['testprofile2']['cmd'], 'XFCE') - self.assertEqual(list_of_profiles['testprofile3']['cmd'], 'KDE') + self.assertEqual(list_of_profiles['testprofile1']['command'], 'GNOME') + self.assertEqual(list_of_profiles['testprofile2']['command'], 'XFCE') + self.assertEqual(list_of_profiles['testprofile3']['command'], 'KDE') username_t = 'thekla' list_of_profiles = inifile_backend.list_profiles(username_t) list_of_profile_ids = list_of_profiles.keys() list_of_profile_ids.sort() self.assertEqual(list_of_profile_ids, ['testprofile2']) - self.assertEqual(list_of_profiles['testprofile2']['cmd'], 'XFCE') + self.assertEqual(list_of_profiles['testprofile2']['command'], 'XFCE') username_w = 'willi' list_of_profiles = inifile_backend.list_profiles(username_w) list_of_profile_ids = list_of_profiles.keys() list_of_profile_ids.sort() self.assertEqual(list_of_profile_ids, ['testprofile1', 'testprofile2']) - self.assertEqual(list_of_profiles['testprofile1']['cmd'], 'GNOME') - self.assertEqual(list_of_profiles['testprofile2']['cmd'], 'XFCE') + self.assertEqual(list_of_profiles['testprofile1']['command'], 'GNOME') + self.assertEqual(list_of_profiles['testprofile2']['command'], 'XFCE') ### TEST: select_session() method diff --git a/x2gobroker/tests/test_broker_zeroconf.py b/x2gobroker/tests/test_broker_zeroconf.py index 0e97b66..1a42278 100644 --- a/x2gobroker/tests/test_broker_zeroconf.py +++ b/x2gobroker/tests/test_broker_zeroconf.py @@ -63,6 +63,8 @@ class TestX2GoBrokerBackendZeroconf(unittest.TestCase): 'sshport': 22, 'setdpi': 0, 'pack': u'16m-jpeg', + # make sure, hard-coded defaults end up in the list_profiles() output of the zeroconf backend, as well + 'directrdp': False, }, } zeroconf_backend = x2gobroker.brokers.zeroconf_broker.X2GoBroker() @@ -73,6 +75,8 @@ class TestX2GoBrokerBackendZeroconf(unittest.TestCase): _test_profiles = { _key: list_of_profiles['unittest'] } + for key in _profiles[_key]: + print key, _profiles[_key][key], _test_profiles[_key][key] self.assertEqual(_profiles, _test_profiles) ### TEST: select_profile() method diff --git a/x2gobroker/uccsjson.py b/x2gobroker/uccsjson.py new file mode 100644 index 0000000..779e2ba --- /dev/null +++ b/x2gobroker/uccsjson.py @@ -0,0 +1,241 @@ +# Copyright (C) 2012 by Mike Gabriel <mike.gabriel@das-netzwerkteam.de> +# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder@obviously-nice.de> +# Copyright (C) 2012 by Heinz-Markus Graesing <heinz-m.graesing@obviously-nice.de> +# +# X2Go Session Broker is free software; you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# X2Go Session Broker is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. + +import json + +def convert_to_builtin_type(obj): + """\ + Helper function for converting Python objects to dictionaries. + Used for doing JSON dumps. + + """ + d = { } + d.update(obj.__dict__) + return d + +class ManagementServer(): + """\ + Base class for generating UCCS compatible JSON object. + + """ + def __init__(self, url, name): + """\ + Initializ instance. + + @param url: URL of the UCCS broker server + @type url: C{unicode} + @param name: human-readable, descriptive server name + @type name: C{unicode} + + """ + self.RemoteDesktopServers = [] + self.AdditionalManagementServers = [] + self.URL = url + self.Name = name + + def set_default(self, ts_name): + """\ + Define the default (terminal) server instance. + + @param ts_name: name of the terminal server that is to be set as default + @type ts_name: C{unicode} + + """ + if isinstance(tsName, str): + self.DefaultServer = tsName + else: + raise TypeError("set_default expects a string argument") + + def add_terminal_server(self, server): + """\ + Add a terminal server to this management server object. + + @param server: instance of class L{RDPServer} or L{X2GoServer}. + @type server: C{obj} + + """ + self.RemoteDesktopServers.append(server) + + # NOT USED!!! + #def add_additional_management_server(self, amserver): + # if isinstance(amserver, AdditionalManagementServer): + # self.AdditionalManagementServers.append(amserver) + # else: + # raise TypeError("add_additional_management_server expects a "\ + # "AdditionalManagementServer argument") + + def toJson(self): + """\ + Dump this instance as JSON object. + + """ + return json.dumps(self, default=convert_to_builtin_type) + + +# NOT USED!!! +#class AdditionalManagementServer(): +# def __init__(self, url, name): +# self.URL = url +# self.Name = name + + +class RDPServer(): + """\ + Instantiate a UCCS compatible RDP server session profile object. + + """ + def __init__(self, host, name, username=None, password=None): + """\ + @param host: hostname of RDP server host + @type host: C{unicode} + @param name: session profile name + @type name: C{unicode} + @param username: username to be used for login + @type username: C{unicode} + @param password: password to be used for login + @type password: C{unicode} + + """ + self.URL = unicode(host) + self.Name = unicode(name) + self.Protocol = u'freerdp' + self.DomainRequired = unicode(True) + self.Username = unicode(username) + self.Password = unicode(password) + + def set_domain(self, domain): + """\ + Set the domain for this RDP server. + + @param domain: the domain name to be set + @type domain: C{unicode} + + @raise TypeError: domain has to be C{str} or C{unicode} + + """ + if isinstance(domainName, str): + self.WindowsDomain = unicode(domain) + elif isinstance(domainName, unicode): + self.WindowsDomain = domain + else: + raise TypeError("set_domain() expects a string or unicode argument") + + def toJson(self): + """\ + Dump this instance as JSON object. + + """ + return json.dumps(self, default=convert_to_builtin_type) + + +class ICAServer(): + """\ + Instantiate a UCCS compatible ICA server session profile object. + + """ + def __init__(self, host, name, username=None, password=None): + """\ + @param host: hostname of ICA server host + @type host: C{unicode} + @param name: session profile name + @type name: C{unicode} + @param username: username to be used for login + @type username: C{unicode} + @param password: password to be used for login + @type password: C{unicode} + + """ + self.URL = unicode(host) + self.Name = unicode(name) + self.Protocol = u'ica' + self.DomainRequired = unicode(True) + self.Username = unicode(username) + self.Password = unicode(password) + + def set_domain(self, domain): + """\ + Set the domain for this ICA server. + + @param domain: the domain name to be set + @type domain: C{unicode} + + @raise TypeError: domain has to be C{str} or C{unicode} + + """ + if isinstance(domainName, str): + self.WindowsDomain = unicode(domain) + elif isinstance(domainName, unicode): + self.WindowsDomain = domain + else: + raise TypeError("set_domain() expects a string or unicode argument") + + def toJson(self): + """\ + Dump this instance as JSON object. + + """ + return json.dumps(self, default=convert_to_builtin_type) + + +class X2GoServer(): + """\ + Instantiate a UCCS compatible X2Go Server session profile object. + + """ + def __init__(self, host, name, username=None, password=None): + """\ + @param host: hostname of X2Go Server host + @type host: C{unicode} + @param name: session profile name + @type name: C{unicode} + @param username: username to be used for login + @type username: C{unicode} + @param password: password to be used for login + @type password: C{unicode} + + """ + self.URL = host + self.Name = name + self.Protocol = 'x2go' + self.SessionTypeRequired = True + self.Username = username + self.Password = password + + def set_session_type(self, session_type): + """\ + Set the session type to be used with this X2Go Server. + + @param session_type: the session type to be set + @type session_type: C{unicode} + + @raise TypeError: session_type has to be C{str} or C{unicode} + + """ + if isinstance(domainName, str): + self.SessionType = sessiontypeName + else: + raise TypeError("set_session_type() expects a string or unicode argument") + + def toJson(self): + """\ + Dump this instance as JSON object. + + """ + return json.dumps(self, default=convert_to_builtin_type) + diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py index be63096..6078383 100644 --- a/x2gobroker/web/uccs.py +++ b/x2gobroker/web/uccs.py @@ -29,84 +29,7 @@ from tornado.escape import native_str, parse_qs_bytes import x2gobroker.defaults from x2gobroker.loggers import logger_broker, logger_error - - -def convert_to_builtin_type(obj): - d = { } - d.update(obj.__dict__) - return d - - -class ManagementServer(): - def __init__(self, url, name): - self.RemoteDesktopServers = [] - self.AdditionalManagementServers = [] - self.URL = url - self.Name = name - - def set_default(self, tsName): - if isinstance(tsName, str): - self.DefaultServer = tsName - else: - raise TypeError("set_default expects a string argument") - - def add_terminal_server(self, server): - self.RemoteDesktopServers.append(server) - - def add_additional_management_server(self, amserver): - if isinstance(amserver, AdditionalManagementServer): - self.AdditionalManagementServers.append(amserver) - else: - raise TypeError("add_additional_management_server expects a "\ - "AdditionalManagementServer argument") - - def toJson(self): - return json.dumps(self, default=convert_to_builtin_type) - - -class AdditionalManagementServer(): - def __init__(self, url, name): - self.URL = url - self.Name = name - - -class RDPServer(): - def __init__(self, url, name, username=None, password=None): - self.URL = url - self.Name = name - self.Protocol = 'freerdp' - self.DomainRequired = True - self.Username = username - self.Password = password - - def add_domain(self, domainName): - if isinstance(domainName, str): - self.WindowsDomain = domainName - else: - raise TypeError("add_domain expects a string argument") - - def toJson(self): - return json.dumps(self, default=convert_to_builtin_type) - - -class X2GoServer(): - def __init__(self, url, name, username=None, password=None): - self.URL = url - self.Name = name - self.Protocol = 'x2go' - self.SessionTypeRequired = True - self.Username = username - self.Password = password - - def add_sessiontype(self, sessiontypeName): - if isinstance(domainName, str): - self.SessionType = sessiontypeName - else: - raise TypeError("add_sessiontype expects a string argument") - - def toJson(self): - return json.dumps(self, default=convert_to_builtin_type) - +import x2gobroker.uccsjson class X2GoBrokerWeb(tornado.web.RequestHandler): @@ -161,6 +84,7 @@ class X2GoBrokerWeb(tornado.web.RequestHandler): logger_error.error('client could not provide an IP address, pretending: 404 Not Found') raise tornado.web.HTTPError(404) + username = 'foo' #username = self.get_argument('user', default='') #password = self.get_argument('password', default='') #cookie = self.get_argument('cookie', default='') @@ -179,20 +103,21 @@ class X2GoBrokerWeb(tornado.web.RequestHandler): profiles = broker_backend.list_profiles(username) if profiles: - ms = ManagementServer('http://localhost:8080/uccs/{backend}'.format(backend=backend), 'X2Go Session Broker') + ms = x2gobroker.uccsjson.ManagementServer('http://localhost:8080/uccs/{backend}'.format(backend=backend), 'X2Go Session Broker') profile_ids = profiles.keys() profile_ids.sort() for profile_id in profile_ids: - if profiles[profile_id]['directrdp']: + print profiles[profile_id] + if profiles[profile_id][u'directrdp']: pass else: - ts = X2GoServer( - url='{hostname}:{port}'.format(hostname=profiles[profile_id]['host'], port=profiles[profile_id]['sshport']) - name=profiles[profile_id]['name'] - username=profiles[profile_id]['user'] + ts = x2gobroker.uccsjson.X2GoServer( + host='{hostname}:{port}'.format(hostname=profiles[profile_id][u'host'], port=profiles[profile_id][u'sshport']), + name=profiles[profile_id][u'name'], + username=profiles[profile_id][u'user'], ) ms.add_terminal(ts) hooks/post-receive -- x2gobroker.git (HTTP(S) Session broker for X2Go) This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).