Ejemplo n.º 1
0
def do_commands(view, what, rows):
    command = None
    title, executor = views.core_command(what,
                                         rows[0])[1:3]  # just get the title
    r = html.confirm(
        _("Do you really want to %(title)s the %(count)d %(what)ss?") % {
            "title": title,
            "count": len(rows),
            "what": _(what + "s"),
        })
    if r != True:
        return r == None  # Show commands on negative answer

    count = 0
    for row in rows:
        nagios_commands, title, executor = views.core_command(what, row)
        for command in nagios_commands:
            if type(command) == unicode:
                command = command.encode("utf-8")
            executor(command, row["site"])
            count += 1

    if command:
        html.message(_("Successfully sent %d commands.") % count)
    return True  # Show commands again
Ejemplo n.º 2
0
def do_commands(view, what, rows):
    command = None
    title, executor = views.core_command(what, rows[0], 0,
                                         len(rows))[1:3]  # just get the title
    title_what = _("hosts") if what == "host" else _("services")
    r = html.confirm(
        _("Do you really want to %(title)s the %(count)d %(what)s?") % {
            "title": title,
            "count": len(rows),
            "what": title_what,
        })
    if r != True:
        return r == None  # Show commands on negative answer

    count = 0
    already_executed = set([])
    for nr, row in enumerate(rows):
        nagios_commands, title, executor = views.core_command(
            what, row, nr, len(rows))
        for command in nagios_commands:
            if command not in already_executed:
                if type(command) == unicode:
                    command = command.encode("utf-8")
                executor(command, row["site"])
                already_executed.add(command)
                count += 1

    if count > 0:
        html.message(_("Successfully sent %d commands.") % count)
    return True  # Show commands again
Ejemplo n.º 3
0
def do_commands(view, what, rows):
    command = None
    title, executor = views.core_command(what, rows[0])[1:3] # just get the title
    r = html.confirm(_("Do you really want to %(title)s the %(count)d %(what)ss?") %
                     (title, len(rows), what), action=html.req.myfile + ".py#commands")
    if r != True:
        return r == None # Show commands on negative answer

    count = 0
    for row in rows:
        nagios_commands, title, executor = views.core_command(what, row)
        for command in nagios_commands:
            if type(command) == unicode:
                command = command.encode("utf-8")
            executor(command, row["site"])
            count += 1

    if command:
        html.message(_("Successfully sent %d commands.") % count)
    return True # Show commands again
Ejemplo n.º 4
0
def do_commands(view, what, rows):
    command = None
    title, executor = views.core_command(what, rows[0], 0, len(rows))[1:3] # just get the title
    r = html.confirm(_("Do you really want to %(title)s the %(count)d %(what)ss?") %
            { "title" : title, "count" : len(rows), "what" : _(what + "s"), })
    if r != True:
        return r == None # Show commands on negative answer

    count = 0
    already_executed = set([])
    for nr, row in enumerate(rows):
        nagios_commands, title, executor = views.core_command(what, row, nr, len(rows))
        for command in nagios_commands:
            if command not in already_executed:
                if type(command) == unicode:
                    command = command.encode("utf-8")
                executor(command, row["site"])
                already_executed.add(command)
                count += 1

    if count > 0:
        html.message(_("Successfully sent %d commands.") % count)
    return True # Show commands again