Exemplo n.º 1
0
    def create_software_deployment(
        self,
        cnxt,
        server_id,
        config_id,
        input_values,
        action,
        status,
        status_reason,
        stack_user_project_id,
        deployment_id=None,
    ):

        if deployment_id is None:
            deployment_id = str(uuid.uuid4())
        sd = software_deployment_object.SoftwareDeployment.create(
            cnxt,
            {
                "id": deployment_id,
                "config_id": config_id,
                "server_id": server_id,
                "input_values": input_values,
                "tenant": cnxt.tenant_id,
                "stack_user_project_id": stack_user_project_id,
                "action": action,
                "status": status,
                "status_reason": status_reason,
            },
        )
        self._push_metadata_software_deployments(cnxt, server_id, sd)
        return api.format_software_deployment(sd)
Exemplo n.º 2
0
    def update_software_deployment(self, cnxt, deployment_id, config_id,
                                   input_values, output_values, action, status,
                                   status_reason):
        update_data = {}
        if config_id:
            update_data['config_id'] = config_id
        if input_values:
            update_data['input_values'] = input_values
        if output_values:
            update_data['output_values'] = output_values
        if action:
            update_data['action'] = action
        if status:
            update_data['status'] = status
        if status_reason:
            update_data['status_reason'] = status_reason
        sd = db_api.software_deployment_update(cnxt, deployment_id,
                                               update_data)

        # only push metadata if this update resulted in the config_id
        # changing, since metadata is just a list of configs
        if config_id:
            self._push_metadata_software_deployments(cnxt, sd.server_id)

        return api.format_software_deployment(sd)
Exemplo n.º 3
0
    def update_software_deployment(self, cnxt, deployment_id, config_id,
                                   input_values, output_values, action,
                                   status, status_reason):
        update_data = {}
        if config_id:
            update_data['config_id'] = config_id
        if input_values:
            update_data['input_values'] = input_values
        if output_values:
            update_data['output_values'] = output_values
        if action:
            update_data['action'] = action
        if status:
            update_data['status'] = status
        if status_reason:
            update_data['status_reason'] = status_reason
        sd = db_api.software_deployment_update(cnxt,
                                               deployment_id, update_data)

        # only push metadata if this update resulted in the config_id
        # changing, since metadata is just a list of configs
        if config_id:
            self._push_metadata_software_deployments(cnxt, sd.server_id)

        return api.format_software_deployment(sd)
Exemplo n.º 4
0
    def update_software_deployment(self, cnxt, deployment_id, config_id,
                                   input_values, output_values, action,
                                   status, status_reason, updated_at):
        update_data = {}
        if config_id:
            update_data['config_id'] = config_id
        if input_values:
            update_data['input_values'] = input_values
        if output_values:
            update_data['output_values'] = output_values
        if action:
            update_data['action'] = action
        if status:
            update_data['status'] = status
        if status_reason:
            update_data['status_reason'] = status_reason
        if updated_at:
            update_data['updated_at'] = timeutils.normalize_time(
                timeutils.parse_isotime(updated_at))
        else:
            update_data['updated_at'] = timeutils.utcnow()

        sd = software_deployment_object.SoftwareDeployment.update_by_id(
            cnxt, deployment_id, update_data)

        # only push metadata if this update resulted in the config_id
        # changing, since metadata is just a list of configs
        if config_id:
            self._push_metadata_software_deployments(
                cnxt, sd.server_id, sd.stack_user_project_id)

        return api.format_software_deployment(sd)
Exemplo n.º 5
0
    def update_software_deployment(self, cnxt, deployment_id, config_id,
                                   input_values, output_values, action,
                                   status, status_reason, updated_at):
        update_data = {}
        if config_id:
            update_data['config_id'] = config_id
        if input_values:
            update_data['input_values'] = input_values
        if output_values:
            update_data['output_values'] = output_values
        if action:
            update_data['action'] = action
        if status:
            update_data['status'] = status
        if status_reason:
            update_data['status_reason'] = status_reason
        if updated_at:
            update_data['updated_at'] = timeutils.normalize_time(
                timeutils.parse_isotime(updated_at))
        else:
            update_data['updated_at'] = timeutils.utcnow()

        sd = software_deployment_object.SoftwareDeployment.update_by_id(
            cnxt, deployment_id, update_data)

        # only push metadata if this update resulted in the config_id
        # changing, since metadata is just a list of configs
        if config_id:
            self._push_metadata_software_deployments(
                cnxt, sd.server_id, sd.stack_user_project_id)

        return api.format_software_deployment(sd)
