def _restoreMetadataDB(context, metadata, stack_resources): workload_policy_name = metadata["workload_policy_name"] workload_policy_obj = { 'name': workload_policy_name, 'tenant_id': context.tenant_id, } workload_policy = api.workload_policy_create(context, workload_policy_obj) for restore_action in metadata["actions"]: # Create action-resource relationships, # New resources IDs from Heat orchestration action_resource = restore_action["resource"] action_name = action_resource["name"] action_rsc_name = action_resource["resource_type"]["name"] new_resource_id = stack_resources[(action_name, action_rsc_name)] resource_obj =\ {'id': new_resource_id, 'name': action_name, 'resource_type_id': action_resource["resource_type_id"], 'tenant_id': context.tenant_id } api.resource_create(context, resource_obj) db_action = restore_action["action"] resource_action_obj = { 'workload_policy_id': workload_policy.id, 'resource_id': new_resource_id, 'action_id': db_action['id'], } api.resource_actions_create(context, resource_action_obj)
def _restoreMetadataDB(context, metadata, stack_resources): workload_policy_name = metadata["workload_policy_name"] workload_policy_obj = {"name": workload_policy_name, "tenant_id": context.tenant_id} workload_policy = api.workload_policy_create(context, workload_policy_obj) for restore_action in metadata["actions"]: # Create action-resource relationships, # New resources IDs from Heat orchestration action_resource = restore_action["resource"] action_name = action_resource["name"] action_rsc_name = action_resource["resource_type"]["name"] new_resource_id = stack_resources[(action_name, action_rsc_name)] resource_obj = { "id": new_resource_id, "name": action_name, "resource_type_id": action_resource["resource_type_id"], "tenant_id": context.tenant_id, } api.resource_create(context, resource_obj) db_action = restore_action["action"] resource_action_obj = { "workload_policy_id": workload_policy.id, "resource_id": new_resource_id, "action_id": db_action["id"], } api.resource_actions_create(context, resource_action_obj)
def set_resource_action(self, cnxt, resource_id, action_id, workload_policy_id): values = {"resource_id": resource_id, "action_id": action_id, "workload_policy_id": workload_policy_id} return db_api.resource_actions_create(cnxt, values)