Python 3: hmac requires bytes key/msg

This change encodes hmac key/msg inputs because py3K requires it.

Change-Id: I54a6789aee2fb707c0d753f569d0b2d5fd460682
Blueprint: neutron-python3
This commit is contained in:
Cedric Brandily
2015-07-29 11:19:45 +00:00
parent 2445d75429
commit 60a9f4a6f8
2 changed files with 7 additions and 3 deletions
+6 -3
View File
@@ -269,9 +269,12 @@ class MetadataProxyHandler(object):
raise Exception(_('Unexpected response code: %s') % resp.status)
def _sign_instance_id(self, instance_id):
return hmac.new(self.conf.metadata_proxy_shared_secret,
instance_id,
hashlib.sha256).hexdigest()
secret = self.conf.metadata_proxy_shared_secret
if isinstance(secret, six.text_type):
secret = secret.encode('utf-8')
if isinstance(instance_id, six.text_type):
instance_id = instance_id.encode('utf-8')
return hmac.new(secret, instance_id, hashlib.sha256).hexdigest()
class UnixDomainMetadataProxy(object):
+1
View File
@@ -176,6 +176,7 @@ commands = python -m testtools.run \
neutron.tests.unit.api.rpc.handlers.test_dvr_rpc \
neutron.tests.unit.api.rpc.agentnotifiers.test_dhcp_rpc_agent_api \
neutron.tests.unit.api.v2.test_attributes \
neutron.tests.unit.agent.metadata.test_agent \
neutron.tests.unit.agent.metadata.test_driver \
neutron.tests.unit.agent.metadata.test_namespace_proxy \
neutron.tests.unit.agent.test_rpc \