Exemplo n.º 1
0
 def _query_lvm(self, option, pv=None):
     if pv:
         return [x.strip() for x in process.check_output(["lvm", "vgs",
                 "--noheadings", "-o", option, pv]).split("\n")]
     else:
         return [x.strip() for x in process.check_output(["lvm", "vgs",
                 "--noheadings", "-o", option]).split("\n")]
Exemplo n.º 2
0
    def commit(self):
        try:
            process.check_output([
                'vdsm-tool', 'register', '--engine-fqdn', self.engine,
                '--node-name',
                socket.gethostname(), '--engine-https-port', self.port,
                '--ssh-user', 'root', '--check-fqdn', 'False'
            ])
        except process.CalledProcessError as e:
            msg_users = ""
            if "No route to host" in e.output:
                msg_users = "No route to host {0}".format(self.engine)

            elif "Connection refused" in e.output:
                msg_users = "Connection refused to {0}".format(self.engine)

            elif "http response was non OK, code 400" in e.output:
                msg_users = "http response was non OK, code 400.\n" \
                            "Have you tried to add into the datacenter an " \
                            "existing hypervisor?"
            else:
                msg_users = e.output

            msg = "{err} {engineaddr}!\n{output_cmd}\n{full_log}".format(
                err='Cannot register the node into',
                engineaddr=self.engine,
                output_cmd=msg_users,
                full_log="Full log: /var/log/vdsm/register.log")
            raise Exception(msg)

        # Registration triggered with success, set OVIRT_NODE_REGISTER
        RegistrationTriggered().update(True)
Exemplo n.º 3
0
    def get_plugins_list(self):
        plugin_dict = {}
        plugin_dir = "/etc/ovirt-plugins.d/"
        if os.path.exists(plugin_dir):
            for f in os.listdir(plugin_dir):
                if not f.endswith(".minimize"):
                    with open(plugin_dir + f) as p:
                        if re.compile(r'Name:.*?\nVer.*:.*?\nInstall Date:.*',
                                      re.M | re.S).match(open(plugin_dir + f
                                                              ).read()):
                            #Hopefully a plugin metadata file
                            lines = p.readlines()
                            name = lines[0].strip().split(":")[1]
                            ver = lines[1].strip().split(":")[1]
                            install_date = lines[2].strip().replace(
                                "Install Date:", "")
                        else:
                            try:
                                cmd = '/bin/rpm -qf %s/%s --qf %%{name}' % \
                                    (plugin_dir, f)
                                package = process.check_output(cmd.split(' ')
                                                               ).strip()
                                cmd = "rpm -q %s --qf 'NAME: %s DATE: \
                                       %%{version}-%%{release}.%%{arch} INST: \
                                       %%{INSTALLTIME:date}\\n'" %\
                                    (package, package)
                                name, ver, install_date = re.match(
                                    r'NAME: (.*?) DATE: (.*?) INST: (.*)',
                                    process.check_output(cmd, shell=True
                                                         ).strip()).groups()
                            except CalledProcessError:
                                continue

                    plugin_dict[name] = (ver, install_date)
        return plugin_dict
Exemplo n.º 4
0
    def commit(self):
        try:
            process.check_output(['vdsm-tool', 'register',
                                  '--engine-fqdn', self.engine,
                                  '--node-name', socket.gethostname(),
                                  '--engine-https-port', self.port,
                                  '--ssh-user', 'root',
                                  '--check-fqdn', 'False'])
        except process.CalledProcessError as e:
            msg_users = ""
            if "No route to host" in e.output:
                msg_users = "No route to host {0}".format(self.engine)

            elif "Connection refused" in e.output:
                msg_users = "Connection refused to {0}".format(self.engine)

            elif "http response was non OK, code 400" in e.output:
                msg_users = "http response was non OK, code 400.\n" \
                            "Have you tried to add into the datacenter an " \
                            "existing hypervisor?"
            else:
                msg_users = e.output

            msg = "{err} {engineaddr}!\n{output_cmd}\n{full_log}".format(
                err='Cannot register the node into',
                engineaddr=self.engine,
                output_cmd=msg_users,
                full_log="Full log: /var/log/vdsm/register.log"
            )
            raise Exception(msg)

        # Registration triggered with success, set OVIRT_NODE_REGISTER
        RegistrationTriggered().update(True)
