marvin: replace encodestring for encodebytes (#7027)

Fixes: #6962
This commit is contained in:
dahn 2023-05-08 09:21:12 +02:00 committed by GitHub
parent ad21e86342
commit 897dad619b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 5 deletions

View File

@ -1025,7 +1025,7 @@ class ConfigDriveUtils:
:rtype: str :rtype: str
""" """
self.debug("Updating userdata for VM - %s" % vm.name) self.debug("Updating userdata for VM - %s" % vm.name)
updated_user_data = base64.encodestring(new_user_data.encode()).decode() updated_user_data = base64.encodebytes(new_user_data.encode()).decode()
with self.stopped_vm(vm): with self.stopped_vm(vm):
vm.update(self.api_client, userdata=updated_user_data) vm.update(self.api_client, userdata=updated_user_data)

View File

@ -126,7 +126,7 @@ class TestDeployVmWithUserDataMultiNic(cloudstackTestCase):
"""Test userdata update when non default nic is without userdata for deploy and update """Test userdata update when non default nic is without userdata for deploy and update
""" """
self.userdata = base64.encodestring(self.userdata.encode()).decode() self.userdata = base64.encodebytes(self.userdata.encode()).decode()
network1 = Network.create( network1 = Network.create(
self.apiclient, self.apiclient,

View File

@ -99,7 +99,7 @@ class TestDeployVmWithUserData(cloudstackTestCase):
# py2 didn't insert any new-lines # py2 didn't insert any new-lines
# so we now do the encoding in the stored userdata string and remove the '\n's # so we now do the encoding in the stored userdata string and remove the '\n's
# to get a good easy string compare in the assert later on. # to get a good easy string compare in the assert later on.
cls.userdata = base64.encodestring(cls.userdata.encode()).decode().replace('\n', '') cls.userdata = base64.encodebytes(cls.userdata.encode()).decode().replace('\n', '')
cls.user_data_2k= ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2000)) cls.user_data_2k= ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2000))
cls.user_data_2kl = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(1900)) cls.user_data_2kl = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(1900))

View File

@ -147,7 +147,7 @@ class CSConnection(object):
).replace("+", "%20")] ).replace("+", "%20")]
) for r in params] ) for r in params]
) )
signature = base64.encodestring( signature = base64.encodebytes(
hmac.new(self.securityKey.encode('utf-8'), hmac.new(self.securityKey.encode('utf-8'),
hash_str.encode('utf-8'), hash_str.encode('utf-8'),
hashlib.sha1).digest()).strip() hashlib.sha1).digest()).strip()

View File

@ -68,7 +68,7 @@ def make_request(command, args, logger, host, port,
str.lower(urllib.quote_plus(str(r[1]))).replace("+", str.lower(urllib.quote_plus(str(r[1]))).replace("+",
"%20")]) for r in request]) "%20")]) for r in request])
sig = urllib.quote_plus(base64.encodestring(hmac.new(secretkey, hashStr, sig = urllib.quote_plus(base64.encodebytes(hmac.new(secretkey, hashStr,
hashlib.sha1).digest()).strip()) hashlib.sha1).digest()).strip())
request_url += "&signature=%s" % sig request_url += "&signature=%s" % sig
request_url = "%s://%s:%s%s?%s" % (protocol, host, port, path, request_url) request_url = "%s://%s:%s%s?%s" % (protocol, host, port, path, request_url)