示例#1
0
文件: base.py 项目: ifooth/horizon
 def __getattr__(self, attr):
     try:
         return self._apidict[attr]
     except KeyError:
         msg = 'Unknown attribute "%(attr)s" on APIResource object ' \
               'of type "%(cls)s"' % {'attr': attr, 'cls': self.__class__}
         LOG.debug(exceptions.error_color(msg))
         raise AttributeError(msg)
示例#2
0
 def __getattr__(self, attr):
     try:
         return self._apidict[attr]
     except KeyError:
         msg = 'Unknown attribute "%(attr)s" on APIResource object ' \
               'of type "%(cls)s"' % {'attr': attr, 'cls': self.__class__}
         LOG.debug(exceptions.error_color(msg))
         raise AttributeError(msg)
示例#3
0
文件: base.py 项目: ifooth/horizon
 def __getattr__(self, attr):
     if attr in self._attrs:
         # __getattr__ won't find properties
         return self._apiresource.__getattribute__(attr)
     else:
         msg = ('Attempted to access unknown attribute "%s" on '
                'APIResource object of type "%s" wrapping resource of '
                'type "%s".') % (attr, self.__class__,
                                 self._apiresource.__class__)
         LOG.debug(exceptions.error_color(msg))
         raise AttributeError(attr)
示例#4
0
 def __getattr__(self, attr):
     if attr in self._attrs:
         # __getattr__ won't find properties
         return self._apiresource.__getattribute__(attr)
     else:
         msg = ('Attempted to access unknown attribute "%s" on '
                'APIResource object of type "%s" wrapping resource of '
                'type "%s".') % (attr, self.__class__,
                                 self._apiresource.__class__)
         LOG.debug(exceptions.error_color(msg))
         raise AttributeError(attr)
示例#5
0
文件: api.py 项目: ccrouch/tuskar-ui
    def rack(self):
        try:
            if not hasattr(self, '_rack'):
                # FIXME the node.rack association should be stored somewhere
                self._rack = None
                for rack in Rack.list(self.request):
                    for node_obj in rack.list_nodes:
                        if node_obj.id == self.id:
                            self._rack = rack

            return self._rack
        except Exception:
            msg = "Could not obtain Nodes's rack"
            LOG.debug(exceptions.error_color(msg))
            return None