def get_all_by_stack(cls, context, stack_id): resources_db = db_api.resource_get_all_by_stack(context, stack_id) resources = [ (resource_name, cls._from_db_object(cls(context), context, resource_db)) for resource_name, resource_db in six.iteritems(resources_db) ] return dict(resources)
def get_all_by_stack(cls, context, stack_id, filters=None): cache = context.cache(ResourceCache) resources = cache.by_stack_id_name.get(stack_id) if resources: return dict(resources) resources_db = db_api.resource_get_all_by_stack( context, stack_id, filters) return cls._resources_to_dict(context, resources_db)
def get_all_by_stack(cls, context, stack_id, filters=None): cache = context.cache(ResourceCache) resources = cache.by_stack_id_name.get(stack_id) if resources: return dict(resources) resources_db = db_api.resource_get_all_by_stack(context, stack_id, filters) return cls._resources_to_dict(context, resources_db)
def db_resource_get(self, name): if not self.id: return None if self._db_resources is None: try: self._db_resources = db_api.resource_get_all_by_stack(self.context, self.id) except exception.NotFound: return None return self._db_resources.get(name)
def get_all_by_stack(cls, context, stack_id, key_id=False, filters=None): resources_db = db_api.resource_get_all_by_stack( context, stack_id, key_id, filters) resources = [ (resource_key, cls._from_db_object(cls(context), context, resource_db)) for resource_key, resource_db in six.iteritems(resources_db) ] return dict(resources)
def db_resource_get(self, name): if not self.id: return None if self._db_resources is None: try: self._db_resources = db_api.resource_get_all_by_stack( self.context, self.id) except exception.NotFound: return None return self._db_resources.get(name)
def get_all_by_stack(cls, context, stack_id): resources_db = db_api.resource_get_all_by_stack(context, stack_id) resources = [ ( resource_name, cls._from_db_object(cls(context), context, resource_db) ) for resource_name, resource_db in resources_db.iteritems() ] return dict(resources)
def get_all_by_stack(cls, context, stack_id, key_id=False): resources_db = db_api.resource_get_all_by_stack(context, stack_id, key_id) resources = [ ( resource_key, cls._from_db_object(cls(context), context, resource_db) ) for resource_key, resource_db in six.iteritems(resources_db) ] return dict(resources)
def load_all_from_stack(context, stack, definitions): ''' Return an iterator over all Resources in a stack. Resources are created from the provided definitions, and any associated state loaded from the DB. ''' db_resources = {} if stack.id is not None: try: db_resources = db_api.resource_get_all_by_stack(context, stack.id) except exception.NotFound: pass for name, definition in definitions.items(): resource = Resource(name, definition, stack) if name in db_resources: resource._load_data(db_resources[name]) yield resource
def load_all_from_stack(context, stack, definitions): ''' Return an iterator over all Resources in a stack. Resources are created from the provided definitions, and any associated state loaded from the DB. ''' db_resources = {} if stack.id is not None: try: db_resources = db_api.resource_get_all_by_stack( context, stack.id) except exception.NotFound: pass for name, definition in definitions.items(): resource = Resource(name, definition, stack) if name in db_resources: resource._load_data(db_resources[name]) yield resource
def get_all_by_stack(cls, context, stack_id, filters=None): resources_db = db_api.resource_get_all_by_stack( context, stack_id, filters) return cls._resources_to_dict(context, resources_db)
def get_all_by_stack(cls, context, stack_id, filters=None): resources_db = db_api.resource_get_all_by_stack(context, stack_id, filters) return cls._resources_to_dict(context, resources_db)