|
|
|
|
@ -15,7 +15,7 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|
|
|
|
DOCUMENTATION = r'''
|
|
|
|
|
---
|
|
|
|
|
module: bigiq_regkey_license_assignment
|
|
|
|
|
short_description: Manage regkey license assignment on BIG-IPs from a BIG-IQ.
|
|
|
|
|
short_description: Manage regkey license assignment on BIG-IPs from a BIG-IQ
|
|
|
|
|
description:
|
|
|
|
|
- Manages the assignment of regkey licenses on a BIG-IQ. Assignment means that
|
|
|
|
|
the license is assigned to a BIG-IP, or, it needs to be assigned to a BIG-IP.
|
|
|
|
|
@ -89,7 +89,7 @@ EXAMPLES = r'''
|
|
|
|
|
user: admin
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
|
|
|
|
|
- name: Register an managed device, by name
|
|
|
|
|
- name: Register a managed device, by name
|
|
|
|
|
bigiq_regkey_license_assignment:
|
|
|
|
|
pool: my-regkey-pool
|
|
|
|
|
key: XXXX-XXXX-XXXX-XXXX-XXXX
|
|
|
|
|
@ -101,7 +101,7 @@ EXAMPLES = r'''
|
|
|
|
|
user: admin
|
|
|
|
|
delegate_to: localhost
|
|
|
|
|
|
|
|
|
|
- name: Register an managed device, by UUID
|
|
|
|
|
- name: Register a managed device, by UUID
|
|
|
|
|
bigiq_regkey_license_assignment:
|
|
|
|
|
pool: my-regkey-pool
|
|
|
|
|
key: XXXX-XXXX-XXXX-XXXX-XXXX
|
|
|
|
|
@ -119,6 +119,7 @@ RETURN = r'''
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
from ansible.module_utils.basic import AnsibleModule
|
|
|
|
|
|
|
|
|
|
@ -129,6 +130,7 @@ try:
|
|
|
|
|
from library.module_utils.network.f5.common import f5_argument_spec
|
|
|
|
|
from library.module_utils.network.f5.common import exit_json
|
|
|
|
|
from library.module_utils.network.f5.common import fail_json
|
|
|
|
|
from library.module_utils.network.f5.ipaddress import is_valid_ip
|
|
|
|
|
except ImportError:
|
|
|
|
|
from ansible.module_utils.network.f5.bigiq import F5RestClient
|
|
|
|
|
from ansible.module_utils.network.f5.common import F5ModuleError
|
|
|
|
|
@ -136,11 +138,7 @@ except ImportError:
|
|
|
|
|
from ansible.module_utils.network.f5.common import f5_argument_spec
|
|
|
|
|
from ansible.module_utils.network.f5.common import exit_json
|
|
|
|
|
from ansible.module_utils.network.f5.common import fail_json
|
|
|
|
|
try:
|
|
|
|
|
import netaddr
|
|
|
|
|
HAS_NETADDR = True
|
|
|
|
|
except ImportError:
|
|
|
|
|
HAS_NETADDR = False
|
|
|
|
|
from ansible.module_utils.network.f5.ipaddress import is_valid_ip
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Parameters(AnsibleF5Parameters):
|
|
|
|
|
@ -205,11 +203,9 @@ class ModuleParameters(Parameters):
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def device_is_address(self):
|
|
|
|
|
try:
|
|
|
|
|
netaddr.IPAddress(self.device)
|
|
|
|
|
if is_valid_ip(self.device):
|
|
|
|
|
return True
|
|
|
|
|
except (ValueError, netaddr.core.AddrFormatError):
|
|
|
|
|
return False
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
@property
|
|
|
|
|
def device_is_id(self):
|
|
|
|
|
@ -484,6 +480,10 @@ class ModuleManager(object):
|
|
|
|
|
self.remove_from_device()
|
|
|
|
|
if self.exists():
|
|
|
|
|
raise F5ModuleError("Failed to delete the resource.")
|
|
|
|
|
# Artificial sleeping to wait for remote licensing (on BIG-IP) to complete
|
|
|
|
|
#
|
|
|
|
|
# This should be something that BIG-IQ can do natively in 6.1-ish time.
|
|
|
|
|
time.sleep(60)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def create(self):
|
|
|
|
|
@ -505,6 +505,11 @@ class ModuleManager(object):
|
|
|
|
|
"Failed to license the remote device."
|
|
|
|
|
)
|
|
|
|
|
self.wait_for_device_to_be_licensed()
|
|
|
|
|
|
|
|
|
|
# Artificial sleeping to wait for remote licensing (on BIG-IP) to complete
|
|
|
|
|
#
|
|
|
|
|
# This should be something that BIG-IQ can do natively in 6.1-ish time.
|
|
|
|
|
time.sleep(60)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def create_on_device(self):
|
|
|
|
|
@ -530,7 +535,7 @@ class ModuleManager(object):
|
|
|
|
|
if 'message' in response:
|
|
|
|
|
raise F5ModuleError(response['message'])
|
|
|
|
|
else:
|
|
|
|
|
raise F5ModuleError(resp._content)
|
|
|
|
|
raise F5ModuleError(resp.content)
|
|
|
|
|
|
|
|
|
|
def wait_for_device_to_be_licensed(self):
|
|
|
|
|
count = 0
|
|
|
|
|
@ -552,7 +557,7 @@ class ModuleManager(object):
|
|
|
|
|
if 'message' in response:
|
|
|
|
|
raise F5ModuleError(response['message'])
|
|
|
|
|
else:
|
|
|
|
|
raise F5ModuleError(resp._content)
|
|
|
|
|
raise F5ModuleError(resp.content)
|
|
|
|
|
if response['status'] == 'LICENSED':
|
|
|
|
|
count += 1
|
|
|
|
|
else:
|
|
|
|
|
@ -611,11 +616,9 @@ def main():
|
|
|
|
|
supports_check_mode=spec.supports_check_mode,
|
|
|
|
|
required_if=spec.required_if
|
|
|
|
|
)
|
|
|
|
|
if not HAS_NETADDR:
|
|
|
|
|
module.fail_json(msg="The python netaddr module is required")
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
client = F5RestClient(module=module)
|
|
|
|
|
client = F5RestClient(**module.params)
|
|
|
|
|
mm = ModuleManager(module=module, client=client)
|
|
|
|
|
results = mm.exec_module()
|
|
|
|
|
exit_json(module, results, client)
|
|
|
|
|
|