2022-04-04 11:17:22 +01:00
|
|
|
from moto.ec2.exceptions import InvalidParameterValueErrorUnknownAttribute
|
2022-03-24 12:57:13 -01:00
|
|
|
from moto.ec2.utils import get_attribute_value, add_tag_specification
|
|
|
|
from ._base_response import EC2BaseResponse
|
2013-02-21 23:13:01 -05:00
|
|
|
|
|
|
|
|
2022-03-24 12:57:13 -01:00
|
|
|
class ElasticNetworkInterfaces(EC2BaseResponse):
|
2023-02-16 20:43:43 -01:00
|
|
|
def create_network_interface(self) -> str:
|
2017-09-16 18:31:30 +05:30
|
|
|
subnet_id = self._get_param("SubnetId")
|
|
|
|
private_ip_address = self._get_param("PrivateIpAddress")
|
2019-11-08 16:40:17 +00:00
|
|
|
private_ip_addresses = self._get_multi_param("PrivateIpAddresses")
|
2021-11-11 02:20:47 +05:30
|
|
|
ipv6_addresses = self._get_multi_param("Ipv6Addresses")
|
|
|
|
ipv6_address_count = self._get_int_param("Ipv6AddressCount", 0)
|
|
|
|
secondary_ips_count = self._get_param("SecondaryPrivateIpAddressCount")
|
2017-09-16 17:08:21 +05:30
|
|
|
groups = self._get_multi_param("SecurityGroupId")
|
2014-10-30 22:46:24 -04:00
|
|
|
subnet = self.ec2_backend.get_subnet(subnet_id)
|
2019-07-15 00:01:37 +02:00
|
|
|
description = self._get_param("Description")
|
2023-02-16 20:43:43 -01:00
|
|
|
tags = add_tag_specification(self._get_multi_param("TagSpecification"))
|
2021-09-17 02:37:18 +05:30
|
|
|
|
2023-02-14 12:43:28 -01:00
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
eni = self.ec2_backend.create_network_interface(
|
|
|
|
subnet,
|
|
|
|
private_ip_address,
|
|
|
|
private_ip_addresses,
|
|
|
|
groups,
|
|
|
|
description,
|
|
|
|
tags,
|
|
|
|
secondary_ips_count=secondary_ips_count,
|
|
|
|
ipv6_addresses=ipv6_addresses,
|
|
|
|
ipv6_address_count=ipv6_address_count,
|
|
|
|
)
|
|
|
|
template = self.response_template(CREATE_NETWORK_INTERFACE_RESPONSE)
|
|
|
|
return template.render(eni=eni)
|
2013-02-21 23:13:01 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def delete_network_interface(self) -> str:
|
2017-09-16 18:31:30 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
2023-02-14 12:43:28 -01:00
|
|
|
|
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
self.ec2_backend.delete_network_interface(eni_id)
|
|
|
|
template = self.response_template(DELETE_NETWORK_INTERFACE_RESPONSE)
|
|
|
|
return template.render()
|
2013-02-21 23:13:01 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def describe_network_interface_attribute(self) -> str:
|
2022-04-04 11:17:22 +01:00
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
|
|
|
attribute = self._get_param("Attribute")
|
2023-02-14 12:43:28 -01:00
|
|
|
|
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
eni = self.ec2_backend.get_all_network_interfaces([eni_id])[0]
|
|
|
|
|
|
|
|
if attribute == "description":
|
|
|
|
template = self.response_template(
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_DESCRIPTION
|
|
|
|
)
|
|
|
|
elif attribute == "groupSet":
|
|
|
|
template = self.response_template(
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_GROUPSET
|
|
|
|
)
|
|
|
|
elif attribute == "sourceDestCheck":
|
|
|
|
template = self.response_template(
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_SOURCEDESTCHECK
|
|
|
|
)
|
|
|
|
elif attribute == "attachment":
|
|
|
|
template = self.response_template(
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_ATTACHMENT
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
raise InvalidParameterValueErrorUnknownAttribute(attribute)
|
2022-04-04 11:17:22 +01:00
|
|
|
return template.render(eni=eni)
|
2013-02-21 23:13:01 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def describe_network_interfaces(self) -> str:
|
2017-09-16 17:08:21 +05:30
|
|
|
eni_ids = self._get_multi_param("NetworkInterfaceId")
|
2022-03-24 12:57:13 -01:00
|
|
|
filters = self._filters_from_querystring()
|
2023-02-14 12:43:28 -01:00
|
|
|
|
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
enis = self.ec2_backend.get_all_network_interfaces(eni_ids, filters)
|
|
|
|
template = self.response_template(DESCRIBE_NETWORK_INTERFACES_RESPONSE)
|
|
|
|
return template.render(enis=enis)
|
2013-02-21 23:13:01 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def attach_network_interface(self) -> str:
|
2017-09-16 18:31:30 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
|
|
|
instance_id = self._get_param("InstanceId")
|
|
|
|
device_index = self._get_param("DeviceIndex")
|
2023-02-14 12:43:28 -01:00
|
|
|
|
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
attachment_id = self.ec2_backend.attach_network_interface(
|
|
|
|
eni_id, instance_id, device_index
|
|
|
|
)
|
|
|
|
template = self.response_template(ATTACH_NETWORK_INTERFACE_RESPONSE)
|
|
|
|
return template.render(attachment_id=attachment_id)
|
2014-09-12 10:53:37 -07:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def detach_network_interface(self) -> str:
|
2017-09-16 18:31:30 +05:30
|
|
|
attachment_id = self._get_param("AttachmentId")
|
2023-02-14 12:43:28 -01:00
|
|
|
|
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
self.ec2_backend.detach_network_interface(attachment_id)
|
|
|
|
template = self.response_template(DETACH_NETWORK_INTERFACE_RESPONSE)
|
|
|
|
return template.render()
|
2013-02-21 23:13:01 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def modify_network_interface_attribute(self) -> str:
|
2017-09-16 18:31:30 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
2021-05-07 13:50:26 +01:00
|
|
|
group_ids = self._get_multi_param("SecurityGroupId")
|
2021-11-11 02:20:47 +05:30
|
|
|
source_dest_check = get_attribute_value("SourceDestCheck", self.querystring)
|
|
|
|
description = get_attribute_value("Description", self.querystring)
|
2023-02-14 12:43:28 -01:00
|
|
|
|
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
self.ec2_backend.modify_network_interface_attribute(
|
|
|
|
eni_id, group_ids, source_dest_check, description
|
|
|
|
)
|
|
|
|
return MODIFY_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE
|
2013-02-21 23:13:01 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def reset_network_interface_attribute(self) -> str:
|
2023-02-14 12:43:28 -01:00
|
|
|
self.error_on_dryrun()
|
|
|
|
|
|
|
|
raise NotImplementedError(
|
|
|
|
"ElasticNetworkInterfaces(AmazonVPC).reset_network_interface_attribute is not yet implemented"
|
|
|
|
)
|
2017-02-23 21:37:43 -05:00
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def assign_private_ip_addresses(self) -> str:
|
2021-11-11 02:20:47 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
|
|
|
secondary_ips_count = self._get_int_param("SecondaryPrivateIpAddressCount", 0)
|
2023-04-03 10:16:31 +01:00
|
|
|
private_ip_addresses = self._get_multi_param("PrivateIpAddress")
|
|
|
|
eni = self.ec2_backend.assign_private_ip_addresses(
|
|
|
|
eni_id, private_ip_addresses, secondary_ips_count
|
|
|
|
)
|
2021-11-11 02:20:47 +05:30
|
|
|
template = self.response_template(ASSIGN_PRIVATE_IP_ADDRESSES)
|
|
|
|
return template.render(eni=eni)
|
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def unassign_private_ip_addresses(self) -> str:
|
2021-11-11 02:20:47 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
|
|
|
private_ip_address = self._get_multi_param("PrivateIpAddress")
|
|
|
|
eni = self.ec2_backend.unassign_private_ip_addresses(eni_id, private_ip_address)
|
|
|
|
template = self.response_template(UNASSIGN_PRIVATE_IP_ADDRESSES)
|
|
|
|
return template.render(eni=eni)
|
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def assign_ipv6_addresses(self) -> str:
|
2021-11-11 02:20:47 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
|
|
|
ipv6_count = self._get_int_param("Ipv6AddressCount", 0)
|
|
|
|
ipv6_addresses = self._get_multi_param("Ipv6Addresses")
|
|
|
|
eni = self.ec2_backend.assign_ipv6_addresses(eni_id, ipv6_addresses, ipv6_count)
|
|
|
|
template = self.response_template(ASSIGN_IPV6_ADDRESSES)
|
|
|
|
return template.render(eni=eni)
|
|
|
|
|
2023-02-16 20:43:43 -01:00
|
|
|
def unassign_ipv6_addresses(self) -> str:
|
2021-11-11 02:20:47 +05:30
|
|
|
eni_id = self._get_param("NetworkInterfaceId")
|
|
|
|
ips = self._get_multi_param("Ipv6Addresses")
|
2023-02-03 12:06:38 -01:00
|
|
|
eni = self.ec2_backend.unassign_ipv6_addresses(eni_id, ips)
|
2021-11-11 02:20:47 +05:30
|
|
|
template = self.response_template(UNASSIGN_IPV6_ADDRESSES)
|
2023-02-03 12:06:38 -01:00
|
|
|
return template.render(eni=eni, unassigned_ips=ips)
|
2021-11-11 02:20:47 +05:30
|
|
|
|
|
|
|
|
|
|
|
ASSIGN_PRIVATE_IP_ADDRESSES = """<AssignPrivateIpAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
|
|
|
|
<requestId>3fb591ba-558c-48f8-ae6b-c2f9d6d06425</requestId>
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<assignedPrivateIpAddressesSet>
|
|
|
|
{% for address in eni.private_ip_addresses %}
|
|
|
|
<item>
|
|
|
|
<privateIpAddress>{{ address.PrivateIpAddress }}</privateIpAddress>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</assignedPrivateIpAddressesSet>
|
|
|
|
<return>true</return>
|
|
|
|
</AssignPrivateIpAddressesResponse>"""
|
|
|
|
|
|
|
|
|
|
|
|
UNASSIGN_PRIVATE_IP_ADDRESSES = """<UnAssignPrivateIpAddressesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
|
|
|
|
<requestId>3fb591ba-558c-48f8-ae6b-c2f9d6d06425</requestId>
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<assignedPrivateIpAddressesSet>
|
|
|
|
{% for address in eni.private_ip_addresses %}
|
|
|
|
<item>
|
|
|
|
<privateIpAddress>{{ address.PrivateIpAddress }}</privateIpAddress>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</assignedPrivateIpAddressesSet>
|
|
|
|
<return>true</return>
|
|
|
|
</UnAssignPrivateIpAddressesResponse>"""
|
|
|
|
|
|
|
|
|
|
|
|
ASSIGN_IPV6_ADDRESSES = """<AssignIpv6AddressesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
|
|
|
|
<requestId>c36d17eb-a0ba-4d38-8727-example</requestId>
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<assignedIpv6Addresses>
|
|
|
|
{% for address in eni.ipv6_addresses %}
|
|
|
|
<item>{{address}}</item>
|
|
|
|
{% endfor %}
|
|
|
|
</assignedIpv6Addresses>
|
|
|
|
</AssignIpv6AddressesResponse>
|
|
|
|
"""
|
|
|
|
|
|
|
|
UNASSIGN_IPV6_ADDRESSES = """<UnassignIpv6AddressesResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
|
|
|
|
<requestId>94d446d7-fc8e-4918-94f9-example</requestId>
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<unassignedIpv6Addresses>
|
|
|
|
{% for address in unassigned_ips %}
|
|
|
|
<item>{{address}}</item>
|
|
|
|
{% endfor %}
|
|
|
|
</unassignedIpv6Addresses>
|
|
|
|
</UnassignIpv6AddressesResponse>"""
|
|
|
|
|
2014-09-08 16:50:18 -07:00
|
|
|
|
|
|
|
CREATE_NETWORK_INTERFACE_RESPONSE = """
|
2016-02-02 16:15:18 +03:00
|
|
|
<CreateNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-09-08 16:50:18 -07:00
|
|
|
<requestId>2c6021ec-d705-445a-9780-420d0c7ab793</requestId>
|
|
|
|
<networkInterface>
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<subnetId>{{ eni.subnet.id }}</subnetId>
|
|
|
|
<vpcId>{{ eni.subnet.vpc_id }}</vpcId>
|
2021-09-17 02:37:18 +05:30
|
|
|
<availabilityZone>{{ eni.subnet.availability_zone }}</availabilityZone>
|
2019-07-15 00:01:37 +02:00
|
|
|
{% if eni.description %}
|
|
|
|
<description>{{ eni.description }}</description>
|
|
|
|
{% endif %}
|
2021-09-17 02:37:18 +05:30
|
|
|
<ownerId>{{ eni.owner_id }}</ownerId>
|
|
|
|
<requesterId>AIDARCSPW2WNREUEN7XFM</requesterId>
|
|
|
|
<requesterManaged>False</requesterManaged>
|
|
|
|
<status>{{ eni.status }}</status>
|
|
|
|
<macAddress>{{ eni.mac_address }}</macAddress>
|
2014-09-08 16:50:18 -07:00
|
|
|
{% if eni.private_ip_address %}
|
|
|
|
<privateIpAddress>{{ eni.private_ip_address }}</privateIpAddress>
|
|
|
|
{% endif %}
|
2021-11-11 02:20:47 +05:30
|
|
|
{% if eni.private_dns_name %}
|
|
|
|
<privateDnsName>{{ eni.private_dns_name }}</privateDnsName>
|
|
|
|
{% endif %}
|
|
|
|
<sourceDestCheck>{{ "true" if eni.source_dest_check == True else "false" }}</sourceDestCheck>
|
2014-09-08 16:50:18 -07:00
|
|
|
<groupSet>
|
|
|
|
{% for group in eni.group_set %}
|
|
|
|
<item>
|
|
|
|
<groupId>{{ group.id }}</groupId>
|
|
|
|
<groupName>{{ group.name }}</groupName>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</groupSet>
|
2021-09-17 02:37:18 +05:30
|
|
|
{% if eni.association %}
|
|
|
|
<association>
|
|
|
|
<publicIp>{{ eni.public_ip }}</publicIp>
|
|
|
|
<ipOwnerId>{{ eni.owner_id }}</ipOwnerId>
|
|
|
|
<allocationId>{{ eni.association.allocationId }}</allocationId>
|
|
|
|
<associationId>{{ eni.association.associationId }}</associationId>
|
|
|
|
<natEnabled>true</natEnabled>
|
|
|
|
</association>
|
|
|
|
{% endif %}
|
|
|
|
<tagSet>
|
|
|
|
{% for tag in eni.get_tags() %}
|
2014-09-08 16:50:18 -07:00
|
|
|
<item>
|
2021-09-17 02:37:18 +05:30
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
2014-09-08 16:50:18 -07:00
|
|
|
</item>
|
2021-09-17 02:37:18 +05:30
|
|
|
{% endfor %}
|
|
|
|
</tagSet>
|
|
|
|
<privateIpAddressesSet>
|
|
|
|
{% for address in eni.private_ip_addresses %}
|
|
|
|
<item>
|
|
|
|
<privateIpAddress>{{ address.PrivateIpAddress }}</privateIpAddress>
|
|
|
|
{% if address.privateDnsName %}
|
2021-11-11 02:20:47 +05:30
|
|
|
<privateDnsName>{{ address.PrivateDnsName }}</privateDnsName>
|
2021-09-17 02:37:18 +05:30
|
|
|
{% endif %}
|
2021-11-11 02:20:47 +05:30
|
|
|
<primary>{{ "true" if address.Primary == True else "false" }}</primary>
|
2021-09-17 02:37:18 +05:30
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</privateIpAddressesSet>
|
2021-11-11 02:20:47 +05:30
|
|
|
<ipv6AddressesSet>
|
|
|
|
{% for address in eni.ipv6_addresses %}
|
|
|
|
<item>
|
|
|
|
<ipv6Address>{{address}}</ipv6Address>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</ipv6AddressesSet>
|
2021-09-17 02:37:18 +05:30
|
|
|
<interfaceType>{{ eni.interface_type }}</interfaceType>
|
2014-09-08 16:50:18 -07:00
|
|
|
</networkInterface>
|
|
|
|
</CreateNetworkInterfaceResponse>
|
|
|
|
"""
|
|
|
|
|
2016-02-02 16:15:18 +03:00
|
|
|
DESCRIBE_NETWORK_INTERFACES_RESPONSE = """<DescribeNetworkInterfacesResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-09-08 16:50:18 -07:00
|
|
|
<requestId>ddb0aaf1-8b65-4f0a-94fa-654b18b8a204</requestId>
|
|
|
|
<networkInterfaceSet>
|
|
|
|
{% for eni in enis %}
|
|
|
|
<item>
|
2021-11-11 02:20:47 +05:30
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<subnetId>{{ eni.subnet.id }}</subnetId>
|
|
|
|
<vpcId>{{ eni.subnet.vpc_id }}</vpcId>
|
|
|
|
<availabilityZone>{{ eni.subnet.availability_zone }}</availabilityZone>
|
|
|
|
{% if eni.description %}
|
|
|
|
<description>{{ eni.description }}</description>
|
|
|
|
{% endif %}
|
|
|
|
<ownerId>{{ eni.owner_id }}</ownerId>
|
|
|
|
<requesterId>AIDARCSPW2WNREUEN7XFM</requesterId>
|
|
|
|
<requesterManaged>False</requesterManaged>
|
|
|
|
<status>{{ eni.status }}</status>
|
|
|
|
<macAddress>{{ eni.mac_address }}</macAddress>
|
|
|
|
{% if eni.private_ip_address %}
|
2021-09-17 02:37:18 +05:30
|
|
|
<privateIpAddress>{{ eni.private_ip_address }}</privateIpAddress>
|
2021-11-11 02:20:47 +05:30
|
|
|
{% endif %}
|
|
|
|
{% if eni.private_dns_name %}
|
|
|
|
<privateDnsName>{{ eni.private_dns_name }}</privateDnsName>
|
|
|
|
{% endif %}
|
|
|
|
<sourceDestCheck>{{ "true" if eni.source_dest_check == True else "false" }}</sourceDestCheck>
|
|
|
|
<groupSet>
|
|
|
|
{% for group in eni.group_set %}
|
|
|
|
<item>
|
|
|
|
<groupId>{{ group.id }}</groupId>
|
|
|
|
<groupName>{{ group.name }}</groupName>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</groupSet>
|
|
|
|
{% if eni.association %}
|
|
|
|
<association>
|
|
|
|
<publicIp>{{ eni.public_ip }}</publicIp>
|
|
|
|
<ipOwnerId>{{ eni.owner_id }}</ipOwnerId>
|
|
|
|
<allocationId>{{ eni.association.allocationId }}</allocationId>
|
|
|
|
<associationId>{{ eni.association.associationId }}</associationId>
|
|
|
|
<natEnabled>true</natEnabled>
|
|
|
|
</association>
|
|
|
|
{% endif %}
|
2022-04-04 11:17:22 +01:00
|
|
|
{% if eni.attachment_id %}
|
|
|
|
<attachment>
|
|
|
|
<attachTime>{{ eni.attach_time }}</attachTime>
|
|
|
|
<attachmentId>{{ eni.attachment_id }}</attachmentId>
|
|
|
|
<deleteOnTermination>{{ eni.delete_on_termination }}</deleteOnTermination>
|
|
|
|
<deviceIndex>{{ eni.device_index }}</deviceIndex>
|
|
|
|
<networkCardIndex>0</networkCardIndex>
|
|
|
|
<instanceId>{{ eni.instance.id }}</instanceId>
|
|
|
|
<instanceOwnerId>{{ eni.instance.owner_id }}</instanceOwnerId>
|
|
|
|
<status>attached</status>
|
|
|
|
</attachment>
|
|
|
|
{% endif %}
|
2021-11-11 02:20:47 +05:30
|
|
|
<tagSet>
|
2021-09-17 02:37:18 +05:30
|
|
|
{% for tag in eni.get_tags() %}
|
2016-05-08 00:19:01 +02:00
|
|
|
<item>
|
2021-09-17 02:37:18 +05:30
|
|
|
<key>{{ tag.key }}</key>
|
|
|
|
<value>{{ tag.value }}</value>
|
2016-05-08 00:19:01 +02:00
|
|
|
</item>
|
2021-09-17 02:37:18 +05:30
|
|
|
{% endfor %}
|
2021-11-11 02:20:47 +05:30
|
|
|
</tagSet>
|
|
|
|
<privateIpAddressesSet>
|
2021-09-17 02:37:18 +05:30
|
|
|
{% for address in eni.private_ip_addresses %}
|
|
|
|
<item>
|
2021-11-11 02:20:47 +05:30
|
|
|
<privateIpAddress>{{ address.PrivateIpAddress }}</privateIpAddress>
|
|
|
|
{% if address.privateDnsName %}
|
|
|
|
<privateDnsName>{{ address.PrivateDnsName }}</privateDnsName>
|
|
|
|
{% endif %}
|
|
|
|
<primary>{{ "true" if address.Primary == True else "false" }}</primary>
|
2021-09-17 02:37:18 +05:30
|
|
|
</item>
|
|
|
|
{% endfor %}
|
2021-11-11 02:20:47 +05:30
|
|
|
</privateIpAddressesSet>
|
|
|
|
<ipv6AddressesSet>
|
|
|
|
{% for address in eni.ipv6_addresses %}
|
|
|
|
<item>
|
|
|
|
<ipv6Address>{{address}}</ipv6Address>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</ipv6AddressesSet>
|
|
|
|
<interfaceType>{{ eni.interface_type }}</interfaceType>
|
2014-09-08 16:50:18 -07:00
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</networkInterfaceSet>
|
|
|
|
</DescribeNetworkInterfacesResponse>"""
|
|
|
|
|
2016-02-02 16:15:18 +03:00
|
|
|
ATTACH_NETWORK_INTERFACE_RESPONSE = """<AttachNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-09-12 10:53:37 -07:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<attachmentId>{{ attachment_id }}</attachmentId>
|
|
|
|
</AttachNetworkInterfaceResponse>"""
|
|
|
|
|
2016-02-02 16:15:18 +03:00
|
|
|
DETACH_NETWORK_INTERFACE_RESPONSE = """<DetachNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-09-12 10:53:37 -07:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<return>true</return>
|
|
|
|
</DetachNetworkInterfaceResponse>"""
|
|
|
|
|
2016-02-02 16:15:18 +03:00
|
|
|
MODIFY_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE = """<ModifyNetworkInterfaceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-09-08 16:50:18 -07:00
|
|
|
<requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
|
|
|
|
<return>true</return>
|
|
|
|
</ModifyNetworkInterfaceAttributeResponse>"""
|
|
|
|
|
|
|
|
DELETE_NETWORK_INTERFACE_RESPONSE = """
|
2016-02-02 16:15:18 +03:00
|
|
|
<DeleteNetworkInterfaceResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
2014-09-08 16:50:18 -07:00
|
|
|
<requestId>34b5b3b4-d0c5-49b9-b5e2-a468ef6adcd8</requestId>
|
|
|
|
<return>true</return>
|
|
|
|
</DeleteNetworkInterfaceResponse>"""
|
2022-04-04 11:17:22 +01:00
|
|
|
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_DESCRIPTION = """
|
|
|
|
<DescribeNetworkInterfaceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<description>
|
|
|
|
<value>{{ eni.description }}</value>
|
|
|
|
</description>
|
|
|
|
</DescribeNetworkInterfaceAttributeResponse>"""
|
|
|
|
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_GROUPSET = """
|
|
|
|
<DescribeNetworkInterfaceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<groupSet>
|
|
|
|
{% for group in eni.group_set %}
|
|
|
|
<item>
|
|
|
|
<groupId>{{ group.id }}</groupId>
|
|
|
|
<groupName>{{ group.name }}</groupName>
|
|
|
|
</item>
|
|
|
|
{% endfor %}
|
|
|
|
</groupSet>
|
|
|
|
</DescribeNetworkInterfaceAttributeResponse>"""
|
|
|
|
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_SOURCEDESTCHECK = """
|
|
|
|
<DescribeNetworkInterfaceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
<sourceDestCheck>
|
|
|
|
<value>{{ "true" if eni.source_dest_check == True else "false" }}</value>
|
|
|
|
</sourceDestCheck>
|
|
|
|
</DescribeNetworkInterfaceAttributeResponse>"""
|
|
|
|
|
|
|
|
DESCRIBE_NETWORK_INTERFACE_ATTRIBUTE_RESPONSE_ATTACHMENT = """
|
|
|
|
<DescribeNetworkInterfaceAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2013-10-15/">
|
|
|
|
<networkInterfaceId>{{ eni.id }}</networkInterfaceId>
|
|
|
|
{% if eni.attachment_id %}
|
|
|
|
<attachment>
|
|
|
|
<attachTime>{{ eni.attach_time }}</attachTime>
|
|
|
|
<attachmentId>{{ eni.attachment_id }}</attachmentId>
|
|
|
|
<deleteOnTermination>{{ eni.delete_on_termination }}</deleteOnTermination>
|
|
|
|
<deviceIndex>{{ eni.device_index }}</deviceIndex>
|
|
|
|
<networkCardIndex>0</networkCardIndex>
|
|
|
|
<instanceId>{{ eni.instance.id }}</instanceId>
|
|
|
|
<instanceOwnerId>{{ eni.instance.owner_id }}</instanceOwnerId>
|
|
|
|
<status>attached</status>
|
|
|
|
</attachment>
|
|
|
|
{% endif %}
|
|
|
|
</DescribeNetworkInterfaceAttributeResponse>"""
|