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
|
# 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
|
# 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):
|
class CloudbaseInitException(Exception):
|
||||||
|
@ -62,7 +62,7 @@ class BaseMetadataService(object):
|
|||||||
return action()
|
return action()
|
||||||
except NotExistingMetadataException:
|
except NotExistingMetadataException:
|
||||||
raise
|
raise
|
||||||
except:
|
except Exception:
|
||||||
if self._enable_retry and i < CONF.retry_count:
|
if self._enable_retry and i < CONF.retry_count:
|
||||||
i += 1
|
i += 1
|
||||||
time.sleep(CONF.retry_count_interval)
|
time.sleep(CONF.retry_count_interval)
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Copyright 2012 Cloudbase Solutions Srl
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# 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
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
@ -50,7 +50,7 @@ class NetworkConfigPlugin(base.BasePlugin):
|
|||||||
|
|
||||||
LOG.debug('network config content:\n%s' % debian_network_conf)
|
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+'
|
m = re.search(r'iface eth0 inet static\s+'
|
||||||
r'address\s+(?P<address>[^\s]+)\s+'
|
r'address\s+(?P<address>[^\s]+)\s+'
|
||||||
r'netmask\s+(?P<netmask>[^\s]+)\s+'
|
r'netmask\s+(?P<netmask>[^\s]+)\s+'
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Copyright 2013 Cloudbase Solutions Srl
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# 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
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Copyright 2013 Cloudbase Solutions Srl
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# 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
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Copyright 2013 Cloudbase Solutions Srl
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# 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
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
@ -17,23 +17,30 @@
|
|||||||
import mock
|
import mock
|
||||||
import os
|
import os
|
||||||
import posixpath
|
import posixpath
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
from six.moves.urllib import error
|
from six.moves.urllib import error
|
||||||
|
|
||||||
from cloudbaseinit.metadata.services import base
|
from cloudbaseinit.metadata.services import base
|
||||||
from cloudbaseinit.metadata.services import maasservice
|
|
||||||
from cloudbaseinit.utils import x509constants
|
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
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
class MaaSHttpServiceTest(unittest.TestCase):
|
class MaaSHttpServiceTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.mock_oauth = mock.MagicMock()
|
if sys.version_info < (3, 0):
|
||||||
maasservice.oauth = self.mock_oauth
|
self.mock_oauth = mock.MagicMock()
|
||||||
self._maasservice = maasservice.MaaSHttpService()
|
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"
|
@mock.patch("cloudbaseinit.metadata.services.maasservice.MaaSHttpService"
|
||||||
"._get_data")
|
"._get_data")
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Copyright 2013 Cloudbase Solutions Srl
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# 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
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
# Copyright 2013 Cloudbase Solutions Srl
|
# 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
|
# not use this file except in compliance with the License. You may obtain
|
||||||
# a copy of the License at
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# 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
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
@ -18,11 +18,19 @@ import importlib
|
|||||||
import mock
|
import mock
|
||||||
import unittest
|
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):
|
class WinRMConfigTests(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self._pywintypes_mock = mock.MagicMock()
|
self._pywintypes_mock = mock.MagicMock()
|
||||||
|
self._pywintypes_mock.com_error = FakeComError
|
||||||
self._win32com_mock = mock.MagicMock()
|
self._win32com_mock = mock.MagicMock()
|
||||||
self._module_patcher = mock.patch.dict(
|
self._module_patcher = mock.patch.dict(
|
||||||
'sys.modules',
|
'sys.modules',
|
||||||
@ -179,8 +187,9 @@ class WinRMConfigTests(unittest.TestCase):
|
|||||||
fake_session.Get.side_effect = [resource]
|
fake_session.Get.side_effect = [resource]
|
||||||
mock_get_wsman_session.return_value = fake_session
|
mock_get_wsman_session.return_value = fake_session
|
||||||
|
|
||||||
if resource is Exception:
|
if resource is exception.CloudbaseInitException:
|
||||||
self.assertRaises(Exception, self._winrmconfig._get_resource,
|
self.assertRaises(exception.CloudbaseInitException,
|
||||||
|
self._winrmconfig._get_resource,
|
||||||
fake_uri)
|
fake_uri)
|
||||||
else:
|
else:
|
||||||
response = self._winrmconfig._get_resource(fake_uri)
|
response = self._winrmconfig._get_resource(fake_uri)
|
||||||
@ -193,7 +202,7 @@ class WinRMConfigTests(unittest.TestCase):
|
|||||||
self._test_get_resource(resource='fake resource')
|
self._test_get_resource(resource='fake resource')
|
||||||
|
|
||||||
def test_get_resource_exception(self):
|
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.'
|
@mock.patch('cloudbaseinit.utils.windows.winrmconfig.WinRMConfig.'
|
||||||
'_get_wsman_session')
|
'_get_wsman_session')
|
||||||
|
@ -193,6 +193,6 @@ class CryptManager(object):
|
|||||||
raise OpenSSLException()
|
raise OpenSSLException()
|
||||||
|
|
||||||
return RSAWrapper(rsa_p)
|
return RSAWrapper(rsa_p)
|
||||||
except:
|
except Exception:
|
||||||
openssl.RSA_free(rsa_p)
|
openssl.RSA_free(rsa_p)
|
||||||
raise
|
raise
|
||||||
|
@ -37,9 +37,7 @@ def check_url(url, retries_count=MAX_URL_CHECK_RETRIES):
|
|||||||
|
|
||||||
|
|
||||||
def check_metadata_ip_route(metadata_url):
|
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()
|
osutils = osutils_factory.get_os_utils()
|
||||||
|
|
||||||
if sys.platform == 'win32' and osutils.check_os_version(6, 0):
|
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
|
pbr>=0.5.22,!=0.5.23,<1.0
|
||||||
pywin32
|
|
||||||
comtypes
|
|
||||||
wmi
|
|
||||||
iso8601
|
iso8601
|
||||||
eventlet
|
eventlet
|
||||||
|
netaddr>=0.7.6
|
||||||
pyserial
|
pyserial
|
||||||
oslo.config
|
oslo.config
|
||||||
six>=1.7.0
|
six>=1.7.0
|
||||||
|
@ -28,6 +28,9 @@ packages =
|
|||||||
setup-hooks =
|
setup-hooks =
|
||||||
pbr.hooks.setup_hook
|
pbr.hooks.setup_hook
|
||||||
|
|
||||||
|
[build_sphinx]
|
||||||
|
source-dir = doc/source
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
cloudbase-init = cloudbaseinit.shell:main
|
cloudbase-init = cloudbaseinit.shell:main
|
||||||
|
8
setup.py
8
setup.py
@ -15,7 +15,13 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import setuptools
|
import setuptools
|
||||||
|
import sys
|
||||||
|
|
||||||
|
if sys.platform == 'win32':
|
||||||
|
platform_requirements = ['pywin32', 'comtypes', 'wmi']
|
||||||
|
else:
|
||||||
|
platform_requirements = []
|
||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
setup_requires=['pbr>=0.5.22,!=0.5.23'],
|
setup_requires=['pbr>=0.5.22,!=0.5.23'] + platform_requirements,
|
||||||
pbr=True)
|
pbr=True)
|
||||||
|
@ -2,4 +2,7 @@ hacking>=0.5.6,<0.8
|
|||||||
coverage>=3.6
|
coverage>=3.6
|
||||||
fixtures>=0.3.14
|
fixtures>=0.3.14
|
||||||
mock>=1.0
|
mock>=1.0
|
||||||
|
sphinx>=1.1.2,<1.1.999
|
||||||
|
oslosphinx
|
||||||
testtools>=0.9.32
|
testtools>=0.9.32
|
||||||
|
testrepository>=0.0.18
|
||||||
|
Loading…
Reference in New Issue
Block a user