Пример #1
0
 def getEditMenu(self, options, err_msg=""):
     """ Displays sub-menu to determine what options to edit """
     utils.outputTitleLines("WORKFLOW ENGINE - Edit options", err_msg,
                            self.term_size, HYPHEN_LINE)
     print " [1] Configure information tag for phase"
     print " [2] Configure error tag for phase"
     print " [3] Configure arguments in display status information line"
     print "[4] Configure set variable tag"
     print "[5] Configure timeout"
     print "[6] Configure output level"
     choice = raw_input("\nPlease select your option or q to quit:\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 6):
         return self.getEditMenu(options,
                             "Invalid option {0}".format(choice))
     val = int(choice)
     if val == 1:
         return self.getEditPhaseName(True)
     elif val == 2:
         return self.getEditPhaseName(False)
     elif val == 3:
         return self.getEditArguments()
     elif val == 4:
         return self.setParameter("set variable", wfconfig.SETVAR)
     elif val == 5:
         return self.setTimeout(options)
     elif val == 6:
         return self.setOutputLevel(options)
Пример #2
0
    def getMenuServers(self, options, desc, err_msg=""):
        """ Displays sub-menu to determine whether to run on
            all servers, servers of particular type, selected servernames.
            Used when running phase or tagged set"""
        utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(desc), err_msg,
                               self.term_size, HYPHEN_LINE)
        # if we are using the menu then we cannot be using --list
        print " [1] Run {0} on all servers".format(desc)

        print " [2] Run {0} on all servers of selected types".format(desc)

        print " [3] Run {0} on selected servers".format(desc)
        choice = raw_input("\nPlease select your option or q to quit:\n")
        if choice == "q":
            return False
        if not utils.digit_in_range(choice, 3):
            return self.getMenuServers(options, desc,
                                       "Invalid option {0}".format(choice))
        val = int(choice)
        LOG.debug("Requesting further details for {0}".\
                               format(desc))
        if val == 1:
            options.unparsed_servertypes = constants.ALL
            options.unparsed_servernames = constants.ALL
        elif val == 2:
            options.unparsed_servernames = constants.ALL
            options.unparsed_servertypes = self.getMenuServerTypes(options)
        elif val == 3:
            options.unparsed_servernames = self.getMenuSelectedServers(desc)
            options.unparsed_servertypes = constants.ALL
        if val == 1 or val == 2:
            # Check if want to exclude server
            if options.exclude == None:
                options.exclude = self.getExcludeServers(options, desc)
        return True
