23
23
import xdg.BaseDirectory
26
def __init__(self, pkg_section):
27
self.HOME = os.getenv("HOME", "")
28
self.ISO_URL = os.getenv("ISO_URL", "")
29
self.VIRT = os.getenv("VIRT", "")
30
self.CACHE = os.getenv("CACHE", None)
31
self.CACHE_ISO = os.getenv("CACHE_ISO", None)
32
self.CACHE_IMG = os.getenv("CACHE_IMG", None)
33
self.CLEAN_IMG = os.getenv("CLEAN_IMG", None)
34
self.MEM = os.getenv("MEM", "")
35
self.SMP = os.getenv("SMP", "")
36
self.DISK_FILE = os.getenv("DISK_FILE", "")
37
self.DISK_SIZE = os.getenv("DISK_SIZE", "")
38
self.KVM_ARGS = os.getenv("KVM_ARGS", "")
39
self.VBOX_NAME = os.getenv("VBOX_NAME", "")
40
self.PKG = "testdrive"
41
self.PKGRC = "%src" % self.PKG
43
self.ISO_PATH_HEADER = None
44
self.PKG_SECTION = pkg_section
45
self.r = None #Release (maverick, lucid, etc)
46
self.m = None #Arch (amd64, i386)
47
self.f = None #Flavor (ubuntu, kubuntu, etc)
48
self.p = None # Ubuntu ISO Repository (cdimage, releases, cloud-daily, cloud-releases)
50
def set_values(self, var, value):
57
if var == 'disk_size':
58
self.DISK_SIZE = value
61
if var == 'cache_img':
62
self.CACHE_IMG = value
63
if var == 'cache_iso':
64
self.CACHE_ISO = value
65
if var == 'clean_img':
66
self.CLEAN_IMG = value
71
if var == 'disk_file':
72
self.DISK_FILE = value
82
def load_config_file(self, config_file):
83
cfg = ConfigParser.ConfigParser()
86
defaults = cfg.items('testdrive-common')
87
for items in defaults:
88
self.set_values(items[0], items[1])
92
configitems = cfg.items(self.PKG_SECTION)
93
for items in configitems:
94
self.set_values(items[0], items[1])
98
## TODO: This possible needs to go outside the class due to in PyGTK front end we might need the list of ISO's before even instancing an object
99
def list_isos(self, ISOS):
102
if iso.split()[1] == self.r:
103
# TODO: Add support for Cloud
104
category = iso.split()[0]
105
if category == 'ubuntu-server':
107
elif category == 'ubuntu-netbook':
109
elif category == 'ubuntu-mobile':
111
elif category == 'kubuntu-netbook':
113
elif category == 'kubuntu-mobile':
115
flavor = iso.split()[0].capitalize()
116
if flavor == 'Ubuntu-netbook':
118
elif flavor == 'Ubuntu-mobile':
120
elif flavor == 'Kubuntu-netbook':
122
elif flavor == 'Kubuntu-mobile':
124
elif flavor == 'Ubuntustudio':
125
flavor = 'Ubuntu Studio'
126
elif flavor == 'Ubuntu-server':
128
elif flavor == 'Cloud-server':
129
flavor = 'Cloud Server'
130
elif flavor == 'Cloud-desktop':
131
flavor = 'Cloud Desktop'
132
release = iso.split()[1]
134
if self.p == 'cloud-daily' or self.p == 'cloud-releases':
135
arch = url.split(".tar.gz")[0].split("-")[-1]
138
arch = url.split(".iso")[0].split("-")[-1]
139
image = url.split("-%s.iso" % arch)[0].split("-")[-1].capitalize()
141
image = url.split("-%s.iso" % arch)[0].split("-")[-1].swapcase()
142
name = "%s %s" % (flavor, image)
143
# Name: Shows a description
144
# URL: Shows the URL from where it downloads the ISO
145
# Arch: Shows the architecture (amd64|i386)
146
# Category: The header used to save the ISO, i.e.: ubuntu_lucid-desktop-i386.iso kubuntu_lucid-desktop-i386.iso
148
ISO.append({"name":name, "url":"%s%s" % (self.u, url), "arch":arch, "category":category})
153
# Check if KVM acceleration can be used
154
if commands.getstatusoutput("which kvm-ok")[0] == 0:
155
# If we have kvm-ok, let's use it...
156
if commands.getstatusoutput("kvm-ok")[0] == 0:
159
# Okay, we don't have kvm-ok, so let's hack it...
160
if commands.getstatusoutput("egrep \"^flags.*:.*(svm|vmx)\" /proc/cpuinfo")[0] == 0:
162
# Prefer KVM if acceleration available and installed
163
if acceleration == 1 and commands.getstatusoutput("which kvm")[0] == 0:
165
# Okay, no KVM, VirtualBox maybe?
166
if commands.getstatusoutput("which VBoxManage")[0] == 0:
168
# No VirtualBox, how about Parallels?
169
if commands.getstatusoutput("which prlctl")[0] == 0:
171
# No hypervisor found; error out with advice
172
if acceleration == 1:
177
def set_defaults(self):
178
# Set defaults where undefined
179
if self.CACHE is None:
180
if xdg.BaseDirectory.xdg_cache_home:
181
self.CACHE = "%s/%s" % (xdg.BaseDirectory.xdg_cache_home, self.PKG)
183
self.CACHE = "%s/.cache/%s" % (self.HOME, self.PKG)
185
if self.CACHE_IMG is None:
186
self.CACHE_IMG = '%s/img' % self.CACHE
187
if not os.path.exists(self.CACHE_IMG):
188
os.makedirs(self.CACHE_IMG, 0700)
189
# if running the image from /dev/shm, remove the image when done
190
# (unless CLEAN_IMG is set)
191
if self.CLEAN_IMG is None:
192
if self.CACHE_IMG == '/dev/shm':
193
self.CLEAN_IMG = True
195
self.CLEAN_IMG = False
197
if self.CACHE_ISO is None:
198
self.CACHE_ISO = '%s/iso' % self.CACHE
199
if not os.path.exists(self.CACHE_ISO):
200
os.makedirs(self.CACHE_ISO, 0700)
202
if len(self.SMP) == 0:
203
self.SMP = commands.getoutput("grep -c ^processor /proc/cpuinfo")
205
if len(self.DISK_SIZE) == 0:
206
self.DISK_SIZE = "6G"
208
if len(self.MEM) == 0:
209
total = commands.getoutput("grep ^MemTotal /proc/meminfo | awk '{print $2}'")
212
elif total > 1000000:
219
if len(self.KVM_ARGS) == 0:
220
self.KVM_ARGS = "-usb -usbdevice tablet -net nic,model=virtio -net user -soundhw es1370"
222
if len(self.VBOX_NAME) == 0:
223
self.VBOX_NAME = self.PKG
225
if self.ISO_PATH_HEADER == None:
226
self.ISO_PATH_HEADER = 'other'
232
if platform.machine() == "x86_64":
233
self.m = ["amd64", "i386"]
240
if self.p == 'cdimage':
241
self.u = 'rsync://cdimage.ubuntu.com/cdimage'
243
if self.p == 'releases':
244
self.u = 'rsync://us.rsync.releases.ubuntu.com/releases'
246
if self.p == 'cloud-daily' or self.p == 'cloud-releases':
247
self.u = 'rsync://cloud-images.ubuntu.com/cloud-images'
250
return(os.system(cmd))
253
if self.PROTO == "rsync":
254
cmd = "rsync -azPL %s %s" % (self.ISO_URL, self.PATH_TO_ISO)
256
elif self.PROTO == "zsync" or self.PROTO == "http" or self.PROTO == "ftp":
257
if commands.getstatusoutput("which zsync")[0] == 0:
258
if self.ISO_URL.partition("://")[0] == "zsync":
259
self.ISO_URL = self.ISO_URL.replace('zsync', 'http')
260
cmd = "cd '%s' && zsync %s.zsync -o %s" % (self.CACHE_ISO, self.ISO_URL, self.PATH_TO_ISO)
263
cmd = "wget %s -O %s" % (self.ISO_URL, self.PATH_TO_ISO)
265
elif self.PROTO == "file":
266
# If the iso is on file:///, use the ISO in place
267
self.PATH_TO_ISO = self.ISO_URL.partition("://")[2]
268
# Get absolute path if a relative path is used
269
DIR = commands.getoutput("cd `dirname '%s'` && pwd" % self.PATH_TO_ISO)
270
FILE = os.path.basename("%s" % self.PATH_TO_ISO)
271
self.PATH_TO_ISO = "%s/%s" % (DIR, FILE)
274
#error("Unsupported protocol [%s]" % self.PROTO)
277
def md5sum(self, file):
278
fh = open(file, 'rb')
285
def delete_image(self):
286
# if requested to clean out the image mark it to be done
292
# If disk image is stock (e.g., you just ran a LiveCD, no installation),
293
# purge it automatically.
294
if os.path.exists(self.DISK_FILE):
295
if os.path.getsize(self.DISK_FILE) == 262144 and self.md5sum(self.DISK_FILE) == "1da7553f642332ec9fb58a6094d2c8ef":
296
# Clean up kvm qcow2 image
298
if os.path.getsize(self.DISK_FILE) == 24576:
299
# Clean up vbox image
301
elif os.path.getsize(self.DISK_FILE) == 0:
302
# Clean up empty file
304
elif self.p == 'cloud-daily' or self.p == 'cloud-releases':
307
#info("Cleaning up disk image [%s]..." % DISK_FILE)
308
os.unlink(self.DISK_FILE)
312
def set_launch_path(self):
313
# Move from set_defaults, due to merge of upstream rev 189
314
ISO_NAME = "%s_%s" % (self.ISO_PATH_HEADER, os.path.basename(self.ISO_URL))
315
self.PROTO = self.ISO_URL.partition(":")[0]
316
self.PATH_TO_ISO = "%s/%s" % (self.CACHE_ISO, ISO_NAME)
318
def launch_usb_creator(self):
319
if os.path.exists("/usr/bin/usb-creator-gtk"):
320
os.execv("/usr/bin/usb-creator-gtk", ["usb-creator-gtk", "-i", self.PATH_TO_ISO])
322
os.execv("/usr/bin/usb-creator-kde", ["usb-creator-kde", "-i", self.PATH_TO_ISO])
324
def is_disk_empty(self):
325
(status, output) = commands.getstatusoutput("file %s | grep -qs 'empty'" % self.DISK_FILE)
330
# Obtain available ISO's from Ubuntu cdimage.
331
def is_iso_list_cached(self):
332
if not os.path.exists(self.CACHE):
333
os.makedirs(self.CACHE, 0700)
334
if not os.path.exists("%s/%s.isos" % (self.CACHE, self.p)):
338
def is_iso_list_cache_expired(self):
339
cache_time = time.localtime(os.path.getmtime("%s/%s.isos" % (self.CACHE, self.p)))
340
local_time = time.localtime()
341
time_difference = time.mktime(local_time) - time.mktime(cache_time)
342
# Check for new release at most every 12hrs (60*60*12 = 43200)
343
if time_difference >= 43200:
347
def obtain_ubuntu_iso_list_from_repo(self):
348
if self.p == 'cdimage':
349
(status, output) = commands.getstatusoutput("wget -q -O- http://cdimage.ubuntu.com/.manifest-daily | egrep '(amd64|i386)'")
350
elif self.p == 'releases':
351
(status, output) = commands.getstatusoutput("wget -q -O- http://releases.ubuntu.com/.manifest | egrep '(amd64|i386)'")
352
elif self.p == 'cloud-daily':
353
(status, output) = commands.getstatusoutput("wget -q -O- http://cloud-images.ubuntu.com/.manifest-daily | egrep '(amd64|i386)'")
354
elif self.p == 'cloud-releases':
355
(status, output) = commands.getstatusoutput("wget -q -O- http://cloud-images.ubuntu.com/.manifest | egrep '(amd64|i386)'")
358
def update_ubuntu_iso_list_cache(self, str):
360
f = open("%s/%s.isos" % (self.CACHE, self.p),'w')
366
def get_ubuntu_iso_list(self):
368
f = open("%s/%s.isos" % (self.CACHE, self.p), 'r')
375
def set_ubuntu_release_codename(self, isos):
378
codename.append(iso.split()[1])
380
self.r = codename[-1]
382
def create_disk_file(self):
383
return tempfile.mkstemp(".img", "testdrive-disk-", "%s" % self.CACHE_IMG)[1]
385
def prepare_cloud_img_tarball(self):
387
TAR_BASENAME = os.path.basename(self.PATH_TO_ISO).split(".tar.gz")[0].split("_")[-1]
388
ORIG_DISK_NAME = "%s.img" % TAR_BASENAME
389
FLOPPY_NAME = "%s-floppy" % TAR_BASENAME
391
image_path = "%s/%s" % (self.CACHE_ISO, ORIG_DISK_NAME)
392
floppy_path = "%s/%s" % (self.CACHE_ISO, FLOPPY_NAME)
394
cmd = 'cd %s && tar Szxvf %s %s %s' % (self.CACHE_ISO, self.PATH_TO_ISO, ORIG_DISK_NAME, FLOPPY_NAME)
26
def __init__(self, pkg_section):
27
self.HOME = os.getenv("HOME", "")
28
self.ISO_URL = os.getenv("ISO_URL", "")
29
self.VIRT = os.getenv("VIRT", "")
30
self.CACHE = os.getenv("CACHE", None)
31
self.CACHE_ISO = os.getenv("CACHE_ISO", None)
32
self.CACHE_IMG = os.getenv("CACHE_IMG", None)
33
self.CLEAN_IMG = os.getenv("CLEAN_IMG", None)
34
self.MEM = os.getenv("MEM", "")
35
self.SMP = os.getenv("SMP", "")
36
self.DISK_FILE = os.getenv("DISK_FILE", "")
37
self.DISK_SIZE = os.getenv("DISK_SIZE", "")
38
self.KVM_ARGS = os.getenv("KVM_ARGS", "")
39
self.VBOX_NAME = os.getenv("VBOX_NAME", "")
40
self.PKG = "testdrive"
41
self.PKGRC = "%src" % self.PKG
43
self.ISO_PATH_HEADER = None
44
self.PKG_SECTION = pkg_section
45
self.r = None #Release (maverick, lucid, etc)
46
self.m = None #Arch (amd64, i386)
47
self.f = None #Flavor (ubuntu, kubuntu, etc)
48
self.p = None # Ubuntu ISO Repository (cdimage, releases, cloud-daily, cloud-releases)
50
def set_values(self, var, value):
57
if var == 'disk_size':
58
self.DISK_SIZE = value
61
if var == 'cache_img':
62
self.CACHE_IMG = value
63
if var == 'cache_iso':
64
self.CACHE_ISO = value
65
if var == 'clean_img':
66
self.CLEAN_IMG = value
71
if var == 'disk_file':
72
self.DISK_FILE = value
76
self.m = value.split()
82
def load_config_file(self, config_file):
83
cfg = ConfigParser.ConfigParser()
86
defaults = cfg.items('testdrive-common')
87
for items in defaults:
88
self.set_values(items[0], items[1])
92
configitems = cfg.items(self.PKG_SECTION)
93
for items in configitems:
94
self.set_values(items[0], items[1])
98
## TODO: This possible needs to go outside the class due to in PyGTK front end we might need the list of ISO's before even instancing an object
99
def list_isos(self, ISOS):
102
if iso.split()[1] == self.r:
103
# TODO: Add support for Cloud
104
category = iso.split()[0]
105
if category == 'ubuntu-server':
107
elif category == 'ubuntu-netbook':
109
elif category == 'ubuntu-mobile':
111
elif category == 'kubuntu-netbook':
113
elif category == 'kubuntu-mobile':
115
flavor = iso.split()[0].capitalize()
116
if flavor == 'Ubuntu-netbook':
118
elif flavor == 'Ubuntu-mobile':
120
elif flavor == 'Kubuntu-netbook':
122
elif flavor == 'Kubuntu-mobile':
124
elif flavor == 'Ubuntustudio':
125
flavor = 'Ubuntu Studio'
126
elif flavor == 'Ubuntu-server':
128
elif flavor == 'Cloud-server':
129
flavor = 'Cloud Server'
130
elif flavor == 'Cloud-desktop':
131
flavor = 'Cloud Desktop'
132
release = iso.split()[1]
134
if self.p == 'cloud-daily' or self.p == 'cloud-releases':
135
arch = url.split(".tar.gz")[0].split("-")[-1]
138
arch = url.split(".iso")[0].split("-")[-1]
139
image = url.split("-%s.iso" % arch)[0].split("-")[-1].capitalize()
141
image = url.split("-%s.iso" % arch)[0].split("-")[-1].swapcase()
142
name = "%s %s" % (flavor, image)
143
# Name: Shows a description
144
# URL: Shows the URL from where it downloads the ISO
145
# Arch: Shows the architecture (amd64|i386)
146
# Category: The header used to save the ISO, i.e.: ubuntu_lucid-desktop-i386.iso kubuntu_lucid-desktop-i386.iso
148
ISO.append({"name":name, "url":"%s%s" % (self.u, url), "arch":arch, "category":category})
153
# Check if KVM acceleration can be used
154
if commands.getstatusoutput("which kvm-ok")[0] == 0:
155
# If we have kvm-ok, let's use it...
156
if commands.getstatusoutput("kvm-ok")[0] == 0:
159
# Okay, we don't have kvm-ok, so let's hack it...
160
if commands.getstatusoutput("egrep \"^flags.*:.*(svm|vmx)\" /proc/cpuinfo")[0] == 0:
162
# Prefer KVM if acceleration available and installed
163
if acceleration == 1 and commands.getstatusoutput("which kvm")[0] == 0:
165
# Okay, no KVM, VirtualBox maybe?
166
if commands.getstatusoutput("which VBoxManage")[0] == 0:
168
# No VirtualBox, how about Parallels?
169
if commands.getstatusoutput("which prlctl")[0] == 0:
171
# No hypervisor found; error out with advice
172
if acceleration == 1:
177
def set_defaults(self):
178
# Set defaults where undefined
179
if self.CACHE is None:
180
if xdg.BaseDirectory.xdg_cache_home:
181
self.CACHE = "%s/%s" % (xdg.BaseDirectory.xdg_cache_home, self.PKG)
183
self.CACHE = "%s/.cache/%s" % (self.HOME, self.PKG)
185
if self.CACHE_IMG is None:
186
self.CACHE_IMG = '%s/img' % self.CACHE
187
if not os.path.exists(self.CACHE_IMG):
188
os.makedirs(self.CACHE_IMG, 0700)
189
# if running the image from /dev/shm, remove the image when done
190
# (unless CLEAN_IMG is set)
191
if self.CLEAN_IMG is None:
192
if self.CACHE_IMG == '/dev/shm':
193
self.CLEAN_IMG = True
195
self.CLEAN_IMG = False
197
if self.CACHE_ISO is None:
198
self.CACHE_ISO = '%s/iso' % self.CACHE
199
if not os.path.exists(self.CACHE_ISO):
200
os.makedirs(self.CACHE_ISO, 0700)
202
if len(self.SMP) == 0:
203
self.SMP = commands.getoutput("grep -c ^processor /proc/cpuinfo")
205
if len(self.DISK_SIZE) == 0:
206
self.DISK_SIZE = "6G"
208
if len(self.MEM) == 0:
209
total = commands.getoutput("grep ^MemTotal /proc/meminfo | awk '{print $2}'")
212
elif total > 1000000:
219
if len(self.KVM_ARGS) == 0:
220
self.KVM_ARGS = "-usb -usbdevice tablet -net nic,model=virtio -net user -soundhw es1370"
222
if len(self.VBOX_NAME) == 0:
223
self.VBOX_NAME = self.PKG
225
if self.ISO_PATH_HEADER == None:
226
self.ISO_PATH_HEADER = 'other'
232
if platform.machine() == "x86_64":
233
self.m = ["amd64", "i386"]
240
if self.p == 'cdimage':
241
self.u = 'rsync://cdimage.ubuntu.com/cdimage'
243
if self.p == 'releases':
244
self.u = 'rsync://us.rsync.releases.ubuntu.com/releases'
246
if self.p == 'cloud-daily' or self.p == 'cloud-releases':
247
self.u = 'rsync://cloud-images.ubuntu.com/cloud-images'
250
return(os.system(cmd))
253
if self.PROTO == "rsync":
254
cmd = "rsync -azPL %s %s" % (self.ISO_URL, self.PATH_TO_ISO)
256
elif self.PROTO == "zsync" or self.PROTO == "http" or self.PROTO == "ftp":
257
if commands.getstatusoutput("which zsync")[0] == 0:
258
if self.ISO_URL.partition("://")[0] == "zsync":
259
self.ISO_URL = self.ISO_URL.replace('zsync', 'http')
260
cmd = "cd '%s' && zsync %s.zsync -o %s" % (self.CACHE_ISO, self.ISO_URL, self.PATH_TO_ISO)
263
cmd = "wget %s -O %s" % (self.ISO_URL, self.PATH_TO_ISO)
265
elif self.PROTO == "file":
266
# If the iso is on file:///, use the ISO in place
267
self.PATH_TO_ISO = self.ISO_URL.partition("://")[2]
268
# Get absolute path if a relative path is used
269
DIR = commands.getoutput("cd `dirname '%s'` && pwd" % self.PATH_TO_ISO)
270
FILE = os.path.basename("%s" % self.PATH_TO_ISO)
271
self.PATH_TO_ISO = "%s/%s" % (DIR, FILE)
274
#error("Unsupported protocol [%s]" % self.PROTO)
277
def md5sum(self, file):
278
fh = open(file, 'rb')
285
def delete_image(self):
286
# if requested to clean out the image mark it to be done
292
# If disk image is stock (e.g., you just ran a LiveCD, no installation),
293
# purge it automatically.
294
if os.path.exists(self.DISK_FILE):
295
if os.path.getsize(self.DISK_FILE) == 262144 and self.md5sum(self.DISK_FILE) == "1da7553f642332ec9fb58a6094d2c8ef":
296
# Clean up kvm qcow2 image
298
if os.path.getsize(self.DISK_FILE) == 24576:
299
# Clean up vbox image
301
elif os.path.getsize(self.DISK_FILE) == 0:
302
# Clean up empty file
304
elif self.p == 'cloud-daily' or self.p == 'cloud-releases':
307
#info("Cleaning up disk image [%s]..." % DISK_FILE)
308
os.unlink(self.DISK_FILE)
312
def set_launch_path(self):
313
# Move from set_defaults, due to merge of upstream rev 189
314
ISO_NAME = "%s_%s" % (self.ISO_PATH_HEADER, os.path.basename(self.ISO_URL))
315
self.PROTO = self.ISO_URL.partition(":")[0]
316
self.PATH_TO_ISO = "%s/%s" % (self.CACHE_ISO, ISO_NAME)
318
def launch_usb_creator(self):
319
if os.path.exists("/usr/bin/usb-creator-gtk"):
320
os.execv("/usr/bin/usb-creator-gtk", ["usb-creator-gtk", "-i", self.PATH_TO_ISO])
322
os.execv("/usr/bin/usb-creator-kde", ["usb-creator-kde", "-i", self.PATH_TO_ISO])
324
def is_disk_empty(self):
325
(status, output) = commands.getstatusoutput("file %s | grep -qs 'empty'" % self.DISK_FILE)
330
# Obtain available ISO's from Ubuntu cdimage.
331
def is_iso_list_cached(self):
332
if not os.path.exists(self.CACHE):
333
os.makedirs(self.CACHE, 0700)
334
if not os.path.exists("%s/%s.isos" % (self.CACHE, self.p)):
338
def is_iso_list_cache_expired(self):
339
cache_time = time.localtime(os.path.getmtime("%s/%s.isos" % (self.CACHE, self.p)))
340
local_time = time.localtime()
341
time_difference = time.mktime(local_time) - time.mktime(cache_time)
342
# Check for new release at most every 12hrs (60*60*12 = 43200)
343
if time_difference >= 43200:
347
def obtain_ubuntu_iso_list_from_repo(self):
348
if self.p == 'cdimage':
349
(status, output) = commands.getstatusoutput("wget -q -O- http://cdimage.ubuntu.com/.manifest-daily | egrep '(amd64|i386)'")
350
elif self.p == 'releases':
351
(status, output) = commands.getstatusoutput("wget -q -O- http://releases.ubuntu.com/.manifest | egrep '(amd64|i386)'")
352
elif self.p == 'cloud-daily':
353
(status, output) = commands.getstatusoutput("wget -q -O- http://cloud-images.ubuntu.com/.manifest-daily | egrep '(amd64|i386)'")
354
elif self.p == 'cloud-releases':
355
(status, output) = commands.getstatusoutput("wget -q -O- http://cloud-images.ubuntu.com/.manifest | egrep '(amd64|i386)'")
358
def update_ubuntu_iso_list_cache(self, str):
360
f = open("%s/%s.isos" % (self.CACHE, self.p),'w')
366
def get_ubuntu_iso_list(self):
368
f = open("%s/%s.isos" % (self.CACHE, self.p), 'r')
375
def set_ubuntu_release_codename(self, isos):
378
codename.append(iso.split()[1])
380
self.r = codename[-1]
382
def create_disk_file(self):
383
return tempfile.mkstemp(".img", "testdrive-disk-", "%s" % self.CACHE_IMG)[1]
385
def prepare_cloud_img_tarball(self):
387
TAR_BASENAME = os.path.basename(self.PATH_TO_ISO).split(".tar.gz")[0].split("_")[-1]
388
ORIG_DISK_NAME = "%s.img" % TAR_BASENAME
389
FLOPPY_NAME = "%s-floppy" % TAR_BASENAME
391
image_path = "%s/%s" % (self.CACHE_ISO, ORIG_DISK_NAME)
392
floppy_path = "%s/%s" % (self.CACHE_ISO, FLOPPY_NAME)
394
cmd = 'cd %s && tar Szxvf %s %s %s' % (self.CACHE_ISO, self.PATH_TO_ISO, ORIG_DISK_NAME, FLOPPY_NAME)