mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Move redudant check_ip_addr method to common ce (#25575)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
a51d64dfe3
commit
8ad04d6348
10 changed files with 32 additions and 212 deletions
|
@ -243,12 +243,10 @@ changed:
|
|||
sample: true
|
||||
'''
|
||||
|
||||
import sys
|
||||
import re
|
||||
import socket
|
||||
from xml.etree import ElementTree
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.ce import get_nc_config, set_nc_config, ce_argument_spec
|
||||
from ansible.module_utils.ce import get_nc_config, set_nc_config, ce_argument_spec, check_ip_addr
|
||||
from ansible.module_utils.ce import get_config, load_config
|
||||
|
||||
CE_NC_GET_SFLOW = """
|
||||
|
@ -331,26 +329,6 @@ def is_valid_ip_vpn(vpname):
|
|||
return True
|
||||
|
||||
|
||||
def check_ip_addr(ipaddr):
|
||||
"""check ip address, Supports IPv4 and IPv6"""
|
||||
|
||||
if not ipaddr or '\x00' in ipaddr:
|
||||
return False
|
||||
|
||||
try:
|
||||
res = socket.getaddrinfo(ipaddr, 0, socket.AF_UNSPEC,
|
||||
socket.SOCK_STREAM,
|
||||
0, socket.AI_NUMERICHOST)
|
||||
return bool(res)
|
||||
except socket.gaierror:
|
||||
err = sys.exc_info()[1]
|
||||
if err.args[0] == socket.EAI_NONAME:
|
||||
return False
|
||||
raise
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def get_ip_version(address):
|
||||
"""get ip version fast"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue