summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxinhuili <lxinhui@vmware.com>2019-03-09 01:57:54 +0000
committerGerrit Code Review <gerrit@onap.org>2019-03-09 01:57:54 +0000
commit753a4331b8ff46c1abcff1cb28e09b533755e44f (patch)
treee776963392ab174bd6db68b1c85e8520b59978d0
parentf54608b1e6da5473e1d27d38e5ddb2256f6f6a85 (diff)
parent4ab0077dd79bcfdee910cdc1e98537c7b05a4bbe (diff)
Merge "Add basic function to update servers in AAI"
-rw-r--r--vio/vio/pub/utils/restcall.py16
-rw-r--r--vio/vio/pub/vim/drivers/vimsdk/heat.py4
-rw-r--r--vio/vio/pub/vim/vimapi/heat/OperateStack.py4
3 files changed, 24 insertions, 0 deletions
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
@@ -48,6 +48,10 @@ class HeatClient(base.DriverBase):
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):
if failures is 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]