Merge remote-tracking branch 'origin/master' into ImproveTemplatePerformance
Conflicts: moto/s3/responses.py
This commit is contained in:
commit
7ce83082ca
9 changed files with 129 additions and 20 deletions
|
|
@ -1817,12 +1817,12 @@ class RouteTableBackend(object):
|
|||
|
||||
class Route(object):
|
||||
def __init__(self, route_table, destination_cidr_block, local=False,
|
||||
internet_gateway=None, instance=None, interface=None, vpc_pcx=None):
|
||||
gateway=None, instance=None, interface=None, vpc_pcx=None):
|
||||
self.id = generate_route_id(route_table.id, destination_cidr_block)
|
||||
self.route_table = route_table
|
||||
self.destination_cidr_block = destination_cidr_block
|
||||
self.local = local
|
||||
self.internet_gateway = internet_gateway
|
||||
self.gateway = gateway
|
||||
self.instance = instance
|
||||
self.interface = interface
|
||||
self.vpc_pcx = vpc_pcx
|
||||
|
|
@ -1861,8 +1861,15 @@ class RouteBackend(object):
|
|||
if interface_id:
|
||||
self.raise_not_implemented_error("CreateRoute to NetworkInterfaceId")
|
||||
|
||||
gateway = None
|
||||
if gateway_id:
|
||||
if EC2_RESOURCE_TO_PREFIX['vpn-gateway'] in gateway_id:
|
||||
gateway = self.get_vpn_gateway(gateway_id)
|
||||
elif EC2_RESOURCE_TO_PREFIX['internet-gateway'] in gateway_id:
|
||||
gateway = self.get_internet_gateway(gateway_id)
|
||||
|
||||
route = Route(route_table, destination_cidr_block, local=local,
|
||||
internet_gateway=self.get_internet_gateway(gateway_id) if gateway_id else None,
|
||||
gateway=gateway,
|
||||
instance=self.get_instance(instance_id) if instance_id else None,
|
||||
interface=None,
|
||||
vpc_pcx=self.get_vpc_peering_connection(vpc_peering_connection_id) if vpc_peering_connection_id else None)
|
||||
|
|
@ -1879,7 +1886,13 @@ class RouteBackend(object):
|
|||
if interface_id:
|
||||
self.raise_not_implemented_error("ReplaceRoute to NetworkInterfaceId")
|
||||
|
||||
route.internet_gateway = self.get_internet_gateway(gateway_id) if gateway_id else None
|
||||
route.gateway = None
|
||||
if gateway_id:
|
||||
if EC2_RESOURCE_TO_PREFIX['vpn-gateway'] in gateway_id:
|
||||
route.gateway = self.get_vpn_gateway(gateway_id)
|
||||
elif EC2_RESOURCE_TO_PREFIX['internet-gateway'] in gateway_id:
|
||||
route.gateway = self.get_internet_gateway(gateway_id)
|
||||
|
||||
route.instance = self.get_instance(instance_id) if instance_id else None
|
||||
route.interface = None
|
||||
route.vpc_pcx = self.get_vpc_peering_connection(vpc_peering_connection_id) if vpc_peering_connection_id else None
|
||||
|
|
|
|||
|
|
@ -16,13 +16,13 @@ class RouteTables(BaseResponse):
|
|||
route_table_id = self.querystring.get('RouteTableId')[0]
|
||||
destination_cidr_block = self.querystring.get('DestinationCidrBlock')[0]
|
||||
|
||||
internet_gateway_id = optional_from_querystring('GatewayId', self.querystring)
|
||||
gateway_id = optional_from_querystring('GatewayId', self.querystring)
|
||||
instance_id = optional_from_querystring('InstanceId', self.querystring)
|
||||
interface_id = optional_from_querystring('NetworkInterfaceId', self.querystring)
|
||||
pcx_id = optional_from_querystring('VpcPeeringConnectionId', self.querystring)
|
||||
|
||||
self.ec2_backend.create_route(route_table_id, destination_cidr_block,
|
||||
gateway_id=internet_gateway_id,
|
||||
gateway_id=gateway_id,
|
||||
instance_id=instance_id,
|
||||
interface_id=interface_id,
|
||||
vpc_peering_connection_id=pcx_id)
|
||||
|
|
@ -66,13 +66,13 @@ class RouteTables(BaseResponse):
|
|||
route_table_id = self.querystring.get('RouteTableId')[0]
|
||||
destination_cidr_block = self.querystring.get('DestinationCidrBlock')[0]
|
||||
|
||||
internet_gateway_id = optional_from_querystring('GatewayId', self.querystring)
|
||||
gateway_id = optional_from_querystring('GatewayId', self.querystring)
|
||||
instance_id = optional_from_querystring('InstanceId', self.querystring)
|
||||
interface_id = optional_from_querystring('NetworkInterfaceId', self.querystring)
|
||||
pcx_id = optional_from_querystring('VpcPeeringConnectionId', self.querystring)
|
||||
|
||||
self.ec2_backend.replace_route(route_table_id, destination_cidr_block,
|
||||
gateway_id=internet_gateway_id,
|
||||
gateway_id=gateway_id,
|
||||
instance_id=instance_id,
|
||||
interface_id=interface_id,
|
||||
vpc_peering_connection_id=pcx_id)
|
||||
|
|
@ -151,8 +151,8 @@ DESCRIBE_ROUTE_TABLES_RESPONSE = """
|
|||
<origin>CreateRouteTable</origin>
|
||||
<state>active</state>
|
||||
{% endif %}
|
||||
{% if route.internet_gateway %}
|
||||
<gatewayId>{{ route.internet_gateway.id }}</gatewayId>
|
||||
{% if route.gateway %}
|
||||
<gatewayId>{{ route.gateway.id }}</gatewayId>
|
||||
<origin>CreateRoute</origin>
|
||||
<state>active</state>
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -324,16 +324,20 @@ filter_dict_attribute_mapping = {
|
|||
'state-reason-code': '_state_reason.code',
|
||||
'source-dest-check': 'source_dest_check',
|
||||
'vpc-id': 'vpc_id',
|
||||
'group-id': 'security_groups',
|
||||
'instance.group-id': 'security_groups'
|
||||
}
|
||||
|
||||
|
||||
def passes_filter_dict(instance, filter_dict):
|
||||
for filter_name, filter_values in filter_dict.items():
|
||||
|
||||
if filter_name in filter_dict_attribute_mapping:
|
||||
instance_attr = filter_dict_attribute_mapping[filter_name]
|
||||
instance_value = get_object_value(instance, instance_attr)
|
||||
if instance_value not in filter_values:
|
||||
if not instance_value_in_filter_values(instance_value, filter_values):
|
||||
return False
|
||||
|
||||
elif is_tag_filter(filter_name):
|
||||
if not tag_filter_matches(instance, filter_name, filter_values):
|
||||
return False
|
||||
|
|
@ -343,6 +347,13 @@ def passes_filter_dict(instance, filter_dict):
|
|||
filter_name)
|
||||
return True
|
||||
|
||||
def instance_value_in_filter_values(instance_value, filter_values):
|
||||
if isinstance(instance_value, list):
|
||||
if not set(filter_values).intersection(set(instance_value)):
|
||||
return False
|
||||
elif instance_value not in filter_values:
|
||||
return False
|
||||
return True
|
||||
|
||||
def filter_reservations(reservations, filter_dict):
|
||||
result = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue