Cleanup: Fix getting name from neutron resources

Some Neutron resources have names, while others don't. In some cases,
it seems to depend on the Neutron version; in some versions ports have
empty names, while in other versions they lack names entirely. This
fixes all of those cases by defaulting to the blank string for
resources that lack names.

Implements: blueprint cleanup-refactoring
Change-Id: Ia5537da52e105af593ace774889290b540df5726
This commit is contained in:
Chris St. Pierre 2016-03-31 12:55:38 -05:00
parent 589d8c81b4
commit 0f8861b855

View File

@ -224,7 +224,7 @@ class NeutronMixin(SynchronizedDeletion, base.ResourceManager):
return self.raw_resource["id"]
def name(self):
return self.raw_resource["name"]
return self.raw_resource.get("name", "")
def delete(self):
delete_method = getattr(self._manager(), "delete_%s" % self._resource)