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
This commit is contained in:
parent
eaa4ec92cc
commit
a7eba2630d
@ -146,15 +146,17 @@ class VSMClient(object):
|
|||||||
self.__set_api_version('2.0');
|
self.__set_api_version('2.0');
|
||||||
self.__set_endpoint("/vdn/scopes")
|
self.__set_endpoint("/vdn/scopes")
|
||||||
response = self.get();
|
response = self.get();
|
||||||
vdn_scope_id = response.json()['allScopes'][0]['objectId']
|
if len(response.json()['allScopes']) == 0:
|
||||||
return vdn_scope_id
|
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):
|
def query_all_logical_switches(self):
|
||||||
lswitches = []
|
lswitches = []
|
||||||
self.__set_api_version('2.0')
|
self.__set_api_version('2.0')
|
||||||
vdn_scope_id = self.get_vdn_scope_id();
|
vdn_scope_id = self.get_vdn_scope_id();
|
||||||
|
if not vdn_scope_id:
|
||||||
|
return lswitches
|
||||||
endpoint = "/vdn/scopes/%s/virtualwires" % (vdn_scope_id)
|
endpoint = "/vdn/scopes/%s/virtualwires" % (vdn_scope_id)
|
||||||
self.__set_endpoint(endpoint)
|
self.__set_endpoint(endpoint)
|
||||||
# Query all logical switches
|
# Query all logical switches
|
||||||
|
Loading…
x
Reference in New Issue
Block a user