This file is indexed.

/usr/share/pyshared/cobbler/codes.py is in python-cobbler 2.2.2-0ubuntu33.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
"""
various codes and constants used by Cobbler

Copyright 2006-2009, Red Hat, Inc
Michael DeHaan <mdehaan@redhat.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301  USA
"""

import utils

# OS variants table.  This is a variance of the data from 
# ls /usr/lib/python2.X/site-packages/virtinst/FullVirtGuest.py
# but replicated here as we can't assume cobbler is installed on a system with libvirt.
# in many cases it will not be (i.e. old EL4 server, etc) and we need this info to
# know how to validate --os-variant and --os-version. 
#
# The keys of this hash correspond with the --breed flag in Cobbler.
# --breed has physical provisioning semantics as well as virt semantics.
#
# presense of something in this table does /not/ mean it's supported.
# for instance, currently, "redhat", "debian", and "suse" do something interesting.
# the rest are undefined (for now), this will evolve.

from distro_info import UbuntuDistroInfo

VALID_OS_BREEDS = [
    "redhat", "debian", "ubuntu", "suse", "generic", "windows", "unix", "vmware", "freebsd", "other"
]

VALID_OS_VERSIONS = {
    "redhat"  : [ "rhel3", "rhel4", "rhel5", "rhel6", "fedora14", "fedora15", "fedora16", "rawhide", "generic24", "generic26", "virtio26", "other" ],
    "suse"    : [ "sles9", "sles10", "sles11", "opensuse11.2", "opensuse11.3", "opensuse11.4", "opensuse12.1", "generic24", "generic26", "virtio26", "other" ],
    "debian"  : [ "lenny", "squeeze", "stable", "testing", "unstable", "generic24", "generic26", "other" ],
    "ubuntu"  : UbuntuDistroInfo().supported(),
    "generic" : [ "generic24", "generic26", "other" ],
    "windows" : [ "winxp", "win2k", "win2k3", "vista", "other" ],
    "unix"    : [ "solaris9", "solaris10", "other" ],
    "vmware"  : [ "esx4", "esxi4" ],
    "freebsd" : [ "7.3", "7.4", "8.1", "8.2", "9.0" ],
    "other"   : [ "msdos", "netware4", "netware5", "netware6", "generic", "other" ]
}

VALID_REPO_BREEDS = [
    "rsync", "rhn", "yum", "apt"
#   "rsync", "rhn", "yum"
]

def uniquify(seq, idfun=None):

    # this is odd (older mod_python scoping bug?) but we can't use 
    # utils.uniquify here because on older distros (RHEL4/5) 
    # mod_python gets another utils.  As a result,
    # it is duplicated here for now.  Bad, but ... now you know.
    #
    # credit: http://www.peterbe.com/plog/uniqifiers-benchmark
    # FIXME: if this is actually slower than some other way, overhaul it

    if idfun is None:
        def idfun(x):
           return x
    seen = {}
    result = []
    for item in seq:
        marker = idfun(item)
        if marker in seen:
            continue
        seen[marker] = 1
        result.append(item)
    return result


def get_all_os_versions():
   """
   Collapse the above list of OS versions for usage/display by the CLI/webapp.
   """
   results = ['']
   for x in VALID_OS_VERSIONS.keys():
      for y in VALID_OS_VERSIONS[x]:
         results.append(y)

   results = uniquify(results)

   results.sort()
   return results