From 4ab0077dd79bcfdee910cdc1e98537c7b05a4bbe Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Mon, 4 Mar 2019 15:13:39 +0800 Subject: Add basic function to update servers in AAI Add basic function for heatbridge Change-Id: I2016b2d755ad088999bd7e5ef29792a315679302 Issue-ID: MULTICLOUD-507 Signed-off-by: Ethan Lynn --- vio/vio/pub/utils/restcall.py | 16 ++++++++++++++++ vio/vio/pub/vim/drivers/vimsdk/heat.py | 4 ++++ vio/vio/pub/vim/vimapi/heat/OperateStack.py | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/vio/vio/pub/utils/restcall.py b/vio/vio/pub/utils/restcall.py index 12986be..33f10cd 100644 --- a/vio/vio/pub/utils/restcall.py +++ b/vio/vio/pub/utils/restcall.py @@ -222,6 +222,22 @@ class AAIClient(object): content=json.dumps(body), headers=self.default_headers) + def add_vservers(self, content): + for server in content['servers']: + resource = ("/vservers/vserver/%s" % server['id']) + body = { + 'vserver-name': server['name'], + 'vserver-name2': server['name'], + "vserver-id": server['id'], + "vserver-selflink": server['link'], + "prov-status": server['status'] + } + logger.debug("Add server to cloud region: %s" % body) + call_req(self.base_url, self.username, self.password, + rest_no_auth, resource, "PUT", + content=json.dumps(body), + headers=self.default_headers) + def add_flavors(self, content): for flavor in content['flavors']: resource = ("/cloud-infrastructure/cloud-regions/cloud-region/" diff --git a/vio/vio/pub/vim/drivers/vimsdk/heat.py b/vio/vio/pub/vim/drivers/vimsdk/heat.py index 0dad830..efb88d4 100644 --- a/vio/vio/pub/vim/drivers/vimsdk/heat.py +++ b/vio/vio/pub/vim/drivers/vimsdk/heat.py @@ -47,6 +47,10 @@ class HeatClient(base.DriverBase): return self.conn.orchestration.delete_stack(stack_id, ignore_missing) + @sdk.translate_exception + def stack_resources(self, stack_id): + return self.conn.orchestration.resources(stack_id) + @sdk.translate_exception def wait_for_stack(self, stack_id, status, failures=None, interval=2, timeout=None): diff --git a/vio/vio/pub/vim/vimapi/heat/OperateStack.py b/vio/vio/pub/vim/vimapi/heat/OperateStack.py index 60b39fa..1824aa4 100644 --- a/vio/vio/pub/vim/vimapi/heat/OperateStack.py +++ b/vio/vio/pub/vim/vimapi/heat/OperateStack.py @@ -53,3 +53,7 @@ class OperateStack(baseclient): def delete_vim_stack(self, stack_id): stack = self.heat(self.param).stack_delete(stack_id) return stack + + def get_stack_resources(self, stack_id): + resources = self.heat(self.param).stack_resources(stack_id) + return [res for res in resources] -- cgit 1.2.3-korg