Implement ImageId parameter in DescribeImages
This commit is contained in:
parent
b5a454e0da
commit
a63601e481
@ -215,8 +215,12 @@ class AmiBackend(object):
|
||||
self.amis[ami_id] = ami
|
||||
return ami
|
||||
|
||||
def describe_images(self):
|
||||
return self.amis.values()
|
||||
def describe_images(self, ami_ids=None):
|
||||
if ami_ids:
|
||||
images = [image for image in self.amis.values() if image.id in ami_ids]
|
||||
else:
|
||||
images = self.amis.values()
|
||||
return images
|
||||
|
||||
def deregister_image(self, ami_id):
|
||||
if ami_id in self.amis:
|
||||
|
@ -1,7 +1,7 @@
|
||||
from jinja2 import Template
|
||||
|
||||
from moto.ec2.models import ec2_backend
|
||||
from moto.ec2.utils import instance_ids_from_querystring
|
||||
from moto.ec2.utils import instance_ids_from_querystring, image_ids_from_querystring
|
||||
|
||||
|
||||
class AmisResponse(object):
|
||||
@ -33,7 +33,8 @@ class AmisResponse(object):
|
||||
raise NotImplementedError('AMIs.describe_image_attribute is not yet implemented')
|
||||
|
||||
def describe_images(self):
|
||||
images = ec2_backend.describe_images()
|
||||
ami_ids = image_ids_from_querystring(self.querystring)
|
||||
images = ec2_backend.describe_images(ami_ids=ami_ids)
|
||||
template = Template(DESCRIBE_IMAGES_RESPONSE)
|
||||
return template.render(images=images)
|
||||
|
||||
|
@ -54,6 +54,14 @@ def instance_ids_from_querystring(querystring_dict):
|
||||
return instance_ids
|
||||
|
||||
|
||||
def image_ids_from_querystring(querystring_dict):
|
||||
image_ids = []
|
||||
for key, value in querystring_dict.iteritems():
|
||||
if 'ImageId' in key:
|
||||
image_ids.append(value[0])
|
||||
return image_ids
|
||||
|
||||
|
||||
def resource_ids_from_querystring(querystring_dict):
|
||||
prefix = 'ResourceId'
|
||||
response_values = {}
|
||||
|
Loading…
Reference in New Issue
Block a user