Esempio n. 1
0
 def meta(self, ra_class, ra_type, ra_provider):
     l = []
     if ra_class == "ocf":
         rc, l = stdout2list("%s/resource.d/%s/%s meta-data" %
                             (os.environ["OCF_ROOT"], ra_provider, ra_type))
     elif ra_class == "stonith":
         if ra_type.startswith("fence_") and os.path.exists("/usr/sbin/%s" % ra_type):
             rc, l = stdout2list("/usr/sbin/%s -o metadata" % ra_type)
         else:
             rc, l = stdout2list("stonith -m -t %s" % ra_type)
     elif ra_class == "nagios":
         rc, l = stdout2list("%s/check_%s --metadata" %
                             (config.path.nagios_plugins, ra_type))
     return l
Esempio n. 2
0
 def meta(self, ra_class, ra_type, ra_provider):
     l = []
     if ra_class == "ocf":
         rc, l = stdout2list("%s/resource.d/%s/%s meta-data" %
                             (os.environ["OCF_ROOT"], ra_provider, ra_type))
     elif ra_class == "stonith":
         if ra_type.startswith("fence_") and os.path.exists("/usr/sbin/%s" % ra_type):
             rc, l = stdout2list("/usr/sbin/%s -o metadata" % ra_type)
         else:
             rc, l = stdout2list("stonith -m -t %s" % ra_type)
     elif ra_class == "nagios":
         rc, l = stdout2list("%s/check_%s --metadata" %
                             (config.path.nagios_plugins, ra_type))
     return l
Esempio n. 3
0
    def do_ticket(self, context, subcmd, ticket):
        "usage: ticket {grant|revoke|standby|activate|show|time|delete} <ticket>"

        base_cmd = "crm_ticket"
        if config.core.force:
            base_cmd += " --force"

        attr_cmd = _ticket_commands.get(subcmd)
        if not attr_cmd:
            context.fatal_error('Expected one of %s' %
                                '|'.join(_ticket_commands.keys()))
        if not utils.is_name_sane(ticket):
            return False
        if subcmd not in ("show", "time"):
            return utils.ext_cmd(attr_cmd % (base_cmd, ticket)) == 0
        rc, l = utils.stdout2list(attr_cmd % (base_cmd, ticket))
        try:
            val = l[0]
        except IndexError:
            context.fatal_error("apparently nothing to show for ticket %s" %
                                ticket)
        if subcmd == "show":
            _show(context, ticket, val)
        else:  # time
            _time(context, ticket, val)
Esempio n. 4
0
File: ra.py Progetto: jonnary/crmsh
def prog_meta(prog):
    '''
    Do external program metadata.
    '''
    if prog == "crmd" and os.path.isfile(os.path.join(config.path.crm_daemon_dir, 'crmd')):
        prog = os.path.join(config.path.crm_daemon_dir, 'crmd')
        rc, l = stdout2list("%s metadata" % prog)
        if rc == 0:
            return l
        common_debug("%s metadata exited with code %d" % (prog, rc))
    elif is_program(prog):
        rc, l = stdout2list("%s metadata" % prog)
        if rc == 0:
            return l
        common_debug("%s metadata exited with code %d" % (prog, rc))
    return []
Esempio n. 5
0
 def lrmadmin(self, opts, xml=False):
     '''
     Get information directly from lrmd using lrmadmin.
     '''
     rc, l = stdout2list("%s %s" % (lrmadmin_prog, opts))
     if l and not xml:
         l = l[1:]  # skip the first line
     return l
Esempio n. 6
0
 def lrmadmin(self, opts, xml=False):
     '''
     Get information directly from lrmd using lrmadmin.
     '''
     rc, l = stdout2list("%s %s" % (lrmadmin_prog, opts))
     if l and not xml:
         l = l[1:]  # skip the first line
     return l
Esempio n. 7
0
 def _stonith_types(self):
     rc, l = stdout2list("stonith -L")
     if rc != 0:
         # stonith(8) may not be installed
         common_debug("stonith exited with code %d" % rc)
         l = []
     for ra in os_types_list("/usr/sbin/fence_*"):
         if ra not in ("fence_ack_manual", "fence_pcmk", "fence_legacy"):
             l.append(ra)
Esempio n. 8
0
File: ra.py Progetto: icclab/crmsh
 def _stonith_types(self):
     rc, l = stdout2list("stonith -L")
     if rc != 0:
         # stonith(8) may not be installed
         common_debug("stonith exited with code %d" % rc)
         l = []
     for ra in os_types_list("/usr/sbin/fence_*"):
         if ra not in ("fence_ack_manual", "fence_pcmk", "fence_legacy"):
             l.append(ra)
Esempio n. 9
0
File: ra.py Progetto: icclab/crmsh
def prog_meta(prog):
    '''
    Do external program metadata.
    '''
    if is_program(prog):
        rc, l = stdout2list("%s metadata" % prog)
        if rc == 0:
            return l
        common_debug("%s metadata exited with code %d" % (prog, rc))
    return []
Esempio n. 10
0
 def crm_resource(self, opts):
     '''
     Get information from crm_resource.
     '''
     rc, l = stdout2list("crm_resource %s" % opts, stderr_on=False)
     # not clear when/why crm_resource exits with non-zero
     # code
     #if rc != 0:
     #    common_debug("crm_resource %s exited with code %d" %
     #                 (opts, rc))
     return l
