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)
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)
def create_software_deployment(self, cnxt, server_id, config_id, input_values, action, status, status_reason, stack_user_project_id, deployment_id=None): if server_id and not isinstance(server_id, six.string_types): LOG.error(_LI('server_id %s must be string.') % server_id) raise ValueError(_('server_id must be string.')) 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)
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)
def create_software_deployment(self, cnxt, server_id, config_id, input_values, action, status, status_reason, stack_user_project_id, deployment_id=None): if server_id and not isinstance(server_id, six.string_types): LOG.error(_LI('server_id %s must be string.') % server_id) raise ValueError(_('server_id must be string.')) 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)
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
def show_software_deployment(self, cnxt, deployment_id): sd = self._show_software_deployment(cnxt, deployment_id) return api.format_software_deployment(sd)