Convert all EC2Response Mixins to subclasses.

This commit is contained in:
Steve Pulec 2013-12-29 08:25:13 -05:00
parent fefc12457e
commit ec938ef904
11 changed files with 22 additions and 12 deletions

View File

@ -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:

View File

@ -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)

View File

@ -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]

View File

@ -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]

View File

@ -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]

View File

@ -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:

View File

@ -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')

View File

@ -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]

View File

@ -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]

View File

@ -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)

View File

@ -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)