charm-nova-compute-proxy/hooks/charmhelpers/osplatform.py
Andrew McLeod 66707ffa31 Pre-release charm-helpers sync 17.02
Get each charm up to date with lp:charm-helpers for release testing.
Add necessary relation between nova cloud controller and neutron gateway
Closes-Bug: 1665008
Change-Id: I3fb3769b147d42d36e53293b759d394f2dc63071
2017-03-02 11:59:50 +01:00

26 lines
982 B
Python

import platform
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
# Warings *not* disabled, as we certainly need to fix this.
tuple_platform = platform.linux_distribution()
current_platform = tuple_platform[0]
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"
else:
raise RuntimeError("This module is not supported on {}."
.format(current_platform))