~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

« back to all changes in this revision

Viewing changes to .pc/9001_Ubuntu.patch/virtinst/osdict.py

  • Committer: Bazaar Package Importer
  • Author(s): Jean-Louis Dupond
  • Date: 2010-05-05 03:32:42 UTC
  • mfrom: (1.3.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100505033242-um6f6pjcc89i07m0
Tags: 0.500.3-1ubuntu1
* Merge from debian unstable. (LP: #590068)  Remaining changes:
  - debian/patches/9001_Ubuntu.patch:
     + Added lucid and maverick to OS list and enable virtio for it.
  - debian/patches/0003-Fix-patch-to-keyboard-configuration.patch: disable
    as the keyboard config in Ubuntu is still in /etc/default/console-setup
    and this was causing virt-manager to always default to a en-us
    keyboard. (LP: #524318)
  - debian/control: added acl package to depends. (LP: #533048)
  - Demote virt-viewer to Suggests, as it's in universe.
  - Recommends libvirt-bin (LP: #215084)
* debian/patches/9002-add-ca-keymap.patch: dropped, its now in upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# List of OS Specific data
 
3
#
 
4
# Copyright 2006-2008  Red Hat, Inc.
 
5
# Jeremy Katz <katzj@redhat.com>
 
6
#
 
7
# This program is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free  Software Foundation; either version 2 of the License, or
 
10
# (at your option)  any later version.
 
11
#
 
12
# This program is distributed in the hope that it will be useful,
 
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
# GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License
 
18
# along with this program; if not, write to the Free Software
 
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
20
# MA 02110-1301 USA.
 
21
 
 
22
import support
 
23
from VirtualDevice import VirtualDevice
 
24
from virtinst import _virtinst as _
 
25
 
 
26
HV_ALL = "all"
 
27
 
 
28
"""
 
29
Default values for OS_TYPES keys. Can be overwritten at os_type or
 
30
variant level
 
31
"""
 
32
 
 
33
NET   = VirtualDevice.VIRTUAL_DEV_NET
 
34
DISK  = VirtualDevice.VIRTUAL_DEV_DISK
 
35
INPUT = VirtualDevice.VIRTUAL_DEV_INPUT
 
36
SOUND = VirtualDevice.VIRTUAL_DEV_AUDIO
 
37
VIDEO = VirtualDevice.VIRTUAL_DEV_VIDEO
 
38
 
 
39
VIRTIO_DISK = {
 
40
    "bus" : [
 
41
        (support.SUPPORT_CONN_HV_VIRTIO, "virtio"),
 
42
    ]
 
43
}
 
44
 
 
45
VIRTIO_NET = {
 
46
    "model" : [
 
47
        (support.SUPPORT_CONN_HV_VIRTIO, "virtio"),
 
48
    ]
 
49
}
 
50
 
 
51
USB_TABLET = {
 
52
    "type" : [
 
53
        (HV_ALL, "tablet"),
 
54
    ],
 
55
    "bus"  : [
 
56
        (HV_ALL, "usb"),
 
57
    ]
 
58
}
 
59
 
 
60
VGA_VIDEO = {
 
61
    "model_type": [
 
62
        (HV_ALL, "vga"),
 
63
    ]
 
64
}
 
65
 
 
66
DEFAULTS = {
 
67
    "acpi":             True,
 
68
    "apic":             True,
 
69
    "clock":            "utc",
 
70
    "continue":         False,
 
71
    "distro":           None,
 
72
    "label":            None,
 
73
    "pv_cdrom_install": False,
 
74
 
 
75
    "devices" : {
 
76
        #  "devname" : { "attribute" : [( ["applicable", "hv-type", list"],
 
77
        #                               "recommended value for hv-types" ),]},
 
78
        INPUT   : {
 
79
            "type" : [
 
80
                (HV_ALL, "mouse")
 
81
            ],
 
82
            "bus"  : [
 
83
                (HV_ALL, "ps2")
 
84
            ],
 
85
        },
 
86
 
 
87
        DISK    : {
 
88
            "bus"  : [
 
89
                (HV_ALL, None)
 
90
            ],
 
91
        },
 
92
 
 
93
        NET     : {
 
94
            "model": [
 
95
                (HV_ALL, None)
 
96
            ],
 
97
        },
 
98
 
 
99
        SOUND : {
 
100
            "model": [
 
101
                (support.SUPPORT_CONN_HV_SOUND_AC97, "ac97"),
 
102
                (HV_ALL, "es1370"),
 
103
            ]
 
104
        },
 
105
 
 
106
        VIDEO : {
 
107
            "model_type": [
 
108
                (HV_ALL, "cirrus"),
 
109
            ]
 
110
        },
 
111
    }
 
112
}
 
113
 
 
114
def sort_helper(tosort):
 
115
    """Helps properly sorting os dictionary entires"""
 
116
    key_mappings = {}
 
117
    keys = []
 
118
    retlist = []
 
119
 
 
120
    for key in tosort.keys():
 
121
        if tosort[key].get("skip"):
 
122
            continue
 
123
 
 
124
        sortby = tosort[key].get("sortby")
 
125
        if not sortby:
 
126
            sortby = key
 
127
        key_mappings[sortby] = key
 
128
        keys.append(sortby)
 
129
 
 
130
    keys.sort()
 
131
    for key in keys:
 
132
        retlist.append(key_mappings[key])
 
133
 
 
134
    return retlist
 
135
 
 
136
def parse_key_entry(conn, hv_type, key_entry, defaults):
 
137
    ret = None
 
138
    found = False
 
139
    if type(key_entry) == list:
 
140
 
 
141
        # List of tuples with (support -> value) mappings
 
142
        for tup in key_entry:
 
143
 
 
144
            support_key = tup[0]
 
145
            value = tup[1]
 
146
 
 
147
            # HV_ALL means don't check for support, just return the value
 
148
            if support_key != HV_ALL:
 
149
                support_ret = support.check_conn_hv_support(conn,
 
150
                                                            support_key,
 
151
                                                            hv_type)
 
152
 
 
153
                if support_ret != True:
 
154
                    continue
 
155
 
 
156
            found = True
 
157
            ret = value
 
158
            break
 
159
    else:
 
160
        found = True
 
161
        ret = key_entry
 
162
 
 
163
    if not found and defaults:
 
164
        ret = parse_key_entry(conn, hv_type, defaults, None)
 
165
 
 
166
    return ret
 
167
 
 
168
def lookup_osdict_key(conn, hv_type, os_type, var, key):
 
169
 
 
170
    defaults = DEFAULTS[key]
 
171
    dictval = defaults
 
172
    if os_type:
 
173
        if var and OS_TYPES[os_type]["variants"][var].has_key(key):
 
174
            dictval = OS_TYPES[os_type]["variants"][var][key]
 
175
        elif OS_TYPES[os_type].has_key(key):
 
176
            dictval = OS_TYPES[os_type][key]
 
177
 
 
178
    return parse_key_entry(conn, hv_type, dictval, defaults)
 
179
 
 
180
 
 
181
def lookup_device_param(conn, hv_type, os_type, var, device_key, param):
 
182
 
 
183
    os_devs = lookup_osdict_key(conn, hv_type, os_type, var, "devices")
 
184
    defaults = DEFAULTS["devices"]
 
185
 
 
186
    for devs in [os_devs, defaults]:
 
187
        if not devs.has_key(device_key):
 
188
            continue
 
189
 
 
190
        return parse_key_entry(conn, hv_type, devs[device_key][param],
 
191
                               defaults.get(param))
 
192
 
 
193
    raise RuntimeError(_("Invalid dictionary entry for device '%s %s'" %
 
194
                       (device_key, param)))
 
195
 
 
196
 
 
197
# NOTE: keep variant keys using only lowercase so we can do case
 
198
#       insensitive checks on user passed input
 
199
OS_TYPES = {
 
200
"linux": {
 
201
    "label": "Linux",
 
202
    "variants": {
 
203
        "rhel2.1": { "label": "Red Hat Enterprise Linux 2.1",
 
204
                     "distro": "rhel" },
 
205
        "rhel3": { "label": "Red Hat Enterprise Linux 3",
 
206
                   "distro": "rhel" },
 
207
        "rhel4": { "label": "Red Hat Enterprise Linux 4",
 
208
                   "distro": "rhel" },
 
209
        "rhel5": { "label": "Red Hat Enterprise Linux 5",
 
210
                   "distro": "rhel" },
 
211
        "rhel5.4": { "label": "Red Hat Enterprise Linux 5.4 or later",
 
212
                     "distro": "rhel",
 
213
                      "devices" : {
 
214
                        DISK : VIRTIO_DISK,
 
215
                        NET  : VIRTIO_NET,
 
216
                      },},
 
217
        "rhel6": { "label": "Red Hat Enterprise Linux 6", "distro": "rhel",
 
218
                   "devices" : {
 
219
                        DISK : VIRTIO_DISK,
 
220
                        NET  : VIRTIO_NET,
 
221
                        INPUT: USB_TABLET,
 
222
                   }},
 
223
        "fedora5": { "sortby": "fedora05",
 
224
                     "label": "Fedora Core 5", "distro": "fedora" },
 
225
        "fedora6": { "sortby": "fedora06",
 
226
                     "label": "Fedora Core 6", "distro": "fedora" },
 
227
        "fedora7": { "sortby": "fedora07",
 
228
                     "label": "Fedora 7", "distro": "fedora" },
 
229
        "fedora8": { "sortby": "fedora08",
 
230
                     "label": "Fedora 8", "distro": "fedora" },
 
231
        "fedora9": { "sortby":  "fedora09",
 
232
                     "label": "Fedora 9", "distro": "fedora",
 
233
                      "devices" : {
 
234
                        # Apparently F9 has selinux errors when installing
 
235
                        # with virtio:
 
236
                        # https://bugzilla.redhat.com/show_bug.cgi?id=470386
 
237
                        #DISK : VIRTIO_DISK,
 
238
                        NET  : VIRTIO_NET,
 
239
                      }},
 
240
        "fedora10": { "label": "Fedora 10", "distro": "fedora",
 
241
                      "devices" : {
 
242
                        DISK : VIRTIO_DISK,
 
243
                        NET  : VIRTIO_NET,
 
244
                      }},
 
245
        "fedora11": { "label": "Fedora 11", "distro": "fedora",
 
246
                      "devices" : {
 
247
                        DISK : VIRTIO_DISK,
 
248
                        NET  : VIRTIO_NET,
 
249
                        INPUT: USB_TABLET,
 
250
                     }},
 
251
        "fedora12": { "label": "Fedora 12", "distro": "fedora",
 
252
                      "devices" : {
 
253
                        DISK : VIRTIO_DISK,
 
254
                        NET  : VIRTIO_NET,
 
255
                        INPUT: USB_TABLET,
 
256
                     }},
 
257
        "fedora13": { "label": "Fedora 13", "distro": "fedora",
 
258
                      "devices" : {
 
259
                        DISK : VIRTIO_DISK,
 
260
                        NET  : VIRTIO_NET,
 
261
                        INPUT: USB_TABLET,
 
262
                     }},
 
263
 
 
264
        "sles10": { "label": "Suse Linux Enterprise Server",
 
265
                    "distro": "suse" },
 
266
        "sles11": { "label": "Suse Linux Enterprise Server 11",
 
267
                    "distro": "suse",
 
268
                      "devices" : {
 
269
                        DISK : VIRTIO_DISK,
 
270
                        NET  : VIRTIO_NET,
 
271
                      },
 
272
                  },
 
273
 
 
274
        "mandriva2009": { "label": "Mandriva Linux 2009 and earlier",
 
275
                          "distro": "mandriva" },
 
276
        "mandriva2010": { "label": "Mandriva Linux 2010 and later",
 
277
                          "distro": "mandriva",
 
278
                          "devices" : {
 
279
                            DISK : VIRTIO_DISK,
 
280
                            NET  : VIRTIO_NET,
 
281
                        },
 
282
                  },
 
283
 
 
284
        "mes5": { "label": "Mandriva Enterprise Server 5.0",
 
285
                    "distro": "mandriva" },
 
286
        "mes5.1": { "label": "Mandriva Enterprise Server 5.1 and later",
 
287
                    "distro": "mandriva",
 
288
                    "devices" : {
 
289
                        DISK : VIRTIO_DISK,
 
290
                        NET  : VIRTIO_NET,
 
291
                    },
 
292
                  },
 
293
        "debianetch": { "label": "Debian Etch", "distro": "debian" },
 
294
        "debianlenny": { "label": "Debian Lenny", "distro": "debian",
 
295
                      "devices" : {
 
296
                        DISK : VIRTIO_DISK,
 
297
                        NET  : VIRTIO_NET,
 
298
                      }},
 
299
        "debiansqueeze": { "label": "Debian Squeeze", "distro": "debian",
 
300
                      "devices" : {
 
301
                        DISK : VIRTIO_DISK,
 
302
                        NET  : VIRTIO_NET,
 
303
                        INPUT: USB_TABLET,
 
304
                     }},
 
305
        "ubuntuhardy": { "label": "Ubuntu 8.04 LTS (Hardy Heron)",
 
306
                         "distro": "ubuntu",
 
307
                         "devices" : {
 
308
                            NET  : VIRTIO_NET,
 
309
                         }},
 
310
        "ubuntuintrepid": { "label": "Ubuntu 8.10 (Intrepid Ibex)",
 
311
                            "distro": "ubuntu",
 
312
                            "devices" : {
 
313
                              NET  : VIRTIO_NET,
 
314
                           }},
 
315
        "ubuntujaunty": { "label": "Ubuntu 9.04 (Jaunty Jackalope)",
 
316
                          "distro": "ubuntu",
 
317
                          "devices" : {
 
318
                            DISK : VIRTIO_DISK,
 
319
                            NET  : VIRTIO_NET,
 
320
                        }},
 
321
        "ubuntukarmic": { "label": "Ubuntu 9.10 (Karmic Koala)",
 
322
                          "distro": "ubuntu",
 
323
                          "devices" : {
 
324
                            DISK : VIRTIO_DISK,
 
325
                            NET  : VIRTIO_NET,
 
326
                        }},
 
327
        "generic24": { "label": "Generic 2.4.x kernel" },
 
328
        "generic26": { "label": "Generic 2.6.x kernel" },
 
329
        "virtio26": { "sortby": "genericvirtio26",
 
330
                      "label": "Generic 2.6.25 or later kernel with virtio",
 
331
                      "devices" : {
 
332
                            DISK : VIRTIO_DISK,
 
333
                            NET  : VIRTIO_NET,
 
334
                    }},
 
335
 
 
336
    },
 
337
},
 
338
 
 
339
"windows": {
 
340
    "label": "Windows",
 
341
    "clock": "localtime",
 
342
    "continue": True,
 
343
    "devices" : {
 
344
        INPUT : USB_TABLET,
 
345
        VIDEO : VGA_VIDEO,
 
346
    },
 
347
    "variants": {
 
348
        "winxp":{ "label": "Microsoft Windows XP (x86)",
 
349
                  "acpi": [
 
350
                    (support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False),
 
351
                  ],
 
352
                  "apic": [
 
353
                    (support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False),
 
354
                  ],
 
355
        },
 
356
        "winxp64":{ "label": "Microsoft Windows XP (x86_64)" },
 
357
        "win2k": { "label": "Microsoft Windows 2000",
 
358
                  "acpi": [
 
359
                    (support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False),
 
360
                  ],
 
361
                  "apic": [
 
362
                    (support.SUPPORT_CONN_HV_SKIP_DEFAULT_ACPI, False),
 
363
                  ],
 
364
        },
 
365
        "win2k3": { "label": "Microsoft Windows 2003" },
 
366
        "win2k8": { "label": "Microsoft Windows 2008" },
 
367
        "vista": { "label": "Microsoft Windows Vista" },
 
368
        "win7": { "label": "Microsoft Windows 7" }
 
369
    },
 
370
},
 
371
 
 
372
"solaris": {
 
373
    "label": "Solaris",
 
374
    "clock": "localtime",
 
375
    "pv_cdrom_install": True,
 
376
    "variants": {
 
377
        "solaris9": { "label": "Sun Solaris 9", },
 
378
        "solaris10": { "label": "Sun Solaris 10",
 
379
                       "devices" : {
 
380
                            INPUT : USB_TABLET,
 
381
                         },
 
382
                       },
 
383
        "opensolaris": { "label": "Sun OpenSolaris",
 
384
                       "devices" : {
 
385
                            INPUT : USB_TABLET,
 
386
                         },
 
387
                       },
 
388
    },
 
389
},
 
390
 
 
391
"unix": {
 
392
    "label": "UNIX",
 
393
    "variants": {
 
394
        "freebsd6": { "label": "Free BSD 6.x" ,
 
395
                      # http://www.nabble.com/Re%3A-Qemu%3A-bridging-on-FreeBSD-7.0-STABLE-p15919603.html
 
396
                      "devices" : {
 
397
                        NET : { "model" : [ (HV_ALL, "ne2k_pci") ] }
 
398
                      }},
 
399
        "freebsd7": { "label": "Free BSD 7.x" ,
 
400
                      "devices" : {
 
401
                        NET : { "model" : [ (HV_ALL, "ne2k_pci") ] }
 
402
                      }},
 
403
        "openbsd4": { "label": "Open BSD 4.x" ,
 
404
                      # http://calamari.reverse-dns.net:980/cgi-bin/moin.cgi/OpenbsdOnQemu
 
405
                      # https://www.redhat.com/archives/et-mgmt-tools/2008-June/msg00018.html
 
406
                      "devices" : {
 
407
                        NET  : { "model" : [ (HV_ALL, "pcnet") ] }
 
408
                    }},
 
409
    },
 
410
},
 
411
 
 
412
"other": {
 
413
    "label": "Other",
 
414
    "variants": {
 
415
        "msdos": { "label": "MS-DOS", "acpi": False, "apic": False },
 
416
        "netware4": { "label": "Novell Netware 4" },
 
417
        "netware5": { "label": "Novell Netware 5" },
 
418
        "netware6": { "label": "Novell Netware 6", "pv_cdrom_install": True, },
 
419
        "generic": { "label": "Generic" },
 
420
    },
 
421
},}
 
422
 
 
423
# Back compatibility entries
 
424
solaris_compat = OS_TYPES["unix"]["variants"]
 
425
 
 
426
solaris_compat["solaris9"] = OS_TYPES["solaris"]["variants"]["solaris9"].copy()
 
427
solaris_compat["solaris9"]["skip"] = True
 
428
 
 
429
solaris_compat["solaris10"] = OS_TYPES["solaris"]["variants"]["solaris10"].copy()
 
430
solaris_compat["solaris10"]["skip"] = True