def create(self): if self.obj_attr_is_set('id'): raise exceptions.ObjectActionError(action='create', reason='already created') updates = self.obj_get_changes() try: orch_job_id = updates.pop('orch_job_id') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Subcloud object without a " "orch_job_id set") updates = self.obj_get_changes() try: target_region_name = updates.pop('target_region_name') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Subcloud object without a " "target_region_name set") db_orch_request = db_api.orch_request_create( self._context, orch_job_id, target_region_name, updates) return self._from_db_object(self._context, self, db_orch_request)
def create(self): if self.obj_attr_is_set('id'): raise exceptions.ObjectActionError(action='create', reason='already created') updates = self.obj_get_changes() try: resource_id = updates.pop('resource_id') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Subcloud object without a " "resource_id set") updates = self.obj_get_changes() try: endpoint_type = updates.pop('endpoint_type') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Subcloud object without a " "endpoint_type set") updates = self.obj_get_changes() try: operation_type = updates.pop('operation_type') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Subcloud object without a " "operation_type set") db_orch_job = db_api.orch_job_create(self._context, resource_id, endpoint_type, operation_type, updates) return self._from_db_object(self._context, self, db_orch_job)
def create(self): if self.obj_attr_is_set('id'): raise exceptions.ObjectActionError(action='create', reason='already created') updates = self.obj_get_changes() try: resource_type = updates.pop('resource_type') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Resource object without a " "resource_type set") db_resource = db_api.resource_create(self._context, resource_type, updates) return self._from_db_object(self._context, self, db_resource)
def create(self): if self.obj_attr_is_set('id'): raise exceptions.ObjectActionError(action='create', reason='already created') updates = self.obj_get_changes() if 'subcloud_resource_id' not in updates: raise exceptions.ObjectActionError( action="create", reason="cannot create a SubcloudResource object without a " "subcloud_resource_id") resource_id = updates.pop('resource_id') subcloud_id = updates.pop('subcloud_id') db_subcloud_resource = db_api.subcloud_resource_create( self._context, subcloud_id, resource_id, updates) return self._from_db_object(self._context, self, db_subcloud_resource)
def create(self): if self.obj_attr_is_set('id'): raise exceptions.ObjectActionError(action='create', reason='already created') updates = self.obj_get_changes() try: region_name = updates.pop('region_name') except KeyError: raise exceptions.ObjectActionError( action="create", reason="cannot create a Subcloud object without a " "region_name set") # create entry into alarm summary table, we will get real values later alarm_updates = {'critical_alarms': -1, 'major_alarms': -1, 'minor_alarms': -1, 'warnings': -1, 'cloud_status': consts.ALARMS_DISABLED} db_api.subcloud_alarms_create(self._context, region_name, alarm_updates) db_subcloud = db_api.subcloud_create( self._context, region_name, updates) return self._from_db_object(self._context, self, db_subcloud)