This is an automated email from the git hooks/post-receive script. x2go pushed a change to branch master in repository x2gobroker. from 0a05cc1 x2gobroker-authservice: Restructure logging. Enable log messages for authentication requests. new 146b933 fix build failure after turning x2gobroker-daemon into a symlink new 5ef6b44 default broker backend is the inifile backend, also apply this change to our wsgi config new 837a0ae rebase with prev new 8a21ac3 add @raise information to __doc__ strings new 340cc71 Get several issues around select_session fixed via tests in the broker's backend base.py. The 5 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: debian/changelog | 2 + debian/x2gobroker-daemon.install | 1 - etc/x2gobroker-wsgi.apache.conf | 4 +- etc/x2gobroker-wsgi.apache.vhost | 2 +- x2gobroker/agent.py | 9 ++ x2gobroker/brokers/base_broker.py | 37 ++++++-- x2gobroker/tests/test_broker_inifile.py | 148 +++++++++++++++++++++++++++++++ 7 files changed, 193 insertions(+), 10 deletions(-) -- Alioth's /srv/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 146b933bc5ea4600eb2d38e4ff17e6b1bf5a42f3 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Nov 2 20:25:35 2014 +0100 fix build failure after turning x2gobroker-daemon into a symlink --- debian/x2gobroker-daemon.install | 1 - 1 file changed, 1 deletion(-) diff --git a/debian/x2gobroker-daemon.install b/debian/x2gobroker-daemon.install index 220c1c4..ae2a660 100644 --- a/debian/x2gobroker-daemon.install +++ b/debian/x2gobroker-daemon.install @@ -1,3 +1,2 @@ logrotate/x2gobroker-daemon etc/logrotate.d/ -bin/x2gobroker-daemon usr/bin/ sbin/x2gobroker-daemon-debug usr/sbin/ -- Alioth's /srv/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 5ef6b449654f2adb5929591ff9c5ed9d2e29c6b9 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Nov 2 20:26:16 2014 +0100 default broker backend is the inifile backend, also apply this change to our wsgi config --- etc/x2gobroker-wsgi.apache.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/x2gobroker-wsgi.apache.conf b/etc/x2gobroker-wsgi.apache.conf index 2dbca95..cb85385 100644 --- a/etc/x2gobroker-wsgi.apache.conf +++ b/etc/x2gobroker-wsgi.apache.conf @@ -8,8 +8,8 @@ WSGIDaemonProcess x2gobroker user=x2gobroker group=x2gobroker processes=5 thread WSGIPassAuthorization On # default broker backend (default: zeroconf) -SetEnv X2GOBROKER_DEFAULT_BACKEND zeroconf -#SetEnv X2GOBROKER_DEFAULT_BACKEND inifile +#SetEnv X2GOBROKER_DEFAULT_BACKEND zeroconf +SetEnv X2GOBROKER_DEFAULT_BACKEND inifile #SetEnv X2GOBROKER_DEFAULT_BACKEND ldap #SetEnv X2GOBROKER_DEFAULT_BACKEND <some-other-broker-backend> -- Alioth's /srv/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 837a0ae12a0ef92b1350f788c04b87c0883de5b0 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Nov 2 20:26:54 2014 +0100 rebase with prev --- etc/x2gobroker-wsgi.apache.vhost | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/x2gobroker-wsgi.apache.vhost b/etc/x2gobroker-wsgi.apache.vhost index 7378501..4cc7a2a 100644 --- a/etc/x2gobroker-wsgi.apache.vhost +++ b/etc/x2gobroker-wsgi.apache.vhost @@ -21,7 +21,7 @@ WSGIDaemonProcess x2gobroker user=x2gobroker group=x2gobroker processes=5 threads=15 WSGIPassAuthorization On - # default broker backend (default: zeroconf) + # default broker backend (default: inifile) #SetEnv X2GOBROKER_DEFAULT_BACKEND zeroconf #SetEnv X2GOBROKER_DEFAULT_BACKEND inifile #SetEnv X2GOBROKER_DEFAULT_BACKEND ldap -- Alioth's /srv/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 8a21ac30272ff6d3878f7586130f171f34a90940 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Nov 2 20:27:50 2014 +0100 add @raise information to __doc__ strings --- x2gobroker/agent.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/x2gobroker/agent.py b/x2gobroker/agent.py index a253f94..e4bef4d 100644 --- a/x2gobroker/agent.py +++ b/x2gobroker/agent.py @@ -77,6 +77,7 @@ def has_remote_broker_agent_setup(): return True return False + def call_broker_agent(username, task, cmdline_args=[], remote_agent=None, **kwargs): """\ Launch X2Go Broker Agent and process its output. @@ -90,6 +91,8 @@ def call_broker_agent(username, task, cmdline_args=[], remote_agent=None, **kwar @param remote_agent: if not C{None} call a remote broker agent via SSH @type remoate_agent: C{dict} + @raise: L{X2GoBrokerAgentException} + """ if remote_agent in (u'LOCAL', None): result = _call_local_broker_agent(username=username, task=task, cmdline_args=cmdline_args) @@ -97,6 +100,7 @@ def call_broker_agent(username, task, cmdline_args=[], remote_agent=None, **kwar result = _call_remote_broker_agent(username=username, task=task, cmdline_args=cmdline_args, remote_agent=remote_agent) return result + def _call_local_broker_agent(username, task, cmdline_args=[]): """\ Launch X2Go Broker Agent locally and process its output. @@ -108,6 +112,8 @@ def _call_local_broker_agent(username, task, cmdline_args=[]): @param cmdline_args: additional command line parameters for the broker agent @type cmdline_args: C{list} + @raise: L{X2GoBrokerAgentException} + """ cmd_line = [ '{x2gobroker_agent_binary}'.format(x2gobroker_agent_binary=x2gobroker.defaults.X2GOBROKER_AGENT_CMD), @@ -153,6 +159,8 @@ def _call_remote_broker_agent(username, task, cmdline_args=[], remote_agent=None @param remote_agent: information about the remote agent that is to be called. @type remote_agent: C{dict} + @raise: L{X2GoBrokerAgentException} + """ if remote_agent is None: logger_error.error('With the SSH agent-query-mode a remote agent host (hostname, port) has to be specified!') @@ -209,6 +217,7 @@ def _call_remote_broker_agent(username, task, cmdline_args=[], remote_agent=None raise x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException('Query to remote X2Go Broker Agent failed with no response') + def icmp_ping(hostname): """\ Perform an ICMP ping to the requested hostname. -- Alioth's /srv/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 340cc71cf37f103104495e9d76861d1d8ab60a00 Author: Mike Gabriel <mike.gabriel@das-netzwerkteam.de> Date: Sun Nov 2 20:28:40 2014 +0100 Get several issues around select_session fixed via tests in the broker's backend base.py. --- debian/changelog | 2 + x2gobroker/brokers/base_broker.py | 37 ++++++-- x2gobroker/tests/test_broker_inifile.py | 148 +++++++++++++++++++++++++++++++ 3 files changed, 181 insertions(+), 6 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1eeadd9..37fe2a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -187,6 +187,8 @@ x2gobroker (0.0.3.0-0x2go1) UNRELEASED; urgency=low the current backend default. - x2gobroker-authservice: Restructure logging. Enable log messages for authentication requests. + - Get several issues around select_session fixed via tests in the + broker's backend base.py. * 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 3e60280..93f86b3 100644 --- a/x2gobroker/brokers/base_broker.py +++ b/x2gobroker/brokers/base_broker.py @@ -1015,7 +1015,7 @@ class X2GoBroker(object): if self.get_session_autologin(profile_id): profile['autologin'] = True - profile['key'] = u'<please-provide-during-session-selection>' + profile['key'] = u'<will-be-exchanged-during-session-selection>' # make sure that desktop sessions (that we know by name) do run with rootless=false if profile['command'] in x2gobroker.defaults.X2GO_DESKTOP_SESSIONS: @@ -1028,21 +1028,33 @@ 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: + + success, running_sessions, suspended_sessions = x2gobroker.agent.has_sessions(username, remote_agent=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.list_profiles(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(running_sessions))) if suspended_sessions: logger_broker.debug('base_broker.X2GoBroker.list_profiles(): found running sessions on host(s): {hosts}'.format(hosts=', '.join(suspended_sessions))) - if x2gobroker.utils.matching_hostnames(profile['host'], running_sessions): profile['status'] = u'R' - if x2gobroker.utils.matching_hostnames(profile['host'], suspended_sessions): profile['status'] = u'S' + 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.list_profiles(): marking session profile {name} as {status}'.format(name=profile['name'], status=profile['status'])) except x2gobroker.x2gobroker_exceptions.X2GoBrokerAgentException: pass + else: + profile['host'] = [profile['host'][0]] - profile['host'] = [profile['host'][0]] list_of_profiles.update({profile_id: profile, }) return list_of_profiles @@ -1104,9 +1116,11 @@ class X2GoBroker(object): try: running_sessions = [] suspended_sessions = [] + + matching_server_names = x2gobroker.utils.matching_hostnames(server_list, [ si.split('|')[3] for si in session_list ]) + for session_info in session_list: - session_host = session_info.split('|')[3] - if session_host in server_list: + if session_info.split('|')[3] in matching_server_names: if session_info.split('|')[4] == 'R': running_sessions.append(session_info) if session_info.split('|')[4] == 'S': @@ -1133,6 +1147,17 @@ class X2GoBroker(object): _session_server_name = session_info.split('|')[3] if profile.has_key('host={server_name}'.format(server_name=_session_server_name)): server_name = _session_server_name + elif _session_server_name in server_list: + server_name = _session_server_name + elif x2gobroker.utils.matching_hostnames(server_list, [_session_server_name]): + for _server_name in server_list: + if _server_name.startswith(_session_server_name): + server_name = _server_name + break + else: + logger_broker.error('base_broker.X2GoBroker.select_session(): configuration error. Hostnames in session profile and actual server names do not match, we won\'t be able to resume/take-over a session this time') + # choosing a random server from the server list, to end up anywhere at least... + server_name = random.choice(server_list) except IndexError: # FIXME: if we get here, we have to deal with a broken session info diff --git a/x2gobroker/tests/test_broker_inifile.py b/x2gobroker/tests/test_broker_inifile.py index 121c07f..8d86e14 100644 --- a/x2gobroker/tests/test_broker_inifile.py +++ b/x2gobroker/tests/test_broker_inifile.py @@ -547,6 +547,154 @@ host = test-7 (-test-6.extern) self.assertEqual(inifile_backend.select_session('testprofile7'), _expected_result_7) + # TEST MULTI-HOST GET_PROFILE / SELECT_SESSION + + def test_multihost_profiles(self): + _session_profiles = """ +[DEFAULT] +command = MATE +user = foo + +[testprofile1] +host = host1 + +[testprofile2] +host = host1, host2 + +[testprofile3] +host = host1.mydomain, host2.mydomain + +[testprofile4] +host = host1.mydomain, host2.yourdomain + +[testprofile5] +host = host1.mydomain (10.0.2.4), host2.mydomain (10.0.2.5) + +[testprofile6] +host = host1.mydomain (10.0.2.4), host2.mydomain (10.0.2.5) +sshport = 23467 + +[testprofile7] +host = docker-vm-1 (localhost:22001), docker-vm-2 (localhost:22002) + +[testprofile8] +host = docker-vm-0 (localhost), docker-vm-1 (localhost:22001), docker-vm-2 (localhost:22002) +sshport = 22000 + +""" + tf = tempfile.NamedTemporaryFile() + print >> tf, _session_profiles + tf.seek(0) + inifile_backend = inifile.X2GoBroker(profile_config_file=tf.name) + + # test "testprofile1" + _profile1 = inifile_backend.get_profile('testprofile1') + self.assertTrue( ( _profile1['host'] == ['host1'] ) ) + for key in _profile1.keys(): + self.assertFalse( (key.startswith('host') and key != 'host' ) ) + _session1 = inifile_backend.select_session('testprofile1') + self.assertEqual ( _session1, {'port': 22, 'server': 'host1'} ) + + # test "testprofile2" + _profile2 = inifile_backend.get_profile('testprofile2') + _profile2['host'].sort() + self.assertTrue( ( _profile2['host'] == ['host1', 'host2'] ) ) + for key in _profile2.keys(): + self.assertFalse( (key.startswith('host') and key != 'host' ) ) + _session2 = inifile_backend.select_session('testprofile2') + self.assertTrue ( _session2['port'] == 22 ) + self.assertTrue ( _session2['server'] in ('host1', 'host2') ) + + # test "testprofile3" + _profile3 = inifile_backend.get_profile('testprofile3') + _profile3['host'].sort() + _profile5 = inifile_backend.get_profile('testprofile5') + self.assertTrue( ( _profile3['host'] == ['host1.mydomain', 'host2.mydomain'] ) ) + for key in _profile3.keys(): + self.assertFalse( (key.startswith('host') and key != 'host' ) ) + _session3 = inifile_backend.select_session('testprofile3') + self.assertTrue ( _session3['port'] == 22 ) + self.assertTrue ( _session3['server'] in ('host1.mydomain', 'host2.mydomain') ) + + # test "testprofile4" + _profile4 = inifile_backend.get_profile('testprofile4') + _profile4['host'].sort() + self.assertTrue( ( _profile4['host'] == ['host1.mydomain', 'host2.yourdomain'] ) ) + for key in _profile4.keys(): + self.assertFalse( (key.startswith('host') and key != 'host' ) ) + _session4 = inifile_backend.select_session('testprofile4') + self.assertTrue ( _session4['port'] == 22 ) + self.assertTrue ( _session4['server'] in ('host1.mydomain', 'host2.yourdomain') ) + + # test "testprofile5" + _profile5 = inifile_backend.get_profile('testprofile5') + _profile5['host'].sort() + self.assertTrue( ( _profile5['host'] == ['host1.mydomain', 'host2.mydomain'] ) ) + self.assertTrue( _profile5.has_key('host=host1.mydomain') ) + self.assertTrue( _profile5.has_key('host=host2.mydomain') ) + self.assertTrue( _profile5['host=host1.mydomain'] == '10.0.2.4' ) + self.assertTrue( _profile5['host=host2.mydomain'] == '10.0.2.5' ) + self.assertTrue( _profile5['sshport'] == 22 ) + _session5 = inifile_backend.select_session('testprofile5') + self.assertTrue ( _session5['port'] == 22 ) + self.assertTrue ( _session5['server'] in ('10.0.2.4', '10.0.2.5') ) + + # test "testprofile6" + _profile6 = inifile_backend.get_profile('testprofile6') + _profile6['host'].sort() + self.assertTrue( ( _profile6['host'] == ['host1.mydomain', 'host2.mydomain'] ) ) + self.assertTrue( _profile6.has_key('host=host1.mydomain') ) + self.assertTrue( _profile6.has_key('host=host2.mydomain') ) + self.assertTrue( _profile6['host=host1.mydomain'] == '10.0.2.4' ) + self.assertTrue( _profile6['host=host2.mydomain'] == '10.0.2.5' ) + self.assertTrue( _profile6['sshport'] == 23467 ) + i = 0 + while i < 10: + _session6 = inifile_backend.select_session('testprofile6') + self.assertTrue ( _session6['port'] == 23467 ) + self.assertTrue ( _session6['server'] in ('10.0.2.4', '10.0.2.5') ) + i += 1 + + # test "testprofile7" + _profile7 = inifile_backend.get_profile('testprofile7') + _profile7['host'].sort() + self.assertTrue( ( _profile7['host'] == ['docker-vm-1', 'docker-vm-2'] ) ) + self.assertTrue( _profile7.has_key('host=docker-vm-1') ) + self.assertTrue( _profile7.has_key('host=docker-vm-2') ) + self.assertTrue( _profile7['host=docker-vm-1'] == 'localhost' ) + self.assertTrue( _profile7['host=docker-vm-2'] == 'localhost' ) + self.assertTrue( _profile7['sshport'] == 22 ) + self.assertTrue( _profile7['sshport=docker-vm-1'] == 22001 ) + self.assertTrue( _profile7['sshport=docker-vm-2'] == 22002 ) + i = 0 + while i < 10: + _session7 = inifile_backend.select_session('testprofile7') + self.assertTrue ( _session7['port'] in (22001, 22002) ) + self.assertTrue ( _session7['server'] == 'localhost' ) + i += 1 + + # test "testprofile8" + _profile8 = inifile_backend.get_profile('testprofile8') + _profile8['host'].sort() + self.assertTrue( ( _profile8['host'] == ['docker-vm-0', 'docker-vm-1', 'docker-vm-2'] ) ) + self.assertTrue( _profile8.has_key('host=docker-vm-0') ) + self.assertTrue( _profile8.has_key('host=docker-vm-1') ) + self.assertTrue( _profile8.has_key('host=docker-vm-2') ) + self.assertTrue( _profile8['host=docker-vm-0'] == 'localhost' ) + self.assertTrue( _profile8['host=docker-vm-1'] == 'localhost' ) + self.assertTrue( _profile8['host=docker-vm-2'] == 'localhost' ) + self.assertTrue( _profile8['sshport'] == 22000 ) + self.assertFalse( _profile8.has_key('sshport=docker-vm-0') ) + self.assertTrue( _profile8['sshport=docker-vm-1'] == 22001 ) + self.assertTrue( _profile8['sshport=docker-vm-2'] == 22002 ) + i = 0 + while i < 10: + _session8 = inifile_backend.select_session('testprofile8', username='foo') + self.assertTrue ( _session8['port'] in (22000, 22001, 22002) ) + self.assertTrue ( _session8['server'] == 'localhost' ) + i += 1 + + def test_suite(): from unittest import TestSuite, makeSuite suite = TestSuite() -- Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2gobroker.git