From 0c1f551e40783f972ae13a5cc7412f463fcbef2e Mon Sep 17 00:00:00 2001 From: Tong Liu Date: Thu, 19 Mar 2015 18:51:44 +0000 Subject: [PATCH] Add method to retrieve vdn_scope_id Current query_all_logical_switches uses hardcoded vdn_scope_id. Add a new method to get the current vnd_scope_id and use it in query_logical_switch endpoint. Change-Id: Ib91d0bba935cb7ccba8f81573c73946a87a2af9c --- devstack/tools/nsxv_cleanup.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/devstack/tools/nsxv_cleanup.py b/devstack/tools/nsxv_cleanup.py index 9d8b704355..dacc8d6e82 100755 --- a/devstack/tools/nsxv_cleanup.py +++ b/devstack/tools/nsxv_cleanup.py @@ -139,11 +139,24 @@ class VSMClient(object): verify=self.verify, data=json.dumps(body)) return response + def get_vdn_scope_id(self): + """ + Retrieve existing network scope id + """ + 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 + + # TODO(Tong): Get exact vdnscope-id instead using of default one def query_all_logical_switches(self): lswitches = [] self.__set_api_version('2.0') - self.__set_endpoint("/vdn/scopes/vdnscope-1/virtualwires") + vdn_scope_id = self.get_vdn_scope_id(); + endpoint = "/vdn/scopes/%s/virtualwires" % (vdn_scope_id) + self.__set_endpoint(endpoint) # Query all logical switches response = self.get() paging_info = response.json()['dataPage']['pagingInfo']