Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
    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
Ejemplo n.º 10
0
    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
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
 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)