Adds support for enable/disable/describe vpc-classic-link-dns-support.
This commit is contained in:
parent
17cc46b91e
commit
6d52cd06cb
@ -2218,7 +2218,7 @@
|
|||||||
- [ ] describe_volumes_modifications
|
- [ ] describe_volumes_modifications
|
||||||
- [X] describe_vpc_attribute
|
- [X] describe_vpc_attribute
|
||||||
- [X] describe_vpc_classic_link
|
- [X] describe_vpc_classic_link
|
||||||
- [ ] describe_vpc_classic_link_dns_support
|
- [X] describe_vpc_classic_link_dns_support
|
||||||
- [ ] describe_vpc_endpoint_connection_notifications
|
- [ ] describe_vpc_endpoint_connection_notifications
|
||||||
- [ ] describe_vpc_endpoint_connections
|
- [ ] describe_vpc_endpoint_connections
|
||||||
- [ ] describe_vpc_endpoint_service_configurations
|
- [ ] describe_vpc_endpoint_service_configurations
|
||||||
@ -2238,7 +2238,7 @@
|
|||||||
- [ ] disable_transit_gateway_route_table_propagation
|
- [ ] disable_transit_gateway_route_table_propagation
|
||||||
- [ ] disable_vgw_route_propagation
|
- [ ] disable_vgw_route_propagation
|
||||||
- [X] disable_vpc_classic_link
|
- [X] disable_vpc_classic_link
|
||||||
- [ ] disable_vpc_classic_link_dns_support
|
- [X] disable_vpc_classic_link_dns_support
|
||||||
- [X] disassociate_address
|
- [X] disassociate_address
|
||||||
- [ ] disassociate_client_vpn_target_network
|
- [ ] disassociate_client_vpn_target_network
|
||||||
- [ ] disassociate_iam_instance_profile
|
- [ ] disassociate_iam_instance_profile
|
||||||
@ -2251,7 +2251,7 @@
|
|||||||
- [ ] enable_vgw_route_propagation
|
- [ ] enable_vgw_route_propagation
|
||||||
- [ ] enable_volume_io
|
- [ ] enable_volume_io
|
||||||
- [X] enable_vpc_classic_link
|
- [X] enable_vpc_classic_link
|
||||||
- [ ] enable_vpc_classic_link_dns_support
|
- [X] enable_vpc_classic_link_dns_support
|
||||||
- [ ] export_client_vpn_client_certificate_revocation_list
|
- [ ] export_client_vpn_client_certificate_revocation_list
|
||||||
- [ ] export_client_vpn_client_configuration
|
- [ ] export_client_vpn_client_configuration
|
||||||
- [ ] export_image
|
- [ ] export_image
|
||||||
|
@ -2435,6 +2435,7 @@ class VPC(TaggedEC2Resource):
|
|||||||
self.instance_tenancy = instance_tenancy
|
self.instance_tenancy = instance_tenancy
|
||||||
self.is_default = 'true' if is_default else 'false'
|
self.is_default = 'true' if is_default else 'false'
|
||||||
self.enable_dns_support = 'true'
|
self.enable_dns_support = 'true'
|
||||||
|
self.classic_link_enabled = 'false'
|
||||||
# This attribute is set to 'true' only for default VPCs
|
# This attribute is set to 'true' only for default VPCs
|
||||||
# or VPCs created using the wizard of the VPC console
|
# or VPCs created using the wizard of the VPC console
|
||||||
self.enable_dns_hostnames = "true" if is_default else "false"
|
self.enable_dns_hostnames = "true" if is_default else "false"
|
||||||
@ -2546,6 +2547,14 @@ class VPC(TaggedEC2Resource):
|
|||||||
self.classic_link_enabled = "false"
|
self.classic_link_enabled = "false"
|
||||||
return self.classic_link_enabled
|
return self.classic_link_enabled
|
||||||
|
|
||||||
|
def enable_vpc_classic_link_dns_support(self):
|
||||||
|
self.classic_link_dns_supported = 'true'
|
||||||
|
return self.classic_link_dns_supported
|
||||||
|
|
||||||
|
def disable_vpc_classic_link_dns_support(self):
|
||||||
|
self.classic_link_dns_supported = 'false'
|
||||||
|
return self.classic_link_dns_supported
|
||||||
|
|
||||||
def disassociate_vpc_cidr_block(self, association_id):
|
def disassociate_vpc_cidr_block(self, association_id):
|
||||||
if self.cidr_block == self.cidr_block_association_set.get(
|
if self.cidr_block == self.cidr_block_association_set.get(
|
||||||
association_id, {}
|
association_id, {}
|
||||||
@ -2684,6 +2693,14 @@ class VPCBackend(object):
|
|||||||
vpc = self.get_vpc(vpc_id)
|
vpc = self.get_vpc(vpc_id)
|
||||||
return vpc.disable_vpc_classic_link()
|
return vpc.disable_vpc_classic_link()
|
||||||
|
|
||||||
|
def enable_vpc_classic_link_dns_support(self, vpc_id):
|
||||||
|
vpc = self.get_vpc(vpc_id)
|
||||||
|
return vpc.enable_vpc_classic_link_dns_support()
|
||||||
|
|
||||||
|
def disable_vpc_classic_link_dns_support(self, vpc_id):
|
||||||
|
vpc = self.get_vpc(vpc_id)
|
||||||
|
return vpc.disable_vpc_classic_link_dns_support()
|
||||||
|
|
||||||
def modify_vpc_attribute(self, vpc_id, attr_name, attr_value):
|
def modify_vpc_attribute(self, vpc_id, attr_name, attr_value):
|
||||||
vpc = self.get_vpc(vpc_id)
|
vpc = self.get_vpc(vpc_id)
|
||||||
if attr_name in ("enable_dns_support", "enable_dns_hostnames"):
|
if attr_name in ("enable_dns_support", "enable_dns_hostnames"):
|
||||||
|
@ -50,6 +50,28 @@ class VPCs(BaseResponse):
|
|||||||
template = self.response_template(DESCRIBE_VPC_ATTRIBUTE_RESPONSE)
|
template = self.response_template(DESCRIBE_VPC_ATTRIBUTE_RESPONSE)
|
||||||
return template.render(vpc_id=vpc_id, attribute=attribute, value=value)
|
return template.render(vpc_id=vpc_id, attribute=attribute, value=value)
|
||||||
|
|
||||||
|
def describe_vpc_classic_link_dns_support(self):
|
||||||
|
vpc_ids = self._get_multi_param('VpcIds')
|
||||||
|
filters = filters_from_querystring(self.querystring)
|
||||||
|
vpcs = self.ec2_backend.get_all_vpcs(vpc_ids=vpc_ids, filters=filters)
|
||||||
|
doc_date = '2013-10-15' if 'Boto/' in self.headers.get('user-agent', '') else '2016-11-15'
|
||||||
|
template = self.response_template(DESCRIBE_VPC_CLASSIC_LINK_DNS_SUPPORT_RESPONSE)
|
||||||
|
return template.render(vpcs=vpcs, doc_date=doc_date)
|
||||||
|
|
||||||
|
def enable_vpc_classic_link_dns_support(self):
|
||||||
|
vpc_id = self._get_param('VpcId')
|
||||||
|
classic_link_dns_supported = self.ec2_backend.enable_vpc_classic_link_dns_support(vpc_id=vpc_id)
|
||||||
|
doc_date = '2013-10-15' if 'Boto/' in self.headers.get('user-agent', '') else '2016-11-15'
|
||||||
|
template = self.response_template(ENABLE_VPC_CLASSIC_LINK_DNS_SUPPORT_RESPONSE)
|
||||||
|
return template.render(classic_link_dns_supported=classic_link_dns_supported, doc_date=doc_date)
|
||||||
|
|
||||||
|
def disable_vpc_classic_link_dns_support(self):
|
||||||
|
vpc_id = self._get_param('VpcId')
|
||||||
|
classic_link_dns_supported = self.ec2_backend.disable_vpc_classic_link_dns_support(vpc_id=vpc_id)
|
||||||
|
doc_date = '2013-10-15' if 'Boto/' in self.headers.get('user-agent', '') else '2016-11-15'
|
||||||
|
template = self.response_template(DISABLE_VPC_CLASSIC_LINK_DNS_SUPPORT_RESPONSE)
|
||||||
|
return template.render(classic_link_dns_supported=classic_link_dns_supported, doc_date=doc_date)
|
||||||
|
|
||||||
def describe_vpc_classic_link(self):
|
def describe_vpc_classic_link(self):
|
||||||
vpc_ids = self._get_multi_param('VpcId')
|
vpc_ids = self._get_multi_param('VpcId')
|
||||||
filters = filters_from_querystring(self.querystring)
|
filters = filters_from_querystring(self.querystring)
|
||||||
@ -171,6 +193,31 @@ CREATE_VPC_RESPONSE = """
|
|||||||
</vpc>
|
</vpc>
|
||||||
</CreateVpcResponse>"""
|
</CreateVpcResponse>"""
|
||||||
|
|
||||||
|
DESCRIBE_VPC_CLASSIC_LINK_DNS_SUPPORT_RESPONSE = """
|
||||||
|
<DescribeVpcClassicLinkDnsSupportResponse xmlns="http://ec2.amazonaws.com/doc/{{doc_date}}/">
|
||||||
|
<requestId>7a62c442-3484-4f42-9342-6942EXAMPLE</requestId>
|
||||||
|
<vpcs>
|
||||||
|
{% for vpc in vpcs %}
|
||||||
|
<item>
|
||||||
|
<vpcId>{{ vpc.id }}</vpcId>
|
||||||
|
<classicLinkDnsSupported>{{ vpc.classic_link_dns_supported }}</classicLinkDnsSupported>
|
||||||
|
</item>
|
||||||
|
{% endfor %}
|
||||||
|
</vpcs>
|
||||||
|
</DescribeVpcClassicLinkDnsSupportResponse>"""
|
||||||
|
|
||||||
|
ENABLE_VPC_CLASSIC_LINK_DNS_SUPPORT_RESPONSE = """
|
||||||
|
<EnableVpcClassicLinkDnsSupportResponse xmlns="http://ec2.amazonaws.com/doc/{{doc_date}}/">
|
||||||
|
<requestId>7a62c442-3484-4f42-9342-6942EXAMPLE</requestId>
|
||||||
|
<return>{{ classic_link_dns_supported }}</return>
|
||||||
|
</EnableVpcClassicLinkDnsSupportResponse>"""
|
||||||
|
|
||||||
|
DISABLE_VPC_CLASSIC_LINK_DNS_SUPPORT_RESPONSE = """
|
||||||
|
<DisableVpcClassicLinkDnsSupportResponse xmlns="http://ec2.amazonaws.com/doc/{{doc_date}}/">
|
||||||
|
<requestId>7a62c442-3484-4f42-9342-6942EXAMPLE</requestId>
|
||||||
|
<return>{{ classic_link_dns_supported }}</return>
|
||||||
|
</DisableVpcClassicLinkDnsSupportResponse>"""
|
||||||
|
|
||||||
DESCRIBE_VPC_CLASSIC_LINK_RESPONSE = """
|
DESCRIBE_VPC_CLASSIC_LINK_RESPONSE = """
|
||||||
<DescribeVpcClassicLinkResponse xmlns="http://ec2.amazonaws.com/doc/{{doc_date}}/">
|
<DescribeVpcClassicLinkResponse xmlns="http://ec2.amazonaws.com/doc/{{doc_date}}/">
|
||||||
<requestId>7a62c442-3484-4f42-9342-6942EXAMPLE</requestId>
|
<requestId>7a62c442-3484-4f42-9342-6942EXAMPLE</requestId>
|
||||||
|
@ -746,3 +746,63 @@ def test_describe_classic_link_multiple():
|
|||||||
response = ec2.meta.client.describe_vpc_classic_link(VpcIds=[vpc1.id, vpc2.id])
|
response = ec2.meta.client.describe_vpc_classic_link(VpcIds=[vpc1.id, vpc2.id])
|
||||||
assert response.get('Vpcs')[0].get('ClassicLinkEnabled').should.be.false
|
assert response.get('Vpcs')[0].get('ClassicLinkEnabled').should.be.false
|
||||||
assert response.get('Vpcs')[1].get('ClassicLinkEnabled').should.be.true
|
assert response.get('Vpcs')[1].get('ClassicLinkEnabled').should.be.true
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_enable_vpc_classic_link_dns_support():
|
||||||
|
ec2 = boto3.resource('ec2', region_name='us-west-1')
|
||||||
|
|
||||||
|
# Create VPC
|
||||||
|
vpc = ec2.create_vpc(CidrBlock='10.1.0.0/16')
|
||||||
|
|
||||||
|
response = ec2.meta.client.enable_vpc_classic_link_dns_support(VpcId=vpc.id)
|
||||||
|
assert response.get('Return').should.be.true
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_disable_vpc_classic_link_dns_support():
|
||||||
|
ec2 = boto3.resource('ec2', region_name='us-west-1')
|
||||||
|
|
||||||
|
# Create VPC
|
||||||
|
vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
|
||||||
|
|
||||||
|
ec2.meta.client.enable_vpc_classic_link_dns_support(VpcId=vpc.id)
|
||||||
|
response = ec2.meta.client.disable_vpc_classic_link_dns_support(VpcId=vpc.id)
|
||||||
|
assert response.get('Return').should.be.false
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_describe_classic_link_dns_support_enabled():
|
||||||
|
ec2 = boto3.resource('ec2', region_name='us-west-1')
|
||||||
|
|
||||||
|
# Create VPC
|
||||||
|
vpc = ec2.create_vpc(CidrBlock='10.0.0.0/16')
|
||||||
|
|
||||||
|
ec2.meta.client.enable_vpc_classic_link_dns_support(VpcId=vpc.id)
|
||||||
|
response = ec2.meta.client.describe_vpc_classic_link_dns_support(VpcIds=[vpc.id])
|
||||||
|
assert response.get('Vpcs')[0].get('ClassicLinkDnsSupported').should.be.true
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_describe_classic_link_dns_support_disabled():
|
||||||
|
ec2 = boto3.resource('ec2', region_name='us-west-1')
|
||||||
|
|
||||||
|
# Create VPC
|
||||||
|
vpc = ec2.create_vpc(CidrBlock='10.90.0.0/16')
|
||||||
|
|
||||||
|
response = ec2.meta.client.describe_vpc_classic_link_dns_support(VpcIds=[vpc.id])
|
||||||
|
assert response.get('Vpcs')[0].get('ClassicLinkDnsSupported').should.be.false
|
||||||
|
|
||||||
|
|
||||||
|
@mock_ec2
|
||||||
|
def test_describe_classic_link_dns_support_multiple():
|
||||||
|
ec2 = boto3.resource('ec2', region_name='us-west-1')
|
||||||
|
|
||||||
|
# Create VPC
|
||||||
|
vpc1 = ec2.create_vpc(CidrBlock='10.90.0.0/16')
|
||||||
|
vpc2 = ec2.create_vpc(CidrBlock='10.0.0.0/16')
|
||||||
|
|
||||||
|
ec2.meta.client.enable_vpc_classic_link_dns_support(VpcId=vpc2.id)
|
||||||
|
response = ec2.meta.client.describe_vpc_classic_link_dns_support(VpcIds=[vpc1.id, vpc2.id])
|
||||||
|
assert response.get('Vpcs')[0].get('ClassicLinkDnsSupported').should.be.false
|
||||||
|
assert response.get('Vpcs')[1].get('ClassicLinkDnsSupported').should.be.true
|
||||||
|
Loading…
Reference in New Issue
Block a user