aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2017-08-30 15:34:20 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2017-08-30 15:34:20 +0800
commit8f429006625d65f9a13cd236b2e709c199a1d2ec (patch)
tree3cd4eeafc786fc58734b38201b18e1bb8f0d4ed4
parentf251f68d2ef5c5359a37342a1bfa6920b7e17ca3 (diff)
Extend rest call param to support aai
Change-Id: Ib33154e78b8549bcf4c0bad1b3ab3167bec821c9 Issue-Id: VFC-191 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/pub/msapi/aai.py9
-rw-r--r--lcm/pub/utils/restcall.py5
2 files changed, 12 insertions, 2 deletions
diff --git a/lcm/pub/msapi/aai.py b/lcm/pub/msapi/aai.py
index 93a1421f..2f8cf935 100644
--- a/lcm/pub/msapi/aai.py
+++ b/lcm/pub/msapi/aai.py
@@ -14,6 +14,7 @@
import json
import logging
+import uuid
from lcm.pub.exceptions import NSLCMException
from lcm.pub.utils import restcall
@@ -23,11 +24,17 @@ 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(base_url=AAI_BASE_URL,
user=AAI_USER,
passwd=AAI_PASSWD,
auth_type=restcall.rest_no_auth,
resource=resource,
method=method,
- content=content)
+ content=content,
+ additional_headers=additional_headers)
+
diff --git a/lcm/pub/utils/restcall.py b/lcm/pub/utils/restcall.py
index 0ef20561..d05d30b3 100644
--- a/lcm/pub/utils/restcall.py
+++ b/lcm/pub/utils/restcall.py
@@ -29,7 +29,8 @@ 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, content=''):
+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')" % (
callid, base_url, user, passwd, auth_type, resource, method, content))
@@ -41,6 +42,8 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''):
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