Exemplo n.º 5
0
 def check_status(self):
     try:
         process.check_output(["ipmitool", "-I", "open",
                               "chassis", "status"])
         return True
     except CalledProcessError as e:
         self.logger.warning("IPMI status call failed with: %s" % e.output)
         return False
 def check_status(self):
     try:
         process.check_output(
             ["ipmitool", "-I", "open", "chassis", "status"])
         return True
     except CalledProcessError as e:
         self.logger.warning("IPMI status call failed with: %s" % e.output)
         return False
Exemplo n.º 7
0
 def _query_lvm(self, option, pv=None):
     if pv:
         return [
             x.strip() for x in process.check_output([
                 "lvm", "vgs", "--noheadings", "-o", option, pv
             ]).split("\n")
         ]
     else:
         return [
             x.strip() for x in process.check_output(
                 ["lvm", "vgs", "--noheadings", "-o", option]).split("\n")
         ]
Exemplo n.º 8
0
    def __run(hooks_directory):
        for hook in os.listdir(hooks_directory):
            script = os.path.join(hooks_directory, hook)

            if script.endswith(".py") or script.endswith(".pyo"):
                continue

            LOGGER.debug("Running hook %s" % script)
            if script.endswith(".pyc"):
                output = process.check_output(["python", script])
            else:
                output = process.check_output("%s &> /dev/null" % script,
                                              shell=True)

            [LOGGER.debug("%s: %s" % (script, line)) for line in output]
Exemplo n.º 9
0
    def __run(hooks_directory):
        for hook in os.listdir(hooks_directory):
            script = os.path.join(hooks_directory, hook)

            if script.endswith(".pyc") or script.endswith(".pyo"):
                continue

            LOGGER.debug("Running hook %s" % script)
            if script.endswith(".py"):
                output = process.check_output(["python", script])
            else:
                output = process.check_output("%s &> /dev/null" % script,
                                              shell=True)

            [LOGGER.debug("%s: %s" % (script, line)) for line in output]
Exemplo n.º 10
0
    def sed(self, expr, inplace=True):
        """Run a sed expression on the file

        >>> f = File("/tmp/afile")
        >>> f.write("Woot")

        Replacement without inplace modifcation:

        >>> f.sed("s/oo/ha/", False)
        u'What'

        Replacement with inplace modifications:

        >>> f.sed("s/oo/alle/")
        >>> f.read()
        'Wallet'

        Chaining of expressions also works:

        >>> f.sed("s/alle/oo/ ; s/oo/ha/", False)
        u'What'

        >>> f.delete()
        """
        cmd = ["sed"]
        if inplace:
            cmd.append("-ci")
        cmd += ["-e", expr, self.filename]
        stdout = process.check_output(cmd)
        return None if inplace else stdout
Exemplo n.º 11
0
 def __get_default_sizes(self):
     if self.application.args.dry:
         if os.geteuid() == 0:
             cmd = "blockdev --getsize64 /dev/[sv]da"
             stdout = process.check_output(cmd, shell=True)
             self._drive_size = int(stdout) / 1024 / 1024
         else:
             # If we're not root and can't query the drive,
             # pretend it's 15G
             self._drive_size = 15*1024**2
         return {"storage.efi_size": "%s" % presets.BOOT_SIZE_MB,
                 "storage.root_size": "%s" % presets.ROOT_SIZE_MB,
                 "storage.swap_size": "0",
                 "storage.config_size": "5",
                 "storage.logging_size": "2048",
                 "storage.data_size": "0",
                 "storage.install_drive": self.__get_install_drive(),
                 "storage.fill_data": True
                 }
     from ovirtnode.storage import Storage
     stor = Storage()
     self._drive_size = self.__get_drives_size(self.__get_install_drive())
     sizes = {"storage.efi_size": "%s" % stor.EFI_SIZE,
              "storage.root_size": "%s" % stor.ROOT_SIZE,
              "storage.swap_size": "%s" % stor.SWAP_SIZE,
              "storage.config_size": "%s" % stor.CONFIG_SIZE,
              "storage.logging_size": "%s" % stor.LOGGING_SIZE,
              "storage.data_size": "%s" % "0",
              "storage.free_space": "0 MB",
              "storage.drive_size": "%s MB" % self._drive_size,
              "storage.install_drive": self.__get_install_drive(),
              "storage.fill_data": True
              }
     return sizes
