livemedia-creator: Removed unused ImageMount class
This commit is contained in:
parent
4b368aab87
commit
01f6f9f242
@ -216,74 +216,6 @@ class IsoMountpoint(object):
|
||||
return
|
||||
|
||||
|
||||
class ImageMount(object):
|
||||
"""
|
||||
# kpartx -p p -v -a /tmp/diskV2DiCW.im
|
||||
# add map loop2p1 (253:2): 0 3481600 linear /dev/loop2 2048
|
||||
# add map loop2p2 (253:3): 0 614400 linear /dev/loop2 3483648
|
||||
|
||||
Find the / partition and only mount that
|
||||
"""
|
||||
def __init__(self, disk_img):
|
||||
"""
|
||||
Use kpartx to mount an image onto temporary directories
|
||||
return a list of the dirs
|
||||
"""
|
||||
self.disk_img = disk_img
|
||||
|
||||
# call kpartx and parse the output
|
||||
cmd = [ "kpartx", "-v", "-p", "p", "-a", disk_img ]
|
||||
log.debug( cmd )
|
||||
kpartx_output = execWithCapture( cmd[0], cmd[1:] )
|
||||
log.debug( kpartx_output )
|
||||
self.loop_devices = []
|
||||
for line in kpartx_output.splitlines():
|
||||
# add map loop2p3 (253:4): 0 7139328 linear /dev/loop2 528384
|
||||
# 3rd element is size in 512 byte blocks
|
||||
if line.startswith("add map "):
|
||||
fields = line[8:].split()
|
||||
self.loop_devices.append((fields[0], int(fields[3])*512))
|
||||
|
||||
log.debug( self.loop_devices )
|
||||
|
||||
# Mount the devices, if possible
|
||||
self.mount_dir = None
|
||||
mount_dir = tempfile.mkdtemp()
|
||||
for dev, size in self.loop_devices:
|
||||
cmd = ["mount", "/dev/mapper/"+dev, mount_dir]
|
||||
log.debug( cmd )
|
||||
try:
|
||||
execWithRedirect( cmd[0], cmd[1:] )
|
||||
if os.path.isfile(mount_dir+"/etc/fstab"):
|
||||
self.mount_dir = mount_dir
|
||||
self.mount_dev = dev
|
||||
self.mount_size = size
|
||||
break
|
||||
cmd = ["umount", mount_dir]
|
||||
execWithRedirect( cmd[0], cmd[1:] )
|
||||
except subprocess.CalledProcessError:
|
||||
log.debug( traceback.format_exc() )
|
||||
|
||||
if self.mount_dir:
|
||||
log.info( "Found root partition, mounted on {0}".format(self.mount_dir) )
|
||||
log.info( "size = {0}".format(self.mount_size) )
|
||||
|
||||
def umount(self):
|
||||
"""
|
||||
unmount the disk image
|
||||
"""
|
||||
if self.mount_dir:
|
||||
cmd = ["umount", self.mount_dir]
|
||||
log.debug( cmd )
|
||||
execWithRedirect( cmd[0], cmd[1:] )
|
||||
os.rmdir(self.mount_dir)
|
||||
self.mount_dir = None
|
||||
|
||||
cmd = ["kpartx", "-d", self.disk_img]
|
||||
log.debug( cmd )
|
||||
execWithRedirect( cmd[0], cmd[1:] )
|
||||
|
||||
|
||||
class VirtualInstall( object ):
|
||||
"""
|
||||
Run virt-install using an iso and kickstart(s)
|
||||
|
Loading…
Reference in New Issue
Block a user