Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIBCLOUD-572 internet-gateways-filters for ec2 driver #307

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion libcloud/compute/drivers/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3828,16 +3828,36 @@ def ex_find_or_import_keypair_by_key_material(self, pubkey):

return result

def ex_list_internet_gateways(self):
def ex_list_internet_gateways(self, gateway_ids=None, filters=None):
"""
Describes available Internet gateways and whether or not they are
attached to a VPC. These are required for VPC nodes to communicate
over the Internet.

:param gateway_ids: Return only intenet gateways matching the
provided internet gateway IDs. If not
specified, a list of all the internet
gateways in the corresponding region is
returned.
:type gateway_ids: ``list``

:param filters: The filters so that the response includes
information for only certain gateways.
:type filters: ``dict``

:rtype: ``list`` of :class:`.VPCInternetGateway`
"""
params = {'Action': 'DescribeInternetGateways'}

if gateway_ids:
for gateway_idx, gateway_id in enumerate(gateway_ids):
gateway_idx += 1 # We want 1-based indexes
gateway_key = 'InternetGatewayId.%s' % gateway_idx
params[gateway_key] = gateway_id

if filters:
params.update(self._build_filters(filters))

response = self.connection.request(self.path, params=params).object

return self._to_internet_gateways(response, 'internetGatewaySet/item')
Expand Down