~ubuntu-branches/ubuntu/quantal/testdrive/quantal

« back to all changes in this revision

Viewing changes to testdrive/virt/parallels.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez, Philip Muškovac, Andres Rodriguez, Robert Ancell
  • Date: 2012-05-15 16:58:37 UTC
  • mfrom: (1.1.46)
  • Revision ID: package-import@ubuntu.com-20120515165837-a8tt6tmn9f31eusg
Tags: 3.16-0ubuntu1
[ Philip Muškovac ]
* Correctly display versions for both -cli and -gtk

[ Andres Rodriguez ]
* testdrive/virt/kvm.py: Generate UUID. (LP: #959308)
* correctly save arch's in preferences (LP: #873235)
* Change tabs to spaces.
* debian/source/format: Added.
* fully migrate to dh_python2

[ Robert Ancell ]
* debian/control:
  - Drop dependency on python-launchpad-integration
* bin/testdrive-gtk:
  - We no longer do Launchpad integration (LP: #999413)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
class Parallels:
25
25
 
26
 
        def __init__(self, td):
27
 
                self.HOME = td.HOME
28
 
                self.CACHE_ISO = td.CACHE_ISO
29
 
                self.PATH_TO_ISO = td.PATH_TO_ISO
30
 
                self.DISK_FILE = td.DISK_FILE
31
 
                self.MEM = td.MEM
32
 
                self.DISK_SIZE = td.DISK_SIZE
33
 
                self.VBOX_NAME = td.VBOX_NAME
34
 
 
35
 
        # Code to validate if virtualization is installed/supported
36
 
        def validate_virt(self):
37
 
                if commands.getstatusoutput("prlctl list %s | grep -qsv \"UUID\"" % self.VBOX_NAME)[0] == 0:
38
 
                        self.run_or_die("prlctl delete %s" % self.VBOX_NAME)
39
 
 
40
 
        # Code to setup virtual machine
41
 
        def setup_virt(self):
42
 
                self.DISK_SIZE = self.DISK_SIZE.replace("G", "000")
43
 
                #info("Creating VM...")
44
 
                print "INFO: Creating VM..."
45
 
                self.run_or_die("prlctl create %s --ostype linux --distribution ubuntu" % self.VBOX_NAME)
46
 
                self.run_or_die("prlctl set %s --memsize %s" % (self.VBOX_NAME, self.MEM))
47
 
                self.run_or_die("prlctl set %s --device-del hdd0" % self.VBOX_NAME)
48
 
                self.run_or_die("prlctl set %s --device-add hdd --type expand --size %s --iface scsi --position 0:0" % (self.VBOX_NAME, self.DISK_SIZE))
49
 
                self.run_or_die("prlctl set %s --device-set cdrom0 --image %s" % (self.VBOX_NAME, self.PATH_TO_ISO))
50
 
 
51
 
        # Code launch virtual machine
52
 
        def launch_virt(self):
53
 
                #self.run_or_die("prlctl start %s" % self.td.VBOX_NAME)
54
 
                return "prlctl start %s" % self.VBOX_NAME
55
 
                # Loop as long as this VM is running
56
 
                #while commands.getstatusoutput("prlctl list %s | grep -qs stopped" % self.td.VBOX_NAME)[0] != 0:
57
 
                #       time.sleep(2)
58
 
 
59
 
        def run(self, cmd):
60
 
                return(os.system(cmd))
61
 
 
62
 
        def run_or_die(self, cmd):
63
 
                if self.run(cmd) != 0:
64
 
                        #error("Command failed\n    `%s`" % cmd)
65
 
                        print "Command failed\n    `%s`" % cmd
 
26
    def __init__(self, td):
 
27
        self.HOME = td.HOME
 
28
        self.CACHE_ISO = td.CACHE_ISO
 
29
        self.PATH_TO_ISO = td.PATH_TO_ISO
 
30
        self.DISK_FILE = td.DISK_FILE
 
31
        self.MEM = td.MEM
 
32
        self.DISK_SIZE = td.DISK_SIZE
 
33
        self.VBOX_NAME = td.VBOX_NAME
 
34
 
 
35
    # Code to validate if virtualization is installed/supported
 
36
    def validate_virt(self):
 
37
        if commands.getstatusoutput("prlctl list %s | grep -qsv \"UUID\"" % self.VBOX_NAME)[0] == 0:
 
38
            self.run_or_die("prlctl delete %s" % self.VBOX_NAME)
 
39
 
 
40
    # Code to setup virtual machine
 
41
    def setup_virt(self):
 
42
        self.DISK_SIZE = self.DISK_SIZE.replace("G", "000")
 
43
        #info("Creating VM...")
 
44
        print "INFO: Creating VM..."
 
45
        self.run_or_die("prlctl create %s --ostype linux --distribution ubuntu" % self.VBOX_NAME)
 
46
        self.run_or_die("prlctl set %s --memsize %s" % (self.VBOX_NAME, self.MEM))
 
47
        self.run_or_die("prlctl set %s --device-del hdd0" % self.VBOX_NAME)
 
48
        self.run_or_die("prlctl set %s --device-add hdd --type expand --size %s --iface scsi --position 0:0" % (self.VBOX_NAME, self.DISK_SIZE))
 
49
        self.run_or_die("prlctl set %s --device-set cdrom0 --image %s" % (self.VBOX_NAME, self.PATH_TO_ISO))
 
50
 
 
51
    # Code launch virtual machine
 
52
    def launch_virt(self):
 
53
        #self.run_or_die("prlctl start %s" % self.td.VBOX_NAME)
 
54
        return "prlctl start %s" % self.VBOX_NAME
 
55
        # Loop as long as this VM is running
 
56
        #while commands.getstatusoutput("prlctl list %s | grep -qs stopped" % self.td.VBOX_NAME)[0] != 0:
 
57
        #   time.sleep(2)
 
58
 
 
59
    def run(self, cmd):
 
60
        return(os.system(cmd))
 
61
 
 
62
    def run_or_die(self, cmd):
 
63
        if self.run(cmd) != 0:
 
64
            #error("Command failed\n    `%s`" % cmd)
 
65
            print "Command failed\n    `%s`" % cmd