Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ Compute
``False``. (GITHUB-1334, GITHUB-1335)
[@r2ronoha]

- [GCE] Add optional ``cpuPlatform`` and ``minCpuPlatform`` attributes to the
``node.extra`` dictionary. (GITHUB-1342, GITHUB-1343)
[@yairshemla]

Storage
~~~~~~~

Expand All @@ -202,6 +206,11 @@ Storage
responses. (GITHUB-1325, GITHUB-1322)
[Clemens Wolff - @c-w]

- [Azure Blobs] Detect bad version of requests that leads to errors in parsing
Azure Storage responses. This scenario is known to happen on RHEL 7.6 when
requests was installed via yum. (GITHUB-1332, GITHUB-1322)
[Clemens Wolff - @c-w]

- [Common, CloudFiles] Fix ``upload_object_via_stream`` and ensure we start
from the beginning when calculating hash for the provided iterator. This way
we avoid hash mismatch errors in scenario where provided iterator is already
Expand Down
20 changes: 20 additions & 0 deletions libcloud/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
except ImportError:
have_paramiko = False

try:
import requests # NOQA
have_requests = True
except ImportError:
have_requests = False

__all__ = [
'__version__',
'enable_debug'
Expand Down Expand Up @@ -72,6 +78,8 @@ def _init_once():

This checks for the LIBCLOUD_DEBUG environment variable, which if it exists
is where we will log debug information about the provider transports.

This also checks for known environment/dependency incompatibilities.
"""
path = os.getenv('LIBCLOUD_DEBUG')
if path:
Expand All @@ -92,5 +100,17 @@ def _init_once():
if have_paramiko and hasattr(paramiko.util, 'log_to_file'):
paramiko.util.log_to_file(filename=path, level=logging.DEBUG)

# check for broken `yum install python-requests`
if have_requests and requests.__version__ == '2.6.0':
chardet_version = requests.packages.chardet.__version__
required_chardet_version = '2.3.0'
assert chardet_version == required_chardet_version, (
'Known bad version of requests detected! This can happen when '
'requests was installed from a source other than PyPI, e.g. via '
'a package manager such as yum. Please either install requests '
'from PyPI or run `pip install chardet==%s` to resolve this '
'issue.' % required_chardet_version
)


_init_once()
2 changes: 2 additions & 0 deletions libcloud/compute/drivers/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -8849,6 +8849,8 @@ def _to_node(self, node, use_disk_cache=False):
extra['zone'] = self.ex_get_zone(node['zone'])
extra['image'] = node.get('image')
extra['machineType'] = node.get('machineType')
extra['cpuPlatform'] = node.get('cpuPlatform')
extra['minCpuPlatform'] = node.get('minCpuPlatform')
extra['disks'] = node.get('disks', [])
extra['networkInterfaces'] = node.get('networkInterfaces')
extra['id'] = node['id']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
},
"selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/instances/node-name",
"status": "RUNNING",
"cpuPlatform": "Intel Skylake",
"minCpuPlatform": "Intel Skylake",
"tags": {
"fingerprint": "42WmSpB8rSM="
},
Expand All @@ -52,4 +54,4 @@
],
"kind": "compute#instanceList",
"selfLink": "https://www.googleapis.com/compute/v1/projects/project_name/zones/us-central1-a/instances"
}
}
2 changes: 2 additions & 0 deletions libcloud/test/compute/test_gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ def test_list_nodes(self):
self.assertEqual(len(nodes_uc1a), 1)
self.assertEqual(nodes[0].name, 'node-name')
self.assertEqual(nodes_uc1a[0].name, 'node-name')
self.assertEqual(nodes_uc1a[0].extra['cpuPlatform'], 'Intel Skylake')
self.assertEqual(nodes_uc1a[0].extra['minCpuPlatform'], 'Intel Skylake')

names = [n.name for n in nodes_all]
self.assertTrue('node-name' in names)
Expand Down
14 changes: 14 additions & 0 deletions libcloud/test/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
except ImportError:
have_paramiko = False

from mock import patch

import libcloud
from libcloud import _init_once
from libcloud.utils.loggingconnection import LoggingConnection
Expand Down Expand Up @@ -64,6 +66,18 @@ def test_raises_error(self):
with self.assertRaises(DriverTypeNotFoundError):
libcloud.get_driver('potato', 'potato')

@patch.object(libcloud.requests, '__version__', '2.6.0')
@patch.object(libcloud.requests.packages.chardet, '__version__', '2.2.1')
def test_init_once_detects_bad_yum_install_requests(self, *args):
expected_msg = 'Known bad version of requests detected'
with self.assertRaisesRegexp(AssertionError, expected_msg):
_init_once()

@patch.object(libcloud.requests, '__version__', '2.6.0')
@patch.object(libcloud.requests.packages.chardet, '__version__', '2.3.0')
def test_init_once_correct_chardet_version(self, *args):
_init_once()


if __name__ == '__main__':
sys.exit(unittest.main())