From e6316ee58e75327e642cd4faeba24f72585a396d Mon Sep 17 00:00:00 2001 From: Michael Gummelt Date: Tue, 19 May 2015 11:12:56 -0700 Subject: [PATCH] support core.dcos_url in `dcos tasks` --- cli/tests/integrations/cli/test_package.py | 8 ++++---- dcos/mesos.py | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cli/tests/integrations/cli/test_package.py b/cli/tests/integrations/cli/test_package.py index a261208f2..cda506ad0 100644 --- a/cli/tests/integrations/cli/test_package.py +++ b/cli/tests/integrations/cli/test_package.py @@ -329,12 +329,12 @@ def test_package_metadata(): def test_install_with_id(): args = ['--app-id=chronos-1'] - stdout = (b"""Installing package [chronos] version [2.3.3] with app """ + stdout = (b"""Installing package [chronos] version [2.3.4] with app """ b"""id [chronos-1]\n""") _install_chronos(args=args, stdout=stdout) args = ['--app-id=chronos-2'] - stdout = (b"""Installing package [chronos] version [2.3.3] with app """ + stdout = (b"""Installing package [chronos] version [2.3.4] with app """ b"""id [chronos-2]\n""") _install_chronos(args=args, stdout=stdout) @@ -448,7 +448,7 @@ def test_list_installed(): "mesosphere", "framework" ], - "version": "2.3.3" + "version": "2.3.4" } ] """ @@ -611,7 +611,7 @@ def _uninstall_chronos(args=[], returncode=0, stdout=b'', stderr=b''): def _install_chronos( args=[], returncode=0, - stdout=b'Installing package [chronos] version [2.3.3]\n', + stdout=b'Installing package [chronos] version [2.3.4]\n', stderr=b'', postInstallNotes=b'Chronos DCOS Service has been successfully ' b'installed!\nWe recommend a minimum of one node ' diff --git a/dcos/mesos.py b/dcos/mesos.py index eca708915..2ff9d134b 100644 --- a/dcos/mesos.py +++ b/dcos/mesos.py @@ -23,9 +23,17 @@ def get_master(config=None): if config is None: config = util.get_config() - mesos_master_url = util.get_config_vals( - config, ['core.mesos_master_url'])[0] - return MesosMaster(mesos_master_url) + mesos_url = get_mesos_url(config) + return MesosMaster(mesos_url) + + +def get_mesos_url(config): + mesos_master_url = config.get('core.mesos_master_url') + if mesos_master_url is None: + dcos_url = util.get_config_vals(config, ['core.dcos_url'])[0] + return urllib.parse.urljoin(dcos_url, 'mesos/') + else: + return mesos_master_url MESOS_TIMEOUT = 3 @@ -51,7 +59,7 @@ def state(self): """ if not self._state: - self._state = self.fetch('/master/state.json').json() + self._state = self.fetch('master/state.json').json() return self._state def slave(self, fltr):