From a7eba2630d8171568f105e2d494589672732bcc8 Mon Sep 17 00:00:00 2001 From: Saurabh Chordiya Date: Mon, 8 Jun 2015 03:17:07 -0700 Subject: [PATCH] Handling IndexError in case there are no vdnscope Currently fuction get_vdn_scope_id throwing error in case of zero vdnscope, this patch handles that situation. Change-Id: I02eb36e6e7fddace05ad349e5a48ef2fa1e1ef50 --- devstack/tools/nsxv_cleanup.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/devstack/tools/nsxv_cleanup.py b/devstack/tools/nsxv_cleanup.py index 2250b520da..b96c87be2f 100755 --- a/devstack/tools/nsxv_cleanup.py +++ b/devstack/tools/nsxv_cleanup.py @@ -146,15 +146,17 @@ class VSMClient(object): self.__set_api_version('2.0'); self.__set_endpoint("/vdn/scopes") response = self.get(); - vdn_scope_id = response.json()['allScopes'][0]['objectId'] - return vdn_scope_id + if len(response.json()['allScopes']) == 0: + return + else: + return response.json()['allScopes'][0]['objectId'] - - # TODO(Tong): Get exact vdnscope-id instead using of default one def query_all_logical_switches(self): lswitches = [] self.__set_api_version('2.0') vdn_scope_id = self.get_vdn_scope_id(); + if not vdn_scope_id: + return lswitches endpoint = "/vdn/scopes/%s/virtualwires" % (vdn_scope_id) self.__set_endpoint(endpoint) # Query all logical switches