summaryrefslogtreecommitdiffstats
path: root/mgr
diff options
context:
space:
mode:
authormaopengzhang <zhang.maopeng1@zte.com.cn>2019-07-16 17:04:49 +0800
committermaopengzhang <zhang.maopeng1@zte.com.cn>2019-07-16 17:15:09 +0800
commit22e08b5a535ab309140e054f7ffebb1fcb3bb5a9 (patch)
treef59f7b33bf0a20f8edac1167bf9cd7417ab47945 /mgr
parent166061a3dc12ac011ae8d2b11256e58761e4f698 (diff)
resolve python2->python3 issues
change base64 code Change-Id: I0cc8607baa58eb7125215e7b17df97eea61344e5 Issue-ID: VFC-1429 Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
Diffstat (limited to 'mgr')
-rw-r--r--mgr/mgr/pub/utils/restcall.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/mgr/mgr/pub/utils/restcall.py b/mgr/mgr/pub/utils/restcall.py
index 883f63c..3e948a2 100644
--- a/mgr/mgr/pub/utils/restcall.py
+++ b/mgr/mgr/pub/utils/restcall.py
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import base64
import sys
import traceback
import logging
@@ -39,7 +40,7 @@ def call_req(base_url, user, passwd, auth_type, resource, method, content=''):
full_url = combine_url(base_url, resource)
headers = {'content-type': 'application/json', 'accept': 'application/json'}
if user:
- headers['Authorization'] = 'Basic ' + ('%s:%s' % (user, passwd)).encode("base64")
+ headers['Authorization'] = 'Basic %s' % base64.b64encode(bytes('%s:%s' % (user, passwd), "utf-8")).decode()
ca_certs = None
for retry_times in range(3):
http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == rest_no_auth))