Skip to content

Instantly share code, notes, and snippets.

@ssato
Created April 11, 2017 03:29
Show Gist options
  • Save ssato/71a27d60ad867d130524c811c1985ae6 to your computer and use it in GitHub Desktop.
Save ssato/71a27d60ad867d130524c811c1985ae6 to your computer and use it in GitHub Desktop.
Auto detect os and distribution w/ using osinfo-db
$ ipython
Python 2.7.13 (default, Jan 12 2017, 17:59:37)
Type "copyright", "credits" or "license" for more information.
IPython 3.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import sys
In [2]: sys.path.insert(-1, "/usr/share/virt-manager/")
In [3]: from virtinst.osdict import OSDB
In [4]: OSDB.lookup_os_by_media("/var/lib/libvirt/images/isos/CentOS-7-x86_64-DVD-1611.iso")
Out[4]: 'centos7.0'
In [5]: cat /etc/fedora-release
Fedora release 25 (Twenty Five)
In [6]: ^D
$ rpm -q osinfo-db virt-install
osinfo-db-20170225-1.fc25.noarch
virt-install-1.4.1-1.fc25.noarch
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment