use the current ec2 backend, not necessarily us-east-1, for vpc operations

This commit is contained in:
Dustin J. Mitchell 2014-10-23 22:26:52 -04:00
parent e67ef8f038
commit ad200286a5

View File

@ -2,27 +2,26 @@ from __future__ import unicode_literals
from jinja2 import Template
from moto.core.responses import BaseResponse
from moto.ec2.models import ec2_backend
from moto.ec2.utils import filters_from_querystring, vpc_ids_from_querystring
class VPCs(BaseResponse):
def create_vpc(self):
cidr_block = self.querystring.get('CidrBlock')[0]
vpc = ec2_backend.create_vpc(cidr_block)
vpc = self.ec2_backend.create_vpc(cidr_block)
template = Template(CREATE_VPC_RESPONSE)
return template.render(vpc=vpc)
def delete_vpc(self):
vpc_id = self.querystring.get('VpcId')[0]
vpc = ec2_backend.delete_vpc(vpc_id)
vpc = self.ec2_backend.delete_vpc(vpc_id)
template = Template(DELETE_VPC_RESPONSE)
return template.render(vpc=vpc)
def describe_vpcs(self):
vpc_ids = vpc_ids_from_querystring(self.querystring)
filters = filters_from_querystring(self.querystring)
vpcs = ec2_backend.get_all_vpcs(vpc_ids=vpc_ids, filters=filters)
vpcs = self.ec2_backend.get_all_vpcs(vpc_ids=vpc_ids, filters=filters)
template = Template(DESCRIBE_VPCS_RESPONSE)
return template.render(vpcs=vpcs)