Fixes requirements on Linux
Platform specific requirements can not be included in requirements.txt Includes also: * testr configuration file * PEP8 fixes * Unit test fixes for passing OpenStack Jenkins checks Change-Id: I6f3f367f3316e0b506bb62e66d7671f9e52c72b5 Closes-Bug: #1376816
This commit is contained in:
parent
5c15cbf4c0
commit
23ddd33fa4
8
.testr.conf
Normal file
8
.testr.conf
Normal file
@ -0,0 +1,8 @@
|
||||
[DEFAULT]
|
||||
test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
||||
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
|
||||
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-160} \
|
||||
${PYTHON:-python} -m subunit.run discover -t ./ ./cloudbaseinit/tests $LISTOPT $IDOPTION
|
||||
|
||||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
@ -9,7 +9,8 @@
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
class CloudbaseInitException(Exception):
|
||||
|
@ -62,7 +62,7 @@ class BaseMetadataService(object):
|
||||
return action()
|
||||
except NotExistingMetadataException:
|
||||
raise
|
||||
except:
|
||||
except Exception:
|
||||
if self._enable_retry and i < CONF.retry_count:
|
||||
i += 1
|
||||
time.sleep(CONF.retry_count_interval)
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
# Copyright 2012 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
@ -50,7 +50,7 @@ class NetworkConfigPlugin(base.BasePlugin):
|
||||
|
||||
LOG.debug('network config content:\n%s' % debian_network_conf)
|
||||
|
||||
# TODO (alexpilotti): implement a proper grammar
|
||||
# TODO(alexpilotti): implement a proper grammar
|
||||
m = re.search(r'iface eth0 inet static\s+'
|
||||
r'address\s+(?P<address>[^\s]+)\s+'
|
||||
r'netmask\s+(?P<netmask>[^\s]+)\s+'
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
# Copyright 2013 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
# Copyright 2013 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
# Copyright 2013 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
@ -17,23 +17,30 @@
|
||||
import mock
|
||||
import os
|
||||
import posixpath
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from oslo.config import cfg
|
||||
from six.moves.urllib import error
|
||||
|
||||
from cloudbaseinit.metadata.services import base
|
||||
from cloudbaseinit.metadata.services import maasservice
|
||||
from cloudbaseinit.utils import x509constants
|
||||
|
||||
if sys.version_info < (3, 0):
|
||||
# TODO(alexpilotti) replace oauth with a Python 3 compatible module
|
||||
from cloudbaseinit.metadata.services import maasservice
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class MaaSHttpServiceTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mock_oauth = mock.MagicMock()
|
||||
maasservice.oauth = self.mock_oauth
|
||||
self._maasservice = maasservice.MaaSHttpService()
|
||||
if sys.version_info < (3, 0):
|
||||
self.mock_oauth = mock.MagicMock()
|
||||
maasservice.oauth = self.mock_oauth
|
||||
self._maasservice = maasservice.MaaSHttpService()
|
||||
else:
|
||||
self.skipTest("Python 3 is not yet supported for maasservice")
|
||||
|
||||
@mock.patch("cloudbaseinit.metadata.services.maasservice.MaaSHttpService"
|
||||
"._get_data")
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
# Copyright 2013 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
# Copyright 2013 Cloudbase Solutions Srl
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the 'License'); you may
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
@ -18,11 +18,19 @@ import importlib
|
||||
import mock
|
||||
import unittest
|
||||
|
||||
from cloudbaseinit import exception
|
||||
|
||||
|
||||
class FakeComError(Exception):
|
||||
def __init__(self):
|
||||
super(FakeComError, self).__init__()
|
||||
self.excepinfo = [None, None, None, None, None, -2144108544]
|
||||
|
||||
|
||||
class WinRMConfigTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self._pywintypes_mock = mock.MagicMock()
|
||||
self._pywintypes_mock.com_error = FakeComError
|
||||
self._win32com_mock = mock.MagicMock()
|
||||
self._module_patcher = mock.patch.dict(
|
||||
'sys.modules',
|
||||
@ -179,8 +187,9 @@ class WinRMConfigTests(unittest.TestCase):
|
||||
fake_session.Get.side_effect = [resource]
|
||||
mock_get_wsman_session.return_value = fake_session
|
||||
|
||||
if resource is Exception:
|
||||
self.assertRaises(Exception, self._winrmconfig._get_resource,
|
||||
if resource is exception.CloudbaseInitException:
|
||||
self.assertRaises(exception.CloudbaseInitException,
|
||||
self._winrmconfig._get_resource,
|
||||
fake_uri)
|
||||
else:
|
||||
response = self._winrmconfig._get_resource(fake_uri)
|
||||
@ -193,7 +202,7 @@ class WinRMConfigTests(unittest.TestCase):
|
||||
self._test_get_resource(resource='fake resource')
|
||||
|
||||
def test_get_resource_exception(self):
|
||||
self._test_get_resource(resource=Exception)
|
||||
self._test_get_resource(resource=exception.CloudbaseInitException)
|
||||
|
||||
@mock.patch('cloudbaseinit.utils.windows.winrmconfig.WinRMConfig.'
|
||||
'_get_wsman_session')
|
||||
|
@ -193,6 +193,6 @@ class CryptManager(object):
|
||||
raise OpenSSLException()
|
||||
|
||||
return RSAWrapper(rsa_p)
|
||||
except:
|
||||
except Exception:
|
||||
openssl.RSA_free(rsa_p)
|
||||
raise
|
||||
|
@ -37,9 +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):
|
||||
|
1
doc/source/conf.py
Normal file
1
doc/source/conf.py
Normal file
@ -0,0 +1 @@
|
||||
# Temporary placeholder
|
@ -1,9 +1,7 @@
|
||||
pbr>=0.5.22,!=0.5.23,<1.0
|
||||
pywin32
|
||||
comtypes
|
||||
wmi
|
||||
iso8601
|
||||
eventlet
|
||||
netaddr>=0.7.6
|
||||
pyserial
|
||||
oslo.config
|
||||
six>=1.7.0
|
||||
|
@ -28,6 +28,9 @@ packages =
|
||||
setup-hooks =
|
||||
pbr.hooks.setup_hook
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
|
||||
[entry_points]
|
||||
console_scripts =
|
||||
cloudbase-init = cloudbaseinit.shell:main
|
||||
|
8
setup.py
8
setup.py
@ -15,7 +15,13 @@
|
||||
# under the License.
|
||||
|
||||
import setuptools
|
||||
import sys
|
||||
|
||||
if sys.platform == 'win32':
|
||||
platform_requirements = ['pywin32', 'comtypes', 'wmi']
|
||||
else:
|
||||
platform_requirements = []
|
||||
|
||||
setuptools.setup(
|
||||
setup_requires=['pbr>=0.5.22,!=0.5.23'],
|
||||
setup_requires=['pbr>=0.5.22,!=0.5.23'] + platform_requirements,
|
||||
pbr=True)
|
||||
|
@ -2,4 +2,7 @@ hacking>=0.5.6,<0.8
|
||||
coverage>=3.6
|
||||
fixtures>=0.3.14
|
||||
mock>=1.0
|
||||
sphinx>=1.1.2,<1.1.999
|
||||
oslosphinx
|
||||
testtools>=0.9.32
|
||||
testrepository>=0.0.18
|
||||
|
Loading…
Reference in New Issue
Block a user