From d5d4683047978bc95aa2dc0db50f1712aa03e845 Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Wed, 1 Nov 2017 15:20:28 -0700 Subject: [PATCH] Removes bigip_snmp_trap from skip file (#32470) --- .../modules/network/f5/bigip_snmp_trap.py | 105 ++++++++++-------- test/sanity/import/skip.txt | 1 - .../network/f5/test_bigip_snmp_trap.py | 20 +--- 3 files changed, 60 insertions(+), 66 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_snmp_trap.py b/lib/ansible/modules/network/f5/bigip_snmp_trap.py index deda06697b..e051f69931 100644 --- a/lib/ansible/modules/network/f5/bigip_snmp_trap.py +++ b/lib/ansible/modules/network/f5/bigip_snmp_trap.py @@ -4,13 +4,17 @@ # 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_snmp_trap -short_description: Manipulate SNMP trap information on a BIG-IP. +short_description: Manipulate SNMP trap information on a BIG-IP description: - Manipulate SNMP trap information on a BIG-IP. version_added: 2.4 @@ -67,70 +71,73 @@ author: - Tim Rupp (@caphrim007) ''' -EXAMPLES = ''' +EXAMPLES = r''' - name: Create snmp v1 trap bigip_snmp_trap: - community: "general" - destination: "1.2.3.4" - name: "my-trap1" - network: "management" - port: "9000" - snmp_version: "1" - server: "lb.mydomain.com" - user: "admin" - password: "secret" + community: general + destination: 1.2.3.4 + name: my-trap1 + network: management + port: 9000 + snmp_version: 1 + server: lb.mydomain.com + user: admin + password: secret delegate_to: localhost - name: Create snmp v2 trap bigip_snmp_trap: - community: "general" - destination: "5.6.7.8" - name: "my-trap2" - network: "default" - port: "7000" - snmp_version: "2c" - server: "lb.mydomain.com" - user: "admin" - password: "secret" + community: general + destination: 5.6.7.8 + name: my-trap2 + network: default + port: 7000 + snmp_version: 2c + server: lb.mydomain.com + user: admin + password: secret delegate_to: localhost ''' -RETURN = ''' +RETURN = r''' snmp_version: - description: The new C(snmp_version) configured on the remote device. - returned: changed and success - type: string - sample: "2c" + description: The new C(snmp_version) configured on the remote device. + returned: changed and success + type: string + sample: 2c community: - description: The new C(community) name for the trap destination. - returned: changed and success - type: list - sample: "secret" + description: The new C(community) name for the trap destination. + returned: changed and success + type: list + sample: secret destination: - description: The new address for the trap destination in either IP or hostname form. - returned: changed and success - type: string - sample: "1.2.3.4" + description: The new address for the trap destination in either IP or hostname form. + returned: changed and success + type: string + sample: 1.2.3.4 port: - description: The new C(port) of the trap destination. - returned: changed and success - type: string - sample: "900" + description: The new C(port) of the trap destination. + returned: changed and success + type: string + sample: 900 network: - description: The new name of the network the SNMP trap is on. - returned: changed and success - type: string - sample: "management" + description: The new name of the network the SNMP trap is on. + returned: changed and success + type: string + sample: management ''' + +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 distutils.version import LooseVersion -from ansible.module_utils.f5_utils import ( - AnsibleF5Client, - AnsibleF5Parameters, - HAS_F5SDK, - F5ModuleError, - iControlUnexpectedHTTPError -) + +try: + from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError +except ImportError: + HAS_F5SDK = False class Parameters(AnsibleF5Parameters): diff --git a/test/sanity/import/skip.txt b/test/sanity/import/skip.txt index d7813bfd29..2155696c19 100644 --- a/test/sanity/import/skip.txt +++ b/test/sanity/import/skip.txt @@ -22,7 +22,6 @@ lib/ansible/modules/network/f5/bigip_pool.py 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/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_snmp_trap.py b/test/units/modules/network/f5/test_bigip_snmp_trap.py index b7aee53594..1251718471 100644 --- a/test/units/modules/network/f5/test_bigip_snmp_trap.py +++ b/test/units/modules/network/f5/test_bigip_snmp_trap.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 @@ -41,6 +27,7 @@ try: from library.bigip_snmp_trap import NetworkedManager from library.bigip_snmp_trap import NonNetworkedManager from library.bigip_snmp_trap import ArgumentSpec + from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError except ImportError: try: from ansible.modules.network.f5.bigip_snmp_trap import NetworkedParameters @@ -49,6 +36,7 @@ except ImportError: from ansible.modules.network.f5.bigip_snmp_trap import NetworkedManager from ansible.modules.network.f5.bigip_snmp_trap import NonNetworkedManager from ansible.modules.network.f5.bigip_snmp_trap import ArgumentSpec + from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError except ImportError: raise SkipTest("F5 Ansible modules require the f5-sdk Python library")