Refactor AmiBackend.describe_images: make logic of missing image simpler
This commit is contained in:
parent
90aa87d53e
commit
4e88d79da2
@ -219,14 +219,14 @@ class AmiBackend(object):
|
|||||||
self.amis[ami_id] = ami
|
self.amis[ami_id] = ami
|
||||||
return ami
|
return ami
|
||||||
|
|
||||||
def describe_images(self, ami_ids=None):
|
def describe_images(self, ami_ids=()):
|
||||||
if ami_ids:
|
images = []
|
||||||
images = [image for image in self.amis.values() if image.id in ami_ids]
|
for ami_id in ami_ids:
|
||||||
for missing_ami in set(ami_ids) - set(ami.id for ami in images):
|
if ami_id in self.amis:
|
||||||
raise InvalidIdError(missing_ami)
|
images.append(self.amis[ami_id])
|
||||||
else:
|
else:
|
||||||
images = self.amis.values()
|
raise InvalidIdError(ami_id)
|
||||||
return images
|
return images or self.amis.values()
|
||||||
|
|
||||||
def deregister_image(self, ami_id):
|
def deregister_image(self, ami_id):
|
||||||
if ami_id in self.amis:
|
if ami_id in self.amis:
|
||||||
|
Loading…
Reference in New Issue
Block a user