コード例 #1
0
    def deploy_instance(self, deploying):
        if self.service.is_database:
            return self.deploy_database(deploying)
        else:
            self.deploying = deploying

            self.host_deploy = HostDeploy.get_or_create(deploy_uuid=self.deploying.uuid, host_uuid=self.host.uuid)
            self.f.write('Deploying to {}@{} with key {}.\n'.format(env.user, env.host_string, env.key_filename[0]))

            self._update_instance_files()
            self._pull_new_container()
            self._kill_running_containers()
            self._start_container()

            self.host_deploy = HostDeploy.update(self.host_deploy.uuid, succeeded=self.succeeded)
            return self.succeeded
コード例 #2
0
    def deploy_database(self, deploying):
        self.deploying = deploying

        self.host_deploy = HostDeploy.get_or_create(deploy_uuid=self.deploying.uuid, host_uuid=self.host.uuid)
        self.f.write('Deploying database to {}@{} with key {}.\n'.format(env.user, env.host_string, env.key_filename[0]))

        self._pull_new_container()
        self._kill_container(self.deploying.docker_tag)
        self.delete_container(self.deploying.docker_tag)
        # check for data volumes
        if not self._check_for_data_volume():
            self._create_data_volume()
        self._start_container()
        # restart container?
        self._kill_container(self.deploying.docker_tag)
        self._restart_container()

        self.host_deploy = HostDeploy.update(self.host_deploy.uuid, succeeded=self.succeeded)
        return self.succeeded
コード例 #3
0
    def restart_deploy(self, deploying, hard_restart=False):
        self.deploying = deploying
        self.host_deploy = HostDeploy.get_or_create(deploy_uuid=self.deploying.uuid, host_uuid=self.host.uuid)
        self.f.write('Restarting container for service {} (hard_restart = {}) on'
                     '{}@{} with key {}.\n'.format(self.service.name,
                                                   hard_restart,
                                                   env.user,
                                                   env.host_string,
                                                   env.key_filename[0]))

        self._kill_running_containers()
        if hard_restart:
            self.f.write('Updating deploy files for service {}.\n'.format(self.service.name))
            self._update_instance_files()
            self.delete_container(self.deploying.docker_tag)
            self._start_container()
        else:
            self._restart_container()

        self.host_deploy = HostDeploy.update(self.host_deploy.uuid, succeeded=self.succeeded)
        return self.succeeded
コード例 #4
0
 def remove_service(self):
     self.deploying = Deploy.get_latest_deploy(self.service.uuid)
     self.host_deploy = HostDeploy.get_or_create(deploy_uuid=self.deploying.uuid, host_uuid=self.host.uuid)
     self.f.write('Remove service for deploy {}\n'.format(self.deploying.uuid))
     self._kill_running_containers()
     self.delete_container(self.deploying.docker_tag)