mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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)
|
||||
except NonExtantPolicyRule:
|
||||
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):
|
||||
def __init__(self, client):
|
||||
super(SimpleManager, self).__init__(client)
|
||||
self.want = SimpleParameters(self.client.module.params)
|
||||
self.have = SimpleParameters()
|
||||
self.changes = SimpleChanges()
|
||||
|
||||
def _set_changed_options(self):
|
||||
|
@ -510,6 +522,7 @@ class ComplexManager(BaseManager):
|
|||
def __init__(self, client):
|
||||
super(ComplexManager, self).__init__(client)
|
||||
self.want = ComplexParameters(self.client.module.params)
|
||||
self.have = ComplexParameters()
|
||||
self.changes = ComplexChanges()
|
||||
|
||||
def _set_changed_options(self):
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
# 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
|
||||
|
@ -29,9 +15,9 @@ 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 units.modules.utils import set_module_args
|
||||
|
||||
try:
|
||||
from library.bigip_policy import Parameters
|
||||
|
@ -40,6 +26,7 @@ try:
|
|||
from library.bigip_policy import ComplexManager
|
||||
from library.bigip_policy 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_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 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")
|
||||
|
||||
|
|
Loading…
Reference in a new issue