Exemplo n.º 6
0
    def create_software_deployment(self,
                                   cnxt,
                                   server_id,
                                   config_id,
                                   input_values,
                                   action,
                                   status,
                                   status_reason,
                                   stack_user_project_id,
                                   deployment_id=None):

        if deployment_id is None:
            deployment_id = str(uuid.uuid4())
        sd = software_deployment_object.SoftwareDeployment.create(
            cnxt, {
                'id': deployment_id,
                'config_id': config_id,
                'server_id': server_id,
                'input_values': input_values,
                'tenant': cnxt.tenant_id,
                'stack_user_project_id': stack_user_project_id,
                'action': action,
                'status': status,
                'status_reason': status_reason
            })
        self._push_metadata_software_deployments(cnxt, server_id,
                                                 stack_user_project_id)
        return api.format_software_deployment(sd)
Exemplo n.º 7
0
 def test_format_software_deployment(self):
     deployment = self._dummy_software_deployment()
     result = api.format_software_deployment(deployment)
     self.assertIsNotNone(result)
     self.assertEqual(deployment.config.id, result['config_id'])
     self.assertEqual(deployment.config.io['inputs'], result['inputs'])
     self.assertEqual(deployment.config.io['outputs'], result['outputs'])
     self.assertEqual(deployment.config.io['options'], result['options'])
Exemplo n.º 8
0
 def show_software_deployment(self, cnxt, deployment_id):
     sd = software_deployment_object.SoftwareDeployment.get_by_id(cnxt, deployment_id)
     if sd.status == rpc_api.SOFTWARE_DEPLOYMENT_IN_PROGRESS:
         c = sd.config.config
         input_values = dict((i["name"], i["value"]) for i in c["inputs"])
         transport = input_values.get("deploy_signal_transport")
         if transport == "TEMP_URL_SIGNAL":
             sd = self._refresh_software_deployment(cnxt, sd, input_values.get("deploy_signal_id"))
     return api.format_software_deployment(sd)
Exemplo n.º 9
0
 def check_software_deployment(self, cnxt, deployment_id, timeout):
     def _check():
         while True:
             sd = self._show_software_deployment(cnxt, deployment_id)
             if sd.status != rpc_api.SOFTWARE_DEPLOYMENT_IN_PROGRESS:
                 return
             yield
     scheduler.TaskRunner(_check)(timeout=timeout)
     sd = software_deployment_object.SoftwareDeployment.get_by_id(
         cnxt, deployment_id)
     return api.format_software_deployment(sd)
Exemplo n.º 10
0
 def show_software_deployment(self, cnxt, deployment_id):
     sd = software_deployment_object.SoftwareDeployment.get_by_id(
         cnxt, deployment_id)
     if sd.status == rpc_api.SOFTWARE_DEPLOYMENT_IN_PROGRESS:
         c = sd.config.config
         input_values = dict((i['name'], i['value']) for i in c['inputs'])
         transport = input_values.get('deploy_signal_transport')
         if transport == 'TEMP_URL_SIGNAL':
             sd = self._refresh_software_deployment(
                 cnxt, sd, input_values.get('deploy_signal_id'))
     return api.format_software_deployment(sd)
Exemplo n.º 11
0
 def test_format_software_deployment(self):
     deployment = self._dummy_software_deployment()
     result = api.format_software_deployment(deployment)
     self.assertIsNotNone(result)
     self.assertEqual(deployment.config.id, result['config_id'])
     self.assertEqual(
         deployment.config.io['inputs'], result['inputs'])
     self.assertEqual(
         deployment.config.io['outputs'], result['outputs'])
     self.assertEqual(
         deployment.config.io['options'], result['options'])
Exemplo n.º 12
0
 def check_software_deployment(self, cnxt, deployment_id, timeout):
     def _check():
         while True:
             sd = self._show_software_deployment(cnxt, deployment_id)
             if sd.status != rpc_api.SOFTWARE_DEPLOYMENT_IN_PROGRESS:
                 return
             yield
     scheduler.TaskRunner(_check)(timeout=timeout)
     sd = software_deployment_object.SoftwareDeployment.get_by_id(
         cnxt, deployment_id)
     return api.format_software_deployment(sd)
