Skip to content

Commit

Permalink
Global mass refactor
Browse files Browse the repository at this point in the history
* remove unnecessary vim comments
* use unittest.mock first, then mock
* consistent spaces
* ignore *.orig files
* pep8 & flake8 compliant

Change-Id: I48e8b5c13b8ea436a48180f526e97fa8da003b68
  • Loading branch information
cmin764 committed Jan 18, 2015
1 parent 66be2a3 commit 415bdc7
Show file tree
Hide file tree
Showing 99 changed files with 251 additions and 189 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,6 +5,7 @@
*.pyc
*.swo
*.swp
*.orig
*.sqlite
.autogenerated
.coverage
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/init.py
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/metadata/factory.py
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/metadata/services/configdrive.py
@@ -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
Expand Down Expand Up @@ -40,6 +38,7 @@


class ConfigDriveService(baseopenstackservice.BaseOpenStackService):

def __init__(self):
super(ConfigDriveService, self).__init__()
self._metadata_path = None
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/metadata/services/httpservice.py
@@ -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
Expand Down
1 change: 1 addition & 0 deletions cloudbaseinit/metadata/services/osconfigdrive/base.py
Expand Up @@ -16,6 +16,7 @@


class BaseConfigDriveManager(object):

@abc.abstractmethod
def get_config_drive_files(self, target_path, check_raw_hhd=True,
check_cdrom=True):
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/metadata/services/osconfigdrive/windows.py
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/osutils/base.py
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/osutils/factory.py
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/osutils/posix.py
@@ -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
Expand All @@ -20,5 +18,6 @@


class PosixUtil(base.BaseOSUtils):

def reboot(self):
os.system('reboot')
3 changes: 1 addition & 2 deletions cloudbaseinit/plugins/base.py
@@ -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
Expand All @@ -19,6 +17,7 @@


class BasePlugin(object):

def get_name(self):
return self.__class__.__name__

Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/plugins/constants.py
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/plugins/factory.py
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/plugins/windows/createuser.py
@@ -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
Expand Down Expand Up @@ -36,6 +34,7 @@


class CreateUserPlugin(base.BasePlugin):

def _get_password(self, osutils):
# Generate a temporary random password to be replaced
# by SetUserPasswordPlugin (starting from Grizzly)
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/plugins/windows/extendvolumes.py
@@ -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
Expand Down Expand Up @@ -44,6 +42,7 @@


class ExtendVolumesPlugin(base.BasePlugin):

def _extend_volumes(self, pack, volume_idxs=None):
enum = pack.QueryVolumes()
while True:
Expand Down
1 change: 1 addition & 0 deletions cloudbaseinit/plugins/windows/licensing.py
Expand Up @@ -33,6 +33,7 @@


class WindowsLicensingPlugin(base.BasePlugin):

def _run_slmgr(self, osutils, args):
if osutils.check_sysnative_dir_exists():
cscript_dir = osutils.get_sysnative_dir()
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/plugins/windows/sethostname.py
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/plugins/windows/setuserpassword.py
@@ -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
Expand All @@ -24,6 +22,7 @@
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 '
Expand All @@ -38,6 +37,7 @@


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:
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/plugins/windows/sshpublickeys.py
@@ -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
Expand Down Expand Up @@ -29,6 +27,7 @@


class SetUserSSHPublicKeysPlugin(base.BasePlugin):

def execute(self, service, shared_data):
public_keys = service.get_public_keys()
if not public_keys:
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/plugins/windows/userdata.py
@@ -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
Expand All @@ -25,6 +23,7 @@
from cloudbaseinit.plugins.windows import userdatautils
from cloudbaseinit.utils import encoding


LOG = logging.getLogger(__name__)


Expand Down
1 change: 1 addition & 0 deletions cloudbaseinit/plugins/windows/userdataplugins/base.py
Expand Up @@ -16,6 +16,7 @@


class BaseUserDataPlugin(object):

def __init__(self, mime_type):
self._mime_type = mime_type

Expand Down
Expand Up @@ -19,6 +19,7 @@


class CloudBootHookPlugin(base.BaseUserDataPlugin):

def __init__(self):
super(CloudBootHookPlugin, self).__init__("text/cloud-boothook")

Expand Down
Expand Up @@ -16,6 +16,7 @@


class MultipartMixedPlugin(base.BaseUserDataPlugin):

def __init__(self):
super(MultipartMixedPlugin, self).__init__("multipart/mixed")

Expand Down
Expand Up @@ -24,6 +24,7 @@


class PartHandlerPlugin(base.BaseUserDataPlugin):

def __init__(self):
super(PartHandlerPlugin, self).__init__("text/part-handler")

Expand Down
Expand Up @@ -25,6 +25,7 @@


class ShellScriptPlugin(base.BaseUserDataPlugin):

def __init__(self):
super(ShellScriptPlugin, self).__init__("text/x-shellscript")

Expand Down
1 change: 1 addition & 0 deletions cloudbaseinit/plugins/windows/userdatautils.py
Expand Up @@ -18,6 +18,7 @@
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
Expand Down
4 changes: 2 additions & 2 deletions cloudbaseinit/plugins/windows/winrmcertificateauth.py
@@ -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
Expand All @@ -23,10 +21,12 @@
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:
Expand Down
3 changes: 1 addition & 2 deletions cloudbaseinit/plugins/windows/winrmlistener.py
@@ -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
Expand All @@ -23,6 +21,7 @@
from cloudbaseinit.utils.windows import winrmconfig
from cloudbaseinit.utils.windows import x509


LOG = logging.getLogger(__name__)

opts = [
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/shell.py
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/tests/__init__.py
@@ -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
Expand Down
1 change: 1 addition & 0 deletions cloudbaseinit/tests/fake.py
Expand Up @@ -14,6 +14,7 @@


class FakeComError(Exception):

def __init__(self):
super(FakeComError, self).__init__()
self.excepinfo = [None, None, None, None, None, -2144108544]
2 changes: 0 additions & 2 deletions cloudbaseinit/tests/metadata/__init__.py
@@ -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
Expand Down
2 changes: 0 additions & 2 deletions cloudbaseinit/tests/metadata/services/__init__.py
@@ -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
Expand Down
@@ -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
Expand Down
@@ -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
Expand All @@ -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


Expand Down
@@ -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
Expand All @@ -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
Expand Down
Expand Up @@ -17,7 +17,10 @@
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
Expand Down
5 changes: 4 additions & 1 deletion cloudbaseinit/tests/metadata/services/test_cloudstack.py
Expand Up @@ -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

Expand Down

0 comments on commit 415bdc7

Please sign in to comment.