def umount(target, fstab=True): logger.debug("umount: target=%s, fstab=%s", target, fstab) (retcode, mount_info) = oscommon.run("mount") if retcode != 0: raise Exception("can't run 'mount' command") if target in mount_info: oscommon.runex("umount %s" % target) else: logger.debug("target %s is not mounted", target) if fstab: txt = TextEditor("/etc/fstab") txt.delete(target) txt.save()
def umount(target, fstab=True): logger.debug("umount: target=%s, fstab=%s", target, fstab) (retcode, mount_info) = oscommon.run("mount") if retcode != 0: raise Exception("can't run 'mount' command") if target in mount_info: oscommon.runex("umount %s" % target) else: logger.debug("target %s is not mounted", target) if fstab: txt = Text.TextEditor("/etc/fstab") txt.delete(target) txt.save()
def mount(source, target, fstype, fstab=False): logger.debug("mount: source=%s, target=%s, fstype=%s, fstab=%s", source, target, fstype, fstab) (retcode, mount_info) = oscommon.run("mount") if retcode != 0: raise Exception("can't run 'mount' command") if source in mount_info: logger.debug("%s is already mounted" % source) else: oscommon.runex("mount -t %s %s %s" % (fstype, source, target)) if fstab: txt = Text.TextEditor("/etc/fstab") txt.delete(target) txt.insert( "%s %s %s defaults 0 0" % (source, target, fstype) ) txt.save()
def mount(source, target, fstype, fstab=False): logger.debug("mount: source=%s, target=%s, fstype=%s, fstab=%s", source, target, fstype, fstab) (retcode, mount_info) = oscommon.run("mount") if retcode != 0: raise Exception("can't run 'mount' command") if source in mount_info: logger.debug("%s is already mounted" % source) else: oscommon.runex("mount -t %s %s %s" % (fstype, source, target)) if fstab: txt = TextEditor("/etc/fstab") txt.delete(target) txt.insert("%s %s %s defaults 0 0" % (source, target, fstype)) txt.save()
def install(self, dirpath, nodeps=False, retry=3): cmd = "rpm -ivh" if nodeps: cmd += " --nodeps" cmd += " %s*" % self.name while True: retcode = oscommon.run(cmd, dirpath)[0] if retcode == 0: break else: if retry > 0: logger.info("rpm package [%s] installed failed. uninstall it and retry.", self.name) self.uninstall() retry = retry - 1 continue else: raise Exception("failed to install: %s" % self.name) logger.info("rpm package [%s] installed successfully.", self.name)
def install(self, dirpath, nodeps=False, attempt=3): cmd = "rpm -ivh" if nodeps: cmd += " --nodeps" cmd += " %s*" % self.name while True: retcode = oscommon.run(cmd, dirpath)[0] if retcode == 0: break else: if attempt > 0: logger.info("rpm package [%s] installed failed. uninstall it and retry.", self.name) self.uninstall() attempt -= 1 continue else: raise Exception("failed to install: %s" % self.name) logger.info("rpm package [%s] installed successfully.", self.name)
def disable_selinux(): txt = Text.TextEditor("/etc/sysconfig/selinux") txt.set_param("SELINUX", "disabled") txt.save() oscommon.run("setenforce 0")
def uninstall(self): retcode = oscommon.run("rpm -q %s" % self.pkg)[0] if retcode == 0: oscommon.runex("rpm -q %s | xargs rpm -e --allmatches --noscripts --nodeps" % self.pkg) else: logger.info("don't find rpm [%s] installed", self.name)
def disable_selinux(): txt = TextEditor("/etc/sysconfig/selinux") txt.set_param("SELINUX", "disabled") txt.save() oscommon.run("setenforce 0")