Merge "Fix AttributeError on Rack.resource_class_id for unassigned racks."
This commit is contained in:
commit
e759d3d1c5
@ -110,7 +110,10 @@ class StringIdAPIResourceWrapper(base.APIResourceWrapper):
|
|||||||
if issubclass(self._apiresource.__class__, dict):
|
if issubclass(self._apiresource.__class__, dict):
|
||||||
return self._apiresource.get(attr)
|
return self._apiresource.get(attr)
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
return self._apiresource.__getattribute__(attr)
|
return self._apiresource.__getattribute__(attr)
|
||||||
|
except AttributeError:
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
raise AttributeError(attr)
|
raise AttributeError(attr)
|
||||||
|
|
||||||
@ -352,7 +355,7 @@ class Rack(StringIdAPIResourceWrapper):
|
|||||||
if only_free_racks:
|
if only_free_racks:
|
||||||
return [Rack(r, request) for r in
|
return [Rack(r, request) for r in
|
||||||
tuskarclient(request).racks.list() if (
|
tuskarclient(request).racks.list() if (
|
||||||
r.resource_class is None)]
|
getattr(r, 'resource_class', None) is None)]
|
||||||
else:
|
else:
|
||||||
return [Rack(r, request) for r in
|
return [Rack(r, request) for r in
|
||||||
tuskarclient(request).racks.list()]
|
tuskarclient(request).racks.list()]
|
||||||
@ -388,7 +391,8 @@ class Rack(StringIdAPIResourceWrapper):
|
|||||||
@property
|
@property
|
||||||
def resource_class_id(self):
|
def resource_class_id(self):
|
||||||
rclass = self.resource_class
|
rclass = self.resource_class
|
||||||
return rclass['id'] if rclass else None
|
resource_class_id = rclass['id'] if rclass else None
|
||||||
|
return resource_class_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def get_resource_class(self):
|
def get_resource_class(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user