summaryrefslogtreecommitdiffstats
path: root/multivimbroker
diff options
context:
space:
mode:
Diffstat (limited to 'multivimbroker')
-rw-r--r--multivimbroker/multivimbroker/pub/config/config.py20
-rw-r--r--multivimbroker/multivimbroker/pub/msapi/extsys.py27
-rw-r--r--multivimbroker/multivimbroker/pub/utils/restcall.py17
3 files changed, 42 insertions, 22 deletions
diff --git a/multivimbroker/multivimbroker/pub/config/config.py b/multivimbroker/multivimbroker/pub/config/config.py
index 5f340ea..71b4d2a 100644
--- a/multivimbroker/multivimbroker/pub/config/config.py
+++ b/multivimbroker/multivimbroker/pub/config/config.py
@@ -15,8 +15,17 @@ import os
MSB_SERVICE_IP = '127.0.0.1'
MSB_SERVICE_PORT = '10080'
+
# [ESR]
-ESR_GET_VIM_URI = "/api/extsys/v1/vims"
+# ESR_GET_VIM_URI = "/api/extsys/v1/vims"
+
+# [A&AI]
+AAI_ADDR = "aai.api.simpledemo.openecomp.org"
+AAI_PORT = "8443"
+AAI_SERVICE_URL = 'https://%s:%s/aai' % (AAI_ADDR, AAI_PORT)
+AAI_SCHEMA_VERSION = "v11"
+AAI_USERNAME = 'AAI'
+AAI_PASSWORD = 'AAI'
# [IMAGE LOCAL PATH]
ROOT_PATH = os.path.dirname(
@@ -27,15 +36,8 @@ REDIS_HOST = '127.0.0.1'
REDIS_PORT = '6379'
REDIS_PASSWD = ''
-# [mysql]
-DB_IP = "127.0.0.1"
-DB_PORT = 3306
-DB_NAME = "multivimbroker"
-DB_USER = "root"
-DB_PASSWD = "password"
-
# [register]
-REG_TO_MSB_WHEN_START = True
+REG_TO_MSB_WHEN_START = False
REG_TO_MSB_REG_URL = "/api/microservices/v1/services"
REG_TO_MSB_REG_PARAM = {
"serviceName": "multivim",
diff --git a/multivimbroker/multivimbroker/pub/msapi/extsys.py b/multivimbroker/multivimbroker/pub/msapi/extsys.py
index 75959a4..2058801 100644
--- a/multivimbroker/multivimbroker/pub/msapi/extsys.py
+++ b/multivimbroker/multivimbroker/pub/msapi/extsys.py
@@ -13,26 +13,29 @@ import json
import logging
from multivimbroker.pub.exceptions import VimBrokerException
-from multivimbroker.pub.utils.restcall import req_by_msb
-from multivimbroker.pub.config.config import ESR_GET_VIM_URI
+from multivimbroker.pub.utils.restcall import get_res_from_aai
logger = logging.getLogger(__name__)
-def get_vims():
- ret = req_by_msb(ESR_GET_VIM_URI, "GET")
- if ret[0] != 0:
- logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
- raise VimBrokerException(
- status_code=404, content="Failed to query VIMs from extsys.")
- return json.JSONDecoder().decode(ret[1])
+def split_vim_to_owner_region(vim_id):
+ split_vim = vim_id.split('_')
+ cloud_owner = split_vim[0]
+ cloud_region = "".join(split_vim[1:])
+ return cloud_owner, cloud_region
def get_vim_by_id(vim_id):
- ret = req_by_msb("%s/%s" % (ESR_GET_VIM_URI, vim_id), "GET")
+ cloud_owner, cloud_region = split_vim_to_owner_region(vim_id)
+ ret = get_res_from_aai("/cloud-infrastructure/cloud-regions/cloud-region"
+ "/%s/%s" % (cloud_owner, cloud_region))
if ret[0] != 0:
- logger.error("Status code is %s, detail is %s.", ret[2], ret[1])
+ logger.error("Status code is %s, detail is %s." % (ret[2], ret[1]))
raise VimBrokerException(
status_code=404,
content="Failed to query VIM with id (%s) from extsys." % vim_id)
- return json.JSONDecoder().decode(ret[1])
+ ret = json.JSONDecoder().decode(ret[1])
+ ret['type'] = ret['cloud-type']
+ ret['version'] = ret['cloud-region-version']
+ ret['vimId'] = vim_id
+ return ret
diff --git a/multivimbroker/multivimbroker/pub/utils/restcall.py b/multivimbroker/multivimbroker/pub/utils/restcall.py
index b25b389..ccdbada 100644
--- a/multivimbroker/multivimbroker/pub/utils/restcall.py
+++ b/multivimbroker/multivimbroker/pub/utils/restcall.py
@@ -16,7 +16,10 @@ import urllib2
import uuid
import httplib2
-
+from multivimbroker.pub.config.config import AAI_SCHEMA_VERSION
+from multivimbroker.pub.config.config import AAI_SERVICE_URL
+from multivimbroker.pub.config.config import AAI_USERNAME
+from multivimbroker.pub.config.config import AAI_PASSWORD
from multivimbroker.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
rest_no_auth, rest_oneway_auth, rest_bothway_auth = 0, 1, 2
@@ -100,6 +103,18 @@ def req_by_msb(resource, method, content='', headers=None):
rest_no_auth, resource, method, content, headers)
+def get_res_from_aai(resource, content=''):
+ headers = {
+ 'X-FromAppId': 'MultiCloud',
+ 'X-TransactionId': '9001',
+ 'content-type': 'application/json',
+ 'accept': 'application/json'
+ }
+ base_url = "%s/%s" % (AAI_SERVICE_URL, AAI_SCHEMA_VERSION)
+ return call_req(base_url, AAI_USERNAME, AAI_PASSWORD, rest_no_auth,
+ resource, "GET", content, headers)
+
+
def combine_url(base_url, resource):
full_url = None
if base_url.endswith('/') and resource.startswith('/'):