Exemplo n.º 13
0
 def create_software_deployment(self, cnxt, server_id, config_id,
                                input_values, action, status,
                                status_reason):
     sd = db_api.software_deployment_create(cnxt, {
         'config_id': config_id,
         'server_id': server_id,
         'input_values': input_values,
         'tenant': cnxt.tenant_id,
         'action': action,
         'status': status,
         'status_reason': status_reason})
     return api.format_software_deployment(sd)
Exemplo n.º 14
0
 def test_format_software_deployment(self):
     deployment = self._dummy_software_deployment()
     result = api.format_software_deployment(deployment)
     self.assertIsNotNone(result)
     self.assertEqual(deployment.id, result['id'])
     self.assertEqual(deployment.config.id, result['config_id'])
     self.assertEqual(deployment.server_id, result['server_id'])
     self.assertEqual(deployment.input_values, result['input_values'])
     self.assertEqual(deployment.output_values, result['output_values'])
     self.assertEqual(deployment.action, result['action'])
     self.assertEqual(deployment.status, result['status'])
     self.assertEqual(deployment.status_reason, result['status_reason'])
Exemplo n.º 15
0
 def test_format_software_deployment(self):
     deployment = self._dummy_software_deployment()
     result = api.format_software_deployment(deployment)
     self.assertIsNotNone(result)
     self.assertEqual(deployment.id, result['id'])
     self.assertEqual(deployment.config.id, result['config_id'])
     self.assertEqual(deployment.server_id, result['server_id'])
     self.assertEqual(deployment.input_values, result['input_values'])
     self.assertEqual(deployment.output_values, result['output_values'])
     self.assertEqual(deployment.action, result['action'])
     self.assertEqual(deployment.status, result['status'])
     self.assertEqual(deployment.status_reason, result['status_reason'])
Exemplo n.º 16
0
 def test_format_software_deployment(self):
     deployment = self._dummy_software_deployment()
     result = api.format_software_deployment(deployment)
     self.assertIsNotNone(result)
     self.assertEqual(deployment.id, result["id"])
     self.assertEqual(deployment.config.id, result["config_id"])
     self.assertEqual(deployment.server_id, result["server_id"])
     self.assertEqual(deployment.input_values, result["input_values"])
     self.assertEqual(deployment.output_values, result["output_values"])
     self.assertEqual(deployment.action, result["action"])
     self.assertEqual(deployment.status, result["status"])
     self.assertEqual(deployment.status_reason, result["status_reason"])
Exemplo n.º 17
0
 def create_software_deployment(self, cnxt, server_id, config_id,
                                input_values, signal_id, action, status,
                                status_reason):
     sd = db_api.software_deployment_create(cnxt, {
         'config_id': config_id,
         'server_id': server_id,
         'input_values': input_values,
         'signal_id': signal_id,
         'tenant': cnxt.tenant_id,
         'action': action,
         'status': status,
         'status_reason': status_reason})
     return api.format_software_deployment(sd)
Exemplo n.º 18
0
 def show_software_deployment(self, cnxt, deployment_id):
     sd = software_deployment_object.SoftwareDeployment.get_by_id(
         cnxt, deployment_id)
     if sd.status == rpc_api.SOFTWARE_DEPLOYMENT_IN_PROGRESS:
         c = sd.config.config
         input_values = dict((i['name'], i['value']) for i in c['inputs'])
         transport = input_values.get('deploy_signal_transport')
         if transport == 'TEMP_URL_SIGNAL':
             sd = self._refresh_swift_software_deployment(
                 cnxt, sd, input_values.get('deploy_signal_id'))
         elif transport == 'ZAQAR_SIGNAL':
             sd = self._refresh_zaqar_software_deployment(
                 cnxt, sd, input_values.get('deploy_queue_id'))
     return api.format_software_deployment(sd)
Exemplo n.º 19
0
    def create_software_deployment(self, cnxt, server_id, config_id,
                                   input_values, action, status,
                                   status_reason, stack_user_project_id):

        sd = software_deployment_object.SoftwareDeployment.create(cnxt, {
            'config_id': config_id,
            'server_id': server_id,
            'input_values': input_values,
            'tenant': cnxt.tenant_id,
            'stack_user_project_id': stack_user_project_id,
            'action': action,
            'status': status,
            'status_reason': status_reason})
        self._push_metadata_software_deployments(cnxt, server_id)
        return api.format_software_deployment(sd)
