summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-09-27 11:14:51 +0800
committerfujinhua <fu.jinhua@zte.com.cn>2018-09-27 11:14:51 +0800
commitc65904f438e6ab0babdfa7c836d2759d2342e273 (patch)
tree8a15b0e9b57507f91591d2dddb9f9b3f967fe895
parent9c1f09333184e610d4e9a4497707c17816e8ead4 (diff)
Refactor deploy workflow plan logic
Change-Id: I82e69668c64369f6f67b1b8fa088e28cc476e8f9 Issue-ID: VFC-1009 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn>
-rw-r--r--lcm/pub/utils/restcall.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/lcm/pub/utils/restcall.py b/lcm/pub/utils/restcall.py
index 848b9bad..171e7265 100644
--- a/lcm/pub/utils/restcall.py
+++ b/lcm/pub/utils/restcall.py
@@ -18,6 +18,7 @@ import logging
import urllib2
import uuid
import httplib2
+import requests
from lcm.pub.config.config import MSB_SERVICE_IP, MSB_SERVICE_PORT
@@ -87,12 +88,11 @@ def req_by_msb(resource, method, content=''):
return call_req(base_url, "", "", rest_no_auth, resource, method, content)
-def upload_by_msb(resource, method, file_data={}):
- headers = {'Content-Type': 'application/octet-stream'}
+def upload_by_msb(resource, method, file_data):
+ headers = {'accept': 'application/json'}
full_url = "http://%s:%s/%s" % (MSB_SERVICE_IP, MSB_SERVICE_PORT, resource)
- http = httplib2.Http()
- resp, resp_content = http.request(full_url, method=method.upper(), body=file_data, headers=headers)
- resp_status, resp_body = resp['status'], resp_content.decode('UTF-8')
+ r = requests.post(full_url, files=file_data, headers=headers)
+ resp_status, resp_body = str(r.status_code), r.text
if resp_status not in status_ok_list:
logger.error("Status code is %s, detail is %s.", resp_status, resp_body)
return [1, "Failed to upload file.", resp_status]