distro
distro copied to clipboard
CloudLinux VM not recognized
I've encountered a CloudLinux VM that distro
is unable to recognize:
$ distro
Name:
Version:
Codename:
$ python -c 'import distro; print(distro.linux_distribution())'
('', '', '')
The problem is that none of the normal search strategies work:
$ which lsb_release
/usr/bin/which: no lsb_release in (...)
$ ls /etc/*release
ls: cannot access /etc/*release: No such file or directory
$ ls /etc/*version
ls: cannot access /etc/*version: No such file or directory
$ uname -a
Linux web.illinois.edu 3.10.0-962.3.2.lve1.5.24.9.el7.x86_64 #1 SMP Wed Feb 13 08:24:50 EST 2019 x86_64 x86_64 x86_64 GNU/Linux
$ cat /proc/version
Linux version 3.10.0-962.3.2.lve1.5.24.9.el7.x86_64 ([email protected]) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Wed Feb 13 08:24:50 EST 2019
The only strategy that seems to work is:
$ hostnamectl
Static hostname: web.illinois.edu
Icon name: computer-vm
Chassis: vm
Boot ID: 5b5b8c522ccd4974808f192aea001491
Virtualization: kvm
Operating System: CloudLinux 7.6 (Vladimir Lyakhov)
CPE OS Name: cpe:/o:cloudlinux:cloudlinux:7.6:GA:server
Kernel: Linux 3.10.0-962.3.2.lve1.5.24.9.el7.x86_64
Architecture: x86-64
We may need to add another search strategy to support this type of VM.
Hey @adamjstewart, do you know where the CPE is provisioned in such an environment ? Thanks, bye 👋
What is a CPE?
Common Platform Enumeration, look at hostnamectl
output.
I'll do some research on my own soon.
Hostnamectl output is attached above. Is there something else you need from me?
So we are looking for OperatingSystemPrettyName
and OperatingSystemCPEName
D-Bus attributes (see sources).
If we can manage to fetch them without reading from the bus (maybe they are provisioned on the file system too ?), we could then implement a trivial CPE parser and extract information from there.
I recursively grepped the entire OS for those strings but didn't find anything useful. Maybe it would be easier to build a hostnamectl
parser?
Thanks for trying this.
hostnamectl --json=short
could make this straightforward.
Maybe we are missing something, and others got a better idea ? Another way would be to read from D-Bus directly... A Python dependency is required though. See you 👋
This version of hostnamectl
doesn't have a --json
option.
So re.search
around hostnamectl
output, or something like dcar if we want to stop calling binaries directly in the future.