From ec938ef90490fcf4db1e4ef64338b314a93ea8f1 Mon Sep 17 00:00:00 2001 From: Steve Pulec Date: Sun, 29 Dec 2013 08:25:13 -0500 Subject: [PATCH] Convert all EC2Response Mixins to subclasses. --- moto/ec2/responses/amis.py | 3 ++- moto/ec2/responses/availability_zones_and_regions.py | 3 ++- moto/ec2/responses/elastic_block_store.py | 3 ++- moto/ec2/responses/elastic_ip_addresses.py | 4 ++-- moto/ec2/responses/general.py | 3 ++- moto/ec2/responses/instances.py | 3 ++- moto/ec2/responses/security_groups.py | 3 ++- moto/ec2/responses/spot_instances.py | 3 ++- moto/ec2/responses/subnets.py | 3 ++- moto/ec2/responses/tags.py | 3 ++- moto/ec2/responses/vpcs.py | 3 ++- 11 files changed, 22 insertions(+), 12 deletions(-) diff --git a/moto/ec2/responses/amis.py b/moto/ec2/responses/amis.py index 10936e635..74375e1b0 100644 --- a/moto/ec2/responses/amis.py +++ b/moto/ec2/responses/amis.py @@ -1,10 +1,11 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend from moto.ec2.utils import instance_ids_from_querystring, image_ids_from_querystring -class AmisResponse(object): +class AmisResponse(BaseResponse): def create_image(self): name = self.querystring.get('Name')[0] if "Description" in self.querystring: diff --git a/moto/ec2/responses/availability_zones_and_regions.py b/moto/ec2/responses/availability_zones_and_regions.py index f216a644f..1e1b482aa 100644 --- a/moto/ec2/responses/availability_zones_and_regions.py +++ b/moto/ec2/responses/availability_zones_and_regions.py @@ -1,9 +1,10 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend -class AvailabilityZonesAndRegions(object): +class AvailabilityZonesAndRegions(BaseResponse): def describe_availability_zones(self): zones = ec2_backend.describe_availability_zones() template = Template(DESCRIBE_ZONES_RESPONSE) diff --git a/moto/ec2/responses/elastic_block_store.py b/moto/ec2/responses/elastic_block_store.py index 64ad65b30..b179ad13a 100644 --- a/moto/ec2/responses/elastic_block_store.py +++ b/moto/ec2/responses/elastic_block_store.py @@ -1,9 +1,10 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend -class ElasticBlockStore(object): +class ElasticBlockStore(BaseResponse): def attach_volume(self): volume_id = self.querystring.get('VolumeId')[0] instance_id = self.querystring.get('InstanceId')[0] diff --git a/moto/ec2/responses/elastic_ip_addresses.py b/moto/ec2/responses/elastic_ip_addresses.py index 60cdbcf5e..5553ef956 100644 --- a/moto/ec2/responses/elastic_ip_addresses.py +++ b/moto/ec2/responses/elastic_ip_addresses.py @@ -1,11 +1,11 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend from moto.ec2.utils import sequence_from_querystring - -class ElasticIPAddresses(object): +class ElasticIPAddresses(BaseResponse): def allocate_address(self): if "Domain" in self.querystring: domain = self.querystring.get('Domain')[0] diff --git a/moto/ec2/responses/general.py b/moto/ec2/responses/general.py index 5353bb99a..77636655f 100644 --- a/moto/ec2/responses/general.py +++ b/moto/ec2/responses/general.py @@ -1,10 +1,11 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend from moto.ec2.utils import instance_ids_from_querystring -class General(object): +class General(BaseResponse): def get_console_output(self): self.instance_ids = instance_ids_from_querystring(self.querystring) instance_id = self.instance_ids[0] diff --git a/moto/ec2/responses/instances.py b/moto/ec2/responses/instances.py index f230dcf49..85b2b4874 100644 --- a/moto/ec2/responses/instances.py +++ b/moto/ec2/responses/instances.py @@ -1,12 +1,13 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.core.utils import camelcase_to_underscores from moto.ec2.models import ec2_backend from moto.ec2.utils import instance_ids_from_querystring, filters_from_querystring, filter_reservations from moto.ec2.exceptions import InvalidIdError -class InstanceResponse(object): +class InstanceResponse(BaseResponse): def describe_instances(self): instance_ids = instance_ids_from_querystring(self.querystring) if instance_ids: diff --git a/moto/ec2/responses/security_groups.py b/moto/ec2/responses/security_groups.py index 1abda915a..163faa1d9 100644 --- a/moto/ec2/responses/security_groups.py +++ b/moto/ec2/responses/security_groups.py @@ -1,5 +1,6 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend @@ -20,7 +21,7 @@ def process_rules_from_querystring(querystring): return (name, ip_protocol, from_port, to_port, ip_ranges, source_groups) -class SecurityGroups(object): +class SecurityGroups(BaseResponse): def authorize_security_group_egress(self): raise NotImplementedError('SecurityGroups.authorize_security_group_egress is not yet implemented') diff --git a/moto/ec2/responses/spot_instances.py b/moto/ec2/responses/spot_instances.py index 759914989..814bbcbd6 100644 --- a/moto/ec2/responses/spot_instances.py +++ b/moto/ec2/responses/spot_instances.py @@ -1,9 +1,10 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend -class SpotInstances(object): +class SpotInstances(BaseResponse): def _get_param(self, param_name): return self.querystring.get(param_name, [None])[0] diff --git a/moto/ec2/responses/subnets.py b/moto/ec2/responses/subnets.py index 761f492e5..754982214 100644 --- a/moto/ec2/responses/subnets.py +++ b/moto/ec2/responses/subnets.py @@ -1,9 +1,10 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend -class Subnets(object): +class Subnets(BaseResponse): def create_subnet(self): vpc_id = self.querystring.get('VpcId')[0] cidr_block = self.querystring.get('CidrBlock')[0] diff --git a/moto/ec2/responses/tags.py b/moto/ec2/responses/tags.py index dd8dce8e8..6a12cf00c 100644 --- a/moto/ec2/responses/tags.py +++ b/moto/ec2/responses/tags.py @@ -1,10 +1,11 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend from moto.ec2.utils import resource_ids_from_querystring -class TagResponse(object): +class TagResponse(BaseResponse): def create_tags(self): resource_ids = resource_ids_from_querystring(self.querystring) diff --git a/moto/ec2/responses/vpcs.py b/moto/ec2/responses/vpcs.py index c2b16f9cd..1decdb33c 100644 --- a/moto/ec2/responses/vpcs.py +++ b/moto/ec2/responses/vpcs.py @@ -1,9 +1,10 @@ from jinja2 import Template +from moto.core.responses import BaseResponse from moto.ec2.models import ec2_backend -class VPCs(object): +class VPCs(BaseResponse): def create_vpc(self): cidr_block = self.querystring.get('CidrBlock')[0] vpc = ec2_backend.create_vpc(cidr_block)