Example #1
0
    def test_4_redfish_v1_computer_reset_force_restart(self):
        # This test will verify the compute node workflow power reset option ForceRestart
        # and corresponding task status.

        if fit_common.VERBOSITY >= 2:
            msg = "Description: Verify Redfish ComputerSystem.reset option \"ForceRestart\" task data"
            print("\n\t{}".format(msg))

        errorlist = []
        tasklist = []

        for node in NODELIST:
            nodetype = fit_common.get_node_sku(node)
            if fit_common.VERBOSITY >= 2:
                print("\n===============================")
                print("\nNode: {} {}".format(node, nodetype))
                print("\nPower node via ComputerSystem.reset ForceRestart")

            # Perform ComputerSystem.reset ForceRestart command
            taskid = rackhd_compute_node_power_action(node, "ForceRestart")
            if taskid:
                tasklist.append(taskid)

        # Poll for task end status
        tasktype = "Reboot Node"
        errorlist = workflow_tasklist_status_poller(tasklist, tasktype)

        if errorlist:
            print json.dumps(errorlist, indent=4)
        self.assertEqual(errorlist, [], "Errors found".format(errorlist))

        # allow power action to work a little
        time.sleep(20)
Example #2
0
def workflow_tasklist_status_poller(tasklist, tasktype, timeout=180):
    """
    This utility will poll the list of taskids for a change from Running state
    It will poll for the specified timeout.
    :param taskid:  list of task ids to poll
    :param timeout: timeout in seconds when polling should fail, default is 600 seconds, 10 minutes
    :return:
        errorlist of taskids, node, status
    """
    count = 0           # loops for timeout
    polltime = 3        # sleep 3 seconds
    taskid_json = []
    task_errorlist = []

    # if timeout set too short, make it one above polltime
    if timeout < polltime:
        timeout = polltime + 1

    if fit_common.VERBOSITY >= 2:
        print("\n===============================")
        print("Polling for power update task completion....")

    # spin thru the list of tasks and taskstates
    while count < timeout:
        for task in tasklist:
            taskid_json = get_taskid_data(task)
            if taskid_json:
                if taskid_json.get("Name") != tasktype:
                    task_errorlist.append("Error: TaskName incorrect, expected {}".format(tasktype))
                taskstate = taskid_json.get("TaskState")
                if taskstate in ['Exception','Killed']: 
                    node = taskid_json["Oem"]["RackHD"].get('SystemId')
                    nodetype = fit_common.get_node_sku(node)
                    task_errorlist.append("Error: Node {} {} Task Failure: {}".format(node, nodetype, taskid_json))
                    tasklist.remove(task)
                elif taskstate in ['Completed']: 
                   # quit polling the completed tasks, remove from list
                    tasklist.remove(task)
        # break out of loop if all tasks have ended
        if not tasklist:
            break
        time.sleep(polltime)
        count += polltime

    # if any tasks left in tasklist, add to error list
    if tasklist:
        task_errorlist.append("Error: Timeout on Task Completion: {} ".format(tasklist))
        for task in tasklist:
            task_errorlist.append("Error Task: {}, {}".format(task, get_taskid_data(task)))

    return task_errorlist