Skip to content

Commit

Permalink
Removing in file cidr tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abhattacharyaNS1 committed Sep 10, 2021
1 parent dfc105a commit 9b18629
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
25 changes: 0 additions & 25 deletions plugins/lookup/aws_service_ip_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@
"""

import json
try:
import netaddr
except ImportError as imp_exc:
NETADDR_LIBRARY_IMPORT_ERROR = imp_exc
else:
NETADDR_LIBRARY_IMPORT_ERROR = None

from ansible.module_utils.six import raise_from
from ansible.errors import AnsibleError
Expand All @@ -61,24 +55,6 @@
from ansible.plugins.lookup import LookupBase


def valid_cidr(ip_address):
"""
Validate IP address
"""
if NETADDR_LIBRARY_IMPORT_ERROR:
raise_from(
AnsibleError('netaddr must be installed to use this plugin'),
NETADDR_LIBRARY_IMPORT_ERROR)
try:
netaddr.IPNetwork(ip_address)
except netaddr.core.AddrFormatError as e:
raise AnsibleError("Not a valid IP address: %s" % e)
cidr = ip_address.split('/')
if (len(cidr) <= 1 or cidr[1] == ''):
return False
return True


class LookupModule(LookupBase):
def run(self, terms, variables, **kwargs):
if "ipv6_prefixes" in kwargs and kwargs["ipv6_prefixes"]:
Expand Down Expand Up @@ -110,6 +86,5 @@ def run(self, terms, variables, **kwargs):
if 'service' in kwargs:
service = str.upper(kwargs['service'])
amazon_response = (item for item in amazon_response if item['service'] == service)

iprange = [item[ip_prefix_label] for item in amazon_response]
return iprange
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
boto>=2.49.0
botocore>=1.16.0
boto3>=1.13.0
netaddr>=0.8.0

0 comments on commit 9b18629

Please sign in to comment.