Skip to content

Commit c8e058e

Browse files
author
Paul Breaux
committed
Fixups after rebasing from development.
1 parent 10731a5 commit c8e058e

3 files changed

Lines changed: 27 additions & 30 deletions

File tree

f5/bigip/resource.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,30 @@ def _produce_instance(self, response):
568568
new_instance._activate_URI(new_instance.selfLink)
569569
return new_instance
570570

571+
def _reduce_boolean_pair(self, config_dict, key1, key2):
572+
'''Ensure only one key with a boolean value is present in dict.
573+
574+
:param config_dict: dict -- dictionary of config or kwargs
575+
:param key1: string -- first key name
576+
:param key2: string -- second key name
577+
:raises: BooleansToReduceHaveSameValue
578+
'''
579+
580+
if key1 in config_dict and key2 in config_dict \
581+
and config_dict[key1] == config_dict[key2]:
582+
msg = 'Boolean pair, %s and %s, have same value: %s. If both ' \
583+
'are given to this method, they cannot be the same, as this ' \
584+
'method cannot decide which one should be True.' \
585+
% (key1, key2, config_dict[key1])
586+
raise BooleansToReduceHaveSameValue(msg)
587+
elif key1 in config_dict and not config_dict[key1]:
588+
config_dict[key2] = True
589+
config_dict.pop(key1)
590+
elif key2 in config_dict and not config_dict[key2]:
591+
config_dict[key1] = True
592+
config_dict.pop(key2)
593+
return config_dict
594+
571595

572596
class OrganizingCollection(ResourceBase):
573597
"""Base class for objects that collect resources under them.
@@ -762,30 +786,6 @@ def _activate_URI(self, selfLinkuri):
762786
'creation_uri_frag': frag,
763787
'allowed_lazy_attributes': attrs})
764788

765-
def _reduce_boolean_pair(self, config_dict, key1, key2):
766-
'''Ensure only one key with a boolean value is present in dict.
767-
768-
:param config_dict: dict -- dictionary of config or kwargs
769-
:param key1: string -- first key name
770-
:param key2: string -- second key name
771-
:raises: BooleansToReduceHaveSameValue
772-
'''
773-
774-
if key1 in config_dict and key2 in config_dict \
775-
and config_dict[key1] == config_dict[key2]:
776-
msg = 'Boolean pair, %s and %s, have same value: %s. If both ' \
777-
'are given to this method, they cannot be the same, as this ' \
778-
'method cannot decide which one should be True.' \
779-
% (key1, key2, config_dict[key1])
780-
raise BooleansToReduceHaveSameValue(msg)
781-
elif key1 in config_dict and not config_dict[key1]:
782-
config_dict[key2] = True
783-
config_dict.pop(key1)
784-
elif key2 in config_dict and not config_dict[key2]:
785-
config_dict[key1] = True
786-
config_dict.pop(key2)
787-
return config_dict
788-
789789
def _create(self, **kwargs):
790790
"""wrapped by `create` override that in subclasses to customize"""
791791
if 'uri' in self._meta_data:

f5/bigip/tm/sys/failover.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@
2727
"""
2828

2929
from f5.bigip.mixins import CommandExecutionMixin
30-
from f5.bigip.mixins import ReduceBooleanPairToTrueMixin
3130
from f5.bigip.resource import UnnamedResource
3231

3332

34-
class Failover(
35-
UnnamedResource, CommandExecutionMixin, ReduceBooleanPairToTrueMixin
36-
):
33+
class Failover(UnnamedResource, CommandExecutionMixin):
3734
'''BIG-IP® Failover stats and state change.
3835
3936
The failover object only supports load, update, and refresh because it is
@@ -93,7 +90,7 @@ def exec_cmd(self, command, **kwargs):
9390
:: raises InvalidParameterValue
9491
"""
9592

96-
self._reduce_boolean_pair(kwargs, 'online', 'offline')
93+
kwargs = self._reduce_boolean_pair(kwargs, 'online', 'offline')
9794
if 'offline' in kwargs:
9895
self._meta_data['exclusive_attributes'].append(
9996
('offline', 'standby'))

test/functional/tm/sys/test_failover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414
#
1515

16-
from f5.bigip.mixins import BooleansToReduceHaveSameValue
16+
from f5.bigip.resource import BooleansToReduceHaveSameValue
1717
from f5.multi_device.utils import get_device_info
1818
from f5.multi_device.utils import pollster
1919
from pprint import pprint as pp

0 commit comments

Comments
 (0)