Clean imports in code

This patch set modifies lines which are importing objects
instead of modules. As per openstack import guide lines, user should
import modules in a file not objects.

http://docs.openstack.org/developer/hacking/#imports

Change-Id: Ic4adc7064a1d9bf306a784c37db8d1d59b0c70ff
This commit is contained in:
Cao Xuan Hoang 2016-08-26 15:28:06 +07:00
parent a495438c9c
commit 3e6edb2f03
2 changed files with 11 additions and 10 deletions

View File

@ -27,7 +27,7 @@
import base64
from Crypto.Hash import HMAC
from Crypto import Hash
from Crypto import Random
from oslo_utils import importutils
import six
@ -82,7 +82,7 @@ class HKDF(object):
if salt is None:
salt = b'\x00' * self.hashfn.digest_size
return HMAC.new(salt, ikm, self.hashfn).digest()
return Hash.HMAC.new(salt, ikm, self.hashfn).digest()
def expand(self, prk, info, length):
"""An expand function that will return arbitrary length output that can
@ -101,7 +101,8 @@ class HKDF(object):
okm = b""
tmp = b""
for block in range(1, N + 1):
tmp = HMAC.new(prk, tmp + info + bchr(block), self.hashfn).digest()
tmp = Hash.HMAC.new(
prk, tmp + info + bchr(block), self.hashfn).digest()
okm += tmp
return okm[:length]
@ -190,7 +191,7 @@ class SymmetricCrypto(object):
:returns out: a base64 encoded signature.
"""
h = HMAC.new(key, msg, self.hashfn)
h = Hash.HMAC.new(key, msg, self.hashfn)
out = h.digest()
if b64encode:
out = base64.b64encode(out)

View File

@ -21,8 +21,8 @@ from heat.engine import environment
from heat.engine.resources.aws.cfn.wait_condition_handle import (
WaitConditionHandle)
from heat.engine.resources.aws.ec2 import instance
from heat.engine.resources.openstack.nova.server import Server
from heat.engine.scheduler import TaskRunner
from heat.engine.resources.openstack.nova import server
from heat.engine import scheduler
from heat.engine import service
from heat.engine import stack as stk
from heat.engine import template as tmpl
@ -215,7 +215,7 @@ class WaitConditionMetadataUpdateTest(common.HeatTestCase):
@mock.patch.object(instance.Instance, 'handle_create')
@mock.patch.object(instance.Instance, 'check_create_complete')
@mock.patch.object(instance.Instance, 'is_service_available')
@mock.patch.object(TaskRunner, '_sleep')
@mock.patch.object(scheduler.TaskRunner, '_sleep')
@mock.patch.object(WaitConditionHandle, 'identifier')
def test_wait_metadata(self, mock_identifier, mock_sleep, mock_available,
mock_check, mock_handle, *args):
@ -295,9 +295,9 @@ class MetadataRefreshServerTest(common.HeatTestCase):
return_value=1)
@mock.patch.object(glance.GlanceClientPlugin, 'find_image_by_name_or_id',
return_value=1)
@mock.patch.object(Server, 'handle_create')
@mock.patch.object(Server, 'check_create_complete')
@mock.patch.object(Server, 'FnGetAtt')
@mock.patch.object(server.Server, 'handle_create')
@mock.patch.object(server.Server, 'check_create_complete')
@mock.patch.object(server.Server, 'FnGetAtt')
def test_FnGetAtt_metadata_update(self, mock_get, mock_check,
mock_handle, *args):
temp = template_format.parse(TEST_TEMPLATE_SERVER)