Exemplo n.º 12
0
    def _get_status(self, cfg):
        rhn_msg = None
        if "satellite" in cfg["rhntype"]:
            rhntype = cfg["rhntype"].title()
        elif "rhn" in cfg["rhntype"]:
            rhntype = "RHSM"
        else:
            rhntype = cfg["rhntype"].upper()

        try:
            cmd = ["subscription-manager", "status"]
            output = process.check_output(cmd)
            if "Status: Unknown" not in output:
                rhn_msg = "RHSM Registration\n\nRegistration Status: %s" \
                          % rhntype

        except process.CalledProcessError as e:
            if "Status: Unknown" in e.output:
                # Not registered or registration failed
                pass
            else:
                rhn_msg = ("Registered to %s, but there are no "
                           "subscriptions attached or it is otherwise"
                           " invalid" % rhntype)

        return rhn_msg
Exemplo n.º 13
0
 def __get_default_sizes(self):
     if self.application.args.dry:
         udiskscmd = "udisksctl info -b /dev/[sv]da* | grep Size"
         stdout = process.check_output(udiskscmd,
                                       shell=True)
         self._drive_size = (int(stdout.strip().split(":")[1].strip())
                             / 1024 / 1024)
         return {"storage.efi_size": "256",
                 "storage.root_size": "50",
                 "storage.swap_size": "0",
                 "storage.config_size": "5",
                 "storage.logging_size": "2048",
                 "storage.data_size": "0",
                 }
     from ovirtnode.storage import Storage
     stor = Storage()
     self._drive_size = self.__get_drives_size(self.__get_install_drive())
     sizes = {"storage.efi_size": "%s" % stor.EFI_SIZE,
              "storage.root_size": "%s" % stor.ROOT_SIZE,
              "storage.swap_size": "%s" % stor.SWAP_SIZE,
              "storage.config_size": "%s" % stor.CONFIG_SIZE,
              "storage.logging_size": "%s" % stor.LOGGING_SIZE,
              "storage.data_size": "%s" % "0",
              "storage.free_space": "0 MB",
              "storage.drive_size": "%s MB" % self._drive_size
              }
     return sizes
 def __get_default_sizes(self):
     if self.application.args.dry:
         udiskscmd = "udisksctl info -b /dev/[sv]da* | grep Size"
         stdout = process.check_output(udiskscmd, shell=True)
         self._drive_size = (int(stdout.strip().split(":")[1].strip()) /
                             1024 / 1024)
         return {
             "storage.efi_size": "256",
             "storage.root_size": "50",
             "storage.swap_size": "0",
             "storage.config_size": "5",
             "storage.logging_size": "2048",
             "storage.data_size": "0",
         }
     from ovirtnode.storage import Storage
     stor = Storage()
     self._drive_size = self.__get_drives_size(self.__get_install_drive())
     sizes = {
         "storage.efi_size": "%s" % stor.EFI_SIZE,
         "storage.root_size": "%s" % stor.ROOT_SIZE,
         "storage.swap_size": "%s" % stor.SWAP_SIZE,
         "storage.config_size": "%s" % stor.CONFIG_SIZE,
         "storage.logging_size": "%s" % stor.LOGGING_SIZE,
         "storage.data_size": "%s" % "0",
         "storage.free_space": "0 MB",
         "storage.drive_size": "%s MB" % self._drive_size
     }
     return sizes
