Global mass refactor

* remove unnecessary vim comments
* use unittest.mock first, then mock
* consistent spaces
* ignore *.orig files
* pep8 & flake8 compliant

Change-Id: I48e8b5c13b8ea436a48180f526e97fa8da003b68
This commit is contained in:
Cosmin Poieana 2015-01-18 14:59:22 +02:00
parent 66be2a3654
commit 415bdc7a72
99 changed files with 251 additions and 189 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@
*.pyc
*.swo
*.swp
*.orig
*.sqlite
.autogenerated
.coverage

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -40,6 +38,7 @@ LOG = logging.getLogger(__name__)
class ConfigDriveService(baseopenstackservice.BaseOpenStackService):
def __init__(self):
super(ConfigDriveService, self).__init__()
self._metadata_path = None

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -16,6 +16,7 @@ import abc
class BaseConfigDriveManager(object):
@abc.abstractmethod
def get_config_drive_files(self, target_path, check_raw_hhd=True,
check_cdrom=True):

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -20,5 +18,6 @@ from cloudbaseinit.osutils import base
class PosixUtil(base.BaseOSUtils):
def reboot(self):
os.system('reboot')

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -19,6 +17,7 @@ PLUGIN_EXECUTE_ON_NEXT_BOOT = 2
class BasePlugin(object):
def get_name(self):
return self.__class__.__name__

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -36,6 +34,7 @@ LOG = logging.getLogger(__name__)
class CreateUserPlugin(base.BasePlugin):
def _get_password(self, osutils):
# Generate a temporary random password to be replaced
# by SetUserPasswordPlugin (starting from Grizzly)

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -44,6 +42,7 @@ LOG = logging.getLogger(__name__)
class ExtendVolumesPlugin(base.BasePlugin):
def _extend_volumes(self, pack, volume_idxs=None):
enum = pack.QueryVolumes()
while True:

View File

