aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorying.yunlong <ying.yunlong@zte.com.cn>2017-09-15 10:22:43 +0800
committerying.yunlong <ying.yunlong@zte.com.cn>2017-09-15 10:22:43 +0800
commitd0739a3fc1347f0c5b55c055cceab1ffda81ec50 (patch)
treef69cf09b1ffb170799a0a6b0781bf79b9f4de78d
parent1bb621407884429f65ca3841aabc094a081d3e53 (diff)
Add vfc catalog call esr function from aai
Change-Id: I025e0a70cda41aa764085c98528c4747083392c1 Issue-ID: VFC-361 Signed-off-by: ying.yunlong <ying.yunlong@zte.com.cn>
-rw-r--r--catalog/pub/config/config.py5
-rw-r--r--catalog/pub/msapi/extsys.py19
-rw-r--r--catalog/pub/utils/restcall.py4
3 files changed, 27 insertions, 1 deletions
diff --git a/catalog/pub/config/config.py b/catalog/pub/config/config.py
index 0f511156..d6acc2be 100644
--- a/catalog/pub/config/config.py
+++ b/catalog/pub/config/config.py
@@ -17,6 +17,11 @@ import os
MSB_SERVICE_IP = '127.0.0.1'
MSB_SERVICE_PORT = '80'
+# [aai config]
+AAI_BASE_URL = "https://127.0.0.1:8443/aai/v11"
+AAI_USER = "AAI"
+AAI_PASSWD = "AAI"
+
# [REDIS]
REDIS_HOST = '127.0.0.1'
REDIS_PORT = '6379'
diff --git a/catalog/pub/msapi/extsys.py b/catalog/pub/msapi/extsys.py
index 3418385e..9f6b43d5 100644
--- a/catalog/pub/msapi/extsys.py
+++ b/catalog/pub/msapi/extsys.py
@@ -14,13 +14,32 @@
import json
import logging
+import uuid
+from catalog.pub.config.config import AAI_BASE_URL, AAI_USER, AAI_PASSWD
from catalog.pub.exceptions import NSLCMException
+from catalog.pub.utils import restcall
from catalog.pub.utils.restcall import req_by_msb
logger = logging.getLogger(__name__)
+def call_aai(resource, method, content=''):
+ additional_headers = {
+ 'X-FromAppId': 'VFC-NFVO-LCM',
+ 'X-TransactionId': str(uuid.uuid1())
+ }
+
+ return restcall.call_req(AAI_BASE_URL,
+ AAI_USER,
+ AAI_PASSWD,
+ restcall.rest_no_auth,
+ resource,
+ method,
+ content,
+ additional_headers)
+
+
def get_vims():
ret = req_by_msb("/api/extsys/v1/vims", "GET")
if ret[0] != 0:
diff --git a/catalog/pub/utils/restcall.py b/catalog/pub/utils/restcall.py
index 1753285d..2825a0cb 100644
--- a/catalog/pub/utils/restcall.py
+++ b/catalog/pub/utils/restcall.py
@@ -29,7 +29,7 @@ HTTP_404_NOTFOUND, HTTP_403_FORBIDDEN, HTTP_401_UNAUTHORIZED, HTTP_400_BADREQUES
logger = logging.getLogger(__name__)
-def call_req(base_url, user, passwd, auth_type, resource, method,
+def call_req(base_url, user, passwd, auth_type, resource, method,
content='', additional_headers={}):
callid = str(uuid.uuid1())
logger.debug("[%s]call_req('%s','%s','%s',%s,'%s','%s','%s')" % (
@@ -42,6 +42,8 @@ def call_req(base_url, user, passwd, auth_type, resource, method,
if user:
headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64")
ca_certs = None
+ if additional_headers:
+ headers.update(additional_headers)
for retry_times in range(3):
http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth))
http.follow_all_redirects = True