Ejemplo n.º 1
0
    def stop_deployment(self):
        log.info('Job started for {}.'.format(self.deployment_id))

        self.job.set_progress(10)

        try:
            if Deployment.is_component(self.deployment):
                self.stop_component()
            elif Deployment.is_application(self.deployment):
                self.stop_application()
            elif Deployment.is_application_kubernetes(self.deployment):
                self.stop_application_kubernetes()
        except Exception as ex:
            log.error('Failed to {0} {1}: {2}'.format(self.job['action'],
                                                      self.deployment_id, ex))
            try:
                self.job.set_status_message(repr(ex))
                self.api_dpl.set_state_error(self.deployment_id)
            except Exception as ex_state:
                log.error('Failed to set error state for {0}: {1}'.format(
                    self.deployment_id, ex_state))

            raise ex

        self.try_delete_deployment_credentials(self.deployment_id)

        self.api_dpl.set_state_stopped(self.deployment_id)

        return 0
Ejemplo n.º 2
0
 def get_connector_name(deployment):
     if Deployment.is_component(deployment):
         return 'docker_service'
     elif Deployment.is_application(deployment):
         is_compose = Deployment.is_compatibility_docker_compose(deployment)
         return 'docker_compose' if is_compose else 'docker_stack'
     elif Deployment.is_application_kubernetes(deployment):
         return 'kubernetes'
Ejemplo n.º 3
0
    def handle_deployment(self, deployment: dict):

        if Deployment.is_component(deployment):
            self.start_component(deployment)
        elif Deployment.is_application(deployment):
            self.start_application(deployment)
        elif Deployment.is_application_kubernetes(deployment):
            self.start_application_kubernetes(deployment)

        self.create_user_output_params(deployment)
Ejemplo n.º 4
0
def push_state(deployment):
    try:
        if Deployment.is_component(nuvla_deployment):
            ds.get_component_state(nuvla_deployment)
        elif Deployment.is_application(nuvla_deployment):
            ds.get_application_state(nuvla_deployment)
        elif Deployment.is_application_kubernetes(nuvla_deployment):
            ds.get_application_kubernetes_state(nuvla_deployment)
    except Exception as ex:
        logging.exception('Failed to get deployment state for {}: {}'.format(Deployment.id(deployment), ex))
        pass
Ejemplo n.º 5
0
    def do_work(self):
        log.info('Job started for {}.'.format(self.deployment_id))
        self.job.set_progress(10)

        try:
            if Deployment.is_component(self.deployment):
                self.get_component_state()
            elif Deployment.is_application(self.deployment):
                self.get_application_state()
            elif Deployment.is_application_kubernetes(self.deployment):
                self.get_application_kubernetes_state()
        except Exception as ex:
            log.error('Failed to {0} {1}: {2}'.format(self.job['action'], self.deployment_id, ex))
            self.job.set_status_message(repr(ex))
            raise ex

        return 0