def store(self, context): '''Store the cluster in database and return its ID. If the ID already exists, we do an update. ''' values = { 'name': self.name, 'profile_id': self.profile_id, 'user': self.user, 'project': self.project, 'domain': self.domain, 'parent': self.parent, 'init_time': self.init_time, 'created_time': self.created_time, 'updated_time': self.updated_time, 'deleted_time': self.deleted_time, 'min_size': self.min_size, 'max_size': self.max_size, 'desired_capacity': self.desired_capacity, 'next_index': self.next_index, 'timeout': self.timeout, 'status': self.status, 'status_reason': self.status_reason, 'meta_data': self.metadata, 'data': self.data, } timestamp = timeutils.utcnow() if self.id: values['updated_time'] = timestamp db_api.cluster_update(context, self.id, values) event_mod.info(context, self, 'update') else: self.init_time = timestamp values['init_time'] = timestamp cluster = db_api.cluster_create(context, values) self.id = cluster.id event_mod.info(context, self, 'create') self._load_runtime_data(context) return self.id
def store(self, context): '''Store the cluster in database and return its ID. If the ID already exists, we do an update. ''' values = { 'name': self.name, 'profile_id': self.profile_id, 'user': self.user, 'project': self.project, 'domain': self.domain, 'parent': self.parent, 'init_time': self.init_time, 'created_time': self.created_time, 'updated_time': self.updated_time, 'deleted_time': self.deleted_time, 'min_size': self.min_size, 'max_size': self.max_size, 'desired_capacity': self.desired_capacity, 'next_index': self.next_index, 'timeout': self.timeout, 'status': self.status, 'status_reason': self.status_reason, 'meta_data': self.metadata, 'data': self.data, } timestamp = timeutils.utcnow() if self.id: values['updated_time'] = timestamp db_api.cluster_update(context, self.id, values) event_mod.info(context, self, 'update') else: self.init_time = timestamp values['init_time'] = timestamp cluster = db_api.cluster_create(context, values) self.id = cluster.id event_mod.info(context, self, 'create') self._load_runtime_data(context) return self.id
def store(self, context): '''Store the cluster in database and return its ID. If the ID already exists, we do an update. ''' values = { 'name': self.name, 'profile_id': self.profile_id, 'user': self.user, 'project': self.project, 'domain': self.domain, 'parent': self.parent, 'init_time': self.init_time, 'created_time': self.created_time, 'updated_time': self.updated_time, 'deleted_time': self.deleted_time, 'size': self.size, 'next_index': self.next_index, 'timeout': self.timeout, 'status': self.status, 'status_reason': self.status_reason, 'tags': self.tags, 'data': self.data, } if self.id: db_api.cluster_update(context, self.id, values) event_mod.info(context, self, 'update') else: values['init_time'] = datetime.datetime.utcnow() cluster = db_api.cluster_create(context, values) self.id = cluster.id event_mod.info(context, self, 'create') self._load_runtime_data(context) return self.id
def create(cls, context, values): values = cls._transpose_metadata(values) obj = db_api.cluster_create(context, values) return cls._from_db_object(context, cls(context), obj)
def create(cls, context, values): obj = db_api.cluster_create(context, values) return cls._from_db_object(context, cls(context), obj)
def create(cls, context, values): values = cls._transpose_metadata(values) values['init_at'] = timeutils.utcnow(True) obj = db_api.cluster_create(context, values) return cls._from_db_object(context, cls(context), obj)
def create(cls, context, values): obj = db_api.cluster_create(context, values) return cls._from_db_object(context, cls(context), obj)