Exemplo n.º 15
0
 def __get_default_sizes(self):
     if self.application.args.dry:
         if os.geteuid() == 0:
             cmd = "blockdev --getsize64 /dev/[sv]da"
             stdout = process.check_output(cmd, shell=True)
             self._drive_size = int(stdout) / 1024 / 1024
         else:
             # If we're not root and can't query the drive,
             # pretend it's 15G
             self._drive_size = 15*1024**2
         return {"storage.efi_size": "%s" % presets.BOOT_SIZE_MB,
                 "storage.root_size": "%s" % presets.ROOT_SIZE_MB,
                 "storage.swap_size": "0",
                 "storage.config_size": "5",
                 "storage.logging_size": "2048",
                 "storage.data_size": "0",
                 "storage.install_drive": self.__get_install_drive()
                 }
     from ovirtnode.storage import Storage
     stor = Storage()
     self._drive_size = self.__get_drives_size(self.__get_install_drive())
     sizes = {"storage.efi_size": "%s" % stor.EFI_SIZE,
              "storage.root_size": "%s" % stor.ROOT_SIZE,
              "storage.swap_size": "%s" % stor.SWAP_SIZE,
              "storage.config_size": "%s" % stor.CONFIG_SIZE,
              "storage.logging_size": "%s" % stor.LOGGING_SIZE,
              "storage.data_size": "%s" % "0",
              "storage.free_space": "0 MB",
              "storage.drive_size": "%s MB" % self._drive_size,
              "storage.install_drive": self.__get_install_drive()
              }
     return sizes
Exemplo n.º 16
0
    def sed(self, expr, inplace=True):
        """Run a sed expression on the file

        >>> f = File("/tmp/afile")
        >>> f.write("Woot")

        Replacement without inplace modifcation:

        >>> f.sed("s/oo/ha/", False)
        u'What'

        Replacement with inplace modifications:

        >>> f.sed("s/oo/alle/")
        >>> f.read()
        'Wallet'

        Chaining of expressions also works:

        >>> f.sed("s/alle/oo/ ; s/oo/ha/", False)
        u'What'

        >>> f.delete()
        """
        cmd = ["sed"]
        if inplace:
            cmd.append("-ci")
        cmd += ["-e", expr, self.filename]
        stdout = process.check_output(cmd)
        return None if inplace else stdout
Exemplo n.º 17
0
    def _get_status(self, cfg):
        rhn_msg = None
        if "satellite" in cfg["rhntype"]:
            rhntype = cfg["rhntype"].title()
        elif "rhn" in cfg["rhntype"]:
            rhntype = "RHSM"
        else:
            rhntype = cfg["rhntype"].upper()

        try:
            cmd = ["subscription-manager", "status"]
            output = process.check_output(cmd)
            if "Status: Unknown" not in output:
                rhn_msg = "RHSM Registration\n\nRegistration Status: %s" \
                          % rhntype

        except process.CalledProcessError as e:
            if "Status: Unknown" in e.output:
                # Not registered or registration failed
                pass
            else:
                rhn_msg = ("Registered to %s, but there are no "
                           "subscriptions attached or it is otherwise"
                           " invalid" % rhntype)

        return rhn_msg
Exemplo n.º 18
0
 def mountpoints(self):
     try:
         targets = process.check_output(["findmnt", "-o", "target", "-n",
                                         self.device]).strip().split("\n")
         return [Mount(t.strip()) for t in targets]
     except process.CalledProcessError:
         return []
Exemplo n.º 19
0
 def mountpoints(self):
     try:
         targets = process.check_output(
             ["findmnt", "-o", "target", "-n",
              self.device]).strip().split("\n")
         return [Mount(t.strip()) for t in targets]
     except process.CalledProcessError:
         return []
Exemplo n.º 20
0
def set_active_profile(profile):
    """Sets the active tuned profile on the system.

    Returns:
        A boolean based on the return of tuned-adm
    """
    try:
        if (profile == "None" or profile == "off"):
            process.check_output(["/usr/sbin/tuned-adm", "off"])
        elif profile not in get_available_profiles():
            raise RuntimeError("%s is not a known profile" % profile)
        else:
            process.check_output(["/usr/sbin/tuned-adm", "profile", profile])
    except process.CalledProcessError:
        raise RuntimeError("Failed to set profile to %s" % profile)

    return True
Exemplo n.º 21
0
def set_active_profile(profile):
    """Sets the active tuned profile on the system.

    Returns:
        A boolean based on the return of tuned-adm
    """
    try:
        if (profile == "None" or profile == "off"):
            process.check_output(["/usr/sbin/tuned-adm", "off"])
        elif not any(profile in s for s in get_available_profiles()):
            raise RuntimeError("%s is not a known profile" % profile)
        else:
            process.check_output(["/usr/sbin/tuned-adm", "profile",
                                  profile])
    except process.CalledProcessError:
        raise RuntimeError("Failed to set profile to %s" % profile)

    return True
Exemplo n.º 22
0
    def __parse_rpmlist(self, plugin_dir, f, plugin_dict):
        try:
            cmd = 'rpm -q --qf %%{name} %s' % f
            package = process.check_output(cmd.split(' ')
                                           ).strip()
            cmd = "rpm -q %s --qf 'NAME: %s DATE: " \
                  "%%{version}-%%{release}.%%{arch} INST: " \
                  "%%{INSTALLTIME:date}\\n'" %\
                (package, package)
            name, ver, install_date = re.match(
                r'NAME: (.*?) DATE: (.*?) INST: (.*)',
                process.check_output(cmd, shell=True
                                     ).strip()).groups()
            plugin_dict[name] = (ver.strip(), install_date)
            return True

        except CalledProcessError:
            self.logger.debug("SET NO")
            return False
Exemplo n.º 23
0
def size():
    """Returns the size of the console as a tuple
    """

    size = namedtuple("consolesize", ["rows", "columns"])

    rows, cols = ([int(x) for x in process.check_output(['stty',
                                                         'size']).split()])

    return size(rows, cols)
Exemplo n.º 24
0
def get_available_profiles():
    """Gets a list of tuned profiles available on the system.

    Returns:
        A list of profiles
    """
    prof_list = [u'None']
    for i in process.check_output("/usr/sbin/tuned-adm list").split("\n"):
        if "- " in i:
            prof_list.append(i.replace("- ", ""))
    return prof_list
Exemplo n.º 25
0
def get_available_profiles():
    """Gets a list of tuned profiles available on the system.

    Returns:
        A list of profiles
    """
    prof_list = [u'None']
    for i in process.check_output("/usr/sbin/tuned-adm list").split("\n"):
        if "- " in i:
            prof_list.append(i.replace("- ", ""))
    return prof_list
Exemplo n.º 26
0
def size():
    """Returns the size of the console as a tuple
    """

    size = namedtuple("consolesize", ["rows", "columns"])

    rows, cols = ([
        int(x) for x in process.check_output(['stty', 'size']).split()
    ])

    return size(rows, cols)
Exemplo n.º 27
0
def get_active_profile():
    """Gets the active tuned profile on the system.

    Returns:
        A string with the active tuned profile
    """
    try:
        profile = process.check_output(["/usr/sbin/tuned-adm", "active"])
        return re.match(r'.*?: (.*)', profile).group(1)
    except:
        return "None"
Exemplo n.º 28
0
def service(name, cmd, do_raise=True):
    """Convenience wrapper to handle service interactions
    """
    try:
        kwargs = {"shell": False, "stderr": process.PIPE}
        r = process.check_output(["service", name, cmd], **kwargs)
    except process.CalledProcessError as e:
        r = e.returncode
        LOGGER.exception("Service: %s" % e.output)
        if do_raise:
            raise
    return r
Exemplo n.º 29
0
 def on_merge(self, changes):
     if changes.contains_any(["diagnostic.logfiles", "diagnostic.tools"]):
         cmds = {}
         changed_field = changes.keys()[0]
         if "diagnostic.tools" in changed_field:
             cmds = dict((name, cmd) for (name, cmd)
                         in self.__diagnostics())
         cmd = cmds.get(changes[changed_field], None)
         if cmd:
             contents = process.check_output(cmd, stderr=process.STDOUT)
             return ui.TextViewDialog("output.dialog", "Command Output",
                                      contents)
Exemplo n.º 30
0
 def on_merge(self, changes):
     if changes.contains_any(["diagnostic.logfiles", "diagnostic.tools"]):
         cmds = {}
         changed_field = changes.keys()[0]
         if "diagnostic.tools" in changed_field:
             cmds = dict((name, cmd) for (name, cmd)
                         in self.__diagnostics())
         cmd = cmds.get(changes[changed_field], None)
         if cmd:
             contents = process.check_output(cmd, stderr=process.STDOUT)
             return ui.TextViewDialog("output.dialog", "Command Output",
                                      contents)
Exemplo n.º 31
0
def service(name, cmd, do_raise=True):
    """Convenience wrapper to handle service interactions
    """
    try:
        kwargs = {"shell": False,
                  "stderr": process.PIPE}
        r = process.check_output(["service", name, cmd], **kwargs)
    except process.CalledProcessError as e:
        r = e.returncode
        LOGGER.exception("Service: %s" % e.output)
        if do_raise:
            raise
    return r
Exemplo n.º 32
0
    def _generate_new_initramfs(self, new_initrd):
        LOGGER.info("Generating new initramfs "
                    "%r (this can take a while)" % new_initrd)

        rd_stdout = ""
        try:
            rd_stdout = check_output(["dracut", new_initrd],
                                     stderr=process.STDOUT)
        except:
            LOGGER.warn("dracut failed to generate the initramfs")
            LOGGER.warn("dracut output: %s" % rd_stdout)
            self.try_unlink(new_initrd)
            raise
Exemplo n.º 33
0
    def run(self, *args, **kwargs):
        """ Executes a commmand
            required parameter: cmd
        """

        if "cmd" not in kwargs:
            raise RuntimeError("A command is required for exec()!")

        cmd = kwargs["cmd"].format(**kwargs)

        self.logger.debug("Running %s" % cmd)
        output = process.check_output(cmd, shell=True)
        self.logger.debug("Output of %s was: %s" % cmd, output)
Exemplo n.º 34
0
    def _generate_new_initramfs(self, new_initrd, kver):
        LOGGER.info("Generating new initramfs " "%r for kver %s (this can take a while)" % (new_initrd, kver))
        rd_stdout = ""
        try:
            argv = ["chroot", self.dracut_chroot, "dracut", "--kver", kver, new_initrd]
            LOGGER.debug("Calling: %s" % argv)

            rd_stdout = process.check_output(argv, stderr=process.STDOUT)
        except:
            LOGGER.warn("dracut failed to generate the initramfs")
            LOGGER.warn("dracut output: %s" % rd_stdout)
            self.try_unlink(new_initrd)
            raise
Exemplo n.º 35
0
    def by_label(label):
        """Determines whether a filesystem with a given label is present on
        this system
        """
        fs = None
        try:
            Filesystem._flush()
            with open(os.devnull, "wb") as DEVNULL:
                device = process.check_output(["blkid", "-c", "/dev/null", "-L", label], stderr=DEVNULL).strip()

            fs = Filesystem(device)

        except process.CalledProcessError as e:
            LOGGER.debug("Failed to resolve disks: %s" % e.cmd, exc_info=True)
        return fs
Exemplo n.º 36
0
    def _query_vgs(self, option, pv=None):
        cmd = ["lvm", "vgs", "--noheadings", "-o", option]

        if pv:
            cmd.append(pv)

        out = process.check_output(cmd).strip()
        vgs = None

        # If not VGs are found, just simulate an empty list of VGs
        if "No volume groups found" in out:
            vgs = []
        else:
            vgs = [x.strip() for x in out.split("\n")]

        return vgs
Exemplo n.º 37
0
    def _query_vgs(self, option, pv=None):
        cmd = ["lvm", "vgs", "--noheadings", "-o", option]

        if pv:
            cmd.append(pv)

        out = process.check_output(cmd).strip()
        vgs = None

        # If not VGs are found, just simulate an empty list of VGs
        if "No volume groups found" in out:
            vgs = []
        else:
            vgs = [x.strip() for x in out.split("\n")]

        return vgs
Exemplo n.º 38
0
    def by_label(label):
        """Determines whether a filesystem with a given label is present on
        this system
        """
        fs = None
        try:
            Filesystem._flush()
            with open(os.devnull, 'wb') as DEVNULL:
                device = process.check_output(
                    ["blkid", "-c", "/dev/null", "-L", label], stderr=DEVNULL)

            fs = Filesystem(device)

        except process.CalledProcessError as e:
            LOGGER.debug("Failed to resolve disks: %s" % e.cmd, exc_info=True)
        return fs
