Corrects idempotency for f5 parameters (#49576)

Several parameters in the profile modules were not idempotent.
This patch fixes those modules
This commit is contained in:
Tim Rupp 2018-12-05 16:17:37 -08:00 committed by GitHub
parent 1c3fa2b07f
commit c0520b94b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 56 additions and 28 deletions

View file

@ -472,6 +472,10 @@ class Difference(object):
def description(self):
return cmp_str_with_none(self.want.description, self.have.description)
@property
def receive_disable(self):
return cmp_str_with_none(self.want.receive_disable, self.have.receive_disable)
class ModuleManager(object):
def __init__(self, *args, **kwargs):
@ -699,7 +703,7 @@ class ArgumentSpec(object):
description=dict(),
send=dict(),
receive=dict(),
receive_disable=dict(required=False),
receive_disable=dict(),
ip=dict(),
port=dict(),
interval=dict(type='int'),

View file

@ -474,6 +474,10 @@ class Difference(object):
def description(self):
return cmp_str_with_none(self.want.description, self.have.description)
@property
def receive_disable(self):
return cmp_str_with_none(self.want.receive_disable, self.have.receive_disable)
class ModuleManager(object):
def __init__(self, *args, **kwargs):
@ -683,7 +687,7 @@ class ArgumentSpec(object):
description=dict(),
send=dict(),
receive=dict(),
receive_disable=dict(required=False),
receive_disable=dict(),
ip=dict(),
up_interval=dict(type='int'),
port=dict(),

View file

@ -358,6 +358,7 @@ try:
from library.module_utils.network.f5.common import transform_name
from library.module_utils.network.f5.common import exit_json
from library.module_utils.network.f5.common import fail_json
from library.module_utils.network.f5.compare import cmp_str_with_none
except ImportError:
from ansible.module_utils.network.f5.bigip import F5RestClient
from ansible.module_utils.network.f5.common import F5ModuleError
@ -368,6 +369,7 @@ except ImportError:
from ansible.module_utils.network.f5.common import transform_name
from ansible.module_utils.network.f5.common import exit_json
from ansible.module_utils.network.f5.common import fail_json
from ansible.module_utils.network.f5.compare import cmp_str_with_none
class Parameters(AnsibleF5Parameters):
@ -439,6 +441,12 @@ class Parameters(AnsibleF5Parameters):
class ApiParameters(Parameters):
@property
def description(self):
if self._values['description'] in [None, 'none']:
return None
return self._values['description']
@property
def quorum(self):
if self._values['monitors'] is None:
@ -489,6 +497,14 @@ class ApiParameters(Parameters):
class ModuleParameters(Parameters):
@property
def description(self):
if self._values['description'] is None:
return None
elif self._values['description'] in ['none', '']:
return ''
return self._values['description']
@property
def monitors_list(self):
if self._values['monitors'] is None:
@ -626,6 +642,10 @@ class Difference(object):
else:
return want
@property
def description(self):
return cmp_str_with_none(self.want.description, self.have.description)
def _monitors_and_quorum(self):
if self.want.monitor_type is None:
self.want.update(dict(monitor_type=self.have.monitor_type))

View file

@ -649,7 +649,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 409]:
if 'code' in response and response['code'] in [400, 409, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -669,7 +669,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -878,7 +878,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -897,7 +897,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -634,7 +634,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -653,7 +653,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -1236,7 +1236,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -1255,7 +1255,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -764,7 +764,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -784,7 +784,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -565,7 +565,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -585,7 +585,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -424,7 +424,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -443,7 +443,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -500,7 +500,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -520,7 +520,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -652,7 +652,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -671,7 +671,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -449,7 +449,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -468,7 +468,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -533,7 +533,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -552,7 +552,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -377,7 +377,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -397,7 +397,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:

View file

@ -356,7 +356,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] in [400, 403]:
if 'code' in response and response['code'] in [400, 403, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else:
@ -376,7 +376,7 @@ class ModuleManager(object):
except ValueError as ex:
raise F5ModuleError(str(ex))
if 'code' in response and response['code'] == 400:
if 'code' in response and response['code'] in [400, 404]:
if 'message' in response:
raise F5ModuleError(response['message'])
else: