def is_bond(self, ifname): """Determins if ifname is a bond device """ return File(self.bond_slaves_path % ifname).exists()
def kernel_cmdline_arguments(cmdline=None): """Return the arguments of the currently booted kernel """ cmdline = cmdline or File("/proc/cmdline").read() return _parse_cmdline_args(cmdline)
def cpe(self): """Return the CPE URI """ return File(self.CPE_FILE).read().strip()
def update_args(self, arg, remove=False): self.__mount.remount(rw=True) grub_cfg = self._parse_config(self.__get_lines(), arg, remove) File(self.__handle.filename).write(grub_cfg, "w") self.__mount.remount(rw=False)
#!/usr/bin/python # -*- coding: utf-8 -*- # # Copyright (C) 2016 Red Hat, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from ovirt.node.utils.fs import File f = File("/etc/ovirt-hosted-engine-ha/agent.conf") f.sed("s/.*base-score.*/base-score=3400/")
def kernel_cmdline_arguments(): """Return the arguments of the currently booted kernel """ return _parse_cmdline_args(File("/proc/cmdline").read())
def __get_domain(self): nfs_config = File(self.configfilename) matches = nfs_config.findall("^Domain = (.*)") return matches[0] if matches else None
def commit(self): cfg = HostedEngine().retrieve() def magic_type(mtype="gzip"): magic_headers = {"gzip": "\x1f\x8b\x08"} magic = None if not imagepath == "%s/" % config.HOSTED_ENGINE_SETUP_DIR: with open(imagepath) as f: magic = f.read(len(magic_headers[mtype])) return True if magic == magic_headers[mtype] else False def write(line): f.write("{line}\n".format(line=line), "a") f = File(temp_cfg_file) self.logger.info("Saving Hosted Engine Config") ova_path = None boot = None write("[environment:default]") if cfg["pxe"]: boot = "pxe" if cfg["imagepath"]: if "file://" in cfg["imagepath"]: imagepath = cfg["imagepath"][7:] else: imagepath = os.path.join( config.HOSTED_ENGINE_SETUP_DIR, os.path.basename(cfg["imagepath"]).lstrip("/")) if imagepath.endswith(".iso"): boot = "cdrom" write("OVEHOSTED_VM/vmCDRom=str:{imagepath}".format( imagepath=imagepath)) else: imagetype = "gzip" if magic_type() else "Unknown" if imagetype == "gzip": boot = "disk" ova_path = imagepath else: os.unlink(temp_cfg_file) raise RuntimeError("Downloaded image is neither an" " OVA nor an ISO, can't use it") bootstr = "str:{boot}".format( boot=boot) if boot else "none:None" write("OVEHOSTED_VM/vmBoot={bootstr}".format(bootstr=bootstr)) ovastr = "str:{ova_path}".format(ova_path=ova_path) if \ ova_path else "none:None" write("OVEHOSTED_VM/ovfArchive={ovastr}".format(ovastr=ovastr)) write("OVEHOSTED_CORE/tempDir=str:{tmpdirHE}".format( tmpdirHE=config.HOSTED_ENGINE_TEMPDIR)) self.logger.info("Wrote hosted engine install configuration to" " {cfg}".format(cfg=temp_cfg_file)) self.logger.debug("Wrote config as:") for line in f: self.logger.debug("{line}".format(line=line.strip()))