[node-patches] Change in ovirt-node[master]: Edit-node cleanup -- remove duplicate code paths
rbarry at redhat.com
rbarry at redhat.com
Tue Oct 22 18:16:53 UTC 2013
Ryan Barry has uploaded a new change for review.
Change subject: Edit-node cleanup -- remove duplicate code paths
......................................................................
Edit-node cleanup -- remove duplicate code paths
Remove duplicate code paths and cleanup code slightly.
Change-Id: If37be3dbf2db1f1dc7d413e381695e927878bc97
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=988672
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M tools/edit-node
1 file changed, 0 insertions(+), 191 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/08/20408/1
diff --git a/tools/edit-node b/tools/edit-node
index 7a78f2f..dbb2d5b 100755
--- a/tools/edit-node
+++ b/tools/edit-node
@@ -318,142 +318,6 @@
finally:
imgmnt.cleanup()
- def mount(self, base_on, cachedir=None):
- """mount existing file system.
-
- We have to override mount b/c we many not be creating an new install
- root nor do we need to setup the file system, i.e., makedirs(/etc/,
- /boot, ...), nor do we want to overwrite fstab, or create selinuxfs.
-
- We also need to get some info about the image before we can mount it.
-
- base_on -- the <LIVEIMG.src> a LiveOS.iso file or an attached LiveOS
- device, such as, /dev/live or /run/initramfs/livedev for
- a currently running image.
-
- cachedir -- a directory in which to store a Yum cache;
- Not used in edit-liveos.
-
- """
-
- if not base_on:
- raise CreatorError("No base LiveOS image specified.")
-
- self.__ensure_builddir()
-
- self._ImageCreator_instroot = self._ImageCreator__builddir + \
- "/install_root"
- self._LoopImageCreator__imagedir = self._ImageCreator__builddir + \
- "/ex"
- self._ImageCreator_outdir = self._ImageCreator__builddir + "/out"
-
- makedirs(self._ImageCreator_instroot)
- makedirs(self._LoopImageCreator__imagedir)
- makedirs(self._ImageCreator_outdir)
-
- LiveImageCreator._base_on(self, base_on)
- self._LoopImageCreator__fstype = get_fsvalue(self._image, 'TYPE')
- self._get_fslabel()
-
- self.fslabel = self._LoopImageCreator__fslabel
- if self._LoopImageCreator__image_size is None:
- self._LoopImageCreator__image_size = os.stat(
- self._image)[stat.ST_SIZE]
-
- self._LoopImageCreator__instloop = ExtDiskMount(
- ExistingSparseLoopbackDisk(self._image,
- self._LoopImageCreator__image_size),
- self._ImageCreator_instroot,
- self._fstype,
- self._LoopImageCreator__blocksize,
- self.fslabel,
- self.tmpdir)
- try:
- self._LoopImageCreator__instloop.mount()
- except MountError, e:
- raise CreatorError("Failed to loopback mount '%s' : %s" %
- (self._image, e))
-
- cachesrc = cachedir or (self._ImageCreator__builddir + "/yum-cache")
- makedirs(cachesrc)
-
- for (f, dest) in [("/sys", None), ("/proc", None),
- ("/dev/pts", None), ("/dev/shm", None),
- (cachesrc, "/var/cache/yum")]:
- self._ImageCreator__bindmounts.append(BindChrootMount(
- f,
- self._instroot,
- dest))
-
- self._do_bindmounts()
- self.__copy_img_root(base_on)
- self._brand(self._builder)
-
- def _base_on(self, base_on):
- """Clone the running LiveOS image as the basis for the new image."""
-
- self.__fstype = 'ext4'
- self.__image_size = 4096L * 1024 * 1024
- self.__blocksize = 4096
-
- self.__instloop = ExtDiskMount(SparseLoopbackDisk(self._image,
- self.__image_size),
- self._instroot,
- self.__fstype,
- self.__blocksize,
- self.fslabel,
- self.tmpdir)
- try:
- self.__instloop.mount()
- except MountError, e:
- raise CreatorError("Failed to loopback mount '%s' : %s" %
- (self._image, e))
-
- subprocess.call(['rsync', '-ptgorlHASx', '--specials', '--progress',
- '--include', '/*/',
- '--exclude', '/etc/mtab',
- '--exclude', '/etc/blkid/*',
- '--exclude', '/dev/*',
- '--exclude', '/proc/*',
- '--exclude', '/home/*',
- '--exclude', '/media/*',
- '--exclude', '/mnt/live',
- '--exclude', '/sys/*',
- '--exclude', '/tmp/*',
- '--exclude', '/.liveimg*',
- '--exclude', '/.autofsck',
- '/', self._instroot])
- subprocess.call(['sync'])
-
- self._ImageCreator__create_minimal_dev()
-
- self.__instloop.cleanup()
-
- def __copy_img_root(self, base_on):
- """helper function to copy root content of the base LiveIMG to
- ISOdir"""
-
- ignore_list = ['ext3fs.img', 'squashfs.img', 'osmin.img', 'home.img',
- 'overlay-*']
-
- imgmnt = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
-
- self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + \
- "/iso"
-
- try:
- imgmnt.mount()
- except MountError, e:
- raise CreatorError("Failed to mount '%s' : %s" % (base_on, e))
- else:
- # include specified files or directories
- #copy over everything but squashfs.img or ext3fs.img
- shutil.copytree(imgmnt.mountdir,
- self._LiveImageCreatorBase__isodir,
- ignore=shutil.ignore_patterns(*ignore_list))
- subprocess.call(['sync'])
- finally:
- imgmnt.cleanup()
def _brand(self, _builder):
"""Adjust the image branding to show its variation from original
@@ -1040,61 +904,6 @@
return True
return True
- class simpleCallback:
- def __init__(self):
- self.fdnos = {}
-
- def callback(self, what, amount, total, mydata, wibble):
- if what == rpm.RPMCALLBACK_TRANS_START:
- pass
-
- elif what == rpm.RPMCALLBACK_INST_OPEN_FILE:
- hdr, path = mydata
- print "Installing %s\r" % (hdr["name"])
- fd = os.open(path, os.O_RDONLY)
- nvr = '%s-%s-%s' % \
- (hdr['name'], hdr['version'], hdr['release'])
- self.fdnos[nvr] = fd
- return fd
-
- elif what == rpm.RPMCALLBACK_INST_CLOSE_FILE:
- hdr, path = mydata
- nvr = '%s-%s-%s' % \
- (hdr['name'], hdr['version'], hdr['release'])
- os.close(self.fdnos[nvr])
-
- elif what == rpm.RPMCALLBACK_INST_PROGRESS:
- hdr, path = mydata
- print "%s: %.5s%% done\r" % (hdr["name"],
- (float(amount) / total) * 100)
-
- def install_rpms(self):
- if kickstart.exclude_docs(self.ks):
- rpm.addMacro("_excludedocs", "1")
- if not kickstart.selinux_enabled(self.ks):
- rpm.addMacro("__file_context_path", "%{nil}")
- if kickstart.inst_langs(self.ks) is not None:
- rpm.addMacro("_install_langs", kickstart.inst_langs(self.ks))
- # start RPM transaction
- ts = rpm.TransactionSet(self._instroot)
- for repo in kickstart.get_repos(self.ks):
- (name, baseurl, mirrorlist, proxy, inc, exc) = repo
- if baseurl.startswith("file://"):
- baseurl = baseurl[7:]
- elif not baseurl.startswith("/"):
- raise CreatorError("edit-node accepts only --baseurl " +
- "pointing to a local folder with RPMs " +
- "(not YUM repo)")
- if not baseurl.endswith("/"):
- baseurl += "/"
- for pkg_from_list in kickstart.get_packages(self.ks):
- # TODO report if package listed in ks is missing
- for pkg in glob.glob(baseurl+pkg_from_list+"-[0-9]*.rpm"):
- fdno = os.open(pkg, os.O_RDONLY)
- hdr = ts.hdrFromFdno(fdno)
- os.close(fdno)
- ts.addInstall(hdr, (hdr, pkg), "u")
- ts.run(self.simpleCallback().callback, '')
def _setup_dns(self):
print "Setting Up DNS For Chroot"
--
To view, visit http://gerrit.ovirt.org/20408
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If37be3dbf2db1f1dc7d413e381695e927878bc97
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>
More information about the node-patches
mailing list