Beispiel #1
0
 def getMenuSingleTask(self, err_msg=""):
     """ Display menu for choosing a single task and server"""
     LOG.debug("Getting task id")
     utils.outputTitleLines("WORKFLOW ENGINE - Select task", err_msg,
                            self.term_size, HYPHEN_LINE)
     task = raw_input("\nEnter id of task to use\n")
     return task
Beispiel #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
Beispiel #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
Beispiel #4
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)
Beispiel #5
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
Beispiel #6
0
 def getMenuSingleTask(self, err_msg=""):
     """ Display menu for choosing a single task and server"""
     LOG.debug("Getting task id")
     utils.outputTitleLines("WORKFLOW ENGINE - Select task", err_msg,
                            self.term_size, HYPHEN_LINE)
     task = raw_input("\nEnter id of task to use\n")
     return task
Beispiel #7
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)
Beispiel #8
0
 def getMenuSelectedServers(self, info, err_msg=""):
     """ Display menu for choosing servernames"""
     LOG.debug("Getting server name for {0}".format(info))
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(info), err_msg,
                            self.term_size, HYPHEN_LINE)
     name = raw_input(
         "\nEnter comma-separated list of server names to use\n")
     return name
Beispiel #9
0
 def getMenuSelectedServers(self, info, err_msg=""):
     """ Display menu for choosing servernames"""
     LOG.debug("Getting server name for {0}".format(info))
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(info),
                      err_msg, self.term_size, HYPHEN_LINE)
     name = raw_input(
            "\nEnter comma-separated list of server names to use\n")
     return name
Beispiel #10
0
 def getMenuTaskList(self, err_msg=""):
     """ Display menu for choosing a task list and server"""
     LOG.debug("Getting task id/s")
     utils.outputTitleLines("WORKFLOW ENGINE - Select tasks", err_msg,
                            self.term_size, HYPHEN_LINE)
     task = \
         raw_input("\nEnter comma-separated list of the task ids to use\n")
     return task
Beispiel #11
0
 def getMenuServerTypes(self, options, err_msg=""):
     """ Display menu for choosing a server type """
     LOG.debug("Getting server type for phase {0}".format(options.phase))
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(options.phase),
                            err_msg, self.term_size, HYPHEN_LINE)
     # TODO: Improve by showing them the choice of server types
     # in the workflow
     choice = raw_input(
         "\nEnter comma-separated list of server types to use\n")
     return choice
Beispiel #12
0
 def getMenuServerTypes(self, options, err_msg=""):
     """ Display menu for choosing a server type """
     LOG.debug("Getting server type for phase {0}".format(options.phase))
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(options.phase),
               err_msg, self.term_size, HYPHEN_LINE)
     # TODO: Improve by showing them the choice of server types
     # in the workflow
     choice = raw_input(
           "\nEnter comma-separated list of server types to use\n")
     return choice
Beispiel #13
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 {}
Beispiel #14
0
    def getDynamicRemoval(self, resDict, dyntype, wfsys):
        """ interactively obtains the details for the dynamic pause/esc removal

            Args:
                resdict: a dictionary to hold the addition details
                dyntype: specifies whether this is a pause or an escape
                wfsys: workflow sys object used in validation
            Returns:
                dictionary containing the alteration details - empty if errors
                encountered or if quitting
        """
        utils.outputTitleLines(
           "WORKFLOW ENGINE DYNAMIC ALTERATIONS - remove %s task" % dyntype,
           "Enter task details, or type q into any field to quit back to menu",
             self.term_size, HYPHEN_LINE)
        resDict[constants.DYN_ACTION] = constants.DYNAMIC_REMOVE
        resDict[constants.DYN_TYPE] = dyntype

        while True:
            if not self.acceptExistingEntry(resDict, constants.DYN_ID):
                entryOK = False
                while not entryOK:
                    entryOK = True
                    localMsgs = []
                    if not self.getRawInput(resDict, constants.DYN_ID,
                           "Enter %s task id" % dyntype, None):
                        return {}
                    LOG.debug("Field %s entered as %s" % \
                               (constants.DYN_ID, resDict[constants.DYN_ID]))
                    if not self.validator.validExecuteTaskId(\
                                resDict[constants.DYN_ID], dyntype,
                                                    wfsys, localMsgs):
                        self.displayErrors(localMsgs)
                        entryOK = False
                    elif self.validator.hasDependents(\
                                   resDict[constants.DYN_ID], wfsys,
                                     localMsgs):
                        self.displayErrors(localMsgs)
                        entryOK = False
            choice = ""
            while not choice == "q" and not choice == "y" and \
                                                 not choice == "a":
                choice = raw_input(
                   "\nPlease select y to remove %s task, a to amend entry, "
                       "or q to quit back to the main menu without removing "
                     "the task:\n" % \
                       dyntype)
                if choice == "q":
                    LOG.debug("Quitting back to menu")
                    return {}
                if choice == "y":
                    LOG.debug("Dynamic removal ready for action")
                    return resDict
