diff options
author | Wojciech Wypior <w.wypior@f5.com> | 2019-02-02 02:14:33 +0000 |
---|---|---|
committer | Tim Rupp <caphrim007@gmail.com> | 2019-02-01 18:14:33 -0800 |
commit | 041da7516d72aa5d06c32fc6312a6e500624e540 (patch) | |
tree | 38b6ac6325d6b670ad853cc871307960c0fa34ad /lib/ansible | |
parent | cccb681c0a688ffabdbe13114c7b895528e5af93 (diff) | |
download | ansible-041da7516d72aa5d06c32fc6312a6e500624e540.tar.gz |
fixes issue #1186 (#51642)
Diffstat (limited to 'lib/ansible')
-rw-r--r-- | lib/ansible/modules/network/f5/bigip_gtm_virtual_server.py | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/ansible/modules/network/f5/bigip_gtm_virtual_server.py b/lib/ansible/modules/network/f5/bigip_gtm_virtual_server.py index 654b9b7199..9ebc8d470a 100644 --- a/lib/ansible/modules/network/f5/bigip_gtm_virtual_server.py +++ b/lib/ansible/modules/network/f5/bigip_gtm_virtual_server.py @@ -704,6 +704,7 @@ class Changes(Parameters): class UsableChanges(Changes): + @property def virtual_server_dependencies(self): if self._values['virtual_server_dependencies'] is None: @@ -957,21 +958,10 @@ class ModuleManager(object): else: return self.create() - def exists(self): - uri = "https://{0}:{1}/mgmt/tm/gtm/server/{2}/virtual-servers/{3}".format( - self.client.provider['server'], - self.client.provider['server_port'], - transform_name(self.want.partition, self.want.server_name), - self.want.name - ) - resp = self.client.api.get(uri) - try: - response = resp.json() - except ValueError: - return False - if resp.status == 404 or 'code' in response and response['code'] == 404: - return False - return True + def absent(self): + if self.exists(): + return self.remove() + return False def update(self): self.have = self.read_current_from_device() @@ -1013,6 +1003,22 @@ class ModuleManager(object): self.create_on_device() return True + def exists(self): + uri = "https://{0}:{1}/mgmt/tm/gtm/server/{2}/virtual-servers/{3}".format( + self.client.provider['server'], + self.client.provider['server_port'], + transform_name(self.want.partition, self.want.server_name), + transform_name(name=self.want.name) + ) + resp = self.client.api.get(uri) + try: + response = resp.json() + except ValueError: + return False + if resp.status == 404 or 'code' in response and response['code'] == 404: + return False + return True + def create_on_device(self): params = self.changes.api_params() params['name'] = self.want.name @@ -1040,7 +1046,7 @@ class ModuleManager(object): self.client.provider['server'], self.client.provider['server_port'], transform_name(self.want.partition, self.want.server_name), - self.want.name + transform_name(name=self.want.name) ) resp = self.client.api.patch(uri, json=params) try: @@ -1054,17 +1060,12 @@ class ModuleManager(object): else: raise F5ModuleError(resp.content) - def absent(self): - if self.exists(): - return self.remove() - return False - def remove_from_device(self): uri = "https://{0}:{1}/mgmt/tm/gtm/server/{2}/virtual-servers/{3}".format( self.client.provider['server'], self.client.provider['server_port'], transform_name(self.want.partition, self.want.server_name), - self.want.name + transform_name(name=self.want.name) ) response = self.client.api.delete(uri) if response.status == 200: @@ -1076,7 +1077,7 @@ class ModuleManager(object): self.client.provider['server'], self.client.provider['server_port'], transform_name(self.want.partition, self.want.server_name), - self.want.name + transform_name(name=self.want.name) ) resp = self.client.api.get(uri) try: |