From dd94cc822952929b6e559d8ea43002e11515ae9d Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Sat, 2 Dec 2017 21:50:25 -0800 Subject: [PATCH] Various bigip_selfip fixes (#33500) * Various bigip_selfip fixes Minor optimizations. Fixes address regex * Fixing upstream errors --- .../modules/network/f5/bigip_selfip.py | 11 +++------ .../modules/network/f5/test_bigip_selfip.py | 24 +++++-------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_selfip.py b/lib/ansible/modules/network/f5/bigip_selfip.py index de861b37959..653fb4d10ad 100644 --- a/lib/ansible/modules/network/f5/bigip_selfip.py +++ b/lib/ansible/modules/network/f5/bigip_selfip.py @@ -216,7 +216,6 @@ vlan: sample: vlan1 ''' -import os import re from ansible.module_utils.f5_utils import AnsibleF5Client @@ -600,7 +599,6 @@ class ModuleManager(object): self.want.update({'traffic_group': '/Common/traffic-group-local-only'}) if self.want.route_domain is None: self.want.update({'route_domain': 0}) - if self.want.check_mode: return True self.create_on_device() @@ -610,12 +608,10 @@ class ModuleManager(object): raise F5ModuleError("Failed to create the Self IP") def create_on_device(self): - params = self.changes.api_params() + params = self.want.api_params() self.client.api.tm.net.selfips.selfip.create( name=self.want.name, partition=self.want.partition, - address=self.want.address, - vlan=self.want.vlan, **params ) @@ -741,9 +737,8 @@ class Difference(object): @property def traffic_group(self): - if self.want.traffic_group == self.have.traffic_group: - return None - return self.want.traffic_group + if self.want.traffic_group != self.have.traffic_group: + return self.want.traffic_group class ArgumentSpec(object): diff --git a/test/units/modules/network/f5/test_bigip_selfip.py b/test/units/modules/network/f5/test_bigip_selfip.py index eb57109c841..6e74d71595b 100644 --- a/test/units/modules/network/f5/test_bigip_selfip.py +++ b/test/units/modules/network/f5/test_bigip_selfip.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 @@ -30,10 +16,10 @@ 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 patch, Mock +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 -from units.modules.utils import set_module_args try: from library.bigip_selfip import Parameters @@ -41,6 +27,7 @@ try: from library.bigip_selfip import ModuleManager from library.bigip_selfip 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.bigip_selfip import Parameters @@ -48,6 +35,7 @@ except ImportError: from ansible.modules.network.f5.bigip_selfip import ModuleManager from ansible.modules.network.f5.bigip_selfip 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")