Пример #1
0
    def cliHelp(self, helpWanted=None):
        knownTopics = ("cli, criteria, filter, help," +
                       "report, sources, topics, values")
        basicHelp = ("Enter exit|quit|bye to quit,\n" +
                     "or help cli for how to use the cli")

        if helpWanted is None:
            print basicHelp
            return

        helpWanted = helpWanted.strip()
        if helpWanted == "cli":
            print "Enter one of the following:"
            print ""
            print "exit|quit|bye to quit,"
            print "filter <expr> where expr is a comma-separated list"
            print "   of assertions, to display a list of hosts matching"
            print "   the filter,"
            print "report <expr> where expr is a comma-separated list"
            print "   of reqirements, to display a report of hosts in those"
            print "   sources and values matching the requirement,"
            print "flush to discard all host source lists; they will be"
            print "   reloaded for the next filter or report"
            print "verbose to display various messages during processing,"
            print "noverbose to turn that off,"
            print "settings to show current settings,"
            print "hosts <expr> to change the value of the hosts option"
            print "   (applies to filters and reports),"
            print "nohosts to unset that,"
            print "set <sourcename> to set a setting for a source (you"
            print "   will be prompted for a setting, enter <setting> <value>"
            print "   for one of host, path, db, user, password,"
            print "   depending on what settings are valid for that source),"
            print "unset <sourcename> to set a setting for a source to"
            print "   '' (you will be prompted for a settingname, enter one"
            print "   of host, path, db, user, password, depending on what"
            print "   settings are valid for that source),"
            print "timeout <int> to set the timeout for remote commands to this"
            print "   many seconds (applies to filters and reports),"
            print "help <topicname> for detailed help on a topic."
            print ""
            print "Known help topics:"
            print knownTopics
        elif helpWanted == "filter":
            print HHelp.getFilterHelp(self.knownSources)
        elif helpWanted == "report":
            print HHelp.getReportHelp(self.knownSources)
        elif helpWanted == "sources":
            print HHelp.getSourcesHelp(self.knownSources)
        elif helpWanted == "criteria":
            print HHelp.getCriteriaHelp()
        elif helpWanted == "values":
            print HHelp.getCriteriaValuesHelp()
        elif helpWanted == "topics":
            print "Enter help <topicname> for detailed help on a topic."
            print "Known topics:"
            print knownTopics
        else:
            print "Unknown help topic <%s>.  Known topics:" % helpWanted
            print knownTopics
Пример #2
0
    def cliHelp(self, helpWanted=None):
        knownTopics = ("cli, criteria, filter, help," +
                       "report, sources, topics, values")
        basicHelp = ("Enter exit|quit|bye to quit,\n" +
                     "or help cli for how to use the cli")

        if helpWanted is None:
            print basicHelp
            return

        helpWanted = helpWanted.strip()
        if helpWanted == "cli":
            print "Enter one of the following:"
            print ""
            print "exit|quit|bye to quit,"
            print "filter <expr> where expr is a comma-separated list"
            print "   of assertions, to display a list of hosts matching"
            print "   the filter,"
            print "report <expr> where expr is a comma-separated list"
            print "   of reqirements, to display a report of hosts in those"
            print "   sources and values matching the requirement,"
            print "flush to discard all host source lists; they will be"
            print "   reloaded for the next filter or report"
            print "verbose to display various messages during processing,"
            print "noverbose to turn that off,"
            print "settings to show current settings,"
            print "hosts <expr> to change the value of the hosts option"
            print "   (applies to filters and reports),"
            print "nohosts to unset that,"
            print "set <sourcename> to set a setting for a source (you"
            print "   will be prompted for a setting, enter <setting> <value>"
            print "   for one of host, path, db, user, password,"
            print "   depending on what settings are valid for that source),"
            print "unset <sourcename> to set a setting for a source to"
            print "   '' (you will be prompted for a settingname, enter one"
            print "   of host, path, db, user, password, depending on what"
            print "   settings are valid for that source),"
            print "timeout <int> to set the timeout for remote commands to this"
            print "   many seconds (applies to filters and reports),"
            print "help <topicname> for detailed help on a topic."
            print ""
            print "Known help topics:"
            print knownTopics
        elif helpWanted == "filter":
            print HHelp.getFilterHelp(self.knownSources)
        elif helpWanted == "report":
            print HHelp.getReportHelp(self.knownSources)
        elif helpWanted == "sources":
            print HHelp.getSourcesHelp(self.knownSources)
        elif helpWanted == "criteria":
            print HHelp.getCriteriaHelp()
        elif helpWanted == "values":
            print HHelp.getCriteriaValuesHelp()
        elif helpWanted == "topics":
            print "Enter help <topicname> for detailed help on a topic."
            print "Known topics:"
            print knownTopics
        else:
            print "Unknown help topic <%s>.  Known topics:" % helpWanted
            print knownTopics
Пример #3
0
 def cliDoUnset(self, command):
     sourceName = command.split()[1]
     if sourceName not in self.knownSources:
         print "Unknown source"
         print HHelp.getSourcesHelp(self.knownSources)
     else:
         setting = raw_input("setting: ")
         setting = setting.strip()
         if ' ' in setting:
             print "Bad setting format; expecting setting-name"
         # update both hr and hf sources
         elif not self.hf.sources[sourceName].update(
                 setting, "", emptyOk=True):
             print "Bad setting for source"
         elif not self.hr.sources[sourceName].update(
                 setting, "", emptyOk=True):
             print "Bad setting for source"
Пример #4
0
 def cliDoUnset(self, command):
     sourceName = command.split()[1]
     if sourceName not in self.knownSources:
         print "Unknown source"
         print HHelp.getSourcesHelp(self.knownSources)
     else:
         setting = raw_input("setting: ")
         setting = setting.strip()
         if ' ' in setting:
             print "Bad setting format; expecting setting-name"
         # update both hr and hf sources
         elif not self.hf.sources[sourceName].update(setting,
                                                     "", emptyOk=True):
             print "Bad setting for source"
         elif not self.hr.sources[sourceName].update(setting,
                                                     "", emptyOk=True):
             print "Bad setting for source"
Пример #5
0
 def cliDoSet(self, setCommand):
     sourceName = setCommand.split()[1]
     if sourceName not in self.knownSources:
         print "Unknown source"
         print HHelp.getSourcesHelp(self.knownSources)
     else:
         setting = raw_input("setting: ")
         setting = setting.strip()
         if ' ' not in setting:
             print ("Bad setting format;" +
                    "expecting setting-name whitespace value")
         # fixme this and the below set of splits is inconsistent
         # and dangerous
         # update both the hf and hr sources
         elif (not self.hf.sources[sourceName].update(
                 setting.split(" ", 1))):
             print "Bad setting for source"
         elif (not self.hr.sources[sourceName].update(
                 setting.split(" ", 1))):
             print "Bad setting for source"
         else:
             print ("setting", setting.split()[0], "updated to",
                    setting.split()[1])
Пример #6
0
 def cliDoSet(self, setCommand):
     sourceName = setCommand.split()[1]
     if sourceName not in self.knownSources:
         print "Unknown source"
         print HHelp.getSourcesHelp(self.knownSources)
     else:
         setting = raw_input("setting: ")
         setting = setting.strip()
         if ' ' not in setting:
             print("Bad setting format;" +
                   "expecting setting-name whitespace value")
         # fixme this and the below set of splits is inconsistent
         # and dangerous
         # update both the hf and hr sources
         elif (not self.hf.sources[sourceName].update(setting.split(" ",
                                                                    1))):
             print "Bad setting for source"
         elif (not self.hr.sources[sourceName].update(setting.split(" ",
                                                                    1))):
             print "Bad setting for source"
         else:
             print("setting",
                   setting.split()[0], "updated to",
                   setting.split()[1])