mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
fixes an issue with removal of virtual disks on blades systems (#54546)
This commit is contained in:
parent
4d42ea32dc
commit
8fed391461
1 changed files with 41 additions and 36 deletions
|
@ -670,7 +670,27 @@ class ModuleManager(object):
|
||||||
return self.remove_virtual_disk_from_device()
|
return self.remove_virtual_disk_from_device()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_virtual_disk_on_device(self):
|
def get_virtual_disks_on_device(self):
|
||||||
|
uri = "https://{0}:{1}/mgmt/tm/vcmp/virtual-disk/".format(
|
||||||
|
self.client.provider['server'],
|
||||||
|
self.client.provider['server_port'],
|
||||||
|
)
|
||||||
|
resp = self.client.api.get(uri)
|
||||||
|
try:
|
||||||
|
response = resp.json()
|
||||||
|
except ValueError as ex:
|
||||||
|
raise F5ModuleError(str(ex))
|
||||||
|
|
||||||
|
if 'code' in response and response['code'] == 400:
|
||||||
|
if 'message' in response:
|
||||||
|
raise F5ModuleError(response['message'])
|
||||||
|
else:
|
||||||
|
raise F5ModuleError(resp.content)
|
||||||
|
|
||||||
|
if 'items' in response:
|
||||||
|
return response
|
||||||
|
|
||||||
|
def virtual_disk_exists(self):
|
||||||
"""Checks if a virtual disk exists for a guest
|
"""Checks if a virtual disk exists for a guest
|
||||||
|
|
||||||
The virtual disk names can differ based on the device vCMP is installed on.
|
The virtual disk names can differ based on the device vCMP is installed on.
|
||||||
|
@ -689,47 +709,32 @@ class ModuleManager(object):
|
||||||
Returns:
|
Returns:
|
||||||
dict
|
dict
|
||||||
"""
|
"""
|
||||||
|
response = self.get_virtual_disks_on_device()
|
||||||
uri = "https://{0}:{1}/mgmt/tm/vcmp/virtual-disk/".format(
|
check = '{0}'.format(self.have.virtual_disk)
|
||||||
self.client.provider['server'],
|
|
||||||
self.client.provider['server_port'],
|
|
||||||
)
|
|
||||||
resp = self.client.api.get(uri)
|
|
||||||
try:
|
|
||||||
response = resp.json()
|
|
||||||
except ValueError as ex:
|
|
||||||
raise F5ModuleError(str(ex))
|
|
||||||
|
|
||||||
if 'code' in response and response['code'] == 400:
|
|
||||||
if 'message' in response:
|
|
||||||
raise F5ModuleError(response['message'])
|
|
||||||
else:
|
|
||||||
raise F5ModuleError(resp.content)
|
|
||||||
|
|
||||||
for resource in response['items']:
|
for resource in response['items']:
|
||||||
check = '{0}'.format(self.have.virtual_disk)
|
|
||||||
if resource['name'].startswith(check):
|
if resource['name'].startswith(check):
|
||||||
return resource
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def virtual_disk_exists(self):
|
|
||||||
response = self.get_virtual_disk_on_device()
|
|
||||||
if response:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def remove_virtual_disk_from_device(self):
|
def remove_virtual_disk_from_device(self):
|
||||||
response = self.get_virtual_disk_on_device()
|
check = '{0}'.format(self.have.virtual_disk)
|
||||||
uri = "https://{0}:{1}/mgmt/tm/vcmp/virtual-disk/{2}".format(
|
response = self.get_virtual_disks_on_device()
|
||||||
self.client.provider['server'],
|
for resource in response['items']:
|
||||||
self.client.provider['server_port'],
|
if resource['name'].startswith(check):
|
||||||
response['name']
|
uri = "https://{0}:{1}/mgmt/tm/vcmp/virtual-disk/{2}".format(
|
||||||
)
|
self.client.provider['server'],
|
||||||
response = self.client.api.delete(uri)
|
self.client.provider['server_port'],
|
||||||
if response.status == 200:
|
resource['name'].replace('/', '~')
|
||||||
return True
|
)
|
||||||
raise F5ModuleError(response.content)
|
response = self.client.api.delete(uri)
|
||||||
|
|
||||||
|
if response.status == 200:
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
raise F5ModuleError(response.content)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
def is_configured(self):
|
def is_configured(self):
|
||||||
"""Checks to see if guest is disabled
|
"""Checks to see if guest is disabled
|
||||||
|
|
Loading…
Reference in a new issue