ab2959b14f
This patchset adds support for focal to the charm, enables the bionic-ussuri and focal-ussuri bundles which verify that the charm works and tests on focal with ussuri. In order for the tests to land, serveral dependent changes to other charms are needed (see links) just so that the charms will run on focal. Also, cinder needs to use local block devices, and due to the related error, a change to charm-test-infra model-defaults is needed for the charm to pass its tests. Links: - disable vdb in charm-test-infra - placement charm focal support - neutron-openvswitch charm focal support - rabbitmq-server charm focal support Change-Id: I99ce6888a9570b34e1a171242a787ed93abdf82d charm-test-infra: https://github.com/openstack-charmers/charm-test-infra/pull/42 Depends-On: If43d096c6bd5c57d00d92c54bc0ce464ba50bfa1 Depends-On: Ie744c1ff4c6651633d12dcd4de28d5e7a3e8646f Depends-On: Ia239b7c2f0ed2383e220cf0fa4ade443149a3b32
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
import platform
|
|
import os
|
|
|
|
|
|
def get_platform():
|
|
"""Return the current OS platform.
|
|
|
|
For example: if current os platform is Ubuntu then a string "ubuntu"
|
|
will be returned (which is the name of the module).
|
|
This string is used to decide which platform module should be imported.
|
|
"""
|
|
# linux_distribution is deprecated and will be removed in Python 3.7
|
|
# Warnings *not* disabled, as we certainly need to fix this.
|
|
if hasattr(platform, 'linux_distribution'):
|
|
tuple_platform = platform.linux_distribution()
|
|
current_platform = tuple_platform[0]
|
|
else:
|
|
current_platform = _get_platform_from_fs()
|
|
|
|
if "Ubuntu" in current_platform:
|
|
return "ubuntu"
|
|
elif "CentOS" in current_platform:
|
|
return "centos"
|
|
elif "debian" in current_platform:
|
|
# Stock Python does not detect Ubuntu and instead returns debian.
|
|
# Or at least it does in some build environments like Travis CI
|
|
return "ubuntu"
|
|
elif "elementary" in current_platform:
|
|
# ElementaryOS fails to run tests locally without this.
|
|
return "ubuntu"
|
|
else:
|
|
raise RuntimeError("This module is not supported on {}."
|
|
.format(current_platform))
|
|
|
|
|
|
def _get_platform_from_fs():
|
|
"""Get Platform from /etc/os-release."""
|
|
with open(os.path.join(os.sep, 'etc', 'os-release')) as fin:
|
|
content = dict(
|
|
line.split('=', 1)
|
|
for line in fin.read().splitlines()
|
|
if '=' in line
|
|
)
|
|
for k, v in content.items():
|
|
content[k] = v.strip('"')
|
|
return content["NAME"]
|