[node-patches] Change in ovirt-node[master]: edit-node: pep8 spacing and line length fixes
jboggs at redhat.com
jboggs at redhat.com
Wed May 15 16:25:05 UTC 2013
Joey Boggs has uploaded a new change for review.
Change subject: edit-node: pep8 spacing and line length fixes
......................................................................
edit-node: pep8 spacing and line length fixes
Signed-off-by: Joey Boggs <jboggs at redhat.com>
Change-Id: Iabe6dad850e2dacdcd9e957176c96a93ea691295
---
M tools/edit-node
1 file changed, 298 insertions(+), 179 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/55/14755/1
diff --git a/tools/edit-node b/tools/edit-node
index fb72c1d..f774d92 100755
--- a/tools/edit-node
+++ b/tools/edit-node
@@ -129,7 +129,7 @@
self.__ensure_builddir()
self._LoopImageCreator__imagedir = \
tempfile.mkdtemp(dir=os.path.abspath(self.tmpdir),
- prefix=self.name + "-")
+ prefix=self.name + "-")
rtn = self._LoopImageCreator__imagedir + "/ext3fs.img"
return rtn
_image = property(__get_image)
@@ -142,10 +142,10 @@
stdout=subprocess.PIPE,
stderr=dev_null).communicate()[0]
- self._LoopImageCreator__fslabel=out.strip()
+ self._LoopImageCreator__fslabel = out.strip()
except IOError, e:
- raise CreatorError("Failed to determine fsimage LABEL: %s" % e )
+ raise CreatorError("Failed to determine fsimage LABEL: %s" % e)
finally:
os.close(dev_null)
@@ -154,8 +154,10 @@
return
try:
- self._ImageCreator__builddir=tempfile.mkdtemp(dir=os.path.abspath(self.tmpdir),
- prefix="edit-liveos-")
+ self._ImageCreator__builddir = tempfile.mkdtemp(
+ dir=os.path.abspath(self.tmpdir),
+ prefix="edit-liveos-"
+ )
except OSError, (err, msg):
raise CreatorError("Failed create build directory in %s: %s" %
(self.tmpdir, msg))
@@ -163,7 +165,7 @@
def _run_script(self, script):
(fd, path) = tempfile.mkstemp(prefix="script-",
- dir=self._instroot + "/tmp")
+ dir=self._instroot + "/tmp")
logging.debug("copying script to install root: %s" % path)
shutil.copy(os.path.abspath(script), path)
@@ -175,7 +177,8 @@
try:
subprocess.call([script], preexec_fn=self._chroot)
except OSError, e:
- raise CreatorError("Failed to execute script %s, %s " % (script, e))
+ raise CreatorError("Failed to execute script %s, %s " %
+ (script, e))
finally:
os.unlink(path)
@@ -201,7 +204,8 @@
self.__ensure_builddir()
- self._ImageCreator_instroot = self._ImageCreator__builddir + "/install_root"
+ self._ImageCreator_instroot = self._ImageCreator__builddir + \
+ "/install_root"
self._LoopImageCreator__imagedir = self._ImageCreator__builddir + "/ex"
self._ImageCreator_outdir = self._ImageCreator__builddir + "/out"
@@ -214,17 +218,18 @@
self._get_fslabel()
self.fslabel = self._LoopImageCreator__fslabel
- if self._LoopImageCreator__image_size == None:
- self._LoopImageCreator__image_size = os.stat(self._image)[stat.ST_SIZE]
+ 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)
+ 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:
@@ -237,7 +242,9 @@
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._ImageCreator__bindmounts.append(BindChrootMount(
+ f, self._instroot, dest)
+ )
self._do_bindmounts()
self.__copy_img_root(base_on)
@@ -292,7 +299,8 @@
imgmnt = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
- self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + "/iso"
+ self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + \
+ "/iso"
try:
imgmnt.mount()
@@ -330,8 +338,10 @@
self.__ensure_builddir()
- self._ImageCreator_instroot = self._ImageCreator__builddir + "/install_root"
- self._LoopImageCreator__imagedir = self._ImageCreator__builddir + "/ex"
+ 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)
@@ -343,17 +353,18 @@
self._get_fslabel()
self.fslabel = self._LoopImageCreator__fslabel
- if self._LoopImageCreator__image_size == None:
- self._LoopImageCreator__image_size = os.stat(self._image)[stat.ST_SIZE]
+ 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)
+ 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:
@@ -366,7 +377,9 @@
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._ImageCreator__bindmounts.append(BindChrootMount(
+ f, self._instroot, dest)
+ )
self._do_bindmounts()
self.__copy_img_root(base_on)
@@ -421,7 +434,8 @@
imgmnt = DiskMount(LoopbackDisk(base_on, 0), self._mkdtemp())
- self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + "/iso"
+ self._LiveImageCreatorBase__isodir = self._ImageCreator__builddir + \
+ "/iso"
try:
imgmnt.mount()
@@ -437,7 +451,7 @@
finally:
imgmnt.cleanup()
- def _brand (self, _builder):
+ def _brand(self, _builder):
"""Adjust the image branding to show its variation from original
source by builder and build date."""
@@ -504,14 +518,15 @@
args = ['/bin/sed', '-i']
if self._releasefile:
args.append('-e')
- args.append('s/Welcome to .*/Welcome to ' + self._releasefile + '!/')
+ args.append('s/Welcome to .*/Welcome to ' + self._releasefile +
+ '!/')
args.append('-e')
args.append('s/root=[^ ]*/root=live:CDLABEL=' + self.name[:32] + '/')
if self.ks:
# bootloader --append "!opt-to-remove opt-to-add"
for param in kickstart.get_kernel_args(self.ks, "").split():
if param.startswith('!'):
- param=param[1:]
+ param = param[1:]
# remove parameter prefixed with !
args.append('-e')
args.append("/^ append/s/%s //" % param)
@@ -527,7 +542,8 @@
eficfgf = os.path.join(efifolder, 'BOOTX64.conf')
efiargs = ['/bin/sed', '-i']
efiargs.append('-e')
- efiargs.append('s/root=[^ ]*/root=live:CDLABEL=' + self.name[:32] + '/')
+ efiargs.append('s/root=[^ ]*/root=live:CDLABEL=' +
+ self.name[:32] + '/')
efiargs.append(eficfgf)
dev_null = os.open("/dev/null", os.O_WRONLY)
try:
@@ -591,36 +607,43 @@
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'] )
+ 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'] )
+ 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),
+ 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) != None:
+ 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)
+ 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:]
+ baseurl = baseurl[7:]
elif not baseurl.startswith("/"):
- raise CreatorError("edit-node accepts only --baseurl pointing to a local folder with RPMs (not YUM repo)")
+ raise CreatorError("edit-node accepts only --baseurl " +
+ "pointing to a local folder with RPMs" +
+ "(not YUM repo)")
if not baseurl.endswith("/"):
- baseurl+="/"
+ 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"):
@@ -655,14 +678,16 @@
print "Failed Parsing %s" % options.uidmod
return False
cmd = "id -u %s" % user
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, \
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
preexec_fn=self._chroot)
old_uid, err = f.communicate()
cmd = "usermod -u %s %s" % (new_uid, user)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
cmd = "find / -uid %s -exec chown %s {} \;" % (old_uid, new_uid)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
def _change_gid(self, options):
@@ -673,32 +698,37 @@
print "Failed Parsing %s" % options.gidmod
return False
cmd = "getent group %s | cut -d: -f3" % group
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, \
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
preexec_fn=self._chroot)
old_gid, err = f.communicate()
cmd = "groupmod -g %s %s" % (new_gid, group)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
- cmd = "find / -gid %s -exec chgrp %s {} \;" % (old_gid.strip(), new_gid)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "find / -gid %s -exec chgrp %s {} \;" % \
+ (old_gid.strip(), new_gid)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
def _print_rpm_manifest(self):
cmd = "rpm -qa|sort"
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
print "%s" % output
return True
def _print_file_manifest(self):
cmd = "find /"
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
print "\n%s\n" % output
return True
def _list_plugins(self):
- plugin_info_dir = "%s/etc/ovirt-plugins.d" % self._instroot
+ plugin_info_dir = "%s/etc/ovirt-plugins.d" % self._instroot
if os.path.exists(plugin_info_dir):
print "\nInstalled Plugins:\n"
for p in os.listdir(plugin_info_dir):
@@ -723,49 +753,57 @@
pkg = "password-set"
print "Creating Manifests"
# Create post-image processing manifests
- cmd = "LC_ALL=C rpm -qa --qf '%%{name}-%%{version}-%%{release}.%%{arch} (%%{SIGPGP:pgpsig})\n' | sort -u > /manifest-%s-%s-rpm.txt" % (timestamp, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "LC_ALL=C rpm -qa --qf '%{name}-%{version}-%{release}.'" + \
+ "'%{arch} (%{SIGPGP:pgpsig})\n' | sort -u > /manifest-" + \
+ "%s-%s-rpm.txt" % (timestamp, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
- cmd = "LC_ALL=C rpm -qa --qf '%%{name}-%%{version}-%%{release}.%%{arch} (%%{SIGPGP:pgpsig})\n' | sort -u > /manifest-%s-%s-rpm.txt" % (timestamp, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
- output, err = f.communicate()
-
- cmd = "LC_ALL=C rpm -qa --qf '%%{sourcerpm}\n' | sort -u > /manifest-%s-%s-srpm.txt" % (timestamp, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "LC_ALL=C rpm -qa --qf '%%{sourcerpm}\n' | sort -u > " + \
+ "/manifest-%s-%s-srpm.txt" % (timestamp, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
# collect all included licenses rhbz#601927
- cmd = "LC_ALL=C rpm -qa --qf '%%{license}\n' | sort -u > /manifest-%s-%s-license.txt" % (timestamp, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "LC_ALL=C rpm -qa --qf '%%{license}\n' | sort -u > " + \
+ "/manifest-%s-%s-license.txt" % (timestamp, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
- cmd = "du -akx --exclude=/var/cache/yum / > /manifest-%s-%s-file.txt" % (timestamp, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "du -akx --exclude=/var/cache/yum / > " + \
+ "/manifest-%s-%s-file.txt" % (timestamp, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
- cmd = "du -x --exclude=/var/cache/yum / > /manifest-%s-%s-dir.txt" % (timestamp, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "du -x --exclude=/var/cache/yum / " + \
+ "> /manifest-%s-%s-dir.txt" % (timestamp, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
# create plugin info
if options.install or options.plugin or options.install_dup:
- plugin_info_dir = "%s/etc/ovirt-plugins.d" % self._instroot
+ plugin_info_dir = "%s/etc/ovirt-plugins.d" % self._instroot
os.system("mkdir -p %s" % plugin_info_dir)
# get version-release
cmd = "rpm -q %s --qf '%%{version}-%%{release}.%%{arch}\n'" % pkg
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, \
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
preexec_fn=self._chroot)
vr, err = f.communicate()
# get install date
cmd = "LC_ALL=C rpm -q %s --qf '%%{INSTALLTIME:date}\n'" % pkg
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, \
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
preexec_fn=self._chroot)
install_date, err = f.communicate()
if os.path.isfile(pkg):
#get rpm name
cmd = "rpm -qp %s --qf '%%{name}'" % pkg
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
pkg, err = f.communicate()
plugin_file = "%s/%s" % (plugin_info_dir, pkg)
pfile = open(plugin_file, "w")
@@ -775,30 +813,50 @@
pfile.close()
# create deltas
- for i in ["file", "dir", "owns", "deps" ]:
+ for i in ["file", "dir", "owns", "deps"]:
# if current-XXX-manifest exists run delta based on it
- if os.path.exists("%s/iso/isolinux/current-manifest-%s.txt" % (self._ImageCreator__builddir, i)):
- cmd = "cp %s/iso/isolinux/current-manifest-%s.txt > %s/manifest-%s.txt" % (self._ImageCreator__builddir, i, self._instroot , i)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ if os.path.exists("%s/iso/isolinux/current-manifest-%s.txt"
+ % (self._ImageCreator__builddir, i)):
+ cmd = "cp %s/iso/isolinux/current-manifest-%s.txt > " + \
+ "%s/manifest-%s.txt" % \
+ (self._ImageCreator__builddir, i, self._instroot, i)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
else:
- cmd = "bzcat %s/iso/isolinux/manifest-%s.txt.bz2|sort > %s/manifest-%s.txt" % (self._ImageCreator__builddir, i, self._instroot , i)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ cmd = "bzcat %s/iso/isolinux/manifest-%s.txt.bz2|sort > " \
+ "%s/manifest-%s.txt" % \
+ (self._ImageCreator__builddir, i, self._instroot, i)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
- cmd = "diff -u /manifest-%s.txt /manifest-%s-%s-%s.txt |egrep -v \"^@|^ \"> /delta-%s-manifest-%s-%s.txt" % (i, timestamp, pkg, i, timestamp, i, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "diff -u /manifest-%s.txt /manifest-%s-%s-%s.txt | egrep" \
+ " -v \"^@|^ \"> /delta-%s-manifest-%s-%s.txt" % \
+ (i, timestamp, pkg, i, timestamp, i, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
for i in ["rpm", "srpm", "license"]:
- if os.path.exists("%s/iso/isolinux/current-manifest-%s.txt" % (self._ImageCreator__builddir, i)):
- cmd = "cat %s/iso/isolinux/current-manifest-%s.txt|sort -u > %s/manifest-%s.txt" % (self._ImageCreator__builddir, i, self._instroot, i)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ if os.path.exists("%s/iso/isolinux/current-manifest-%s.txt" %
+ (self._ImageCreator__builddir, i)):
+ cmd = "cat %s/iso/isolinux/current-manifest-%s.txt|sort" \
+ "-u > %s/manifest-%s.txt" % \
+ (self._ImageCreator__builddir, i, self._instroot, i)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
else:
- cmd = "cat %s/iso/isolinux/manifest-%s.txt|sort -u > %s/manifest-%s.txt" % (self._ImageCreator__builddir, i, self._instroot, i)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ cmd = "cat %s/iso/isolinux/manifest-%s.txt|sort -u >" \
+ " %s/manifest-%s.txt" % \
+ (self._ImageCreator__builddir, i, self._instroot, i)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
- cmd = "diff -u /manifest-%s.txt /manifest-%s-%s-%s.txt |egrep -v \"^@|^ \" > /delta-%s-manifest-%s-%s.txt" % (i, timestamp, pkg, i, timestamp, i, pkg)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "diff -u /manifest-%s.txt /manifest-%s-%s-%s.txt |egrep " \
+ "-v \"^@|^ \" > /delta-%s-manifest-%s-%s.txt" % \
+ (i, timestamp, pkg, i, timestamp, i, pkg)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
# cleanup copied manifests
for i in ["rpm", "srpm", "license", "file", "dir", "owns", "deps"]:
@@ -807,29 +865,36 @@
output, err = f.communicate()
print "Copying Manifests"
for file in glob.glob("%s/*manifest-*" % self._instroot):
- rootfs_manifest_dir = "%s/etc/ovirt-plugins-manifests.d" % self._instroot
+ rootfs_manifest_dir = "%s/etc/ovirt-plugins-manifests.d" % \
+ self._instroot
os.system("mkdir -p %s" % rootfs_manifest_dir)
cmd = "cp %s %s" % (file, rootfs_manifest_dir)
f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
if f.returncode > 0:
output, err = f.communicate()
print output
- print "Failed to copy %s to %s/manifests" % (file, plugin_info_dir)
+ print "Failed to copy %s to %s/manifests" % \
+ (file, plugin_info_dir)
return False
- cmd = "mv %s %s/iso/isolinux" % (file, self._ImageCreator__builddir)
+ cmd = "mv %s %s/iso/isolinux" % \
+ (file, self._ImageCreator__builddir)
f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
output, err = f.communicate()
if f.returncode > 0:
cmd = "ls -al %s" % self._ImageCreator__builddir
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
print output
- print "Failed to copy %s to %s/iso/isolinux" % (file, self._ImageCreator__builddir)
+ print "Failed to copy %s to %s/iso/isolinux" % \
+ (file, self._ImageCreator__builddir)
return False
# update symlink
- for f in ["rpm", "srpm", "license", "file", "dir" ]:
- if os.path.exists("%s/iso/isolinux/current-manifest-%s.txt" % (self._ImageCreator__builddir, f)):
- os.system("rm -rf %s/iso/isolinux/current-manifest-%s.txt" % (self._ImageCreator__builddir, f))
+ for f in ["rpm", "srpm", "license", "file", "dir"]:
+ if os.path.exists("%s/iso/isolinux/current-manifest-%s.txt" %
+ (self._ImageCreator__builddir, f)):
+ os.system("rm -rf %s/iso/isolinux/current-manifest-%s.txt" %
+ (self._ImageCreator__builddir, f))
cwd = os.getcwd()
os.chdir("%s/iso/isolinux" % self._ImageCreator__builddir)
src = "manifest-%s-%s-%s.txt" % (timestamp, pkg, f)
@@ -858,7 +923,7 @@
cmd = "cp -a %s /tmp/%s" % (file, dirname)
f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
output, err = f.communicate()
- cmd = "tar cjvf %s.tar.bz2 %s" % (dirname, dirname)
+ cmd = "tar cjvf %s.tar.bz2 %s" % (dirname, dirname)
cwd = os.getcwd()
os.chdir("/tmp")
f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
@@ -954,36 +1019,41 @@
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'] )
+ 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'] )
+ 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),
+ 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) != None:
+ 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)
+ 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:]
+ baseurl = baseurl[7:]
elif not baseurl.startswith("/"):
- raise CreatorError("edit-node accepts only --baseurl pointing to a local folder with RPMs (not YUM repo)")
+ raise CreatorError("edit-node accepts only --baseurl " +
+ "pointing to a local folder with RPMs " +
+ "(not YUM repo)")
if not baseurl.endswith("/"):
- baseurl+="/"
+ 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"):
@@ -997,34 +1067,43 @@
print "Setting Up DNS For Chroot"
# bind mount resolv.conf
os.system("touch %s/etc/resolv.conf" % self._instroot)
- os.system("mount -o bind /etc/resolv.conf %s/etc/resolv.conf" % self._instroot)
+ os.system("mount -o bind /etc/resolv.conf %s/etc/resolv.conf" %
+ self._instroot)
def _setup_yum_repo(self, options):
print "Configuring Yum Repo"
- self.dd_dir = tempfile.mkdtemp(dir=os.path.abspath(self.tmpdir), prefix="dd-iso")
+ self.dd_dir = tempfile.mkdtemp(dir=os.path.abspath(self.tmpdir),
+ prefix="dd-iso")
if not options.repo:
return True
else:
- if os.path.isfile(options.repo) and not options.repo.lower().endswith(".iso"):
+ if os.path.isfile(options.repo) and not \
+ options.repo.lower().endswith(".iso"):
cmd = "touch /etc/yum.repos.d/plugin.repo"
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
if f.returncode > 0:
print output
print "Can't Create Repo File"
return False
- cmd = "mount -o bind %s %s/etc/yum.repos.d/plugin.repo" % (options.repo, self._instroot)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ cmd = "mount -o bind %s %s/etc/yum.repos.d/plugin.repo" % \
+ (options.repo, self._instroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
if f.returncode > 0:
print "Can't Bind Mount Repo File"
print output
return False
return True
- elif os.path.isdir(options.repo) or options.repo.lower().endswith(".iso"):
+ elif os.path.isdir(options.repo) or \
+ options.repo.lower().endswith(".iso"):
if options.repo.lower().endswith(".iso"):
cmd = "mount -o loop %s %s" % (options.repo, self.dd_dir)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
if f.returncode > 0:
print cmd
@@ -1034,11 +1113,14 @@
if os.path.exists("%s/rpms/x86_64" % self.dd_dir):
options.repo = "%s/rpms/x86_64" % self.dd_dir
else:
- print "Cant find rpm directory: %s/rpms/x86_64" % self.dd_dir
+ print "Cant find rpm directory: %s/rpms/x86_64" \
+ % self.dd_dir
return False
os.system("mkdir %s/tmp/yumrepo" % self._instroot)
- cmd = "mount -o bind %s %s/tmp/yumrepo" % (options.repo, self._instroot)
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
+ cmd = "mount -o bind %s %s/tmp/yumrepo" \
+ % (options.repo, self._instroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = f.communicate()
if f.returncode > 0:
print cmd
@@ -1057,10 +1139,7 @@
baseurl=file:///tmp/yumrepo
enabled=1
"""
- repo_dict = {
- "gpg_check" : gpgcheck
- }
-
+ repo_dict = {"gpg_check": gpgcheck}
f = open(self._instroot + "/etc/yum.repos.d/plugin.repo", "w")
f.write(repo_template % repo_dict)
f.close()
@@ -1073,23 +1152,24 @@
_usr_loc = glob.glob("/usr/share/%s*" % rpm)
_doc_loc = glob.glob("/usr/share/doc/%s*" % rpm)
if options.plugin:
- valid_write_locations = [ "/etc",
- "/opt",
- "/usr/share/man",
- "/usr/lib/python",
- "/usr/lib/systemd"]
+ valid_write_locations = ["/etc",
+ "/opt",
+ "/usr/share/man",
+ "/usr/lib/python",
+ "/usr/lib/systemd"]
elif options.install_dup:
- valid_write_locations = [ "/etc/modprobe.d",
- "/etc/depmod.d",
- "/usr/share",
- "/lib/modules",
- "/lib/firmware" ]
+ valid_write_locations = ["/etc/modprobe.d",
+ "/etc/depmod.d",
+ "/usr/share",
+ "/lib/modules",
+ "/lib/firmware"]
for entry in _usr_loc:
valid_write_locations.append(entry)
for entry in _doc_loc:
valid_write_locations.append(entry)
cmd = "rpm -ql %s" % rpm
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
output = output.splitlines()
i_files = []
@@ -1108,7 +1188,8 @@
break
print "Package Validation Completed For: %s" % rpm
if len(i_files) > 0:
- print "Unable to install package due to directory restrictions on:\n"
+ print "Unable to install package due to directory " + \
+ "restrictions on:\n"
for file in i_files:
print "%s" % file
return False
@@ -1118,12 +1199,14 @@
print "Running Minimizer"
minimizer = "/usr/bin/image-minimizer"
if os.path.exists(minimizer):
- print glob.glob("%s/etc/ovirt-plugins.d/*.minimize" % self._instroot)
- for f in glob.glob("%s/etc/ovirt-plugins.d/*.minimize" % self._instroot):
+ print glob.glob("%s/etc/ovirt-plugins.d/*.minimize"
+ % self._instroot)
+ for f in glob.glob("%s/etc/ovirt-plugins.d/*.minimize"
+ % self._instroot):
cmd = "%s -v -i %s %s" % (minimizer, self._instroot, f)
print cmd
- minimize = subprocess.Popen(cmd, shell=True, stdout=PIPE, \
- stderr=STDOUT)
+ minimize = subprocess.Popen(cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT)
output, err = minimize.communicate()
print output
@@ -1134,7 +1217,8 @@
try:
os.remove(self._instroot + "/etc/yum.repos.d/plugin.repo")
except:
- os.system("umount %s/etc/yum.repos.d/plugin.repo" % self._instroot)
+ os.system("umount %s/etc/yum.repos.d/plugin.repo"
+ % self._instroot)
if os.path.exists(self._instroot + "/tmp/yumrepo"):
# cleanup local repo if exists
if os.system("umount %s/tmp/yumrepo" % self._instroot):
@@ -1149,18 +1233,21 @@
return False
if os.path.isfile(pkgs):
os.system("mkdir %s/tmp/yumrepo" % self._instroot)
- os.system("touch %s/tmp/yumrepo/%s" % (self._instroot, os.path.basename(pkgs)))
- os.system("mount -o bind %s %s/tmp/yumrepo/%s" % (pkgs, self._instroot, os.path.basename(pkgs)))
+ os.system("touch %s/tmp/yumrepo/%s" % (self._instroot,
+ os.path.basename(pkgs)))
+ os.system("mount -o bind %s %s/tmp/yumrepo/%s" %
+ (pkgs, self._instroot, os.path.basename(pkgs)))
print os.listdir("%s/tmp/yumrepo" % self._instroot)
- yum_cmd = "yum localinstall -y /tmp/yumrepo/%s" % os.path.basename(pkgs)
+ yum_cmd = "yum localinstall -y /tmp/yumrepo/%s" % \
+ os.path.basename(pkgs)
else:
yum_cmd = "yum install -y %s " % pkgs
# make sure rpm keys are imported
rpm_cmd = "rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*"
- rpm = subprocess.Popen(rpm_cmd, shell=True, stdout=PIPE, \
- stderr=STDOUT, preexec_fn=self._chroot)
+ rpm = subprocess.Popen(rpm_cmd, shell=True, stdout=PIPE,
+ stderr=STDOUT, preexec_fn=self._chroot)
output, err = rpm.communicate()
- yum = subprocess.Popen(yum_cmd, shell=True, stdout=PIPE, \
+ yum = subprocess.Popen(yum_cmd, shell=True, stdout=PIPE,
stderr=STDOUT, preexec_fn=self._chroot)
output, err = yum.communicate()
print output
@@ -1170,7 +1257,8 @@
self._cleanup_editing()
return False
if "localinstall" in yum_cmd:
- os.system("umount %s/tmp/yumrepo/%s" % (self._instroot, os.path.basename(pkgs)))
+ os.system("umount %s/tmp/yumrepo/%s" % (self._instroot,
+ os.path.basename(pkgs)))
os.system("rm -rf %s/tmp/yumrepo" % self._instroot)
return True
@@ -1233,21 +1321,26 @@
dracut_conf.write('add_dracutmodules+="dmsquash-live"')
dracut_conf.close()
cmd = "rpm -q kernel"
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
kver = output.strip().replace("kernel-", "")
- cmd = "new-kernel-pkg --package kernel --mkinitrd --dracut --depmod --update %s" % kver
- f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT, preexec_fn=self._chroot)
+ cmd = "new-kernel-pkg --package kernel --mkinitrd --dracut " + \
+ "--depmod --update %s" % kver
+ f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT,
+ preexec_fn=self._chroot)
output, err = f.communicate()
if f.returncode > 0:
print output
print "Failed to generate new initramfs"
return False
else:
- initramfs_file = glob.glob("%s/boot/initramfs*" % self._instroot)[0]
+ initramfs_file = glob.glob("%s/boot/initramfs*"
+ % self._instroot)[0]
f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
output, err = f.communicate()
- cmd = "mv %s %s/isolinux/initrd0.img" % (initramfs_file, self._LiveImageCreatorBase__isodir)
+ cmd = "mv %s %s/isolinux/initrd0.img" % \
+ (initramfs_file, self._LiveImageCreatorBase__isodir)
f = subprocess.Popen(cmd, shell=True, stdout=PIPE, stderr=STDOUT)
output, err = f.communicate()
if f.returncode > 0:
@@ -1284,7 +1377,8 @@
"fsimage")
parser.add_option("-w", "--passwd", action="extend", dest="password",
- help="comma delimited list of user and encrypted password")
+ help="comma delimited list of user and "
+ "encrypted password")
parser.add_option("-l", "--sshkey", action="extend", dest="ssh_keys",
help="comma delimited list of ssh public key files")
@@ -1299,7 +1393,8 @@
dest="tmpdir", default="/var/tmp",
help="Temporary directory to use (default: /var/tmp)")
- parser.add_option("-r", "--releasefile", type="string", dest="releasefile",
+ parser.add_option("-r", "--releasefile", type="string",
+ dest="releasefile",
help="Specify release file/s for branding.")
parser.add_option("-b", "--builder", type="string",
@@ -1313,28 +1408,47 @@
dest="install", help="Specify packages to install")
parser.add_option("--install-kmod", type="string",
- dest="install_dup", help="Specify driver update packages to install")
+ dest="install_dup",
+ help="Specify driver update packages to install")
parser.add_option("--repo", type="string",
- dest="repo", help="Specify yum repo file or yum repository on the filesystem")
+ dest="repo",
+ help="Specify yum repo file or yum repository on the"
+ " filesystem")
parser.add_option("--nogpgcheck", action="store_false", default=True,
- dest="gpgcheck", help="Allow unsigned packages to be installed")
+ dest="gpgcheck",
+ help="Allow unsigned packages to be installed")
m_grp = optparse.OptionGroup(parser, ("Manifest Options"))
+
m_grp.add_option("", "--list-plugins", action="store_true", default=False,
dest="listplugins", help="List Installed Plugins")
- m_grp.add_option("", "--print-version", action="store_true", default=False,
- dest="printversion", help="Print Current Version of ISO")
- m_grp.add_option("", "--print-manifests", action="store_true", default=False,
- dest="printmanifests", help="Print a list of manifests files within the iso")
+
+ m_grp.add_option("", "--print-version", action="store_true",
+ default=False, dest="printversion",
+ help="Print Current Version of ISO")
+
+ m_grp.add_option("", "--print-manifests", action="store_true",
+ default=False, dest="printmanifests",
+ help="Print a list of manifests files within the iso")
+
m_grp.add_option("", "--print-manifest", type="string", default="",
- dest="printmanifest", help="Print manifest file to stdout")
- m_grp.add_option("", "--get-manifests", action="store_true", default=False,
- dest="getmanifests", help="Creates a tar file of manifests files within the iso")
- m_grp.add_option("", "--print-file-manifest", action="store_true", default=False,
- dest="filemanifest", help="Prints contents of rootfs on iso to stdout")
- m_grp.add_option("", "--print-rpm-manifest", action="store_true", default=False,
- dest="rpmmanifest", help="Prints installed rpms within rootfs on iso to stdout")
+ dest="printmanifest",
+ help="Print manifest file to stdout")
+
+ m_grp.add_option("", "--get-manifests", action="store_true",
+ default=False, dest="getmanifests",
+ help="Creates a tar file of manifests files"
+ " within the iso")
+
+ m_grp.add_option("", "--print-file-manifest", action="store_true",
+ default=False, dest="filemanifest",
+ help="Prints contents of rootfs on iso to stdout")
+
+ m_grp.add_option("", "--print-rpm-manifest", action="store_true",
+ default=False, dest="rpmmanifest",
+ help="Prints installed rpms within rootfs on iso"
+ "to stdout")
parser.add_option_group(m_grp)
@@ -1355,10 +1469,10 @@
args = ['/sbin/blkid', '-s', tag, '-o', 'value', filesystem]
try:
fs_type = subprocess.Popen(args,
- stdout=subprocess.PIPE,
- stderr=dev_null).communicate()[0]
+ stdout=subprocess.PIPE,
+ stderr=dev_null).communicate()[0]
except IOError, e:
- raise CreatorError("Failed to determine fs %s: %s" % value, e )
+ raise CreatorError("Failed to determine fs %s: %s" % value, e)
finally:
os.close(dev_null)
@@ -1384,7 +1498,7 @@
def main():
# LiveOS set to <LIVEIMG.src>
(LiveOS, options) = parse_options(sys.argv[1:])
- if os.geteuid () != 0:
+ if os.geteuid() != 0:
print >> sys.stderr, "You must run edit-node as root"
return 1
if options.name:
@@ -1418,7 +1532,8 @@
if options.kscfg:
editor.ks = read_kickstart(options.kscfg)
# part / --size <new rootfs size to be resized to>
- editor._LoopImageCreator__image_size = kickstart.get_image_size(editor.ks)
+ editor._LoopImageCreator__image_size = \
+ kickstart.get_image_size(editor.ks)
if options.ssh_keys:
for key in options.ssh_keys:
if "," in key:
@@ -1440,7 +1555,8 @@
elif options.repo is None and len(p) < 0:
print "An Editing Option Must Be Specified"
return False
- # only mount rootfs as required since it's not necesary for all operations
+ # only mount rootfs as required since it's not
+ # necesary for all operations
elif mount:
editor.mount(LiveOS, cachedir=None)
if options.printversion:
@@ -1474,26 +1590,28 @@
print "Installing Packages"
if not editor._install_pkgs(options):
logging.error("Error Installing Requested Package",
- ": %s" % options.install)
+ ": %s" % options.install)
failed = True
elif options.plugin:
print "Installing Plugins"
if not editor._install_plugins(options):
- logging.error("Error Installing Plugin(s) : %s" % options.plugin)
+ logging.error("Error Installing Plugin(s) : %s"
+ % options.plugin)
failed = True
elif options.install_dup:
print "Installing DUP"
if not editor._install_dup(options):
editor.unmount()
- logging.error("Error Installing Drive Update Package : %s" % options.install_dup)
+ logging.error("Error Installing Drive Update " +
+ "Package : %s" % options.install_dup)
failed = True
#raise RuntimeError("Unable to Install Package")
except RuntimeError as e:
raise RuntimeError(e)
finally:
if selinux_enforcing:
- print "Returning SELinux To Enforcing"
- selinux.security_setenforce(1)
+ print "Returning SELinux To Enforcing"
+ selinux.security_setenforce(1)
if failed:
sys.exit(1)
if not options.password is None:
@@ -1510,7 +1628,8 @@
editor._minimize()
editor._create_manifests(options)
print "Editing Complete"
- editor._configure_bootloader(editor._LiveImageCreatorBase__isodir)
+ editor._configure_bootloader(
+ editor._LiveImageCreatorBase__isodir)
rebuild_iso_symlinks(editor._LiveImageCreatorBase__isodir)
editor._rebuild_initramfs()
editor.unmount()
@@ -1528,16 +1647,16 @@
if n:
finished_iso = build_isoname_for_plugins(edited_iso, [n])
else:
- finished_iso= edited_iso
+ finished_iso = edited_iso
print "Moving '%s' to '%s'" % (edited_iso, finished_iso)
shutil.move(edited_iso, finished_iso)
- logging.info("%s.iso saved to %s" % (finished_iso, output))
+ logging.info("%s.iso saved to %s" % (finished_iso, output))
else:
# in manifest mode print do necessary items
editor.unmount()
- logging.info("%s.iso saved to %s" % (editor.name, output))
+ logging.info("%s.iso saved to %s" % (editor.name, output))
except CreatorError, e:
logging.error(u"Error editing LiveOS : %s" % e)
return 1
--
To view, visit http://gerrit.ovirt.org/14755
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iabe6dad850e2dacdcd9e957176c96a93ea691295
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>
More information about the node-patches
mailing list