Exemplo n.º 20
0
    def create_software_deployment(self, cnxt, server_id, config_id,
                                   input_values, action, status, status_reason,
                                   stack_user_project_id):

        sd = db_api.software_deployment_create(
            cnxt, {
                'config_id': config_id,
                'server_id': server_id,
                'input_values': input_values,
                'tenant': cnxt.tenant_id,
                'stack_user_project_id': stack_user_project_id,
                'action': action,
                'status': status,
                'status_reason': status_reason
            })
        self._push_metadata_software_deployments(cnxt, server_id)
        return api.format_software_deployment(sd)
Exemplo n.º 21
0
 def update_software_deployment(self, cnxt, deployment_id, config_id,
                                input_values, output_values, action,
                                status, status_reason):
     update_data = {}
     if config_id:
         update_data['config_id'] = config_id
     if input_values:
         update_data['input_values'] = input_values
     if output_values:
         update_data['output_values'] = output_values
     if action:
         update_data['action'] = action
     if status:
         update_data['status'] = status
     if status_reason:
         update_data['status_reason'] = status_reason
     sd = db_api.software_deployment_update(cnxt,
                                            deployment_id, update_data)
     return api.format_software_deployment(sd)
Exemplo n.º 22
0
 def update_software_deployment(self, cnxt, deployment_id, config_id,
                                input_values, output_values, action, status,
                                status_reason):
     update_data = {}
     if config_id:
         update_data['config_id'] = config_id
     if input_values:
         update_data['input_values'] = input_values
     if output_values:
         update_data['output_values'] = output_values
     if action:
         update_data['action'] = action
     if status:
         update_data['status'] = status
     if status_reason:
         update_data['status_reason'] = status_reason
     sd = db_api.software_deployment_update(cnxt, deployment_id,
                                            update_data)
     return api.format_software_deployment(sd)
Exemplo n.º 23
0
    def create_software_deployment(self, cnxt, server_id, config_id,
                                   input_values, action, status,
                                   status_reason, stack_user_project_id,
                                   deployment_id=None):

        if deployment_id is None:
            deployment_id = str(uuid.uuid4())
        sd = software_deployment_object.SoftwareDeployment.create(cnxt, {
            'id': deployment_id,
            'config_id': config_id,
            'server_id': server_id,
            'input_values': input_values,
            'tenant': cnxt.tenant_id,
            'stack_user_project_id': stack_user_project_id,
            'action': action,
            'status': status,
            'status_reason': six.text_type(status_reason)})
        self._push_metadata_software_deployments(
            cnxt, server_id, stack_user_project_id)
        return api.format_software_deployment(sd)
Exemplo n.º 24
0
 def list_software_deployments(self, cnxt, server_id):
     all_sd = db_api.software_deployment_get_all(cnxt, server_id)
     result = [api.format_software_deployment(sd) for sd in all_sd]
     return result
Exemplo n.º 25
0
 def list_software_deployments(self, cnxt, server_id):
     all_sd = software_deployment_object.SoftwareDeployment.get_all(
         cnxt, server_id)
     result = [api.format_software_deployment(sd) for sd in all_sd]
     return result
Exemplo n.º 26
0
 def list_software_deployments(self, cnxt, server_id):
     all_sd = software_deployment_object.SoftwareDeployment.get_all(
         cnxt, server_id)
     result = [api.format_software_deployment(sd) for sd in all_sd]
     return result
Exemplo n.º 27
0
 def show_software_deployment(self, cnxt, deployment_id):
     sd = self._show_software_deployment(cnxt, deployment_id)
     return api.format_software_deployment(sd)
 def test_format_software_deployment_none(self):
     self.assertIsNone(api.format_software_deployment(None))
Exemplo n.º 29
0
 def show_software_deployment(self, cnxt, deployment_id):
     sd = self._show_software_deployment(cnxt, deployment_id)
     return api.format_software_deployment(sd)
Exemplo n.º 30
0
 def test_format_software_deployment_none(self):
     self.assertIsNone(api.format_software_deployment(None))
Exemplo n.º 31
0
 def list_software_deployments(self, cnxt, server_id):
     all_sd = db_api.software_deployment_get_all(cnxt, server_id)
     result = [api.format_software_deployment(sd) for sd in all_sd]
     return result