def store(self, context): '''Store the policy object into database table.''' timestamp = timeutils.utcnow() values = { 'name': self.name, 'type': self.type, 'user': self.user, 'project': self.project, 'domain': self.domain, 'spec': self.spec, 'data': self.data, } if self.id is not None: self.updated_at = timestamp values['updated_at'] = timestamp db_api.policy_update(context, self.id, values) else: self.created_at = timestamp values['created_at'] = timestamp policy = db_api.policy_create(context, values) self.id = policy.id return self.id
def store(self, context): '''Store the policy object into database table.''' timestamp = timeutils.utcnow() values = { 'name': self.name, 'type': self.type, 'user': self.user, 'project': self.project, 'domain': self.domain, 'spec': self.spec, 'level': self.level, 'cooldown': self.cooldown, 'data': self.data, } if self.id is not None: self.updated_time = timestamp values['updated_time'] = timestamp db_api.policy_update(context, self.id, values) else: self.created_time = timestamp values['created_time'] = timestamp policy = db_api.policy_create(context, values) self.id = policy.id return self.id
def _create_db_policy(self, **kwargs): values = { 'name': 'test-policy', 'type': 'senlin.policy.dummy-1.0', 'spec': self.spec, 'user': self.ctx.user, 'project': self.ctx.project, 'domain': self.ctx.domain, 'data': {} } values.update(kwargs) return db_api.policy_create(self.ctx, values)
def store(self, context): '''Store the policy object into database table.''' timestamp = datetime.datetime.utcnow() values = { 'name': self.name, 'type': self.type, 'spec': self.spec, 'level': self.level, 'cooldown': self.cooldown, 'data': self.data, } if self.id is not None: self.updated_time = timestamp values['updated_time'] = timestamp db_api.policy_update(self.context, self.id, values) else: self.created_time = timestamp values['created_time'] = timestamp policy = db_api.policy_create(self.context, values) self.id = policy.id return self.id
def create(cls, context, values): obj = db_api.policy_create(context, values) return cls._from_db_object(context, cls(context), obj)
def create(cls, context, values): values = cls._transpose_metadata(values) obj = db_api.policy_create(context, values) return cls._from_db_object(context, cls(context), obj)