Exemplo n.º 39
0
    def on_merge(self, changes):
        if changes.contains_any(["support.logfile"]):
            logfile = changes["support.logfile"]
            cmds = {"node": "cat /var/log/ovirt.log | less",
                    "ui": "cat /tmp/ovirt.debug.log | less",
                    "messages": "cat /var/log/messages | less",
                    "audit": "cat /var/log/audit/audit.log | less",
                    "dmesg": "dmesg | less",
                    "journal": "journalctl --all --catalog --full"
                    }

            cmd = cmds[logfile] if logfile in cmds else None

            if cmd:
                contents = process.check_output(cmd, stderr=process.STDOUT)
                return ui.TextViewDialog("output.dialog", "Logfile",
                                         contents)
Exemplo n.º 40
0
    def on_merge(self, changes):
        if changes.contains_any(["support.logfile"]):
            logfile = changes["support.logfile"]
            cmds = {
                "node": "cat /var/log/ovirt.log | less",
                "ui": "cat /tmp/ovirt.debug.log | less",
                "messages": "cat /var/log/messages | less",
                "audit": "cat /var/log/audit/audit.log | less",
                "dmesg": "dmesg | less",
                "journal": "journalctl --all --catalog --full"
            }

            cmd = cmds[logfile] if logfile in cmds else None

            if cmd:
                contents = process.check_output(cmd, stderr=process.STDOUT)
                return ui.TextViewDialog("output.dialog", "Logfile", contents)
Exemplo n.º 41
0
    def _generate_new_initramfs(self, new_initrd, kver):
        LOGGER.info("Generating new initramfs "
                    "%r for kver %s (this can take a while)" %
                    (new_initrd, kver))
        rd_stdout = ""
        try:
            argv = [
                "chroot", self.dracut_chroot, "dracut", "--kver", kver,
                new_initrd
            ]
            LOGGER.debug("Calling: %s" % argv)

            rd_stdout = process.check_output(argv, stderr=process.STDOUT)
        except:
            LOGGER.warn("dracut failed to generate the initramfs")
            LOGGER.warn("dracut output: %s" % rd_stdout)
            self.try_unlink(new_initrd)
            raise
Exemplo n.º 42
0
 def _call_ipmi(self, args):
     assert type(args) is list
     return process.check_output(["ipmitool"] + args, stderr=process.PIPE)
Exemplo n.º 43
0
 def _call(self, cmd):
     return process.check_output(cmd)
Exemplo n.º 44
0
 def _tokens(self):
     tokens = process.check_output(["blkid", "-o", "export", self.device])
     return parse_varfile(tokens)
Exemplo n.º 45
0
 def _tokens(self):
     tokens = process.check_output(["blkid", "-o", "export", self.device])
     return parse_varfile(tokens)
Exemplo n.º 46
0
 def _find_device(self):
     try:
         return process.check_output(["findmnt", "-o", "SOURCE", "-n",
                                      self.path]).strip()
     except:
         raise RuntimeError("Couldn't find mount device for %s" % self.path)
Exemplo n.º 47
0
 def _call(self, cmd):
     return process.check_output(cmd)
Exemplo n.º 48
0
 def is_open():
     pat = "%s dpt:%s" % (proto, port)
     for rule in process.check_output(["iptables", "-L", "-n"]).split("\n"):
         if rule.strip().endswith(pat):
             return True
     return False
Exemplo n.º 49
0
 def mountpoints(self):
     targets = process.check_output(
         ["findmnt", "-o", "target", "-n", self.device]).split("\n")
     return [Mount(t.strip()) for t in targets]
Exemplo n.º 50
0
 def is_open():
     pat = "%s dpt:%s" % (proto, port)
     for rule in process.check_output(["iptables", "-L", "-n"]).split("\n"):
         if rule.strip().endswith(pat):
             return True
     return False
Exemplo n.º 51
0
 def _find_device(self):
     try:
         return process.check_output(
             ["findmnt", "-o", "SOURCE", "-n", self.path]).strip()
     except:
         raise RuntimeError("Couldn't find mount device for %s" % self.path)
Exemplo n.º 52
0
 def mountpoints(self):
     targets = process.check_output(["findmnt", "-o", "target", "-n",
                                     self.device]).split("\n")
     return [Mount(t.strip()) for t in targets]
Exemplo n.º 53
0
 def _call_ipmi(self, args):
     assert type(args) is list
     return process.check_output(["ipmitool"] + args, stderr=process.PIPE)