diff options
author | Nathaniel Case <this.is@nathanielca.se> | 2021-02-03 17:33:16 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-03 22:33:16 +0000 |
commit | 4e8356f7ae00e55ea7554b9c817141035e40826b (patch) | |
tree | 11d019653381ff0fb021011c160adf6cef321f5b /plugins | |
parent | 52457c14d33ec6387a693368eeb090c6b58eb443 (diff) | |
download | vyos-ansible-old-4e8356f7ae00e55ea7554b9c817141035e40826b.tar.gz vyos-ansible-old-4e8356f7ae00e55ea7554b9c817141035e40826b.zip |
Remove reliance on netcommon's ipaddress (#120)
Remove reliance on netcommon's ipaddress
Reviewed-by: https://github.com/apps/ansible-zuul
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/module_utils/network/vyos/utils/utils.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/module_utils/network/vyos/utils/utils.py b/plugins/module_utils/network/vyos/utils/utils.py index 7ce4688..f6ac9f5 100644 --- a/plugins/module_utils/network/vyos/utils/utils.py +++ b/plugins/module_utils/network/vyos/utils/utils.py @@ -8,9 +8,14 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type from ansible.module_utils.six import iteritems -from ansible_collections.ansible.netcommon.plugins.module_utils.compat import ( - ipaddress, -) +from ansible.module_utils.basic import missing_required_lib + +try: + import ipaddress + + HAS_IPADDRESS = True +except ImportError: + HAS_IPADDRESS = False def search_obj_in_list(name, lst, key="name"): @@ -212,6 +217,9 @@ def get_ip_address_version(address): :param address: IP address :return: """ + if not HAS_IPADDRESS: + raise Exception(missing_required_lib("ipaddress")) + try: address = unicode(address) except NameError: |