summaryrefslogtreecommitdiff
path: root/cloudinit/util.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-06-15 10:03:45 -0400
committerScott Moser <smoser@brickies.net>2017-06-15 17:10:54 -0400
commitecb408afa1104fe49ce6eb1dc5708be56abd5cb2 (patch)
tree8d1161c2f44f07aec73348fa6d2c8a14701d7dd6 /cloudinit/util.py
parent9ccb8f5e2ab262ee04bb9c103c1302479f7c81d3 (diff)
downloadvyos-cloud-init-ecb408afa1104fe49ce6eb1dc5708be56abd5cb2.tar.gz
vyos-cloud-init-ecb408afa1104fe49ce6eb1dc5708be56abd5cb2.zip
FreeBSD: Make freebsd a variant, fix unittests and tools/build-on-freebsd.
- Simplify the logic of 'variant' in util.system_info much of the data from https://github.com/hpcugent/easybuild/wiki/OS_flavor_name_version - fix get_resource_disk_on_freebsd when running on a system without an Azure resource disk. - fix tools/build-on-freebsd to replace oauth with oauthlib and add bash which is a dependency for tests. - update a fiew places that were checking for freebsd but not using the util.is_FreeBSD()
Diffstat (limited to 'cloudinit/util.py')
-rw-r--r--cloudinit/util.py46
1 files changed, 19 insertions, 27 deletions
diff --git a/cloudinit/util.py b/cloudinit/util.py
index ec68925e..c93b6d7e 100644
--- a/cloudinit/util.py
+++ b/cloudinit/util.py
@@ -573,7 +573,7 @@ def is_ipv4(instr):
def is_FreeBSD():
- return system_info()['platform'].startswith('FreeBSD')
+ return system_info()['variant'] == "freebsd"
def get_cfg_option_bool(yobj, key, default=False):
@@ -598,37 +598,29 @@ def get_cfg_option_int(yobj, key, default=0):
def system_info():
info = {
'platform': platform.platform(),
+ 'system': platform.system(),
'release': platform.release(),
'python': platform.python_version(),
'uname': platform.uname(),
- 'dist': platform.linux_distribution(), # pylint: disable=W1505
+ 'dist': platform.dist(), # pylint: disable=W1505
}
- plat = info['platform'].lower()
- # Try to get more info about what it actually is, in a format
- # that we can easily use across linux and variants...
- if plat.startswith('darwin'):
- info['variant'] = 'darwin'
- elif plat.endswith("bsd"):
- info['variant'] = 'bsd'
- elif plat.startswith('win'):
- info['variant'] = 'windows'
- elif 'linux' in plat:
- # Try to get a single string out of these...
- linux_dist, _version, _id = info['dist']
- linux_dist = linux_dist.lower()
- if linux_dist in ('ubuntu', 'linuxmint', 'mint'):
- info['variant'] = 'ubuntu'
+ system = info['system'].lower()
+ var = 'unknown'
+ if system == "linux":
+ linux_dist = info['dist'][0].lower()
+ if linux_dist in ('centos', 'fedora', 'debian'):
+ var = linux_dist
+ elif linux_dist in ('ubuntu', 'linuxmint', 'mint'):
+ var = 'ubuntu'
+ elif linux_dist == 'redhat':
+ var = 'rhel'
else:
- for prefix, variant in [('redhat', 'rhel'),
- ('centos', 'centos'),
- ('fedora', 'fedora'),
- ('debian', 'debian')]:
- if linux_dist.startswith(prefix):
- info['variant'] = variant
- if 'variant' not in info:
- info['variant'] = 'linux'
- if 'variant' not in info:
- info['variant'] = 'unknown'
+ var = 'linux'
+ elif system in ('windows', 'darwin', "freebsd"):
+ var = system
+
+ info['variant'] = var
+
return info