Ejemplo n.º 1
0
    def obj_load_attr(self, attrname):
        if attrname not in CONTAINER_OPTIONAL_ATTRS:
            raise exception.ObjectActionError(
                action='obj_load_attr',
                reason=_('attribute %s not lazy-loadable') % attrname)

        if not self._context:
            raise exception.OrphanedObjectError(method='obj_load_attr',
                                                objtype=self.obj_name())

        LOG.debug("Lazy-loading '%(attr)s' on %(name)s uuid %(uuid)s", {
            'attr': attrname,
            'name': self.obj_name(),
            'uuid': self.uuid,
        })

        # NOTE(danms): We handle some fields differently here so that we
        # can be more efficient
        if attrname == 'pci_devices':
            self._load_pci_devices()

        if attrname == 'exec_instances':
            self._load_exec_instances()

        if attrname == 'registry':
            self._load_registry()

        self.obj_reset_changes([attrname])
Ejemplo n.º 2
0
    def obj_load_attr(self, attrname):
        if attrname not in VOLUME_MAPPING_OPTIONAL_ATTRS:
            raise exception.ObjectActionError(
                action='obj_load_attr',
                reason='attribute %s not lazy-loadable' % attrname)
        if not self._context:
            raise exception.OrphanedObjectError(method='obj_load_attr',
                                                objtype=self.obj_name())

        LOG.debug("Lazy-loading '%(attr)s' on %(name)s", {
            'attr': attrname,
            'name': self.obj_name(),
        })

        if attrname in VOLUME_ATTRS:
            value = getattr(self.volume, attrname)
            setattr(self, attrname, value)
            self.obj_reset_changes(fields=[attrname])
        if attrname == 'container':
            self.container = container.ContainerBase.get_container_any_type(
                self._context, self.container_uuid)
            self.obj_reset_changes(fields=['container'])
        if attrname == 'volume':
            self.volume = volume_obj.Volume.get_by_id(self._context,
                                                      self.volume_id)
            self.obj_reset_changes(fields=['volume'])
Ejemplo n.º 3
0
    def obj_load_attr(self, attrname):
        if attrname not in VOLUME_MAPPING_OPTIONAL_ATTRS:
            raise exception.ObjectActionError(
                action='obj_load_attr',
                reason='attribute %s not lazy-loadable' % attrname)
        if not self._context:
            raise exception.OrphanedObjectError(method='obj_load_attr',
                                                objtype=self.obj_name())

        LOG.debug("Lazy-loading '%(attr)s' on %(name)s uuid %(uuid)s", {
            'attr': attrname,
            'name': self.obj_name(),
            'uuid': self.uuid,
        })
        self.container = container.Container.get_by_uuid(
            self._context, self.container_uuid)
        self.obj_reset_changes(fields=['container'])