diff --git a/lib/ansible/modules/network/f5/bigip_ucs.py b/lib/ansible/modules/network/f5/bigip_ucs.py index 299d51a9ead..2c5ffe5df8d 100644 --- a/lib/ansible/modules/network/f5/bigip_ucs.py +++ b/lib/ansible/modules/network/f5/bigip_ucs.py @@ -4,14 +4,18 @@ # 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 + + ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'} -DOCUMENTATION = ''' +DOCUMENTATION = r''' --- module: bigip_ucs -short_description: Manage upload, installation and removal of UCS files. +short_description: Manage upload, installation and removal of UCS files description: - Manage upload, installation and removal of UCS files. version_added: "2.4" @@ -112,84 +116,91 @@ author: - Tim Rupp (@caphrim007) ''' -EXAMPLES = ''' +EXAMPLES = r''' - name: Upload UCS bigip_ucs: - server: "lb.mydomain.com" - user: "admin" - password: "secret" - ucs: "/root/bigip.localhost.localdomain.ucs" - state: "present" + server: lb.mydomain.com + user: admin + password: secret + ucs: /root/bigip.localhost.localdomain.ucs + state: present delegate_to: localhost - name: Install (upload, install) UCS. bigip_ucs: - server: "lb.mydomain.com" - user: "admin" - password: "secret" - ucs: "/root/bigip.localhost.localdomain.ucs" - state: "installed" + server: lb.mydomain.com + user: admin + password: secret + ucs: /root/bigip.localhost.localdomain.ucs + state: installed delegate_to: localhost - name: Install (upload, install) UCS without installing the license portion bigip_ucs: - server: "lb.mydomain.com" - user: "admin" - password: "secret" - ucs: "/root/bigip.localhost.localdomain.ucs" - state: "installed" - no_license: "yes" + server: lb.mydomain.com + user: admin + password: secret + ucs: /root/bigip.localhost.localdomain.ucs + state: installed + no_license: yes delegate_to: localhost - name: Install (upload, install) UCS except the license, and bypassing the platform check bigip_ucs: - server: "lb.mydomain.com" - user: "admin" - password: "secret" - ucs: "/root/bigip.localhost.localdomain.ucs" - state: "installed" - no_license: "yes" - no_platform_check: "yes" + server: lb.mydomain.com + user: admin + password: secret + ucs: /root/bigip.localhost.localdomain.ucs + state: installed + no_license: yes + no_platform_check: yes delegate_to: localhost - name: Install (upload, install) UCS using a passphrase necessary to load the UCS bigip_ucs: - server: "lb.mydomain.com" - user: "admin" - password: "secret" - ucs: "/root/bigip.localhost.localdomain.ucs" - state: "installed" - passphrase: "MyPassphrase1234" + server: lb.mydomain.com + user: admin + password: secret + ucs: /root/bigip.localhost.localdomain.ucs + state: installed + passphrase: MyPassphrase1234 delegate_to: localhost - name: Remove uploaded UCS file bigip_ucs: - server: "lb.mydomain.com" - user: "admin" - password: "secret" - ucs: "bigip.localhost.localdomain.ucs" - state: "absent" + server: lb.mydomain.com + user: admin + password: secret + ucs: bigip.localhost.localdomain.ucs + state: absent delegate_to: localhost ''' -RETURN = ''' +RETURN = r''' # only common fields returned ''' import os import re +import sys import time -from collections import OrderedDict from distutils.version import LooseVersion -from ansible.module_utils.f5_utils import ( - AnsibleF5Client, - AnsibleF5Parameters, - HAS_F5SDK, - F5ModuleError, - iControlUnexpectedHTTPError, - iteritems -) +from ansible.module_utils.f5_utils import AnsibleF5Client +from ansible.module_utils.f5_utils import AnsibleF5Parameters +from ansible.module_utils.f5_utils import HAS_F5SDK +from ansible.module_utils.f5_utils import F5ModuleError +from ansible.module_utils.six import iteritems + +try: + from collections import OrderedDict +except ImportError: + pass + +try: + from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError +except ImportError: + HAS_F5SDK = False class Parameters(AnsibleF5Parameters): @@ -250,7 +261,6 @@ class Parameters(AnsibleF5Parameters): cmd = 'tmsh load sys ucs /var/local/ucs/{0}'.format(self.basename) # Append any options that might be specified options = OrderedDict(sorted(self.options.items(), key=lambda t: t[0])) - print(options) for k, v in iteritems(options): if v is False or v is None: continue @@ -578,6 +588,9 @@ def main(): if not HAS_F5SDK: raise F5ModuleError("The python f5-sdk module is required") + if sys.version_info < (2, 7): + raise F5ModuleError("F5 Ansible modules require Python >= 2.7") + spec = ArgumentSpec() client = AnsibleF5Client( diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index c4398c0866a..d7813bfd298 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -23,7 +23,6 @@ lib/ansible/modules/network/f5/bigip_provision.py lib/ansible/modules/network/f5/bigip_qkview.py lib/ansible/modules/network/f5/bigip_snmp.py lib/ansible/modules/network/f5/bigip_snmp_trap.py -lib/ansible/modules/network/f5/bigip_ucs.py lib/ansible/modules/network/ios/ios_static_route.py lib/ansible/modules/network/lenovo/cnos_backup.py lib/ansible/modules/network/lenovo/cnos_bgp.py diff --git a/test/units/modules/network/f5/test_bigip_ucs.py b/test/units/modules/network/f5/test_bigip_ucs.py index 922cda57b5b..e4e69cc604b 100644 --- a/test/units/modules/network/f5/test_bigip_ucs.py +++ b/test/units/modules/network/f5/test_bigip_ucs.py @@ -1,21 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright 2017 F5 Networks Inc. -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see . +# 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 @@ -42,6 +28,7 @@ try: from library.bigip_ucs import ArgumentSpec from library.bigip_ucs import V1Manager from library.bigip_ucs import V2Manager + from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError except ImportError: try: from ansible.modules.network.f5.bigip_ucs import Parameters @@ -49,6 +36,7 @@ except ImportError: from ansible.modules.network.f5.bigip_ucs import ArgumentSpec from ansible.modules.network.f5.bigip_ucs import V1Manager from ansible.modules.network.f5.bigip_ucs import V2Manager + from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError except ImportError: raise SkipTest("F5 Ansible modules require the f5-sdk Python library")