summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormaopengzhang <zhang.maopeng1@zte.com.cn>2019-07-16 16:57:27 +0800
committermaopengzhang <zhang.maopeng1@zte.com.cn>2019-07-16 16:57:27 +0800
commit6e5a035802da0ada3984b56ef90816b8fcf5def5 (patch)
tree978a3aebad8716a6036a0b36e43f307340214131
parentd62e91d886dad0d9631e8e374e2f0a558d364756 (diff)
resolve python2->python3 issues
change base64 code Change-Id: Ia1f980f1f199723ff87b459226dc133704b33fea Issue-ID: VFC-1429 Signed-off-by: maopengzhang <zhang.maopeng1@zte.com.cn>
-rw-r--r--zte/vmanager/driver/pub/utils/restcall.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/zte/vmanager/driver/pub/utils/restcall.py b/zte/vmanager/driver/pub/utils/restcall.py
index 6b2c4b05..cc3985ad 100644
--- a/zte/vmanager/driver/pub/utils/restcall.py
+++ b/zte/vmanager/driver/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 logging
import sys
import traceback
@@ -40,7 +41,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))