mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-28 03:00:23 -07:00
Various bigip policy fixes (#33491)
Test fixes, formatting, and added a difference checking method
This commit is contained in:
parent
008e23dcd1
commit
4f8f99479a
2 changed files with 19 additions and 18 deletions
|
@ -372,12 +372,24 @@ class BaseManager(object):
|
||||||
resource.modify(ordinal=idx)
|
resource.modify(ordinal=idx)
|
||||||
except NonExtantPolicyRule:
|
except NonExtantPolicyRule:
|
||||||
policy.rules_s.rules.create(name=rule, ordinal=idx)
|
policy.rules_s.rules.create(name=rule, ordinal=idx)
|
||||||
|
self._remove_rule_difference(rules, policy)
|
||||||
|
|
||||||
|
def _remove_rule_difference(self, rules, policy=None):
|
||||||
|
if not rules or not self.have.rules:
|
||||||
|
return
|
||||||
|
have_rules = set(self.have.rules)
|
||||||
|
want_rules = set(rules)
|
||||||
|
removable = have_rules.difference(want_rules)
|
||||||
|
for remove in removable:
|
||||||
|
resource = policy.rules_s.rules.load(name=remove)
|
||||||
|
resource.delete()
|
||||||
|
|
||||||
|
|
||||||
class SimpleManager(BaseManager):
|
class SimpleManager(BaseManager):
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
super(SimpleManager, self).__init__(client)
|
super(SimpleManager, self).__init__(client)
|
||||||
self.want = SimpleParameters(self.client.module.params)
|
self.want = SimpleParameters(self.client.module.params)
|
||||||
|
self.have = SimpleParameters()
|
||||||
self.changes = SimpleChanges()
|
self.changes = SimpleChanges()
|
||||||
|
|
||||||
def _set_changed_options(self):
|
def _set_changed_options(self):
|
||||||
|
@ -510,6 +522,7 @@ class ComplexManager(BaseManager):
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
super(ComplexManager, self).__init__(client)
|
super(ComplexManager, self).__init__(client)
|
||||||
self.want = ComplexParameters(self.client.module.params)
|
self.want = ComplexParameters(self.client.module.params)
|
||||||
|
self.have = ComplexParameters()
|
||||||
self.changes = ComplexChanges()
|
self.changes = ComplexChanges()
|
||||||
|
|
||||||
def _set_changed_options(self):
|
def _set_changed_options(self):
|
||||||
|
|
|
@ -1,21 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright 2017 F5 Networks Inc.
|
# Copyright (c) 2017 F5 Networks Inc.
|
||||||
#
|
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
# 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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
@ -29,9 +15,9 @@ if sys.version_info < (2, 7):
|
||||||
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
raise SkipTest("F5 Ansible modules require Python >= 2.7")
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
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 AnsibleF5Client
|
||||||
from units.modules.utils import set_module_args
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from library.bigip_policy import Parameters
|
from library.bigip_policy import Parameters
|
||||||
|
@ -40,6 +26,7 @@ try:
|
||||||
from library.bigip_policy import ComplexManager
|
from library.bigip_policy import ComplexManager
|
||||||
from library.bigip_policy import ArgumentSpec
|
from library.bigip_policy import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from test.unit.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
try:
|
try:
|
||||||
from ansible.modules.network.f5.bigip_policy import Parameters
|
from ansible.modules.network.f5.bigip_policy import Parameters
|
||||||
|
@ -48,6 +35,7 @@ except ImportError:
|
||||||
from ansible.modules.network.f5.bigip_policy import ComplexManager
|
from ansible.modules.network.f5.bigip_policy import ComplexManager
|
||||||
from ansible.modules.network.f5.bigip_policy import ArgumentSpec
|
from ansible.modules.network.f5.bigip_policy import ArgumentSpec
|
||||||
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
from ansible.module_utils.f5_utils import iControlUnexpectedHTTPError
|
||||||
|
from units.modules.utils import set_module_args
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
raise SkipTest("F5 Ansible modules require the f5-sdk Python library")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue