[MGM] Add --rm_fip_ignore_500 option
Add option to ignore HTTP 500 error when deleting the floating IP from an instance and treat it as a successful response. Change-Id: Ic81181795725823d4d953f2d9fae25775fb7c91d
This commit is contained in:
committed by
Andrew Hutchings
parent
2f1638dd10
commit
2caf2785ec
@@ -119,3 +119,7 @@ Command Line Options
|
||||
Used to specify the Gearman job server hostname and port. This option
|
||||
can be used multiple times to specify multiple job servers
|
||||
|
||||
.. option:: --rm_fip_ignore_500
|
||||
|
||||
When removing a floating IP, ignore the HTTP 500 error and treat it as
|
||||
a successful response.
|
||||
|
||||
@@ -155,6 +155,10 @@ def main():
|
||||
dest='threads', type=int, default=4,
|
||||
help='Number of worker threads to spawn'
|
||||
)
|
||||
options.parser.add_argument(
|
||||
'--rm_fip_ignore_500', action='store_true',
|
||||
help='Ignore HTTP 500 error when removing a floating IP'
|
||||
)
|
||||
|
||||
args = options.run()
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ class Node(object):
|
||||
self.secgroup = args.nova_secgroup
|
||||
self.node_basename = args.node_basename
|
||||
self.az = args.nova_az_name
|
||||
self.rm_fip_ignore_500 = args.rm_fip_ignore_500
|
||||
|
||||
# Replace '_' with '-' in basename
|
||||
if self.node_basename:
|
||||
self.node_basename = self.node_basename.replace('_', '-')
|
||||
@@ -99,17 +101,23 @@ class Node(object):
|
||||
)
|
||||
|
||||
def vip_remove(self, node_id, vip):
|
||||
""" assign a virtual IP to a Nova instance """
|
||||
""" delete a virtual IP from a Nova instance """
|
||||
url = '/servers/{0}/action'.format(node_id)
|
||||
body = {
|
||||
"removeFloatingIp": {
|
||||
"address": vip
|
||||
}
|
||||
}
|
||||
resp, body = self.nova.post(url, body=body)
|
||||
try:
|
||||
resp, body = self.nova.post(url, body=body)
|
||||
except exceptions.ClientException as e:
|
||||
if e.code == 500 and self.rm_fip_ignore_500:
|
||||
return
|
||||
raise
|
||||
|
||||
if resp.status_code != 202:
|
||||
raise Exception(
|
||||
'Response code {0}, message {1} when assigning vip'
|
||||
'Response code {0}, message {1} when removing vip'
|
||||
.format(resp.status_code, body)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user