Added support for filtering AMIs by self (#1398)

* Added support for filtering AMIs by self

Closes: https://github.com/spulec/moto/issues/1396

* Adjusted regex to also match signature v4 and fixed py3 compatibility
This commit is contained in:
Nuwan Goonasekera 2018-01-04 15:31:17 +05:30 committed by Terry Cain
commit 56ce26a728
4 changed files with 44 additions and 6 deletions

View file

@ -11,7 +11,7 @@ class AmisResponse(BaseResponse):
instance_id = self._get_param('InstanceId')
if self.is_not_dryrun('CreateImage'):
image = self.ec2_backend.create_image(
instance_id, name, description)
instance_id, name, description, context=self)
template = self.response_template(CREATE_IMAGE_RESPONSE)
return template.render(image=image)
@ -39,7 +39,8 @@ class AmisResponse(BaseResponse):
owners = self._get_multi_param('Owner')
exec_users = self._get_multi_param('ExecutableBy')
images = self.ec2_backend.describe_images(
ami_ids=ami_ids, filters=filters, exec_users=exec_users, owners=owners)
ami_ids=ami_ids, filters=filters, exec_users=exec_users,
owners=owners, context=self)
template = self.response_template(DESCRIBE_IMAGES_RESPONSE)
return template.render(images=images)