This is an automated email from the git hooks/post-receive script. x2go pushed a commit to branch master in repository x2gobroker. commit 0e792e061b7a64f5a0fead1139f57cf26ef2aac5 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Thu Mar 19 02:14:03 2015 +0100 Don't check for running/suspended session if the session profile will request a shadowing session. --- debian/changelog | 2 + x2gobroker/brokers/base_broker.py | 77 +++++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/debian/changelog b/debian/changelog index 46229ae..c40a4be 100644 --- a/debian/changelog +++ b/debian/changelog @@ -222,6 +222,8 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low if the <hostname> is a valid address on the local network (broker <-> <server> communication), but the host address is valid for clients (client <-> server communication). + - Don't check for running/suspended session if the session profile will + request a shadowing session. * debian/control: + Provide separate bin:package for SSH brokerage: x2gobroker-ssh. + Replace LDAP support with session brokerage support in LONG_DESCRIPTION. diff --git a/x2gobroker/brokers/base_broker.py b/x2gobroker/brokers/base_broker.py index 49042ec..bddca67 100644 --- a/x2gobroker/brokers/base_broker.py +++ b/x2gobroker/brokers/base_broker.py @@ -1039,6 +1039,40 @@ class X2GoBroker(object): return remote_agent + def is_shadow_profile(self, profile_id): + """\ + Detect from the session profile, if it defines a desktop sharing (shadow) + session. + + @param profile_id: ID of a valid session profile + @type profile_id: C{unicode} + + return: C{True} if the session profile defines a desktop sharing (shadow) session + rtype: C{bool} + + """ + profile = self.get_profile(profile_id) + return profile['command'] == "SHADOW" + + def check_for_sessions(self, profile_id): + """\ + Detect from the session profile, if we should query the remote broker + agent for running or suspended sessions. + + @param profile_id: ID of a valid session profile + @type profile_id: C{unicode} + + return: C{True} if the remote broker agent should be queried for running/suspended sessions + rtype: C{bool} + + """ + do_check = True + + # do check, for all commands except the "SHADOW" command + do_check = do_check and self.is_shadow_profile(profile_id) + + return do_check + def get_profile_for_user(self, profile_id, username, broker_frontend=None): """\ Expect a profile id and perform some checks and preparations to @@ -1088,29 +1122,30 @@ class X2GoBroker(object): remote_agent = self.get_remote_agent(profile_id) agent_query_mode = ( remote_agent == u'LOCAL') and u'LOCAL' or u'SSH' - if remote_agent: - try: - success, running_sessions, suspended_sessions = x2gobroker.agent.has_sessions(username, remote_agent=remote_agent) - if running_sessions: - logger_broker.debug('base_broker.X2GoBroker.get_profile_for_user(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(running_sessions))) - if suspended_sessions: - logger_broker.debug('base_broker.X2GoBroker.get_profile_for_user(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(suspended_sessions))) - suspended_matching_hostnames = x2gobroker.utils.matching_hostnames(profile['host'], suspended_sessions) - running_matching_hostnames = x2gobroker.utils.matching_hostnames(profile['host'], running_sessions) - if suspended_matching_hostnames: - profile['status'] = u'S' - profile['host'] = [suspended_matching_hostnames[0]] - elif running_matching_hostnames: - profile['status'] = u'R' - profile['host'] = [running_matching_hostnames[0]] - else: - profile['host'] = [profile['host'][0]] + if self.check_for_sessions(profile_id): + if remote_agent: + try: + success, running_sessions, suspended_sessions = x2gobroker.agent.has_sessions(username, remote_agent=remote_agent) + if running_sessions: + logger_broker.debug('base_broker.X2GoBroker.get_profile_for_user(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(running_sessions))) + if suspended_sessions: + logger_broker.debug('base_broker.X2GoBroker.get_profile_for_user(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(suspended_sessions))) + suspended_matching_hostnames = x2gobroker.utils.matching_hostnames(profile['host'], suspended_sessions) + running_matching_hostnames = x2gobroker.utils.matching_hostnames(profile['host'], running_sessions) + if suspended_matching_hostnames: + profile['status'] = u'S' + profile['host'] = [suspended_matching_hostnames[0]] + elif running_matching_hostnames: + profile['status'] = u'R' + profile['host'] = [running_matching_hostnames[0]] + else: + profile['host'] = [profile['host'][0]] - if profile.has_key('status') and profile['status']: - logger_broker.debug('base_broker.X2GoBroker.get_profile_for_user(): marking session profile {name} as {status}'.format(name=profile['name'], status=profile['status'])) + if profile.has_key('status') and profile['status']: + logger_broker.debug('base_broker.X2GoBroker.get_profile_for_user(): marking session profile {name} as {status}'.format(name=profile['name'], status=profile['status'])) - except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: - pass + except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: + pass else: profile['host'] = [profile['host'][0]] -- Alioth's /srv/git/code.x2go.org/x2gobroker.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git