pull/27866/head
Wojciech Wypior 6 years ago committed by Tim Rupp
parent cccb681c0a
commit 041da7516d

@ -704,6 +704,7 @@ class Changes(Parameters):
class UsableChanges(Changes): class UsableChanges(Changes):
@property @property
def virtual_server_dependencies(self): def virtual_server_dependencies(self):
if self._values['virtual_server_dependencies'] is None: if self._values['virtual_server_dependencies'] is None:
@ -957,21 +958,10 @@ class ModuleManager(object):
else: else:
return self.create() return self.create()
def exists(self): def absent(self):
uri = "https://{0}:{1}/mgmt/tm/gtm/server/{2}/virtual-servers/{3}".format( if self.exists():
self.client.provider['server'], return self.remove()
self.client.provider['server_port'], return False
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 update(self): def update(self):
self.have = self.read_current_from_device() self.have = self.read_current_from_device()
@ -1013,6 +1003,22 @@ class ModuleManager(object):
self.create_on_device() self.create_on_device()
return True 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): def create_on_device(self):
params = self.changes.api_params() params = self.changes.api_params()
params['name'] = self.want.name params['name'] = self.want.name
@ -1040,7 +1046,7 @@ class ModuleManager(object):
self.client.provider['server'], self.client.provider['server'],
self.client.provider['server_port'], self.client.provider['server_port'],
transform_name(self.want.partition, self.want.server_name), 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) resp = self.client.api.patch(uri, json=params)
try: try:
@ -1054,17 +1060,12 @@ class ModuleManager(object):
else: else:
raise F5ModuleError(resp.content) raise F5ModuleError(resp.content)
def absent(self):
if self.exists():
return self.remove()
return False
def remove_from_device(self): def remove_from_device(self):
uri = "https://{0}:{1}/mgmt/tm/gtm/server/{2}/virtual-servers/{3}".format( uri = "https://{0}:{1}/mgmt/tm/gtm/server/{2}/virtual-servers/{3}".format(
self.client.provider['server'], self.client.provider['server'],
self.client.provider['server_port'], self.client.provider['server_port'],
transform_name(self.want.partition, self.want.server_name), transform_name(self.want.partition, self.want.server_name),
self.want.name transform_name(name=self.want.name)
) )
response = self.client.api.delete(uri) response = self.client.api.delete(uri)
if response.status == 200: if response.status == 200:
@ -1076,7 +1077,7 @@ class ModuleManager(object):
self.client.provider['server'], self.client.provider['server'],
self.client.provider['server_port'], self.client.provider['server_port'],
transform_name(self.want.partition, self.want.server_name), transform_name(self.want.partition, self.want.server_name),
self.want.name transform_name(name=self.want.name)
) )
resp = self.client.api.get(uri) resp = self.client.api.get(uri)
try: try:

Loading…
Cancel
Save