Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 8651b93

Browse files
committed
Guest: Allow filtering os lists
So we can remove unsupported options in enterprisey distros.
1 parent 033ace2 commit 8651b93

2 files changed

Lines changed: 22 additions & 10 deletions

File tree

virtinst/Guest.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,30 +105,41 @@ def pretty_os_list():
105105
return ret
106106

107107
@staticmethod
108-
def list_os_types(supported=False):
108+
def list_os_types(supported=False, filtervars=None):
109+
"""
110+
@param filtervars: List of only variants we want to show by default
111+
"""
109112
vals = osdict.sort_helper(Guest._OS_TYPES)
110113
for t in vals[:]:
111-
if not Guest.list_os_variants(t, supported=supported):
114+
if not Guest.list_os_variants(t, supported=supported,
115+
filtervars=filtervars):
112116
vals.remove(t)
113117
return vals
114118

115119
@staticmethod
116-
def list_os_variants(type, sortpref=None, supported=False):
120+
def list_os_variants(type, sortpref=None, supported=False, filtervars=None):
117121
"""
118122
Return a list of sorted os variants for the passed distro type
119123
120124
@param sortpref: An option list of osdict 'distro' tags to
121125
prioritize in the returned list, e.g. passing ["fedora"] will make
122126
the sorted list have all fedora distros first
127+
@param filtervars: List of only variants we want to show by default
123128
"""
124129
vals = osdict.sort_helper(Guest._OS_TYPES[type]["variants"],
125130
sortpref)
126-
for v in vals[:]:
127-
if (supported and
128-
not osdict.lookup_osdict_key(None, None,
129-
type, v, "supported")):
130-
vals.remove(v)
131-
return vals
131+
ret = []
132+
for v in vals:
133+
if filtervars:
134+
if v not in filtervars:
135+
continue
136+
elif supported:
137+
if not osdict.lookup_osdict_key(None, None,
138+
type, v, "supported"):
139+
continue
140+
141+
ret.append(v)
142+
return ret
132143

133144
@staticmethod
134145
def get_os_type_label(type):

virtinst/osdict.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@ def lookup_device_param(conn, hv_type, os_type, var, device_key, param):
472472
"devices" : {
473473
DISK : VIRTIO_DISK,
474474
NET : VIRTIO_NET,
475-
},},
475+
},
476+
},
476477
"ubuntumaverick": {
477478
"label": "Ubuntu 10.10 (Maverick Meerkat)",
478479
"distro": "ubuntu",

0 commit comments

Comments
 (0)