@ -33,6 +33,7 @@ LOG = logging.getLogger(__name__)
class WindowsLicensingPlugin(base.BasePlugin):
def _run_slmgr(self, osutils, args):
if osutils.check_sysnative_dir_exists():
cscript_dir = osutils.get_sysnative_dir()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -24,6 +22,7 @@ from cloudbaseinit.plugins import base
from cloudbaseinit.plugins import constants
from cloudbaseinit.utils import crypt
opts = [
cfg.BoolOpt('inject_user_password', default=True, help='Set the password '
'provided in the configuration. If False or no password is '
@ -38,6 +37,7 @@ LOG = logging.getLogger(__name__)
class SetUserPasswordPlugin(base.BasePlugin):
def _encrypt_password(self, ssh_pub_key, password):
cm = crypt.CryptManager()
with cm.load_ssh_rsa_public_key(ssh_pub_key) as rsa:

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -29,6 +27,7 @@ LOG = logging.getLogger(__name__)
class SetUserSSHPublicKeysPlugin(base.BasePlugin):
def execute(self, service, shared_data):
public_keys = service.get_public_keys()
if not public_keys:

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -25,6 +23,7 @@ from cloudbaseinit.plugins.windows.userdataplugins import factory
from cloudbaseinit.plugins.windows import userdatautils
from cloudbaseinit.utils import encoding
LOG = logging.getLogger(__name__)

View File

@ -16,6 +16,7 @@ import abc
class BaseUserDataPlugin(object):
def __init__(self, mime_type):
self._mime_type = mime_type

View File

@ -19,6 +19,7 @@ LOG = logging.getLogger(__name__)
class CloudBootHookPlugin(base.BaseUserDataPlugin):
def __init__(self):
super(CloudBootHookPlugin, self).__init__("text/cloud-boothook")

View File

@ -16,6 +16,7 @@ from cloudbaseinit.plugins.windows.userdataplugins import base
class MultipartMixedPlugin(base.BaseUserDataPlugin):
def __init__(self):
super(MultipartMixedPlugin, self).__init__("multipart/mixed")

View File

@ -24,6 +24,7 @@ LOG = logging.getLogger(__name__)
class PartHandlerPlugin(base.BaseUserDataPlugin):
def __init__(self):
super(PartHandlerPlugin, self).__init__("text/part-handler")

View File

@ -25,6 +25,7 @@ LOG = logging.getLogger(__name__)
class ShellScriptPlugin(base.BaseUserDataPlugin):
def __init__(self):
super(ShellScriptPlugin, self).__init__("text/x-shellscript")

View File

@ -18,6 +18,7 @@ import re
from cloudbaseinit.openstack.common import log as logging
from cloudbaseinit.plugins.common import execcmd
LOG = logging.getLogger(__name__)
# Avoid 80+ length by using a local variable, which

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -23,10 +21,12 @@ from cloudbaseinit.utils.windows import security
from cloudbaseinit.utils.windows import winrmconfig
from cloudbaseinit.utils.windows import x509
LOG = logging.getLogger(__name__)
class ConfigWinRMCertificateAuthPlugin(base.BasePlugin):
def _get_credentials(self, shared_data):
user_name = shared_data.get(constants.SHARED_DATA_USERNAME)
if not user_name:

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -23,6 +21,7 @@ from cloudbaseinit.utils.windows import security
from cloudbaseinit.utils.windows import winrmconfig
from cloudbaseinit.utils.windows import x509
LOG = logging.getLogger(__name__)
opts = [

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -14,6 +14,7 @@
class FakeComError(Exception):
def __init__(self):
super(FakeComError, self).__init__()
self.excepinfo = [None, None, None, None, None, -2144108544]

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import sys
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.metadata.services.osconfigdrive import factory

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,10 +13,13 @@
# under the License.
import importlib
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit import exception

View File

@ -17,7 +17,10 @@ import functools
import posixpath
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.metadata.services import base

View File

@ -12,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from six.moves import urllib

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,17 +13,21 @@
# under the License.
import importlib
import mock
import os
import unittest
import uuid
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
CONF = cfg.CONF
class ConfigDriveServiceTest(unittest.TestCase):
def setUp(self):
self._win32com_mock = mock.MagicMock()
self._ctypes_mock = mock.MagicMock()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import posixpath
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from six.moves.urllib import error
@ -28,6 +29,7 @@ CONF = cfg.CONF
class EC2ServiceTest(unittest.TestCase):
def setUp(self):
CONF.set_override('retry_count_interval', 0)
self._service = ec2service.EC2Service()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from six.moves.urllib import error
@ -28,6 +29,7 @@ CONF = cfg.CONF
class HttpServiceTest(unittest.TestCase):
def setUp(self):
CONF.set_override('retry_count_interval', 0)
self._httpservice = httpservice.HttpService()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,12 +12,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import posixpath
import sys
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from six.moves.urllib import error
@ -34,6 +35,7 @@ CONF = cfg.CONF
class MaaSHttpServiceTest(unittest.TestCase):
def setUp(self):
if sys.version_info < (3, 0):
self.mock_oauth = mock.MagicMock()

View File

@ -17,7 +17,10 @@ import re
import textwrap
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.metadata.services import base
from cloudbaseinit.metadata.services import opennebulaservice

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -17,9 +15,9 @@
import unittest
try:
import mock
except ImportError:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit import exception
from cloudbaseinit.metadata import factory

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,11 +12,15 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import subprocess
import sys
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.osutils import base

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.osutils import factory

View File

@ -17,7 +17,10 @@ import importlib
import os
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
import six

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -15,7 +15,10 @@
import os
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.plugins.common import execcmd
from cloudbaseinit.tests import testutils

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins import factory

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins import base

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,10 +13,13 @@
# under the License.
import importlib
import mock
import re
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
CONF = cfg.CONF

View File

@ -14,7 +14,10 @@
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.plugins.common import execcmd
from cloudbaseinit.plugins.windows import fileexecutils

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit import exception

View File

@ -12,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.plugins import base
from cloudbaseinit.plugins.windows import localscripts
from oslo.config import cfg

View File

@ -14,7 +14,10 @@
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
import six
from cloudbaseinit.plugins import base

View File

@ -16,7 +16,10 @@
import functools
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit import exception
from cloudbaseinit.metadata.services import base as service_base

View File

@ -12,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit import exception

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins import base

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins import constants

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit import exception

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.metadata.services import base as metadata_services_base

View File

@ -15,7 +15,10 @@
import os
import unittest
import mock
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.plugins.common import execcmd
from cloudbaseinit.plugins.windows import userdatautils

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,19 +13,24 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit import exception
from cloudbaseinit.plugins import base
from cloudbaseinit.plugins import constants
from oslo.config import cfg
CONF = cfg.CONF
class ConfigWinRMCertificateAuthPluginTests(unittest.TestCase):
def setUp(self):
self._ctypes_mock = mock.MagicMock()
self._win32com_mock = mock.MagicMock()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,16 +13,22 @@
# under the License.
import importlib
import mock
import unittest
from cloudbaseinit.plugins import base
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins import base
CONF = cfg.CONF
class ConfigWinRMListenerPluginTests(unittest.TestCase):
def setUp(self):
self._mock_wintypes = mock.MagicMock()
self._mock_pywintypes = mock.MagicMock()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins.windows.userdataplugins import cloudboothook

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,9 +13,12 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
CONF = cfg.CONF

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,9 +12,12 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins.windows.userdataplugins import factory

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins.windows.userdataplugins import heat

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.plugins.windows.userdataplugins import parthandler

View File

@ -12,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.plugins.windows.userdataplugins import shellscript

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import sys
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit import init
@ -27,6 +28,7 @@ CONF = cfg.CONF
class InitManagerTest(unittest.TestCase):
def setUp(self):
self._win32com_mock = mock.MagicMock()
self._comtypes_mock = mock.MagicMock()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -12,12 +12,16 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import netifaces
import socket
import struct
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.utils import dhcp

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,16 +13,20 @@
# under the License.
import importlib
import mock
import six
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
import six
CONF = cfg.CONF
class SerialPortHandlerTests(unittest.TestCase):
def setUp(self):
self._serial = mock.MagicMock()
self._stream = mock.MagicMock()

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -14,10 +12,13 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
import sys
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from oslo.config import cfg
from cloudbaseinit.utils import network
@ -26,6 +27,7 @@ CONF = cfg.CONF
class NetworkUtilsTest(unittest.TestCase):
@mock.patch('cloudbaseinit.osutils.factory.get_os_utils')
@mock.patch('six.moves.urllib.parse.urlparse')
def _test_check_metadata_ip_route(self, mock_urlparse, mock_get_os_utils,

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -13,9 +13,13 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit import exception as cbinit_exception

View File

@ -13,9 +13,13 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit import exception as cbinit_exception

View File

@ -13,12 +13,17 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
class FakeWindowsError(Exception):
"""WindowsError is available on Windows only."""
def __init__(self, errno):
self.errno = errno

View File

@ -13,9 +13,13 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
class WindowsVdsUtilsTests(unittest.TestCase):

View File

@ -13,9 +13,13 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit import exception

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,14 +13,19 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit import exception
from cloudbaseinit.tests import fake
class WinRMConfigTests(unittest.TestCase):
def setUp(self):
self._pywintypes_mock = mock.MagicMock()
self._pywintypes_mock.com_error = fake.FakeComError

View File

@ -13,9 +13,13 @@
# under the License.
import importlib
import mock
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
class WS2_32UtilsTests(unittest.TestCase):

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,10 +13,14 @@
# under the License.
import importlib
import mock
import six
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from cloudbaseinit.utils import x509constants

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -23,6 +21,7 @@ LOG = logging.getLogger(__name__)
class ClassLoader(object):
def load_class(self, class_path):
LOG.debug('Loading class \'%s\'' % class_path)
parts = class_path.rsplit('.', 1)

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -103,6 +101,7 @@ class CryptException(Exception):
class OpenSSLException(CryptException):
def __init__(self):
message = self._get_openssl_error_msg()
super(OpenSSLException, self).__init__(message)
@ -116,6 +115,7 @@ class OpenSSLException(CryptException):
class RSAWrapper(object):
def __init__(self, rsa_p):
self._rsa_p = rsa_p
@ -145,6 +145,7 @@ class RSAWrapper(object):
class CryptManager(object):
def load_ssh_rsa_public_key(self, ssh_pub_key):
ssh_rsa_prefix = "ssh-rsa "

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2014 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -35,7 +35,9 @@ LOG = openstack_logging.getLogger(__name__)
class SerialPortHandler(logging.StreamHandler):
class _UnicodeToBytesStream(object):
def __init__(self, stream):
self._stream = stream

View File

@ -37,7 +37,7 @@ def check_url(url, retries_count=MAX_URL_CHECK_RETRIES):
def check_metadata_ip_route(metadata_url):
#Workaround for: https://bugs.launchpad.net/quantum/+bug/1174657
# Workaround for: https://bugs.launchpad.net/quantum/+bug/1174657
osutils = osutils_factory.get_os_utils()
if sys.platform == 'win32' and osutils.check_os_version(6, 0):

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -21,6 +19,7 @@ from ctypes import wintypes
class CryptoAPIException(Exception):
def __init__(self):
message = self._get_windows_error()
super(CryptoAPIException, self).__init__(message)

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2013 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may

View File

@ -1,5 +1,3 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Cloudbase Solutions Srl
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may