Skip to content

Commit

Permalink
Merge pull request #104 from dcos/dcoscli_0415
Browse files Browse the repository at this point in the history
Require dcoscli `0.4.15`
  • Loading branch information
kensipe authored Jan 5, 2017
2 parents b03b1e2 + c4809f3 commit a38a18f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
zip_safe=False,
install_requires=[
'click',
'dcoscli==0.4.14',
'dcoscli==0.4.15',
'paramiko',
'pytest',
'pytest-timeout',
Expand Down
37 changes: 18 additions & 19 deletions shakedown/dcos/package.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import json
import time

from dcos import (cosmospackage, subcommand)
from dcoscli.package.main import get_cosmos_url
from dcos import (cosmos, packagemanager, subcommand)

import shakedown

Expand All @@ -25,14 +24,14 @@ def _get_options(options_file=None):
return options


def _get_cosmos():
def _get_package_manager():
""" Get an instance of Cosmos with the correct URL.
:return: Cosmos instance
:rtype: cosmospackage.Cosmos
:rtype: packagemanager.PackageManager
"""

return cosmospackage.Cosmos(get_cosmos_url())
return packagemanager.PackageManager(cosmos.get_cosmos_url())


def install_package(
Expand Down Expand Up @@ -72,8 +71,8 @@ def install_package(
else:
options = {}

cosmos = _get_cosmos()
pkg = cosmos.get_package_version(package_name, package_version)
package_manager = _get_package_manager()
pkg = package_manager.get_package_version(package_name, package_version)
if service_name is None:
labels = pkg.marathon_json(options).get('labels')
if 'DCOS_SERVICE_NAME' in labels:
Expand All @@ -95,7 +94,7 @@ def install_package(
if pre_install_notes:
print(pre_install_notes)

cosmos.install_app(pkg, options, service_name)
package_manager.install_app(pkg, options, service_name)

# Print post-install notes to console log
post_install_notes = pkg.package_json().get('postInstallNotes')
Expand Down Expand Up @@ -154,8 +153,8 @@ def package_installed(package_name, service_name=None):
:rtype: bool
"""

cosmos = _get_cosmos()
return len(cosmos.installed_apps(package_name, service_name)) > 0
package_manager = _get_package_manager()
return len(package_manager.installed_apps(package_name, service_name)) > 0


def uninstall_package(
Expand All @@ -182,8 +181,8 @@ def uninstall_package(
:rtype: bool
"""

cosmos = _get_cosmos()
pkg = cosmos.get_package_version(package_name, None)
package_manager = _get_package_manager()
pkg = package_manager.get_package_version(package_name, None)
if service_name is None:
labels = pkg.marathon_json({}).get('labels')
if 'DCOS_SERVICE_NAME' in labels:
Expand All @@ -200,7 +199,7 @@ def uninstall_package(
shakedown.cli.helpers.fchr('>>'), package_name, service_name)
)

cosmos.uninstall_app(package_name, all_instances, service_name)
package_manager.uninstall_app(package_name, all_instances, service_name)

# Optionally wait for the service to unregister as a framework
if wait_for_completion:
Expand Down Expand Up @@ -243,8 +242,8 @@ def get_package_repos(
""" Return a list of configured package repositories
"""

cosmos = _get_cosmos()
return cosmos.get_repos()
package_manager = _get_package_manager()
return package_manager.get_repos()


def add_package_repo(
Expand All @@ -265,8 +264,8 @@ def add_package_repo(
:rtype: bool
"""

cosmos = _get_cosmos()
return cosmos.add_repo(repo_name, repo_url, index)
package_manager = _get_package_manager()
return package_manager.add_repo(repo_name, repo_url, index)


def remove_package_repo(
Expand All @@ -281,5 +280,5 @@ def remove_package_repo(
:rtype: bool
"""

cosmos = _get_cosmos()
return cosmos.remove_repo(repo_name)
package_manager = _get_package_manager()
return package_manager.remove_repo(repo_name)

0 comments on commit a38a18f

Please sign in to comment.