summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/network/f5/bigip_partition.py
diff options
context:
space:
mode:
authorWojciech Wypior <w.wypior@f5.com>2019-03-19 07:12:17 +0100
committerTim Rupp <caphrim007@gmail.com>2019-03-18 23:12:17 -0700
commit348b6e7da9694eb95f98dbc2f4d60808a2a2f542 (patch)
tree861f806b86dc2b44e62436702e868797ec6fc288 /lib/ansible/modules/network/f5/bigip_partition.py
parent1a411e9c6b9d3aef4c3b8ff8611c5df3877f7dc3 (diff)
downloadansible-348b6e7da9694eb95f98dbc2f4d60808a2a2f542.tar.gz
Refactors main() function and module manager in multiple modules in line with recent changes (#53982)
Adds variable types to docs Refactors unit tests to remove deprecated parameters
Diffstat (limited to 'lib/ansible/modules/network/f5/bigip_partition.py')
-rw-r--r--lib/ansible/modules/network/f5/bigip_partition.py24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/ansible/modules/network/f5/bigip_partition.py b/lib/ansible/modules/network/f5/bigip_partition.py
index bf11f849ea..6a8caa0cf5 100644
--- a/lib/ansible/modules/network/f5/bigip_partition.py
+++ b/lib/ansible/modules/network/f5/bigip_partition.py
@@ -23,22 +23,26 @@ options:
name:
description:
- Name of the partition
+ type: str
required: True
description:
description:
- The description to attach to the Partition.
+ type: str
route_domain:
description:
- The default Route Domain to assign to the Partition. If no route domain
is specified, then the default route domain for the system (typically
zero) will be used only when creating a new partition.
+ type: int
state:
description:
- Whether the partition should exist or not.
- default: present
+ type: str
choices:
- present
- absent
+ default: present
notes:
- Requires BIG-IP software version >= 12
extends_documentation_fragment: f5
@@ -118,18 +122,12 @@ try:
from library.module_utils.network.f5.common import F5ModuleError
from library.module_utils.network.f5.common import AnsibleF5Parameters
from library.module_utils.network.f5.common import f5_argument_spec
- from library.module_utils.network.f5.common import cleanup_tokens
- 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.compare import cmp_str_with_none
except ImportError:
from ansible.module_utils.network.f5.bigip import F5RestClient
from ansible.module_utils.network.f5.common import F5ModuleError
from ansible.module_utils.network.f5.common import AnsibleF5Parameters
from ansible.module_utils.network.f5.common import f5_argument_spec
- from ansible.module_utils.network.f5.common import cleanup_tokens
- from ansible.module_utils.network.f5.common import exit_json
- from ansible.module_utils.network.f5.common import fail_json
from ansible.module_utils.network.f5.compare import cmp_str_with_none
@@ -238,7 +236,7 @@ class Difference(object):
class ModuleManager(object):
def __init__(self, *args, **kwargs):
self.module = kwargs.get('module', None)
- self.client = kwargs.get('client', None)
+ self.client = F5RestClient(**self.module.params)
self.want = ModuleParameters(params=self.module.params)
self.have = ApiParameters()
self.changes = UsableChanges()
@@ -486,16 +484,12 @@ def main():
supports_check_mode=spec.supports_check_mode
)
- client = F5RestClient(**module.params)
-
try:
- mm = ModuleManager(module=module, client=client)
+ mm = ModuleManager(module=module)
results = mm.exec_module()
- cleanup_tokens(client)
- exit_json(module, results, client)
+ module.exit_json(**results)
except F5ModuleError as ex:
- cleanup_tokens(client)
- fail_json(module, ex, client)
+ module.fail_json(msg=str(ex))
if __name__ == '__main__':