def __init__(self): self.consumer_repo = repo.get_container_consumer_repository() self.container_repo = repo.get_container_repository() self.secret_repo = repo.get_secret_repository() self.validator = validators.ContainerValidator() self.quota_enforcer = quota.QuotaEnforcer('containers', self.container_repo)
def __init__(self, container_id): self.container_id = container_id self.consumer_repo = repo.get_container_consumer_repository() self.container_repo = repo.get_container_repository() self.project_repo = repo.get_project_repository() self.validator = validators.ContainerConsumerValidator() self.quota_enforcer = quota.QuotaEnforcer('consumers', self.consumer_repo)
def __init__(self, container): self.container = container self.container_id = container.id self.consumer_repo = repo.get_container_consumer_repository() self.container_repo = repo.get_container_repository() self.validator = validators.ContainerValidator() self.consumers = consumers.ContainerConsumersController( self.container_id) self.acl = acls.ContainerACLsController(self.container)
def __init__(self, container): self.container = container self.container_id = container.id self.consumer_repo = repo.get_container_consumer_repository() self.container_repo = repo.get_container_repository() self.validator = validators.ContainerValidator() self.consumers = consumers.ContainerConsumersController( self.container_id) self.acls = acls.ContainerACLsController(self.container_id)
def create_container_consumer_meta(container=None, parsed_request=None, session=None): if not parsed_request: parsed_request = {"name": "name", "URL": "URL"} container_consumer_meta = models.ContainerConsumerMetadatum( container_id=container.id, project_id=container.project_id, parsed_request=parsed_request, ) cont_cons_meta_repo = repositories.get_container_consumer_repository() cont_cons_meta_repo.create_from(container_consumer_meta, session=session) return container_consumer_meta
class ContainerConsumerMetadatum(base.BarbicanObject, base.BarbicanPersistentObject, object_base.VersionedObjectDictCompat): fields = { 'container_id': fields.StringField(nullable=False), 'project_id': fields.StringField(nullable=True, default=None), 'name': fields.StringField(nullable=True, default=None), 'URL': fields.StringField(nullable=True, default=None), 'data_hash': fields.StringField(nullable=True, default=None) } db_model = models.ContainerConsumerMetadatum db_repo = repos.get_container_consumer_repository() @classmethod def get_by_container_id(cls, container_id, offset_arg=None, limit_arg=None, suppress_exception=False, session=None): entities_db, offset, limit, total = \ cls.db_repo.get_by_container_id( container_id, offset_arg, limit_arg, suppress_exception, session) entities = [cls()._from_db_object(entity_db) for entity_db in entities_db] return entities, offset, limit, total @classmethod def get_by_values(cls, container_id, name, URL, suppress_exception=False, show_deleted=False, session=None): consumer_db = cls.db_repo.get_by_values(container_id, name, URL, suppress_exception, show_deleted, session) return cls()._from_db_object(consumer_db) @classmethod def create_or_update_from_model(cls, new_consumer, container, session=None): """Create or update container :param new_consumer: a instance of ContainerConsumerMetadatum model :param container: a instance of Container OVO :param session: a session to connect with database :return: None It is used during converting from model to OVO. It will be removed after Container resource is implemented OVO. """ session = cls.get_session(session=session) try: container.updated_at = timeutils.utcnow() container.save(session=session) new_consumer.save(session=session) except db_exc.DBDuplicateEntry: session.rollback() # We know consumer already exists. # This operation is idempotent, so log this and move on LOG.debug("Consumer %s with URL %s already exists for " "container %s, continuing...", new_consumer.name, new_consumer.URL, new_consumer.container_id) # Get the existing entry and reuse it by clearing the deleted flags existing_consumer = cls.get_by_values( new_consumer.container_id, new_consumer.name, new_consumer.URL, show_deleted=True) existing_consumer.deleted = False existing_consumer.deleted_at = None # We are not concerned about timing here -- set only, no reads existing_consumer.save(session=session) @classmethod def create_or_update_from(cls, new_consumer, container, session=None): """Create or update container :param new_consumer: a instance of ContainerConsumerMetadatum OVO :param container: a instance of Container OVO :param session: a session to connect with database :return: None """ session = cls.get_session(session=session) try: container.updated_at = timeutils.utcnow() container.consumers.append(new_consumer) container.save(session=session) except db_exc.DBDuplicateEntry: session.rollback() # We know consumer already exists. # This operation is idempotent, so log this and move on LOG.debug("Consumer %s with URL %s already exists for " "container %s, continuing...", new_consumer.name, new_consumer.URL, new_consumer.container_id) # Get the existing entry and reuse it by clearing the deleted flags existing_consumer = cls.get_by_values( new_consumer.container_id, new_consumer.name, new_consumer.URL, show_deleted=True) existing_consumer.deleted = False existing_consumer.deleted_at = None # We are not concerned about timing here -- set only, no reads existing_consumer.save(session=session)
def __init__(self, container_id): self.container_id = container_id self.consumer_repo = repo.get_container_consumer_repository() self.container_repo = repo.get_container_repository() self.validator = validators.ContainerConsumerValidator()
def __init__(self): self.consumer_repo = repo.get_container_consumer_repository() self.container_repo = repo.get_container_repository() self.secret_repo = repo.get_secret_repository() self.validator = validators.ContainerValidator()
def __init__(self, container, consumer_id): super().__init__() self.container = container self.consumer_id = consumer_id self.consumer_repo = repo.get_container_consumer_repository() self.validator = validators.ContainerConsumerValidator()