Пример #3
0
 def getMenuSingleTaskServers(self, options, err_msg=""):
     """ Displays sub-menu to determine whether to run task on
         all servers, or selected servers"""
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(options.task),
                            err_msg, self.term_size, HYPHEN_LINE)
     # if we are using the menu then we cannot be using --list
     print " [1] Run {0} on all servers".format(options.task)
     print " [2] Run {0} on selected servers".format(options.task)
     LOG.debug("Requesting further details for {0} task".\
                                               format(options.task))
     choice = raw_input("\nPlease select your option or q to quit:\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 2):
         return self.getMenuSingleTaskServers(options, \
                       "Invalid option {0}".format(choice))
     val = int(choice)
     if val == 1:
         if options.exclude == None:
             options.exclude = self.getExcludeServers(options, options.task)
         options.unparsed_servernames = constants.ALL
         return True
     elif val == 2:
         options.unparsed_servernames = \
                          self.getMenuSelectedServers(options.task)
     return True
Пример #4
0
 def getMenuSingleTaskServers(self, options, err_msg=""):
     """ Displays sub-menu to determine whether to run task on
         all servers, or selected servers"""
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(options.task),
                            err_msg, self.term_size, HYPHEN_LINE)
     # if we are using the menu then we cannot be using --list
     print " [1] Run {0} on all servers".format(options.task)
     print " [2] Run {0} on selected servers".format(options.task)
     LOG.debug("Requesting further details for {0} task".\
                                               format(options.task))
     choice = raw_input("\nPlease select your option or q to quit:\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 2):
         return self.getMenuSingleTaskServers(options, \
                       "Invalid option {0}".format(choice))
     val = int(choice)
     if val == 1:
         if options.exclude == None:
             options.exclude = self.getExcludeServers(options, options.task)
         options.unparsed_servernames = constants.ALL
         return True
     elif val == 2:
         options.unparsed_servernames = \
                          self.getMenuSelectedServers(options.task)
     return True
Пример #5
0
 def getEditMenu(self, options, err_msg=""):
     """ Displays sub-menu to determine what options to edit """
     utils.outputTitleLines("WORKFLOW ENGINE - Edit options", err_msg,
                            self.term_size, HYPHEN_LINE)
     print " [1] Configure information tag for phase"
     print " [2] Configure error tag for phase"
     print " [3] Configure arguments in display status information line"
     print "[4] Configure set variable tag"
     print "[5] Configure timeout"
     print "[6] Configure output level"
     choice = raw_input("\nPlease select your option or q to quit:\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 6):
         return self.getEditMenu(options,
                                 "Invalid option {0}".format(choice))
     val = int(choice)
     if val == 1:
         return self.getEditPhaseName(True)
     elif val == 2:
         return self.getEditPhaseName(False)
     elif val == 3:
         return self.getEditArguments()
     elif val == 4:
         return self.setParameter("set variable", wfconfig.SETVAR)
     elif val == 5:
         return self.setTimeout(options)
     elif val == 6:
         return self.setOutputLevel(options)
Пример #6
0
    def getDynamicAlteration(self, wfsys, msgs):
        """ interactively obtains the details for the dynamic pause/esc
            alteration

            Args:
                wfsys: the workflow
                msgs: list to hold messages to be displayed to user
            Returns:
                dictionary containing the alteration details - empty if
                errors encountered, None if quitting
        """
        if not len(msgs) == 0:
            LOG.info("\n\n\n")
            for m in msgs:
                LOG.info(m)
            choice = raw_input(
                  "\nPress enter to continue\n")
            msgs = []

        utils.outputTitleLines("WORKFLOW ENGINE DYNAMIC ALTERATIONS", "",
                               self.term_size, HYPHEN_LINE)

        print " [1] Enter new dynamic ESCAPE task"
        print " [2] Enter new dynamic PAUSE task"
        print " [3] Delete existing dynamic ESCAPE task"
        print " [4] Delete existing dynamic PAUSE task"
        choice = raw_input(
            "\nPlease select your option or q to quit:\n")

        if choice == "q":
            return None
        if not utils.digit_in_range(choice, 4):
            msgs.append("Invalid option {0}".format(choice))
            return {}

        val = int(choice)
        dtask = {}

        if val == 1:
            return self.getDynamicAddition(dtask, constants.DYNAMIC_ESCAPE,
                                           wfsys)
        elif val == 2:
            return self.getDynamicAddition(dtask, constants.DYNAMIC_PAUSE,
                                           wfsys)
        elif val == 3:
            return self.getDynamicRemoval(dtask, constants.DYNAMIC_ESCAPE,
                                           wfsys)
        elif val == 4:
            return self.getDynamicRemoval(dtask, constants.DYNAMIC_PAUSE,
                                           wfsys)
        else:
            LOG.debug("Option out of range - this should never happen as "
                      "should be protected by range test")
            return {}
Пример #7
0
 def setTimeout(self, options, err_msg=""):
     """ Displays the menu to get the timeout value"""
     utils.outputTitleLines("WORKFLOW ENGINE - Edit timeout", err_msg,
                            self.term_size, HYPHEN_LINE)
     choice = raw_input("\nPlease enter timeout (secs) or q to quit\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, sys.maxint):
         return self.setTimeout(options, "Invalid value {0}".format(choice))
     val = int(choice)
     options.timeout = val
     return True
Пример #8
0
    def getOptions(self, options, err_msg=""):
        """ Get menu options, and populate options object

            Args:
                options: WorkflowOptions
                err_msg: error message to display
            Returns:
                boolean: True if ok, False if should quit
        """
        utils.outputTitleLines("WORKFLOW ENGINE", err_msg,
                               self.term_size, HYPHEN_LINE)
        # if we are using the menu then we cannot be using --list
        print " [1] Run display deployment"
        print " [2] Run pre-checks"
        print " [3] Run execute workflow"
        print " [4] Run post-checks"
        print " [5] Run named tasks"
        print " [6] Run tagged set of tasks"
        print " [7] Edit Workflow Engine options"
        choice = raw_input("\nPlease select your option or q to quit:\n")
        if choice == "q":
            return False
        if not utils.digit_in_range(choice, 7):
            return self.getOptions(options, "Invalid option {0}".\
                                               format(choice))
        val = int(choice)
        if val == 1:
            options.phase = constants.OPT_DISPLAY
            return self.getMenuPhase(options)
        elif val == 2:
            options.phase = constants.OPT_PRECHECK
            return self.getMenuPhase(options)
        elif val == 3:
            options.phase = constants.OPT_EXECUTE
            return self.getMenuPhase(options)
        elif val == 4:
            options.phase = constants.OPT_POSTCHECK
            return self.getMenuPhase(options)
        elif val == 5:
            options.unparsed_task = self.getMenuTaskList()
            if options.unparsed_task != None:
                options.task = utils.split_commas(options.unparsed_task)
            options.phase = constants.OPT_POSTCHECK
            return self.getMenuTaskListServers(options,
                                  "task {0}".format(options.task))
        elif val == 6:
            # TODO: If run tag should also run postcheck or not by default?
            options.phase = constants.OPT_EXECUTE
            return self.getMenuTag(options)
        elif val == 7:
            self.getEditMenu(options)
            # Re-display menu as done editing
            return self.getOptions(options)
Пример #9
0
 def setTimeout(self, options, err_msg=""):
     """ Displays the menu to get the timeout value"""
     utils.outputTitleLines("WORKFLOW ENGINE - Edit timeout", err_msg,
                            self.term_size, HYPHEN_LINE)
     choice = raw_input("\nPlease enter timeout (secs) or q to quit\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, sys.maxint):
         return self.setTimeout(options,
                                "Invalid value {0}".format(choice))
     val = int(choice)
     options.timeout = val
     return True
Пример #10
0
    def getDynamicAlteration(self, wfsys, msgs):
        """ interactively obtains the details for the dynamic pause/esc
            alteration
            Arguments:
                wfsys: the workflow
                msgs: list to hold messages to be displayed to user
            Returns:
                dictionary containing the alteration details - empty if
                errors encountered, None if quitting
        """
        if not len(msgs) == 0:
            LOG.info("\n\n\n")
            for m in msgs:
                LOG.info(m)
            choice = raw_input("\nPress enter to continue\n")
            msgs = []

        utils.outputTitleLines("WORKFLOW ENGINE DYNAMIC ALTERATIONS", "",
                               self.term_size, HYPHEN_LINE)

        print " [1] Enter new dynamic ESCAPE task"
        print " [2] Enter new dynamic PAUSE task"
        print " [3] Delete existing dynamic ESCAPE task"
        print " [4] Delete existing dynamic PAUSE task"
        choice = raw_input("\nPlease select your option or q to quit:\n")

        if choice == "q":
            return None
        if not utils.digit_in_range(choice, 4):
            msgs.append("Invalid option {0}".format(choice))
            return {}

        val = int(choice)
        dtask = {}

        if val == 1:
            return self.getDynamicAddition(dtask, constants.DYNAMIC_ESCAPE,
                                           wfsys)
        elif val == 2:
            return self.getDynamicAddition(dtask, constants.DYNAMIC_PAUSE,
                                           wfsys)
        elif val == 3:
            return self.getDynamicRemoval(dtask, constants.DYNAMIC_ESCAPE,
                                          wfsys)
        elif val == 4:
            return self.getDynamicRemoval(dtask, constants.DYNAMIC_PAUSE,
                                          wfsys)
        else:
            LOG.debug("Option out of range - this should never happen as "
                      "should be protected by range test")
            return {}
Пример #11
0
 def getOptions(self, options, err_msg=""):
     """ Get menu options, and populate options object
         Arguments:
             options: WorkflowOptions
             err_msg: error message to display
         Returns:
             True if ok, False if should quit
     """
     utils.outputTitleLines("WORKFLOW ENGINE", err_msg, self.term_size,
                            HYPHEN_LINE)
     # if we are using the menu then we cannot be using --list
     print " [1] Run display deployment"
     print " [2] Run pre-checks"
     print " [3] Run execute workflow"
     print " [4] Run post-checks"
     print " [5] Run single workflow task"
     print " [6] Run tagged set of tasks"
     print " [7] Edit Workflow Engine options"
     choice = raw_input("\nPlease select your option or q to quit:\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 7):
         return self.getOptions(options, "Invalid option {0}".\
                                            format(choice))
     val = int(choice)
     if val == 1:
         options.phase = constants.OPT_DISPLAY
         return self.getMenuPhase(options)
     elif val == 2:
         options.phase = constants.OPT_PRECHECK
         return self.getMenuPhase(options)
     elif val == 3:
         options.phase = constants.OPT_EXECUTE
         return self.getMenuPhase(options)
     elif val == 4:
         options.phase = constants.OPT_POSTCHECK
         return self.getMenuPhase(options)
     elif val == 5:
         options.task = self.getMenuSingleTask()
         options.phase = constants.OPT_POSTCHECK
         return self.getMenuSingleTaskServers(
             options, "task {0}".format(options.task))
     elif val == 6:
         # TODO: If run tag should also run postcheck or not by default?
         options.phase = constants.OPT_EXECUTE
         return self.getMenuTag(options)
     elif val == 7:
         self.getEditMenu(options)
         # Re-display menu as done editing
         return self.getOptions(options)
Пример #12
0
 def setOutputLevel(self, options, err_msg=""):
     """ Displays the menu to get the output level"""
     utils.outputTitleLines("WORKFLOW ENGINE - Set output level",
                        err_msg, self.term_size, HYPHEN_LINE)
     print " [0] Quiet (suppress info and error tags)"
     print " [1] Output error tags only"
     print " [2] Output info and error tags"
     choice = raw_input("\nPlease select your option or q to quit\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 2, 0):
         return self.setOutputLevel(options, "Invalid option {0}".\
                                            format(choice))
     val = int(choice)
     options.output_level = val
     return True
Пример #13
0
 def setOutputLevel(self, options, err_msg=""):
     """ Displays the menu to get the output level"""
     utils.outputTitleLines("WORKFLOW ENGINE - Set output level", err_msg,
                            self.term_size, HYPHEN_LINE)
     print " [0] Quiet (suppress info and error tags)"
     print " [1] Output error tags only"
     print " [2] Output info and error tags"
     choice = raw_input("\nPlease select your option or q to quit\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 2, 0):
         return self.setOutputLevel(options, "Invalid option {0}".\
                                            format(choice))
     val = int(choice)
     options.output_level = val
     return True
Пример #14
0
 def getEditArguments(self, err_msg=""):
     """ Displays the user the choice of display information tags
         can set """
     utils.outputTitleLines("WORKFLOW ENGINE - Edit status arguments",
                            err_msg, self.term_size, HYPHEN_LINE)
     print " [1] Configure software version tag"
     print " [2] Configure server type tag"
     print " [3] Configure os version tag"
     choice = raw_input("\nPlease select your option or q to quit\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 3):
         return self.getEditArguments("Invalid option {0}".format(choice))
     val = int(choice)
     if val == 1:
         return self.setParameter("software version", wfconfig.SWVER)
     elif val == 2:
         return self.setParameter("server type", wfconfig.TYPE)
     elif val == 3:
         return self.setParameter("os version", wfconfig.OSVER)
Пример #15
0
 def getEditArguments(self, err_msg=""):
     """ Displays the user the choice of display information tags
         can set """
     utils.outputTitleLines("WORKFLOW ENGINE - Edit status arguments",
                            err_msg, self.term_size, HYPHEN_LINE)
     print " [1] Configure software version tag"
     print " [2] Configure server type tag"
     print " [3] Configure os version tag"
     choice = raw_input("\nPlease select your option or q to quit\n")
     if choice == "q":
         return False
     if not utils.digit_in_range(choice, 3):
         return self.getEditArguments("Invalid option {0}".format(choice))
     val = int(choice)
     if val == 1:
         return self.setParameter("software version", wfconfig.SWVER)
     elif val == 2:
         return self.setParameter("server type", wfconfig.TYPE)
     elif val == 3:
         return self.setParameter("os version", wfconfig.OSVER)
Пример #16
0
    def getEditPhaseName(self, is_info, err_msg=""):
        """ Asks user which phase want to change info or error tag for

            Args:
                is_info: True if changing info tag, False if error
                err_msg: Whether error message to display
            Returns:
                boolean: True if set parameter, else False
        """
        if is_info:
            tagname = "information"
            paramname = "_INFO"
        else:
            tagname = "error"
            paramname = "_ERR"
        utils.outputTitleLines("WORKFLOW ENGINE - Edit {0} tags".\
                          format(tagname), err_msg, self.term_size,
                          HYPHEN_LINE)
        print " [1] Configure display {0} tag".format(tagname)
        print " [2] Configure precheck {0} tag".format(tagname)
        print " [3] Configure execute {0} tag".format(tagname)
        print " [4] Configure postcheck {0} tag".format(tagname)
        choice = raw_input("\nPlease select your option or q to quit:\n")
        if choice == "q":
            return False
        if not utils.digit_in_range(choice, 4):
            return self.getEditPhaseName("Invalid option {0}".format(choice))
        val = int(choice)
        if val == 1:
            phase = "DISPLAY"
        elif val == 2:
            phase = "PRECHECK"
        elif val == 3:
            phase = "EXECUTE"
        else:
            phase = "POSTCHECK"

        return self.setParameter("{0} {1} tag".format(phase, tagname),
                         phase + paramname)
Пример #17
0
    def getEditPhaseName(self, is_info, err_msg=""):
        """ Asks user which phase want to change info or error tag for
            Arguments:
                is_info: True if changing info tag, False if error
                err_msg: Whether error message to display
            Returns:
                True if set parameter, else False
        """
        if is_info:
            tagname = "information"
            paramname = "_INFO"
        else:
            tagname = "error"
            paramname = "_ERR"
        utils.outputTitleLines("WORKFLOW ENGINE - Edit {0} tags".\
                          format(tagname), err_msg, self.term_size,
                          HYPHEN_LINE)
        print " [1] Configure display {0} tag".format(tagname)
        print " [2] Configure precheck {0} tag".format(tagname)
        print " [3] Configure execute {0} tag".format(tagname)
        print " [4] Configure postcheck {0} tag".format(tagname)
        choice = raw_input("\nPlease select your option or q to quit:\n")
        if choice == "q":
            return False
        if not utils.digit_in_range(choice, 4):
            return self.getEditPhaseName("Invalid option {0}".format(choice))
        val = int(choice)
        if val == 1:
            phase = "DISPLAY"
        elif val == 2:
            phase = "PRECHECK"
        elif val == 3:
            phase = "EXECUTE"
        else:
            phase = "POSTCHECK"

        return self.setParameter("{0} {1} tag".format(phase, tagname),
                                 phase + paramname)
Пример #18
0
    def getMenuServers(self, options, desc, err_msg=""):
        """ Displays sub-menu to determine whether to run on
            all servers, servers of particular type, selected servernames.
            Used when running phase or tagged set"""
        utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(desc),
                               err_msg, self.term_size, HYPHEN_LINE)
        # if we are using the menu then we cannot be using --list
        print " [1] Run {0} on all servers".format(desc)

        print " [2] Run {0} on all servers of selected types".format(desc)

        print " [3] Run {0} on selected servers".format(desc)
        choice = raw_input("\nPlease select your option or q to quit:\n")
        if choice == "q":
            return False
        if not utils.digit_in_range(choice, 3):
            return self.getMenuServers(options, desc,
                                        "Invalid option {0}".format(choice))
        val = int(choice)
        LOG.debug("Requesting further details for {0}".\
                               format(desc))
        if val == 1:
            options.unparsed_servertypes = constants.ALL
            options.unparsed_servernames = constants.ALL
        elif val == 2:
            options.unparsed_servernames = constants.ALL
            options.unparsed_servertypes = self.getMenuServerTypes(options)
        elif val == 3:
            options.unparsed_servernames = self.getMenuSelectedServers(desc)
            options.unparsed_servertypes = constants.ALL
        if val == 1 or val == 2:
            # Check if want to exclude server
            if options.exclude == None:
                options.exclude = self.getExcludeServers(options,
                                                         desc)
        return True