mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
Removes f5-sdk code from bigip modules (#44595)
This patch is part of an ongoing effort to fully remove the f5sdk from the f5 modules.
This commit is contained in:
parent
4bea004a4e
commit
9c12d845ab
9 changed files with 149 additions and 203 deletions
|
@ -99,6 +99,8 @@ try:
|
|||
from library.module_utils.network.f5.common import cleanup_tokens
|
||||
from library.module_utils.network.f5.common import fq_name
|
||||
from library.module_utils.network.f5.common import f5_argument_spec
|
||||
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
||||
from library.module_utils.compat.ipaddress import ip_network
|
||||
try:
|
||||
from library.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||
except ImportError:
|
||||
|
@ -111,17 +113,13 @@ except ImportError:
|
|||
from ansible.module_utils.network.f5.common import cleanup_tokens
|
||||
from ansible.module_utils.network.f5.common import fq_name
|
||||
from ansible.module_utils.network.f5.common import f5_argument_spec
|
||||
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
||||
from ansible.module_utils.compat.ipaddress import ip_network
|
||||
try:
|
||||
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
|
||||
except ImportError:
|
||||
HAS_F5SDK = False
|
||||
|
||||
try:
|
||||
import netaddr
|
||||
HAS_NETADDR = True
|
||||
except ImportError:
|
||||
HAS_NETADDR = False
|
||||
|
||||
|
||||
class Parameters(AnsibleF5Parameters):
|
||||
api_map = {
|
||||
|
@ -159,9 +157,9 @@ class ModuleParameters(Parameters):
|
|||
if self._values['network'] == 'default':
|
||||
return 'default'
|
||||
try:
|
||||
addr = netaddr.IPNetwork(self._values['network'])
|
||||
addr = ip_network(u"{0}".format(str(self._values['network'])))
|
||||
return str(addr)
|
||||
except netaddr.core.AddrFormatError:
|
||||
except ValueError:
|
||||
raise F5ModuleError(
|
||||
"The 'network' must either be a network address (with CIDR) or the word 'default'."
|
||||
)
|
||||
|
@ -170,12 +168,11 @@ class ModuleParameters(Parameters):
|
|||
def gateway(self):
|
||||
if self._values['gateway'] is None:
|
||||
return None
|
||||
try:
|
||||
addr = netaddr.IPNetwork(self._values['gateway'])
|
||||
return str(addr.ip)
|
||||
except netaddr.core.AddrFormatError:
|
||||
if is_valid_ip(self._values['gateway']):
|
||||
return self._values['gateway']
|
||||
else:
|
||||
raise F5ModuleError(
|
||||
"The 'gateway' must either be an IP address."
|
||||
"The 'gateway' must an IP address."
|
||||
)
|
||||
|
||||
|
||||
|
@ -402,8 +399,6 @@ def main():
|
|||
)
|
||||
if not HAS_F5SDK:
|
||||
module.fail_json(msg="The python f5-sdk module is required")
|
||||
if not HAS_NETADDR:
|
||||
module.fail_json(msg="The python netaddr module is required")
|
||||
|
||||
try:
|
||||
client = F5Client(**module.params)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue