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

Commit e1c498e

Browse files
committed
osdict: Add RHEL 5.4 (and later) value
Also, fix up the URL test suite to verify this change.
1 parent 6ec28e3 commit e1c498e

4 files changed

Lines changed: 105 additions & 30 deletions

File tree

tests/urltest.py

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,16 @@ def distroClass(distname):
113113
'x86_64': FEDORA_BASEURL % ("11", "x86_64"),
114114
'distro': ("linux", "fedora11")
115115
},
116-
"fedora-rawhide" : {
117-
'i386' : FEDORA_RAWHIDE_BASEURL % ("i386"),
118-
'x86_64': FEDORA_RAWHIDE_BASEURL % ("x86_64"),
116+
"fedora12" : {
117+
'i386' : FEDORA_BASEURL % ("12", "i386"),
118+
'x86_64': FEDORA_BASEURL % ("12", "x86_64"),
119119
'distro': ("linux", "fedora12")
120120
},
121+
"fedora-rawhide" : {
122+
#'i386' : FEDORA_RAWHIDE_BASEURL % ("i386"),
123+
#'x86_64': FEDORA_RAWHIDE_BASEURL % ("x86_64"),
124+
#'distro': ("linux", "fedora13")
125+
},
121126

122127
# SUSE Distros
123128
"opensuse10.2" : {
@@ -136,23 +141,27 @@ def distroClass(distname):
136141
# Debian Distros
137142
"debian-etch" : {
138143
'i386' : DEBIAN_BASEURL % ("etch", "i386"),
139-
'x86_64': DEBIAN_BASEURL % ("etch", "amd64")
144+
'x86_64': DEBIAN_BASEURL % ("etch", "amd64"),
145+
'distro': ("linux", None)
140146
},
141147
"debian-lenny-32" : {
142148
'i386' : DEBIAN_BASEURL % ("lenny", "i386"),
149+
'distro': ("linux", None)
143150
},
144151
"debian-lenny-64" : {
145-
'x86_64': DEBIAN_BASEURL % ("lenny", "amd64")
152+
'x86_64': DEBIAN_BASEURL % ("lenny", "amd64"),
153+
'distro': ("linux", None)
146154
},
147155
"debian-daily" : {
148156
'i386' : "http://people.debian.org/~joeyh/d-i/",
157+
'distro': ("linux", None)
149158
},
150159

151160
# CentOS Distros
152161
"centos-5-latest" : {
153162
'i386' : CURCENTOS_BASEURL % ("5", "i386"),
154-
'x86_64' : CURCENTOS_BASEURL % ("5", "x86_64"),
155-
'distro': ("linux", "rhel5")
163+
#'x86_64' : CURCENTOS_BASEURL % ("5", "x86_64"), # No .treeinfo
164+
'distro': ("linux", "rhel5.4")
156165
},
157166
"centos-4-latest" : {
158167
'i386' : CURCENTOS_BASEURL % ("4", "i386"),
@@ -171,49 +180,64 @@ def distroClass(distname):
171180
},
172181

173182
# Scientific Linux
183+
"scientific-5.4" : {
184+
'i386' : SCIENTIFIC_BASEURL % ("54", "i386"),
185+
'x86_64': SCIENTIFIC_BASEURL % ("54", "x86_64"),
186+
'distro': ("linux", "rhel5.4")
187+
},
174188
"scientific-5.2" : {
175189
'i386' : SCIENTIFIC_BASEURL % ("52", "i386"),
176190
'x86_64': SCIENTIFIC_BASEURL % ("52", "x86_64"),
191+
'distro': ("linux", "rhel5")
177192
},
178193
"scientific-5.0" : {
179194
'i386' : SCIENTIFIC_BASEURL % ("50", "i386"),
180195
'x86_64': SCIENTIFIC_BASEURL % ("50", "x86_64"),
196+
'distro': ("linux", None)
181197
},
182198
"scientific-4.7" : {
183199
'i386' : SCIENTIFIC_BASEURL % ("47", "i386"),
184200
'x86_64': SCIENTIFIC_BASEURL % ("47", "x86_64"),
201+
'distro': ("linux", None)
185202
},
186203
"scientific-4.0" : {
187204
'i386' : SCIENTIFIC_BASEURL % ("40", "i386"),
188205
'x86_64': SCIENTIFIC_BASEURL % ("40", "x86_64"),
206+
'distro': ("linux", None)
189207
},
190208

191209
# Ubuntu
192210
"ubuntu-gutsy" : {
193211
'i386': UBUNTU_BASEURL % ("gutsy", "i386"),
194212
'x86_64': UBUNTU_BASEURL % ("gutsy", "amd64"),
213+
'distro': ("linux", None)
195214
},
196215
"ubuntu-hardy" : {
197216
'i386': UBUNTU_BASEURL % ("hardy", "i386"),
198217
'x86_64': UBUNTU_BASEURL % ("hardy", "amd64"),
218+
'distro': ("linux", None)
199219
},
200220
"ubuntu-intrepid" : {
201221
'i386': UBUNTU_BASEURL % ("intrepid", "i386"),
202222
'x86_64': UBUNTU_BASEURL % ("intrepid", "amd64"),
223+
'distro': ("linux", None)
203224
},
204225

205226
# Mandriva
206227
"mandriva-2007.1" : {
207228
'i386': MANDRIVA_BASEURL % ("2007.1", "i586"),
208229
'x86_64': MANDRIVA_BASEURL % ("2007.1", "x86_64"),
230+
'distro': ("linux", None)
209231
},
210232
"mandriva-2008.1" : {
211233
'i386': MANDRIVA_BASEURL % ("2008.1", "i586"),
212234
'x86_64': MANDRIVA_BASEURL % ("2008.1", "x86_64"),
235+
'distro': ("linux", None)
213236
},
214237
"mandriva-2009.0" : {
215238
'i386': MANDRIVA_BASEURL % ("2009.0", "i586"),
216239
'x86_64': MANDRIVA_BASEURL % ("2009.0", "x86_64"),
240+
'distro': ("linux", None)
217241
},
218242

219243
}
@@ -410,7 +434,7 @@ def testURLFetch(self):
410434
continue
411435

412436
try:
413-
print "Testing %s-%s" % (label, arch)
437+
print "Testing %s-%s : %s" % (label, arch, url)
414438
self._fetchFromURLDict(label, url, arch, distro_info)
415439
except AssertionError:
416440
print "%s-%s FAILED." % (label, arch)

virtinst/DistroInstaller.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,6 @@ def detect_distro(self):
265265
logging.exception("Error attempting to detect distro.")
266266
return (None, None)
267267

268-
# Verify these are valid values
268+
# detectMediaDistro should only return valid values
269269
dtype, dvariant = dist_info
270-
import osdict
271-
272-
if dtype and osdict.OS_TYPES.has_key(dtype):
273-
if not (dvariant and
274-
osdict.OS_TYPES[dtype]["variants"].has_key(dvariant)):
275-
logging.debug("Variant returned from detect_distro is not "
276-
"valid: %s" % dvariant)
277-
dvariant = None
278-
else:
279-
logging.debug("Type returned from detect_distro is not valid: %s"
280-
% dtype)
281-
dtype = None
282-
dvariant = None
283-
284270
return (dtype, dvariant)

virtinst/OSDistro.py

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
from ImageFetcher import HTTPImageFetcher
3838
from ImageFetcher import DirectImageFetcher
3939

40+
def safeint(c):
41+
try:
42+
val = int(c)
43+
except:
44+
val = 0
45+
return val
46+
4047
def _fetcherForURI(uri, scratchdir=None):
4148
if uri.startswith("http://"):
4249
fclass = HTTPImageFetcher
@@ -142,6 +149,12 @@ def acquireBootDisk(baseuri, progresscb, arch, scratchdir="/var/tmp",
142149
return _acquireMedia(False, None, baseuri, progresscb, arch,
143150
scratchdir, type, distro)
144151

152+
def _check_ostype_valid(os_type):
153+
return bool(os_type in Guest.list_os_types())
154+
def _check_osvariant_valid(os_type, os_variant):
155+
return bool(_check_ostype_valid(os_type) and
156+
os_variant in Guest.list_os_variants(os_type))
157+
145158
# Attempt to detect the os type + variant for the passed location
146159
def detectMediaDistro(location, arch):
147160
import urlgrabber
@@ -260,13 +273,15 @@ def get_osdict_info(self):
260273
if not self.os_type:
261274
return (None, None)
262275

263-
if self.os_type not in Guest.list_os_types():
276+
if not _check_ostype_valid(self.os_type):
264277
logging.debug("%s set os_type to %s, which is not in osdict." %
265278
(self, self.os_type))
266279
return (None, None)
267280

268-
if (self.os_variant and
269-
self.os_variant not in Guest.list_os_variants(self.os_type)):
281+
if not self.os_variant:
282+
return (self.os_type, None)
283+
284+
if not _check_osvariant_valid(self.os_type, self.os_variant):
270285
logging.debug("%s set os_variant to %s, which is not in osdict"
271286
" for distro %s." %
272287
(self, self.os_variant, self.os_type))
@@ -505,15 +520,49 @@ def isValidStore(self, fetcher, progresscb):
505520
return True
506521
return False
507522

523+
def _parseTreeinfoVersion(self, verstr):
524+
version = safeint(verstr[0])
525+
update = 0
526+
527+
updinfo = verstr.split(".")
528+
if len(updinfo) > 1:
529+
update = safeint(updinfo[1])
530+
531+
return version, update
532+
508533
def _variantFromVersion(self):
509-
# XXX: Version will look like '5.2', rather than just '5'. We
510-
# need to support this in the os dictionary at some point, but for
511-
# now, just use the '5' part
512534
ver = self.treeinfo.get("general", "version")
513535
if not ver:
514536
return
515537

516-
self.os_variant = "rhel" + ver[0]
538+
version, update = self._parseTreeinfoVersion(ver)
539+
self._setRHELVariant(version, update)
540+
541+
def _setRHELVariant(self, version, update):
542+
if not _check_ostype_valid(self.os_type):
543+
return
544+
545+
base = "rhel" + str(version)
546+
if update < 0:
547+
update = 0
548+
549+
ret = None
550+
while update >= 0:
551+
tryvar = base + ".%s" % update
552+
if not _check_osvariant_valid(self.os_type, tryvar):
553+
update -= 1
554+
continue
555+
556+
ret = tryvar
557+
break
558+
559+
if not ret:
560+
# Try plain rhel5, rhel6, whatev
561+
if _check_osvariant_valid(self.os_type, base):
562+
ret = base
563+
564+
if ret:
565+
self.os_variant = ret
517566

518567

519568
# CentOS distro check
@@ -561,6 +610,16 @@ def isValidStore(self, fetcher, progresscb):
561610
return True
562611
return False
563612

613+
def _parseTreeinfoVersion(self, verstr):
614+
"""
615+
Overrides method in RHELDistro
616+
"""
617+
version = safeint(verstr[0])
618+
update = 0
619+
620+
if len(verstr) > 1:
621+
update = safeint(verstr[1])
622+
return version, update
564623

565624

566625
# Suse image store is harder - we fetch the kernel RPM and a helper

virtinst/osdict.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ def lookup_device_param(conn, hv_type, os_type, var, device_key, param):
185185
"distro": "rhel" },
186186
"rhel5": { "label": "Red Hat Enterprise Linux 5",
187187
"distro": "rhel" },
188+
"rhel5.4": { "label": "Red Hat Enterprise Linux 5.4 or later",
189+
"distro": "rhel",
190+
"devices" : {
191+
"disk" : VIRTIO_DISK,
192+
"net" : VIRTIO_NET,
193+
},},
188194
"fedora5": { "sortby": "fedora05",
189195
"label": "Fedora Core 5", "distro": "fedora" },
190196
"fedora6": { "sortby": "fedora06",

0 commit comments

Comments
 (0)