~andreserl/+junk/cobbler

« back to all changes in this revision

Viewing changes to .pc/47_ubuntu_add_oneiric_codename.patch/cobbler/codes.py

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2011-06-17 18:12:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110617181254-tauizkc2mhxf8m2x
Tags: 2.1.0+git20110602-0ubuntu7
* debian/patches:
  - 47_ubuntu_add_oneiric_codename.patch: Add oneiric codename to
    not fail on Oneiric imports.
  - 48_ubuntu_mini_iso_autodetect.patch: Obtain os_version/arch when
    importing mini ISO from info file (.disk/mini-info).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
"""
 
3
various codes and constants used by Cobbler
 
4
 
 
5
Copyright 2006-2009, Red Hat, Inc
 
6
Michael DeHaan <mdehaan@redhat.com>
 
7
 
 
8
This program is free software; you can redistribute it and/or modify
 
9
it under the terms of the GNU General Public License as published by
 
10
the Free Software Foundation; either version 2 of the License, or
 
11
(at your option) any later version.
 
12
 
 
13
This program is distributed in the hope that it will be useful,
 
14
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
GNU General Public License for more details.
 
17
 
 
18
You should have received a copy of the GNU General Public License
 
19
along with this program; if not, write to the Free Software
 
20
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
21
02110-1301  USA
 
22
"""
 
23
 
 
24
import utils
 
25
 
 
26
# OS variants table.  This is a variance of the data from 
 
27
# ls /usr/lib/python2.X/site-packages/virtinst/FullVirtGuest.py
 
28
# but replicated here as we can't assume cobbler is installed on a system with libvirt.
 
29
# in many cases it will not be (i.e. old EL4 server, etc) and we need this info to
 
30
# know how to validate --os-variant and --os-version. 
 
31
#
 
32
# The keys of this hash correspond with the --breed flag in Cobbler.
 
33
# --breed has physical provisioning semantics as well as virt semantics.
 
34
#
 
35
# presense of something in this table does /not/ mean it's supported.
 
36
# for instance, currently, "redhat", "debian", and "suse" do something interesting.
 
37
# the rest are undefined (for now), this will evolve.
 
38
 
 
39
VALID_OS_BREEDS = [
 
40
    "redhat", "debian", "ubuntu", "suse", "generic", "windows", "unix", "vmware", "other"
 
41
]
 
42
 
 
43
VALID_OS_VERSIONS = {
 
44
    "redhat"  : [ "rhel2.1", "rhel3", "rhel4", "rhel5", "rhel6", "fedora5", "fedora6", "fedora7", "fedora8", "fedora9", "fedora10", "fedora11", "fedora12", "fedora13", "fedora14", "generic24", "generic26", "virtio26", "other" ],
 
45
    "suse"    : [ "sles10", "generic24", "generic26", "virtio26", "other" ],
 
46
    "debian"  : [ "etch", "lenny", "squeeze", "sid", "stable", "testing", "unstable", "generic24", "generic26", "other" ],
 
47
    "ubuntu"  : [ "dapper", "hardy", "intrepid", "jaunty", "karmic", "lucid", "maverick", "natty" ],
 
48
    "generic" : [ "generic24", "generic26", "other" ],
 
49
    "windows" : [ "winxp", "win2k", "win2k3", "vista", "other" ],
 
50
    "unix"    : [ "solaris9", "solaris10", "freebsd6", "openbsd4", "other" ],
 
51
    "vmware"  : [ "esx4", "esxi4" ],
 
52
    "other"   : [ "msdos", "netware4", "netware5", "netware6", "generic", "other" ]
 
53
}
 
54
 
 
55
VALID_REPO_BREEDS = [
 
56
    "rsync", "rhn", "yum", "apt"
 
57
#   "rsync", "rhn", "yum"
 
58
]
 
59
 
 
60
def uniquify(seq, idfun=None):
 
61
 
 
62
    # this is odd (older mod_python scoping bug?) but we can't use 
 
63
    # utils.uniquify here because on older distros (RHEL4/5) 
 
64
    # mod_python gets another utils.  As a result,
 
65
    # it is duplicated here for now.  Bad, but ... now you know.
 
66
    #
 
67
    # credit: http://www.peterbe.com/plog/uniqifiers-benchmark
 
68
    # FIXME: if this is actually slower than some other way, overhaul it
 
69
 
 
70
    if idfun is None:
 
71
        def idfun(x):
 
72
           return x
 
73
    seen = {}
 
74
    result = []
 
75
    for item in seq:
 
76
        marker = idfun(item)
 
77
        if marker in seen:
 
78
            continue
 
79
        seen[marker] = 1
 
80
        result.append(item)
 
81
    return result
 
82
 
 
83
 
 
84
def get_all_os_versions():
 
85
   """
 
86
   Collapse the above list of OS versions for usage/display by the CLI/webapp.
 
87
   """
 
88
   results = ['']
 
89
   for x in VALID_OS_VERSIONS.keys():
 
90
      for y in VALID_OS_VERSIONS[x]:
 
91
         results.append(y)
 
92
 
 
93
   results = uniquify(results)
 
94
 
 
95
   results.sort()
 
96
   return results
 
97
 
 
98