Esempio n. 11
0
def prog_meta(prog):
    '''
    Do external program metadata.
    '''
    l = []
    if is_program(prog):
        rc, l = stdout2list("%s metadata" % prog)
        if rc != 0:
            common_debug("%s metadata exited with code %d" % (prog, rc))
            l = []
    return l
Esempio n. 12
0
 def crm_resource(self, opts):
     '''
     Get information from crm_resource.
     '''
     rc, l = stdout2list("crm_resource %s" % opts, stderr_on=False)
     # not clear when/why crm_resource exits with non-zero
     # code
     if rc != 0:
         common_debug("crm_resource %s exited with code %d" %
                      (opts, rc))
     return l
Esempio n. 13
0
File: ra.py Progetto: icclab/crmsh
 def _systemd_types(self):
     l = []
     rc, lines = stdout2list("systemctl list-unit-files --full")
     if rc != 0:
         return l
     t = re.compile(r'^(.+)\.service')
     for line in lines:
         m = t.search(line)
         if m:
             l.append(m.group(1))
     return l
Esempio n. 14
0
def prog_meta(prog):
    '''
    Do external program metadata.
    '''
    prog = is_program(prog)
    if prog:
        rc, l = stdout2list("%s metadata" % prog)
        if rc == 0:
            return l
        common_debug("%s metadata exited with code %d" % (prog, rc))
    return []
Esempio n. 15
0
 def _systemd_types(self):
     l = []
     rc, lines = stdout2list("systemctl list-unit-files --full")
     if rc != 0:
         return l
     t = re.compile(r'^(.+)\.service')
     for line in lines:
         m = t.search(line)
         if m:
             l.append(m.group(1))
     return l
Esempio n. 16
0
 def do_ticket(self, context, subcmd, ticket):
     "usage: ticket {grant|revoke|standby|activate|show|time|delete} <ticket>"
     attr_cmd = _ticket_commands.get(subcmd)
     if not attr_cmd:
         context.fatal_error('Expected one of %s' % '|'.join(_ticket_commands.keys()))
     if not utils.is_name_sane(ticket):
         return False
     if subcmd not in ("show", "time"):
         return utils.ext_cmd(attr_cmd % ticket) == 0
     rc, l = utils.stdout2list(attr_cmd % ticket)
     try:
         val = l[0]
     except IndexError:
         context.fatal_error("apparently nothing to show for ticket %s" % ticket)
     if subcmd == "show":
         _show(context, ticket, val)
     else:  # time
         _time(context, ticket, val)
Esempio n. 17
0
 def types(self, ra_class="ocf", ra_provider=""):
     'List of types for a class.'
     l = []
     prov = ra_provider and ra_provider or "*"
     if ra_class == "ocf":
         l = os_types_list("%s/resource.d/%s/*" % (os.environ["OCF_ROOT"], prov))
     elif ra_class == "lsb":
         l = os_types_list("/etc/init.d/*")
     elif ra_class == "stonith":
         rc, l = stdout2list("stonith -L")
         if rc != 0:
             # stonith(8) may not be installed
             common_debug("stonith exited with code %d" % rc)
             l = []
         for ra in os_types_list("/usr/sbin/fence_*"):
             if ra not in ("fence_ack_manual", "fence_pcmk", "fence_legacy"):
                 l.append(ra)
     elif ra_class == "nagios":
         l = os_types_list("%s/check_*" % config.path.nagios_plugins)
         l = [x.replace("check_", "") for x in l]
     l = list(set(l))
     l.sort()
     return l
Esempio n. 18
0
 def types(self, ra_class="ocf", ra_provider=""):
     'List of types for a class.'
     l = []
     prov = ra_provider and ra_provider or "*"
     if ra_class == "ocf":
         l = os_types_list("%s/resource.d/%s/*" % (os.environ["OCF_ROOT"], prov))
     elif ra_class == "lsb":
         l = os_types_list("/etc/init.d/*")
     elif ra_class == "stonith":
         rc, l = stdout2list("stonith -L")
         if rc != 0:
             # stonith(8) may not be installed
             common_debug("stonith exited with code %d" % rc)
             l = []
         for ra in os_types_list("/usr/sbin/fence_*"):
             if ra not in ("fence_ack_manual", "fence_pcmk", "fence_legacy"):
                 l.append(ra)
     elif ra_class == "nagios":
         l = os_types_list("%s/check_*" % config.path.nagios_plugins)
         l = [x.replace("check_", "") for x in l]
     l = list(set(l))
     l.sort()
     return l
Esempio n. 19
0
def listshadows():
    dir = cib_shadow_dir()
    if not os.path.isdir(dir):
        return []
    rc, l = stdout2list("ls %s | fgrep shadow. | sed 's/^shadow\\.//'" % dir)
    return l
Esempio n. 20
0
def listshadows():
    dir = cib_shadow_dir()
    if not os.path.isdir(dir):
        return []
    rc, l = stdout2list("ls %s | fgrep shadow. | sed 's/^shadow\\.//'" % dir)
    return l