From 2e4ae2397348178f64eac4a905711e6a17f923cd Mon Sep 17 00:00:00 2001 From: Yxn Date: Fri, 14 Sep 2018 10:30:22 +0800 Subject: [PATCH 1/2] fix aliyun cloud typeerror --- salt/cloud/clouds/aliyun.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/salt/cloud/clouds/aliyun.py b/salt/cloud/clouds/aliyun.py index 9d81e12dcc11..58ef15ddd39d 100644 --- a/salt/cloud/clouds/aliyun.py +++ b/salt/cloud/clouds/aliyun.py @@ -770,7 +770,7 @@ def percent_encode(line): # All aliyun API only support GET method stringToSign = 'GET&%2F&' + percent_encode(canonicalizedQueryString[1:]) - h = hmac.new(access_key_secret + "&", stringToSign, sha1) + h = hmac.new(bytearray(access_key_secret + "&", 'utf-8'), bytearray(stringToSign, 'utf-8'), sha1) signature = base64.encodestring(h.digest()).strip() return signature From 1f227fce145abfdbffcfc4567278a3845aa16fae Mon Sep 17 00:00:00 2001 From: Yxn Date: Fri, 28 Sep 2018 14:05:25 +0800 Subject: [PATCH 2/2] use stringutils instead of hard code --- salt/cloud/clouds/aliyun.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/salt/cloud/clouds/aliyun.py b/salt/cloud/clouds/aliyun.py index 58ef15ddd39d..9e587d948612 100644 --- a/salt/cloud/clouds/aliyun.py +++ b/salt/cloud/clouds/aliyun.py @@ -50,6 +50,7 @@ SaltCloudExecutionFailure, SaltCloudExecutionTimeout ) +from salt.utils.stringutils import to_bytes # Import 3rd-party libs from salt.ext import six @@ -770,7 +771,7 @@ def percent_encode(line): # All aliyun API only support GET method stringToSign = 'GET&%2F&' + percent_encode(canonicalizedQueryString[1:]) - h = hmac.new(bytearray(access_key_secret + "&", 'utf-8'), bytearray(stringToSign, 'utf-8'), sha1) + h = hmac.new(to_bytes(access_key_secret + "&"), stringToSign, sha1) signature = base64.encodestring(h.digest()).strip() return signature