2013-02-21 03:21:55 +00:00
|
|
|
from urlparse import parse_qs
|
|
|
|
|
2013-02-22 00:34:57 +00:00
|
|
|
from moto.ec2.utils import camelcase_to_underscores, method_namess_from_class
|
2013-02-21 03:21:55 +00:00
|
|
|
|
2013-02-22 04:13:01 +00:00
|
|
|
from .amazon_dev_pay import AmazonDevPay
|
2013-02-23 19:22:09 +00:00
|
|
|
from .amis import AmisResponse
|
2013-02-22 04:13:01 +00:00
|
|
|
from .availability_zonesand_regions import AvailabilityZonesandRegions
|
|
|
|
from .customer_gateways import CustomerGateways
|
|
|
|
from .dhcp_options import DHCPOptions
|
|
|
|
from .elastic_block_store import ElasticBlockStore
|
|
|
|
from .elastic_ip_addresses import ElasticIPAddresses
|
|
|
|
from .elastic_network_interfaces import ElasticNetworkInterfaces
|
|
|
|
from .general import General
|
|
|
|
from .internet_gateways import InternetGateways
|
|
|
|
from .ip_addresses import IPAddresses
|
|
|
|
from .key_pairs import KeyPairs
|
|
|
|
from .monitoring import Monitoring
|
|
|
|
from .network_acls import NetworkACLs
|
|
|
|
from .placement_groups import PlacementGroups
|
|
|
|
from .reserved_instances import ReservedInstances
|
|
|
|
from .route_tables import RouteTables
|
|
|
|
from .security_groups import SecurityGroups
|
|
|
|
from .spot_instances import SpotInstances
|
|
|
|
from .subnets import Subnets
|
|
|
|
from .virtual_private_gateways import VirtualPrivateGateways
|
|
|
|
from .vm_export import VMExport
|
|
|
|
from .vm_import import VMImport
|
|
|
|
from .vpcs import VPCs
|
|
|
|
from .vpn_connections import VPNConnections
|
|
|
|
from .windows import Windows
|
|
|
|
|
2013-02-21 03:21:55 +00:00
|
|
|
from .instances import InstanceResponse
|
2013-02-21 04:19:43 +00:00
|
|
|
from .tags import TagResponse
|
2013-02-21 03:21:55 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EC2Response(object):
|
|
|
|
|
2013-02-23 19:22:09 +00:00
|
|
|
sub_responses = [InstanceResponse, TagResponse, AmisResponse]
|
2013-02-21 03:21:55 +00:00
|
|
|
|
|
|
|
def dispatch(self, uri, body, headers):
|
|
|
|
if body:
|
|
|
|
querystring = parse_qs(body)
|
|
|
|
else:
|
|
|
|
querystring = parse_qs(headers)
|
|
|
|
|
|
|
|
action = querystring['Action'][0]
|
2013-02-22 00:34:57 +00:00
|
|
|
action = camelcase_to_underscores(action)
|
2013-02-21 03:21:55 +00:00
|
|
|
|
|
|
|
for sub_response in self.sub_responses:
|
|
|
|
method_names = method_namess_from_class(sub_response)
|
|
|
|
if action in method_names:
|
|
|
|
response = sub_response(querystring)
|
|
|
|
method = getattr(response, action)
|
|
|
|
return method()
|
2013-02-21 04:19:43 +00:00
|
|
|
import pdb;pdb.set_trace()
|