This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2gobroker. from 562c651 UCCS API change for X2Go Sessions: Rename "SessionType" to "Command". new 914579d obligatory profile keys: Move from inifile backend to UCCS frontend, as those requirements are frontend specific. new 0bfc365 UCCS: Start working on API version 5. The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Summary of changes: x2gobroker/brokers/inifile_broker.py | 12 --------- x2gobroker/defaults.py | 2 ++ x2gobroker/uccsjson.py | 50 ++++++++++++++++++++++++++++++------ x2gobroker/web/uccs.py | 33 +++++++++++++++++++++--- 4 files changed, 73 insertions(+), 24 deletions(-) -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit 914579d4db5d7c4a1e71f46adb579c7ee5c6c623 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu May 3 12:44:17 2018 +0200 obligatory profile keys: Move from inifile backend to UCCS frontend, as those requirements are frontend specific. --- x2gobroker/brokers/inifile_broker.py | 12 ------------ x2gobroker/web/uccs.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/x2gobroker/brokers/inifile_broker.py b/x2gobroker/brokers/inifile_broker.py index 4c5a15d..0f0894d 100644 --- a/x2gobroker/brokers/inifile_broker.py +++ b/x2gobroker/brokers/inifile_broker.py @@ -78,18 +78,6 @@ class X2GoBroker(base.X2GoBroker): if key not in list(profile.keys()): profile.update({ key: profile_defaults[key] }) - # obligatory profile keys: - - if 'host' not in profile: - raise x2gobroker.x2gobroker_exceptions.X2GoBrokerProfileException('Session profile ID \'{profile_id}\' lacks \'host\' key; profile is unusable'.format(profile_id=profile_id)) - - if 'name' not in profile: - profile['name'] = profile_id - - if not ('directrdp' in profile and profile['directrdp']): - if 'sshport' not in profile: - profile['sshport'] = 22 - for key in list(profile.keys()): if key.startswith('acl-'): del profile[key] diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py index 0ce80b3..8985681 100644 --- a/x2gobroker/web/uccs.py +++ b/x2gobroker/web/uccs.py @@ -160,6 +160,17 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): ) ts.set_domain('LOCAL') else: + + # obligatory profile keys: + if 'host' not in profile: + raise x2gobroker.x2gobroker_exceptions.X2GoBrokerProfileException('Session profile ID \'{profile_id}\' lacks \'host\' key; profile is unusable'.format(profile_id=profile_id)) + + if 'name' not in profile: + profile['name'] = profile_id + + if 'sshport' not in profile: + profile['sshport'] = 22 + _hostname = random.choice(hosts) _port = profile['sshport'] if 'sshport={hostname}'.format(hostname=_hostname) in profile: -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git
This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit 0bfc3653849a6ab33c5b77065fdeb4fc3a51ec71 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu May 3 12:48:54 2018 +0200 UCCS: Start working on API version 5. --- x2gobroker/defaults.py | 2 ++ x2gobroker/uccsjson.py | 50 ++++++++++++++++++++++++++++++++++++++++++-------- x2gobroker/web/uccs.py | 22 ++++++++++++++++++---- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/x2gobroker/defaults.py b/x2gobroker/defaults.py index 9ed7abf..3b7fbc1 100644 --- a/x2gobroker/defaults.py +++ b/x2gobroker/defaults.py @@ -323,3 +323,5 @@ X2GOBROKER_SESSIONPROFILE_DEFAULTS = { 'acl-any-order': 'deny-allow', }, } + +X2GOBROKER_LATEST_UCCS_API_VERSION = 5 \ No newline at end of file diff --git a/x2gobroker/uccsjson.py b/x2gobroker/uccsjson.py index e271019..e582e29 100644 --- a/x2gobroker/uccsjson.py +++ b/x2gobroker/uccsjson.py @@ -20,6 +20,8 @@ try: import simplejson as json except ImportError: import json +from x2gobroker.defaults import X2GOBROKER_LATEST_UCCS_API_VERSION as latest_api_version + def convert_to_builtin_type(obj): """\ Helper function for converting Python objects to dictionaries. @@ -35,7 +37,7 @@ class ManagementServer(): Base class for generating UCCS compatible JSON object. """ - def __init__(self, url, name): + def __init__(self, url, name, api_version=latest_api_version): """\ Initializ instance. @@ -43,8 +45,11 @@ class ManagementServer(): @type url: C{unicode} @param name: human-readable, descriptive server name @type name: C{unicode} + @param api_version: API version used between remote logon service and broker + @type api_version: C{int} """ + self._api_version = api_version self.RemoteDesktopServers = [] self.AdditionalManagementServers = [] self.URL = url @@ -104,7 +109,7 @@ class RDPServer(): Instantiate a UCCS compatible RDP server session profile object. """ - def __init__(self, host, name, username='', password=''): + def __init__(self, host, name, username='', password='', api_version=latest_api_version): """\ @param host: hostname of RDP server host @type host: C{unicode} @@ -114,8 +119,11 @@ class RDPServer(): @type username: C{unicode} @param password: password to be used for login @type password: C{unicode} + @param api_version: API version used between remote logon service and broker + @type api_version: C{int} """ + self._api_version = api_version self.URL = 'http://{url}/'.format(url=host) self.Name = name self.Protocol = 'rdp' @@ -153,7 +161,7 @@ class ICAServer(): Instantiate a UCCS compatible ICA server session profile object. """ - def __init__(self, host, name, username='', password=''): + def __init__(self, host, name, username='', password='', api_version=latest_api_version): """\ @param host: hostname of ICA server host @type host: C{unicode} @@ -163,8 +171,11 @@ class ICAServer(): @type username: C{unicode} @param password: password to be used for login @type password: C{unicode} + @param api_version: API version used between remote logon service and broker + @type api_version: C{int} """ + self._api_version = api_version self.URL = 'http://{url}/'.format(url=host) self.Name = name self.Protocol = 'ica' @@ -202,7 +213,7 @@ class X2GoServer(): Instantiate a UCCS compatible X2Go Server session profile object. """ - def __init__(self, host, name, username='', password=''): + def __init__(self, host, name, username='', password='', api_version=latest_api_version): """\ @param host: hostname of X2Go Server host @type host: C{unicode} @@ -212,15 +223,39 @@ class X2GoServer(): @type username: C{unicode} @param password: password to be used for login @type password: C{unicode} + @param api_version: API version used between remote logon service and broker + @type api_version: C{int} """ + self._api_version = api_version self.URL = 'http://{url}/'.format(url=host) self.Name = name self.Protocol = 'x2go' - self.CommandRequired = True + if self._api_version == 4: + self.SessionTypeRequired = True + else: + self.CommandRequired = True self.Username = username self.Password = password + # legacy: API v4 (not used in API v5 and higher) + def set_session_type(self, session_type): + """\ + Set the session_type to be used on this X2Go Server. + + @param command: the session type to be set + @type command: C{unicode} + + @raise TypeError: command has to be C{str} + + """ + #FIXME: throw an exception when used with API v5 or newer + if isinstance(session_type, str): + self.SessionType = session_type + else: + raise TypeError("set_session_type() expects a string argument") + + # since: API v5 def set_command(self, command): """\ Set the command to be used on this X2Go Server. @@ -231,12 +266,11 @@ class X2GoServer(): @raise TypeError: command has to be C{str} """ + #FIXME: throw an exception when used with API v4 if isinstance(command, str): self.Command = command - elif isinstance(command, str): - self.Command = command else: - raise TypeError("set_command() expects a string or unicode argument") + raise TypeError("set_command() expects a string argument") def toJson(self): """\ diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py index 8985681..7b15147 100644 --- a/x2gobroker/web/uccs.py +++ b/x2gobroker/web/uccs.py @@ -67,6 +67,13 @@ class X2GoBrokerWeb(_RequestHandler): @x2gobroker.basicauth.require_basic_auth('Authentication required', credentials_validate) class X2GoBrokerWebAPI(tornado.web.RequestHandler): + def __init__(self, *args, **kwargs): + # latest API version is 5 + self.api_version = 5 + self.api_versions_supported = [4, 5] + self.latest_api_version = max (self.api_versions_supported) + tornado.web.RequestHandler.__init__(self, *args, **kwargs) + http_header_items = { 'Content-Type': 'text/plain; charset=utf-8', 'Expires': '+1h', @@ -84,9 +91,10 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): backend = args[0] api_version = args[1] try: - api_version = int(api_version) + self.api_version = int(api_version) except TypeError: - api_version = 4 + # assume latest API, shouldn't we actually throw an error here? + self.api_version = self.latest_api_version if not backend: self.backend = x2gobroker.defaults.X2GOBROKER_DEFAULT_BACKEND @@ -157,8 +165,10 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): host='{hostname}'.format(hostname=hosts[0]), name=profile['name'], username=profile['user'], + api_version=self.api_version, ) ts.set_domain('LOCAL') + else: # obligatory profile keys: @@ -185,7 +195,12 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): _cmd = profile['command'] if _cmd.upper() in x2gobroker.defaults.X2GO_DESKTOP_SESSIONS: _cmd = _cmd.upper() - ts.set_command(_cmd) + + if api_version == 4: + ts.set_session_type(_cmd) + else: + ts.set_command(_cmd) + ms.add_terminalserver(ts) ms.set_default(ts.Name) @@ -193,4 +208,3 @@ class X2GoBrokerWebAPI(tornado.web.RequestHandler): self.write(output) return - -- Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git