~ubuntu-branches/ubuntu/raring/virtinst/raring-proposed

« back to all changes in this revision

Viewing changes to virtinst/LiveCDInstaller.py

  • Committer: Bazaar Package Importer
  • Author(s): Guido Günther
  • Date: 2009-03-22 20:13:27 UTC
  • mto: (1.4.1 sid)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090322201327-5ch3kqxe772e23zx
Tags: upstream-0.400.3
Import upstream version 0.400.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
20
# MA 02110-1301 USA.
21
21
 
22
 
import Guest
 
22
import Installer
23
23
from VirtualDisk import VirtualDisk
24
 
import CapabilitiesParser
25
24
from virtinst import _virtinst as _
26
25
 
27
26
class LiveCDInstallerException(Exception):
28
27
    def __init__(self, msg):
29
28
        Exception.__init__(self, msg)
30
29
 
31
 
class LiveCDInstaller(Guest.Installer):
 
30
class LiveCDInstaller(Installer.Installer):
32
31
    def __init__(self, type = "xen", location = None, os_type = None,
33
32
                 conn = None):
34
 
        Guest.Installer.__init__(self, type=type, location=location,
35
 
                                 os_type=os_type, conn=conn)
36
 
 
37
 
    def prepare(self, guest, meter, distro = None):
38
 
        self.cleanup()
39
 
 
40
 
        capabilities = CapabilitiesParser.parse(guest.conn.getCapabilities())
41
 
 
42
 
        found = False
43
 
        for guest_caps in capabilities.guests:
44
 
            if guest_caps.os_type == "hvm":
45
 
                found = True
46
 
                break
47
 
 
48
 
        if not found:
49
 
            raise LiveCDInstallerException(_("Connection does not support HVM virtualisation, cannot boot live CD"))
50
 
 
 
33
        Installer.Installer.__init__(self, type=type, location=location,
 
34
                                     os_type=os_type, conn=conn)
 
35
 
 
36
 
 
37
    # LiveCD specific methods/overwrites
 
38
 
 
39
    def _get_location(self):
 
40
        return self._location
 
41
    def _set_location(self, val):
51
42
        path = None
52
43
        vol_tuple = None
53
 
        if type(self.location) is tuple:
54
 
            vol_tuple = self.location
55
 
        elif self.location:
56
 
            path = self.location
57
 
        elif not self.cdrom:
58
 
            raise LiveCDInstallerException(_("CDROM media must be specified "
59
 
                                             "for the live CD installer."))
 
44
        if type(val) is tuple:
 
45
            vol_tuple = val
 
46
        else:
 
47
            path = val
60
48
 
61
49
        if path or vol_tuple:
62
 
            disk = VirtualDisk(path=path, conn=guest.conn, volName=vol_tuple,
63
 
                               device = VirtualDisk.DEVICE_CDROM,
64
 
                               readOnly = True)
65
 
            guest._install_disks.insert(0, disk)
66
 
 
67
 
    def _get_osblob(self, install, hvm, arch=None, loader=None, conn=None):
68
 
        if install:
69
 
            # XXX: This seems wrong? If install is True, maybe we should
70
 
            # error and say that isn't a valid value for LiveCD?
 
50
            self._install_disk = VirtualDisk(path=path, conn=self.conn,
 
51
                                             volName=vol_tuple,
 
52
                                             device = VirtualDisk.DEVICE_CDROM,
 
53
                                             readOnly = True)
 
54
 
 
55
        self._location = val
 
56
        self.cdrom = True
 
57
    location = property(_get_location, _set_location)
 
58
 
 
59
 
 
60
    # General Installer methods
 
61
 
 
62
    def prepare(self, guest, meter, distro = None):
 
63
        self.cleanup()
 
64
 
 
65
        if not self._install_disk:
 
66
            raise ValueError(_("CDROM media must be specified for the live "
 
67
                               "CD installer."))
 
68
 
 
69
    def get_install_xml(self, guest, isinstall):
 
70
        if isinstall:
 
71
            # Signifies to the 'Guest' that there is no 'install' phase
71
72
            return None
72
73
 
73
 
        return self._get_osblob_helper(isinstall=install, ishvm=hvm,
74
 
                                       arch=arch, loader=loader, conn=conn,
 
74
        return self._get_osblob_helper(isinstall=isinstall, guest=guest,
75
75
                                       kernel=None, bootdev="cdrom")
76
76
 
77
77
    def post_install_check(self, guest):