26
def __init__(self, td):
28
self.CACHE_ISO = td.CACHE_ISO
29
self.PATH_TO_ISO = td.PATH_TO_ISO
30
self.DISK_FILE = td.DISK_FILE
32
self.DISK_SIZE = td.DISK_SIZE
33
self.VBOX_NAME = td.VBOX_NAME
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)
40
# Code to setup virtual machine
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))
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:
60
return(os.system(cmd))
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):
28
self.CACHE_ISO = td.CACHE_ISO
29
self.PATH_TO_ISO = td.PATH_TO_ISO
30
self.DISK_FILE = td.DISK_FILE
32
self.DISK_SIZE = td.DISK_SIZE
33
self.VBOX_NAME = td.VBOX_NAME
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)
40
# Code to setup virtual machine
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))
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:
60
return(os.system(cmd))
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