示例#1
0
    def asinfo(results, line_sep, cluster, **kwargs):
        like = set(kwargs['like'])
        for node_id, value in results.iteritems():
            prefix = cluster.getPrefixes()[node_id]
            node = cluster.getNode(node_id)[0]

            print "%s%s (%s) returned%s:"%(terminal.bold()
                                           , prefix
                                           , node.ip
                                           , terminal.reset())

            if isinstance(value, Exception):
                print "%s%s%s"%(terminal.fg_red()
                                , value
                                , terminal.reset())
                print "\n"
            else:
                # most info commands return a semicolon delimited list of key=value.
                # Assuming this is the case here, later we may want to try to detect
                # the format.
                value = value.split(';')
                likes = CliView.compileLikes(like)
                value = filter(likes.search, value)

                if not line_sep:
                    value = [";".join(value)]

                for line in sorted(value):
                    print line
                print
示例#2
0
    def asinfo(results, line_sep, cluster, **kwargs):
        like = set(kwargs['like'])
        for node_id, value in results.iteritems():
            prefix = cluster.getPrefixes()[node_id]
            node = cluster.getNode(node_id)[0]

            print "%s%s (%s) returned%s:" % (terminal.bold(), prefix, node.ip,
                                             terminal.reset())

            if isinstance(value, Exception):
                print "%s%s%s" % (terminal.fg_red(), value, terminal.reset())
                print "\n"
            else:
                # most info commands return a semicolon delimited list of key=value.
                # Assuming this is the case here, later we may want to try to detect
                # the format.
                value = value.split(';')
                likes = CliView.compileLikes(like)
                value = filter(likes.search, value)

                if not line_sep:
                    value = [";".join(value)]

                for line in sorted(value):
                    print line
                print
示例#3
0
    def dun(results, cluster, **kwargs):
        for node_id, command_result in results.iteritems():
            prefix = cluster.getPrefixes()[node_id]
            node = cluster.getNode(node_id)[0]

            print "%s%s (%s) returned%s:" % (terminal.bold(), prefix, node.ip,
                                             terminal.reset())

            if isinstance(command_result, Exception):
                print "%s%s%s" % (terminal.fg_red(), command_result,
                                  terminal.reset())
                print "\n"
            else:
                command, result = command_result
                print "asinfo -v '%s'" % (command)
                print result
示例#4
0
    def dun(results, cluster, **kwargs):
        for node_id, command_result in results.iteritems():
            prefix = cluster.getPrefixes()[node_id]
            node = cluster.getNode(node_id)[0]

            print "%s%s (%s) returned%s:"%(terminal.bold()
                                           , prefix
                                           , node.ip
                                           , terminal.reset())

            if isinstance(command_result, Exception):
                print "%s%s%s"%(terminal.fg_red()
                                , command_result
                                , terminal.reset())
                print "\n"
            else:
                command, result = command_result
                print "asinfo -v '%s'"%(command)
                print result
示例#5
0
    def precmd(self, line):
        lines = self.cleanLine(line)

        if not lines:  # allow empty lines
            return ""

        for line in lines:
            if line[0] in self.commands:
                return " ".join(line)

            if len(lines) > 1:
                print "~~~ %s%s%s ~~~" % (terminal.bold(), " ".join(line[1:]), terminal.reset())

            sys.stdout.write(terminal.reset())
            try:
                response = self.ctrl.execute(line)
                if response == "EXIT":
                    return "exit"
            except ShellException as e:
                print "%sERR: %s%s" % (terminal.fg_red(), e, terminal.fg_clear())
        return ""  # line was handled by execute