mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-06 01:01:32 -07:00
Adds the bigiq_regkey_license module (#34543)
This module can be used to add license offerings to a pool. This is the second part required to license a remote device from a BIG-IQ (the first being to create a pool with bigiq_regkey_pool)
This commit is contained in:
parent
8c07ebe860
commit
f4a2b0b103
3 changed files with 657 additions and 0 deletions
|
@ -0,0 +1,96 @@
|
|||
{
|
||||
"description": "foo bar baz",
|
||||
"dossier": "5d54d976",
|
||||
"encryptedPrivateKey": [
|
||||
27,
|
||||
-10,
|
||||
12,
|
||||
58,
|
||||
75
|
||||
],
|
||||
"generation": 2,
|
||||
"internalPrivateKey": "sKpXEU7",
|
||||
"kind": "cm:device:licensing:pool:regkey:licenses:item:offerings:regkeypoollicenseofferingstate",
|
||||
"lastUpdateMicros": 1513107721123304,
|
||||
"licenseState": {
|
||||
"vendor": "F5 Networks, Inc.",
|
||||
"licensedDateTime": "2017-12-12T00:00:00-08:00",
|
||||
"licensedVersion": "5.3.0",
|
||||
"evaluationStartDateTime": "2017-12-11T00:00:00-08:00",
|
||||
"evaluationEndDateTime": "2018-01-12T00:00:00-08:00",
|
||||
"licenseEndDateTime": "2018-01-12T00:00:00-08:00",
|
||||
"licenseStartDateTime": "2017-12-11T00:00:00-08:00",
|
||||
"registrationKey": "J7217-42420-80195-30148-6427094",
|
||||
"dossier": "1a44262799bc",
|
||||
"authorization": "03fc41d1e8666",
|
||||
"usage": "F5 Internal Product Development",
|
||||
"platformId": "Z100",
|
||||
"authVers": "5b",
|
||||
"serviceCheckDateTime": "2017-12-12T00:00:00-08:00",
|
||||
"serviceStatus": "As of 2017-12-12 there is no active service contract. This may inhibit your ability to upgrade your software.",
|
||||
"exclusivePlatform": [
|
||||
"Z100",
|
||||
"Z100A",
|
||||
"Z100AzureCloud",
|
||||
"Z100GoogleCloud",
|
||||
"Z100K",
|
||||
"Z100x",
|
||||
"Z100H"
|
||||
],
|
||||
"activeModules": [
|
||||
"APM, Max, VE (2500 CCU, 10000 Access Sessions)|P961057-1761515|Anti-Virus Checks",
|
||||
"LTM, 10 Gbps, VE|T487107-2453693|, VE|DNSSEC",
|
||||
"PEM, VE|X895364-1851682"
|
||||
],
|
||||
"optionalModules": [
|
||||
"APM, Base, VE (50 CCU / 200 AS)",
|
||||
"App Mode (TMSH Only, No Root/Bash)",
|
||||
"Concurrent Users",
|
||||
"Concurrent Users and Access Sessions, VE",
|
||||
"FIPS 140-2 Level 1, BIG-IP VE-1G to 10G",
|
||||
"IP Intelligence, 1Yr, VE",
|
||||
"IP Intelligence, 1Yr, VE-10G",
|
||||
"IP Intelligence, 3Yr, VE-10G",
|
||||
"LTM to Better Bundle Upgrade, 10Gbps",
|
||||
"PEM URL Filtering, 1Yr, HIGH PERF",
|
||||
"PEM URL Filtering, 3Yr, HIGH PERF",
|
||||
"Routing Bundle",
|
||||
"Secure Web Gateway, 1Yr, VE",
|
||||
"URL Filtering, 1Yr, VE"
|
||||
],
|
||||
"moduleEvaluations": [
|
||||
{
|
||||
"moduleName": "IP Intelligence, 3Yr, VE|SUBSCRIPTION",
|
||||
"endDate": "soon"
|
||||
},
|
||||
{
|
||||
"moduleName": "Secure Web Gateway, 3Yr, VE|SUBSCRIPTION",
|
||||
"endDate": "soon"
|
||||
},
|
||||
{
|
||||
"moduleName": "URL Filtering, 3Yr, VE|SUBSCRIPTION",
|
||||
"endDate": "soon"
|
||||
}
|
||||
],
|
||||
"featureFlags": [
|
||||
{
|
||||
"featureName": "gtm_rate_limit",
|
||||
"featureValue": "12345"
|
||||
}
|
||||
],
|
||||
"generation": 0,
|
||||
"lastUpdateMicros": 0
|
||||
},
|
||||
"licenseText": "#Auth vers : BIG-IQ Product License File#",
|
||||
"message": "License XXXX-XXXX-XXXX-XXXX-XXXX ready",
|
||||
"name": "License for XXXX-XXXX-XXXX-XXXX-XXXX",
|
||||
"publicKey": [
|
||||
48,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"regKey": "XXXX-XXXX-XXXX-XXXX-XXXX",
|
||||
"selfLink": "https://localhost/mgmt/cm/device/licensing/pool/regkey/licenses/452f8628-1e56-4b4d-946c-0e68f5780aa1/offerings/XXXX-XXXX-XXXX-XXXX-XXXX",
|
||||
"sortName": "Registration Key Pool Item",
|
||||
"status": "READY"
|
||||
}
|
118
test/units/modules/network/f5/test_bigiq_regkey_license.py
Normal file
118
test/units/modules/network/f5/test_bigiq_regkey_license.py
Normal file
|
@ -0,0 +1,118 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright: (c) 2017, F5 Networks Inc.
|
||||
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
import os
|
||||
import json
|
||||
import pytest
|
||||
import sys
|
||||
|
||||
from nose.plugins.skip import SkipTest
|
||||
if sys.version_info < (2, 7):
|
||||
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
||||
|
||||
from ansible.compat.tests import unittest
|
||||
from ansible.compat.tests.mock import Mock
|
||||
from ansible.compat.tests.mock import patch
|
||||
from ansible.module_utils.f5_utils import AnsibleF5Client
|
||||
from ansible.module_utils.f5_utils import F5ModuleError
|
||||
|
||||
try:
|
||||
from library.bigiq_regkey_license import ModuleParameters
|
||||
from library.bigiq_regkey_license import ApiParameters
|
||||
from library.bigiq_regkey_license import ModuleManager
|
||||
from library.bigiq_regkey_license import ArgumentSpec
|
||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||
from test.unit.modules.utils import set_module_args
|
||||
except ImportError:
|
||||
try:
|
||||
from ansible.modules.network.f5.bigiq_regkey_license import ModuleParameters
|
||||
from ansible.modules.network.f5.bigiq_regkey_license import ApiParameters
|
||||
from ansible.modules.network.f5.bigiq_regkey_license import ModuleManager
|
||||
from ansible.modules.network.f5.bigiq_regkey_license import ArgumentSpec
|
||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||
from units.modules.utils import set_module_args
|
||||
except ImportError:
|
||||
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
||||
|
||||
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||
fixture_data = {}
|
||||
|
||||
|
||||
def load_fixture(name):
|
||||
path = os.path.join(fixture_path, name)
|
||||
|
||||
if path in fixture_data:
|
||||
return fixture_data[path]
|
||||
|
||||
with open(path) as f:
|
||||
data = f.read()
|
||||
|
||||
try:
|
||||
data = json.loads(data)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
fixture_data[path] = data
|
||||
return data
|
||||
|
||||
|
||||
class TestParameters(unittest.TestCase):
|
||||
def test_module_parameters(self):
|
||||
args = dict(
|
||||
regkey_pool='foo',
|
||||
license_key='XXXX-XXXX-XXXX-XXXX-XXXX',
|
||||
accept_eula=True,
|
||||
description='this is a description'
|
||||
)
|
||||
|
||||
p = ModuleParameters(args)
|
||||
assert p.regkey_pool == 'foo'
|
||||
assert p.license_key == 'XXXX-XXXX-XXXX-XXXX-XXXX'
|
||||
assert p.accept_eula is True
|
||||
assert p.description == 'this is a description'
|
||||
|
||||
def test_api_parameters(self):
|
||||
args = load_fixture('load_regkey_license_key.json')
|
||||
|
||||
p = ApiParameters(args)
|
||||
assert p.description == 'foo bar baz'
|
||||
|
||||
|
||||
@patch('ansible.module_utils.f5_utils.AnsibleF5Client._get_mgmt_root',
|
||||
return_value=True)
|
||||
class TestManager(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.spec = ArgumentSpec()
|
||||
|
||||
def test_create(self, *args):
|
||||
set_module_args(dict(
|
||||
regkey_pool='foo',
|
||||
license_key='XXXX-XXXX-XXXX-XXXX-XXXX',
|
||||
accept_eula=True,
|
||||
description='this is a description',
|
||||
password='passsword',
|
||||
server='localhost',
|
||||
user='admin'
|
||||
))
|
||||
|
||||
client = AnsibleF5Client(
|
||||
argument_spec=self.spec.argument_spec,
|
||||
supports_check_mode=self.spec.supports_check_mode,
|
||||
f5_product_name=self.spec.f5_product_name
|
||||
)
|
||||
mm = ModuleManager(client)
|
||||
|
||||
# Override methods to force specific logic in the module to happen
|
||||
mm.exists = Mock(side_effect=[False, True])
|
||||
mm.create_on_device = Mock(return_value=True)
|
||||
|
||||
results = mm.exec_module()
|
||||
|
||||
assert results['changed'] is True
|
||||
assert results['description'] == 'this is a description'
|
Loading…
Add table
Add a link
Reference in a new issue