示例#1
0
    def test_deployment_type(self):
        manager = DeployManager(config=DeploymentConfig.from_dict(
            {"deploymentType": DeploymentTypes.DOCKER_COMPOSE}))
        assert manager.deployment_type == DeploymentTypes.DOCKER_COMPOSE
        assert manager.is_docker_compose is True

        manager = DeployManager(config=DeploymentConfig.from_dict(
            {"deploymentType": DeploymentTypes.KUBERNETES}))
        assert manager.deployment_type == DeploymentTypes.KUBERNETES
        assert manager.is_kubernetes is True

        manager = DeployManager(config=DeploymentConfig.from_dict(
            {"deploymentType": DeploymentTypes.HEROKU}))
        assert manager.deployment_type == DeploymentTypes.HEROKU
        assert manager.is_heroku is True

        manager = DeployManager(config=DeploymentConfig.from_dict(
            {"deploymentType": DeploymentTypes.DOCKER}))
        assert manager.deployment_type == DeploymentTypes.DOCKER
        assert manager.is_docker is True
示例#2
0
def deploy(config_file, manager_path, check, dry_run):
    """Deploy polyaxon."""
    config = read_deployment_config(config_file)
    manager = DeployManager(config=config,
                            filepath=config_file,
                            manager_path=manager_path,
                            dry_run=dry_run)
    exception = None
    if check:
        try:
            manager.check()
        except Exception as e:
            handle_cli_error(e,
                             message="Polyaxon deployment file is not valid.")
            sys.exit(1)

        Printer.print_success("Polyaxon deployment file is valid.")
    else:
        try:
            manager.install()
        except Exception as e:
            Printer.print_error("Polyaxon could not be installed.")
            exception = e

    if exception:
        Printer.print_error("Error message: {}.".format(exception))
示例#3
0
文件: admin.py 项目: smilee/polyaxon
def deploy(config_file, deployment_type, manager_path, check, dry_run):
    """Deploy polyaxon."""
    config = read_deployment_config(config_file)
    manager = DeployManager(
        config=config,
        filepath=config_file,
        deployment_type=deployment_type,
        manager_path=manager_path,
        dry_run=dry_run,
    )
    exception = None
    if config:
        Printer.print_success("Polyaxon `{}` deployment file is valid.".format(
            config.deployment_chart))
    if check:
        try:
            manager.check()
        except Exception as e:
            handle_cli_error(e,
                             message="Polyaxon deployment manager error.",
                             sys_exit=True)

    else:
        try:
            manager.install()
        except Exception as e:
            Printer.print_error("Polyaxon could not be installed.")
            exception = e

    if exception:
        Printer.print_error("Error message: {}.".format(exception),
                            sys_exit=True)
示例#4
0
def upgrade(config_file, manager_path, check, dry_run):
    """Upgrade a Polyaxon deployment."""
    config = read_deployment_config(config_file)
    manager = DeployManager(config=config,
                            filepath=config_file,
                            manager_path=manager_path,
                            dry_run=dry_run)
    exception = None
    Printer.print_success("Polyaxon `{}` deployment file is valid.".format(
        config.deployment_chart))
    if check:
        try:
            manager.check()
        except Exception as e:
            handle_cli_error(e, message="Polyaxon deployment manager error.")
            sys.exit(1)
    else:
        try:
            manager.upgrade()
        except Exception as e:
            Printer.print_error("Polyaxon could not upgrade the deployment.")
            exception = e

    if exception:
        Printer.print_error("Error message: {}.".format(exception))
示例#5
0
def teardown(config_file):
    """Teardown a polyaxon deployment given a config file."""
    config = read_deployment_config(config_file)
    manager = DeployManager(config=config, filepath=config_file)
    exception = None
    try:
        if click.confirm("Would you like to execute pre-delete hooks?",
                         default=True):
            manager.teardown(hooks=True)
        else:
            manager.teardown(hooks=False)
    except Exception as e:
        Printer.print_error("Polyaxon could not teardown the deployment.")
        exception = e

    if exception:
        Printer.print_error("Error message: {}.".format(exception))
示例#6
0
 def test_default_props(self):
     manager = DeployManager()
     assert manager.deployment_type == DeploymentTypes.KUBERNETES
     assert manager.is_kubernetes is True
     assert isinstance(manager.helm, HelmOperator)
     assert isinstance(manager.kubectl, KubectlOperator)