Beispiel #15
0
    def getDynamicRemoval(self, resDict, dyntype, wfsys):
        """ interactively obtains the details for the dynamic pause/esc removal
            Arguments:
                resdict: a dictionary to hold the addition details
                dyntype: specifies whether this is a pause or an escape
                wfsys: workflow sys object used in validation
            Returns:
                dictionary containing the alteration details - empty if errors
                encountered or if quitting
        """
        utils.outputTitleLines(
            "WORKFLOW ENGINE DYNAMIC ALTERATIONS - remove %s task" % dyntype,
            "Enter task details, or type q into any field to quit back to menu",
            self.term_size, HYPHEN_LINE)
        resDict[constants.DYN_ACTION] = constants.DYNAMIC_REMOVE
        resDict[constants.DYN_TYPE] = dyntype

        while True:
            if not self.acceptExistingEntry(resDict, constants.DYN_ID):
                entryOK = False
                while not entryOK:
                    entryOK = True
                    localMsgs = []
                    if not self.getRawInput(resDict, constants.DYN_ID,
                                            "Enter %s task id" % dyntype,
                                            None):
                        return {}
                    LOG.debug("Field %s entered as %s" % \
                               (constants.DYN_ID, resDict[constants.DYN_ID]))
                    if not self.validator.validExecuteTaskId(\
                                resDict[constants.DYN_ID], dyntype,
                                                    wfsys, localMsgs):
                        self.displayErrors(localMsgs)
                        entryOK = False
                    elif self.validator.hasDependents(\
                                   resDict[constants.DYN_ID], wfsys,
                                     localMsgs):
                        self.displayErrors(localMsgs)
                        entryOK = False
            choice = ""
            while not choice == "q" and not choice == "y" and \
                                                 not choice == "a":
                choice = raw_input(
                   "\nPlease select y to remove %s task, a to amend entry, "
                       "or q to quit back to the main menu without removing "
                     "the task:\n" % \
                       dyntype)
                if choice == "q":
                    LOG.debug("Quitting back to menu")
                    return {}
                if choice == "y":
                    LOG.debug("Dynamic removal ready for action")
                    return resDict
Beispiel #16
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
Beispiel #17
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)
Beispiel #18
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
Beispiel #19
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 {}
Beispiel #20
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)
Beispiel #21
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
Beispiel #22
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
Beispiel #23
0
 def getMenuTag(self, options, err_msg=""):
     """ Displays sub-menu to get tag to run
         Returns:
             True if entered tag
             False if want to quit"""
     utils.outputTitleLines("WORKFLOW ENGINE - Select tag", err_msg,
                            self.term_size, HYPHEN_LINE)
     # if we are using the menu then we cannot be using --list
     tag = raw_input("\nEnter tag to run or enter to quit\n")
     if len(tag) == 0:
         return False
     else:
         options.tag = tag
         options.phase = constants.OPT_EXECUTE
         return self.getMenuServers(options, "{0} tag".format(options.tag),
                                    err_msg)
Beispiel #24
0
 def getExcludeServers(self, options, info, err_msg=""):
     """ Display menu for choosing excluded servers """
     LOG.debug("Getting exclude servers for {0}".format(info))
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(info),
                           err_msg, self.term_size, HYPHEN_LINE)
     print "\nEnter servers to exclude as a comma separated list"
     # if we are using the menu then we cannot be using --list
     if options.unparsed_servertypes == constants.ALL:
         choice = raw_input("\nOr hit return to run on all servers: \n")
     else:
         choice = raw_input("\nOr hit return to run on all {0} servers: \n"\
                                .format(options.unparsed_servertypes))
     if choice == "":
         servers = None
     else:
         servers = choice
     return servers
Beispiel #25
0
 def getExcludeServers(self, options, info, err_msg=""):
     """ Display menu for choosing excluded servers """
     LOG.debug("Getting exclude servers for {0}".format(info))
     utils.outputTitleLines("WORKFLOW ENGINE - {0}".format(info), err_msg,
                            self.term_size, HYPHEN_LINE)
     print "\nEnter servers to exclude as a comma separated list"
     # if we are using the menu then we cannot be using --list
     if options.unparsed_servertypes == constants.ALL:
         choice = raw_input("\nOr hit return to run on all servers: \n")
     else:
         choice = raw_input("\nOr hit return to run on all {0} servers: \n"\
                                .format(options.unparsed_servertypes))
     if choice == "":
         servers = None
     else:
         servers = choice
     return servers
Beispiel #26
0
 def getMenuTag(self, options, err_msg=""):
     """ Displays sub-menu to get tag to run
         Returns:
             True if entered tag
             False if want to quit"""
     utils.outputTitleLines("WORKFLOW ENGINE - Select tag",
                            err_msg, self.term_size, HYPHEN_LINE)
     # if we are using the menu then we cannot be using --list
     tag = raw_input("\nEnter tag to run or enter to quit\n")
     if len(tag) == 0:
         return False
     else:
         options.tag = tag
         options.phase = constants.OPT_EXECUTE
         return self.getMenuServers(options,
                                 "{0} tag".format(options.tag),
                                 err_msg)
