diff options
author | Stuart Mackie <wsmackie@juniper.net> | 2017-07-25 10:37:57 -0700 |
---|---|---|
committer | Stuart Mackie <wsmackie@juniper.net> | 2017-07-25 10:37:57 -0700 |
commit | 711967ae9639095ce41500bb0e6f80c8b80fab95 (patch) | |
tree | 07f598b35664ddbd269b76f21cf587f5679cab86 /contrail-kubernetes/hooks/charmhelpers/osplatform.py | |
parent | efd4f1414b79dd51c6316a73893ade33bc9f668e (diff) |
Contrail charms
Change-Id: I2d259d03f63fce38348b8384e26ac23e3fce44a8
Signed-off-by: Stuart Mackie <wsmackie@juniper.net>
Diffstat (limited to 'contrail-kubernetes/hooks/charmhelpers/osplatform.py')
-rw-r--r-- | contrail-kubernetes/hooks/charmhelpers/osplatform.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/contrail-kubernetes/hooks/charmhelpers/osplatform.py b/contrail-kubernetes/hooks/charmhelpers/osplatform.py new file mode 100644 index 0000000..d9a4d5c --- /dev/null +++ b/contrail-kubernetes/hooks/charmhelpers/osplatform.py @@ -0,0 +1,25 @@ +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)) |