From e5d77c77821e0b48b42eb2119a6678e3481c8caf Mon Sep 17 00:00:00 2001 From: Tim Rupp Date: Fri, 5 Jan 2018 15:53:26 -0800 Subject: [PATCH] Fixes for bigip monitors and profiles (#34524) Fixed incorrect parent comparison. Fixed old fqdn_name usage. Fixed incorrect default parents --- .../modules/network/f5/bigip_monitor_http.py | 15 ++++++++------- .../modules/network/f5/bigip_monitor_https.py | 15 ++++++++------- .../modules/network/f5/bigip_monitor_snmp_dca.py | 15 ++++++++------- .../modules/network/f5/bigip_monitor_tcp_echo.py | 9 +++++++-- .../network/f5/bigip_monitor_tcp_half_open.py | 9 +++++++-- .../modules/network/f5/bigip_monitor_udp.py | 9 +++++++-- .../network/f5/bigip_profile_client_ssl.py | 2 +- 7 files changed, 46 insertions(+), 28 deletions(-) diff --git a/lib/ansible/modules/network/f5/bigip_monitor_http.py b/lib/ansible/modules/network/f5/bigip_monitor_http.py index 4cbbc278ce9..aa24f927aea 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_http.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_http.py @@ -232,6 +232,11 @@ class Parameters(AnsibleF5Parameters): # If the mapped value is not a @property self._values[map_key] = v + def _fqdn_name(self, value): + if value is not None and not value.startswith('/'): + return '/{0}/{1}'.format(self.partition, value) + return value + def to_return(self): result = {} try: @@ -316,11 +321,7 @@ class Parameters(AnsibleF5Parameters): def parent(self): if self._values['parent'] is None: return None - if self._values['parent'].startswith('/'): - parent = os.path.basename(self._values['parent']) - result = '/{0}/{1}'.format(self.partition, parent) - else: - result = '/{0}/{1}'.format(self.partition, self._values['parent']) + result = self._fqdn_name(self._values['parent']) return result @property @@ -355,7 +356,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent monitor cannot be changed" ) @@ -569,7 +570,7 @@ class ArgumentSpec(object): self.supports_check_mode = True self.argument_spec = dict( name=dict(required=True), - parent=dict(default='http'), + parent=dict(default='/Common/http'), send=dict(), receive=dict(), receive_disable=dict(required=False), diff --git a/lib/ansible/modules/network/f5/bigip_monitor_https.py b/lib/ansible/modules/network/f5/bigip_monitor_https.py index 0edc066b6bb..a7436068c8d 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_https.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_https.py @@ -221,6 +221,11 @@ class Parameters(AnsibleF5Parameters): # If the mapped value is not a @property self._values[map_key] = v + def _fqdn_name(self, value): + if value is not None and not value.startswith('/'): + return '/{0}/{1}'.format(self.partition, value) + return value + def to_return(self): result = {} try: @@ -313,11 +318,7 @@ class Parameters(AnsibleF5Parameters): def parent(self): if self._values['parent'] is None: return None - if self._values['parent'].startswith('/'): - parent = os.path.basename(self._values['parent']) - result = '/{0}/{1}'.format(self.partition, parent) - else: - result = '/{0}/{1}'.format(self.partition, self._values['parent']) + result = self._fqdn_name(self._values['parent']) return result @property @@ -340,7 +341,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent monitor cannot be changed" ) @@ -551,7 +552,7 @@ class ArgumentSpec(object): self.supports_check_mode = True self.argument_spec = dict( name=dict(required=True), - parent=dict(default='https'), + parent=dict(default='/Common/https'), send=dict(), receive=dict(), receive_disable=dict(required=False), diff --git a/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py b/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py index bded8d815f5..6aab4668d54 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_snmp_dca.py @@ -292,6 +292,11 @@ class Parameters(AnsibleF5Parameters): # If the mapped value is not a @property self._values[map_key] = v + def _fqdn_name(self, value): + if value is not None and not value.startswith('/'): + return '/{0}/{1}'.format(self.partition, value) + return value + def to_return(self): result = {} try: @@ -338,11 +343,7 @@ class Parameters(AnsibleF5Parameters): def parent(self): if self._values['parent'] is None: return None - if self._values['parent'].startswith('/'): - parent = os.path.basename(self._values['parent']) - result = '/{0}/{1}'.format(self.partition, parent) - else: - result = '/{0}/{1}'.format(self.partition, self._values['parent']) + result = self._fqdn_name(self._values['parent']) return result @property @@ -406,7 +407,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent monitor cannot be changed" ) @@ -622,7 +623,7 @@ class ArgumentSpec(object): self.argument_spec = dict( name=dict(required=True), description=dict(), - parent=dict(), + parent=dict(default='/Common/snmp_dca'), ip=dict(), interval=dict(type='int'), timeout=dict(type='int'), diff --git a/lib/ansible/modules/network/f5/bigip_monitor_tcp_echo.py b/lib/ansible/modules/network/f5/bigip_monitor_tcp_echo.py index 643adfada50..09809526d71 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_tcp_echo.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_tcp_echo.py @@ -194,6 +194,11 @@ class Parameters(AnsibleF5Parameters): # If the mapped value is not a @property self._values[map_key] = v + def _fqdn_name(self, value): + if value is not None and not value.startswith('/'): + return '/{0}/{1}'.format(self.partition, value) + return value + def to_return(self): result = {} try: @@ -289,7 +294,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent monitor cannot be changed" ) @@ -486,7 +491,7 @@ class ArgumentSpec(object): self.supports_check_mode = True self.argument_spec = dict( name=dict(required=True), - parent=dict(default='tcp_echo'), + parent=dict(default='/Common/tcp_echo'), ip=dict(), interval=dict(type='int'), timeout=dict(type='int'), diff --git a/lib/ansible/modules/network/f5/bigip_monitor_tcp_half_open.py b/lib/ansible/modules/network/f5/bigip_monitor_tcp_half_open.py index 0279f619724..e2a7bc5e213 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_tcp_half_open.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_tcp_half_open.py @@ -213,6 +213,11 @@ class Parameters(AnsibleF5Parameters): # If the mapped value is not a @property self._values[map_key] = v + def _fqdn_name(self, value): + if value is not None and not value.startswith('/'): + return '/{0}/{1}'.format(self.partition, value) + return value + def to_return(self): result = {} try: @@ -324,7 +329,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent monitor cannot be changed" ) @@ -533,7 +538,7 @@ class ArgumentSpec(object): self.supports_check_mode = True self.argument_spec = dict( name=dict(required=True), - parent=dict(default='tcp_half_open'), + parent=dict(default='/Common/tcp_half_open'), ip=dict(), port=dict(type='int'), interval=dict(type='int'), diff --git a/lib/ansible/modules/network/f5/bigip_monitor_udp.py b/lib/ansible/modules/network/f5/bigip_monitor_udp.py index 63a61d9fef3..ac2000d2f8a 100644 --- a/lib/ansible/modules/network/f5/bigip_monitor_udp.py +++ b/lib/ansible/modules/network/f5/bigip_monitor_udp.py @@ -214,6 +214,11 @@ class Parameters(AnsibleF5Parameters): # If the mapped value is not a @property self._values[map_key] = v + def _fqdn_name(self, value): + if value is not None and not value.startswith('/'): + return '/{0}/{1}'.format(self.partition, value) + return value + def to_return(self): result = {} try: @@ -329,7 +334,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent monitor cannot be changed" ) @@ -539,7 +544,7 @@ class ArgumentSpec(object): self.supports_check_mode = True self.argument_spec = dict( name=dict(required=True), - parent=dict(default='udp'), + parent=dict(default='/Common/udp'), send=dict(), receive=dict(), receive_disable=dict(required=False), diff --git a/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py b/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py index 0992b815acd..43c6b42d35c 100644 --- a/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py +++ b/lib/ansible/modules/network/f5/bigip_profile_client_ssl.py @@ -340,7 +340,7 @@ class Difference(object): @property def parent(self): - if self.want.parent != self.want.parent: + if self.want.parent != self.have.parent: raise F5ModuleError( "The parent profile cannot be changed" )