Beispiel #27
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)
Beispiel #28
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)
Beispiel #29
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)
Beispiel #30
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)
Beispiel #31
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
Beispiel #32
0
    def getDynamicAddition(self, resDict, dyntype, wfsys):
        """ interactively obtains the details for the dynamic pause/esc
            addition
            Arguments:
                resdict: a dictionary to hold the addition details
                dyntype: specifies whether this is a pause or an escape
                wfsys: workflow sys object used in validation
            Returns:
                dictionary containing the alteration details - empty if
                errors encountered or if quitting
        """
        utils.outputTitleLines(
           "WORKFLOW ENGINE DYNAMIC ALTERATIONS - add %s task" % dyntype,
           "Enter task details, or type q into any field to quit back to menu",
                self.term_size, HYPHEN_LINE)
        resDict[constants.DYN_ACTION] = constants.DYNAMIC_ADD
        resDict[constants.DYN_TYPE] = dyntype
        while True:

            if not self.dynAddField(resDict, constants.DYN_ID,
                   "Enter %s task id" % dyntype, dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_REFID,
                   "Enter reference id (task before/after which new "
                    "task will appear)", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_POS,
                   "Enter [before] to insert before ref task, or "
                     "[after] to insert after", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_MSG,
                   "msg", dyntype, wfsys):
                return {}

            if not self.dynAddHostAndServer(resDict, dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_DEP,
                   "dependency", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_DEPSINGLE,
                   "depsingle", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_SWVER,
                   "swversion", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_OSVER,
                   "osversion", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_CHECKPARAMS,
                   "checkparams", dyntype, wfsys):
                return {}

            LOG.info(self.getDetails(resDict, dyntype))

            choice = ""
            while not choice == "q" and not choice == "y" and \
                       not choice == "a":
                choice = raw_input(
                  "\nPlease select y to insert %s task, a to amend entries, "
                     "or q to quit back to the main menu without inserting "
                     "the task:\n" % \
                       dyntype)
                if choice == "q":
                    LOG.debug("Quitting back to menu")
                    return {}
                if choice == "y":
                    LOG.debug("Dynamic addition ready for action")
                    return resDict
                if choice == "a":
                    LOG.debug("Amending dynamic addition entries")
Beispiel #33
0
    def getDynamicAddition(self, resDict, dyntype, wfsys):
        """ interactively obtains the details for the dynamic pause/esc
            addition
            Arguments:
                resdict: a dictionary to hold the addition details
                dyntype: specifies whether this is a pause or an escape
                wfsys: workflow sys object used in validation
            Returns:
                dictionary containing the alteration details - empty if
                errors encountered or if quitting
        """
        utils.outputTitleLines(
            "WORKFLOW ENGINE DYNAMIC ALTERATIONS - add %s task" % dyntype,
            "Enter task details, or type q into any field to quit back to menu",
            self.term_size, HYPHEN_LINE)
        resDict[constants.DYN_ACTION] = constants.DYNAMIC_ADD
        resDict[constants.DYN_TYPE] = dyntype
        while True:

            if not self.dynAddField(resDict, constants.DYN_ID,
                                    "Enter %s task id" % dyntype, dyntype,
                                    wfsys):
                return {}

            if not self.dynAddField(
                    resDict, constants.DYN_REFID,
                    "Enter reference id (task before/after which new "
                    "task will appear)", dyntype, wfsys):
                return {}

            if not self.dynAddField(
                    resDict, constants.DYN_POS,
                    "Enter [before] to insert before ref task, or "
                    "[after] to insert after", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_MSG, "msg", dyntype,
                                    wfsys):
                return {}

            if not self.dynAddHostAndServer(resDict, dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_DEP, "dependency",
                                    dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_DEPSINGLE,
                                    "depsingle", dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_SWVER, "swversion",
                                    dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_OSVER, "osversion",
                                    dyntype, wfsys):
                return {}

            if not self.dynAddField(resDict, constants.DYN_CHECKPARAMS,
                                    "checkparams", dyntype, wfsys):
                return {}

            LOG.info(self.getDetails(resDict, dyntype))

            choice = ""
            while not choice == "q" and not choice == "y" and \
                       not choice == "a":
                choice = raw_input(
                  "\nPlease select y to insert %s task, a to amend entries, "
                     "or q to quit back to the main menu without inserting "
                     "the task:\n" % \
                       dyntype)
                if choice == "q":
                    LOG.debug("Quitting back to menu")
                    return {}
                if choice == "y":
                    LOG.debug("Dynamic addition ready for action")
                    return resDict
                if choice == "a":
                    LOG.debug("Amending dynamic addition entries")