def test_3_poller_headers(self):
        msg = "Description: Verify header data reported on the poller"
        if fit_common.VERBOSITY >= 2:
            print "\t{0}".format(msg)

        errorlist = []
        for node in NODELIST:
            mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node +
                                           "/pollers")
            self.assertIn(
                mondata['status'], [200],
                "Incorrect HTTP return code, expecting 200, received {}".
                format(mondata['status']))
            if fit_common.VERBOSITY >= 2:
                nodetype = test_api_utils.get_rackhd_nodetype(node)
                print "\nNode: {} Type: {}".format(node, nodetype)

            poller_dict = test_api_utils.get_supported_pollers(node)
            for poller in poller_dict:
                poller_id = poller_dict[poller]["poller_id"]
                if fit_common.VERBOSITY >= 2:
                    print "Poller: {}  ID: {} ".format(poller, str(poller_id))
                poller_data = test_api_utils.get_poller_data_by_id(poller_id)
                if poller_data == []:
                    errorlist.append(
                        "Error: Node {} Poller ID {}, {} failed to return any data"
                        .format(node, poller_id, poller))
                if fit_common.VERBOSITY >= 3:
                    print fit_common.json.dumps(poller_data, indent=4)

        if errorlist != []:
            if fit_common.VERBOSITY >= 2:
                print "{}".format(fit_common.json.dumps(errorlist, indent=4))
            self.assertEqual(errorlist, [], "Error reported.")
    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 = test_api_utils.get_rackhd_nodetype(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)
Exemplo n.º 3
0
    def test_get_poller_status_timestamp(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Display status and timestamp from current poll"
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                print "\nNode: ", node
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    monurl = "/api/2.0/pollers/" + str(
                        poller_id) + "/data/current"
                    mondata = fit_common.rackhdapi(url_cmd=monurl)
                    print "Return status", mondata['status']
                    if mondata['status'] == 200:
                        print "Timestamp:", mondata['json'][0]['timestamp']
                        if fit_common.VERBOSITY >= 2:
                            print fit_common.json.dumps(mondata['json'][0],
                                                        indent=4)
    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 = test_api_utils.get_rackhd_nodetype(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)
    def test_6_poller_status_timestamp(self):
        msg = "Description: Display status and timestamp from current poll"
        if fit_common.VERBOSITY >= 2:
            print "\t{0}".format(msg)

        errorlist = []
        for node in NODELIST:
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            if fit_common.VERBOSITY >= 2:
                print "\nNode: {} Type: {}".format(node, nodetype)
            poller_dict = test_api_utils.get_supported_pollers(node)
            for poller in poller_dict:
                poller_id = poller_dict[poller]["poller_id"]
                if fit_common.VERBOSITY >= 2:
                    print "Poller: {}  ID: {} ".format(poller, str(poller_id))
                monurl = "/api/2.0/pollers/" + str(poller_id) + "/data/current"
                mondata = fit_common.rackhdapi(url_cmd=monurl)
                if mondata['status'] == 200:
                    if fit_common.VERBOSITY >= 2:
                        print "Timestamp: {}".format(
                            mondata['json'][0]['timestamp'])
                else:
                    errorlist.append(
                        "Error: Node {} Poller_ID {} Failed to get current poller data, status {}"
                        .format(node, poller_id, mondata['status']))
        if errorlist != []:
            if fit_common.VERBOSITY >= 2:
                print "{}".format(fit_common.json.dumps(errorlist, indent=4))
            self.assertEqual(errorlist, [], "Error reported.")
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 = test_api_utils.get_rackhd_nodetype(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
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 = test_api_utils.get_rackhd_nodetype(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
    def test_4_poller_default_cache(self):
        msg = "Description: Check number of polls being kept for poller ID"
        if fit_common.VERBOSITY >= 2:
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                nodetype = test_api_utils.get_rackhd_nodetype(node)
                print "Node: {}  Type: {}".format(node, nodetype)
        errorlist = []
        for node in NODELIST:
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            if fit_common.VERBOSITY >= 2:
                print "\nNode: {} Type: {}".format(node, nodetype)

            poller_dict = test_api_utils.get_supported_pollers(node)
            for poller in poller_dict:
                poller_id = poller_dict[poller]["poller_id"]
                poller_data = test_api_utils.get_poller_data_by_id(poller_id)
                poll_len = len(poller_data)
                if fit_common.VERBOSITY >= 2:
                    print "Poller: {}  ID: {} ".format(poller, str(poller_id))
                    print "Number of polls for " + str(poller_id) + ": " + str(
                        len(poller_data))
                if poll_len > 10:
                    errorlist.append(
                        'Error: Poller {} ID: {} - Number of cached polls should not exceed 10'
                        .format(poller_id, poller))
                elif poll_len == 0:
                    errorlist.append(
                        'Error: Poller {} ID: {} - Pollers not running'.format(
                            poller_id, poller))

        if errorlist != []:
            if fit_common.VERBOSITY >= 2:
                print "{}".format(fit_common.json.dumps(errorlist, indent=4))
            self.assertEqual(errorlist, [], "Error reported.")
    def test_2_pollers_by_id(self):
        msg = "Description: Display the poller data per node."
        if fit_common.VERBOSITY >= 2:
            print "\t{0}".format(msg)

        errorlist = []
        poller_list = [
            'driveHealth', 'sel', 'chassis', 'selInformation', 'sdr'
        ]
        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                nodetype = test_api_utils.get_rackhd_nodetype(node)
                print "Node: {}  Type: {}".format(node, nodetype)
            mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node +
                                           "/pollers")
            self.assertIn(
                mondata['status'], [200],
                "Incorrect HTTP return code, expecting 200, received {}".
                format(mondata['status']))

            # check required fields
            for item in mondata['json']:
                if item['pollInterval'] == 0:
                    errorlist.append(
                        "Node: {} pollInterval field error: {}".format(
                            node, item['pollInterval']))
                for subitem in [
                        'node', 'config', 'createdAt', 'id', 'name', 'config'
                ]:
                    if subitem not in item:
                        errorlist.append("Node: {} field error: {}".format(
                            node, subitem))

            # display poller data for the node
            poller_dict = test_api_utils.get_supported_pollers(node)
            for poller in poller_dict:
                poller_id = poller_dict[poller]["poller_id"]
                if fit_common.VERBOSITY >= 2:
                    print "Poller: {}  ID: {} ".format(poller, str(poller_id))
                poll_data = fit_common.rackhdapi("/api/2.0/pollers/" +
                                                 poller_id)
                if fit_common.VERBOSITY >= 3:
                    print fit_common.json.dumps(poll_data.get('json', ""),
                                                indent=4)

        if errorlist != []:
            if fit_common.VERBOSITY >= 2:
                print "{}".format(fit_common.json.dumps(errorlist, indent=4))
            self.assertEqual(errorlist, [], "Error reported.")
    def test_display_raid_controller_firmware(self):

        inode = 1
        for node in NODELIST:
            print "==== Displaying MegaRAID and Controller info ===="
            source_set = []
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            print "\nNode " + str(inode) + ": " + node
            print "Type: ", nodetype
            if nodetype != "unknown" and nodetype != "Unmanaged":
                monurl = "/api/1.1/nodes/" + node + "/catalogs"
                mondata = fit_common.rackhdapi(monurl, action="get")
                catalog = mondata['json']
                result = mondata['status']
                if result != 200:
                    print "ERROR: failed catalog request"
                else:
                    source_set = test_api_utils.get_node_source_id_list(node)
                    if 'megaraid-controllers' in source_set:
                        print "Source: megaraid-controllers\n"
                        raidurl = "/api/1.1/nodes/" + node + "/catalogs/megaraid-controllers"
                        raiddata = fit_common.rackhdapi(raidurl, action="get")
                        catalog = raiddata['json']
                        result = raiddata['status']
                        print " Basics: ", catalog["data"]["Controllers"][0][
                            "Command Status"]
                        print " Version: ",
                        pprint.pprint(catalog["data"]["Controllers"][0]
                                      ["Response Data"]["Version"])
                    else:
                        print "Info: monorail catalog did not contain megraid-controllers source"
                    # display controller data if available, no firmware revs are present in the output
                    device_ids = redfish_simple_storage_members(node)
                    for dev_id in device_ids:
                        devurl = "/redfish/v1/Systems/" + node + "/SimpleStorage/" + dev_id
                        devdata = fit_common.rackhdapi(url_cmd=devurl)
                        controller = devdata['json']
                        result = devdata['status']
                        if result == 200:
                            controller = devdata['json']
                            print "Controller: " + str(
                                dev_id) + " Name: " + str(
                                    controller.get('Name', ""))
                            print "Description: ", json.dumps(controller.get(
                                'Description', ""),
                                                              indent=4)
            inode += 1
        print "========================================================="
 def test_display_raid_controller_firmware(self):
     # This test displays the MegaRaid controller firmware data from the compute
     # node if it exists.  It then displays the controller info contained in the
     # RackHD redfish managed system data
     # No asserts are used in this test, avoiding early exit on errors
     inode = 1
     for node in NODELIST:
         print "==== Displaying MegaRAID and Controller info ===="
         source_set = []
         nodetype = test_api_utils.get_rackhd_nodetype(node)
         print "\nNode " + str(inode) + ": " + node
         print "Type: ", nodetype
         if nodetype != "unknown" and nodetype != "Unmanaged":
             monurl = "/api/2.0/nodes/" + node + "/catalogs"
             mondata = fit_common.rackhdapi(monurl, action="get")
             catalog = mondata['json']
             result = mondata['status']
             if result != 200:
                 print "ERROR: failed catalog request"
             else:
                 source_set = test_api_utils.get_node_source_id_list(node)
                 if 'megaraid-controllers' in source_set:
                     print "Source: megaraid-controllers\n"
                     raidurl = "/api/2.0/nodes/" + node + "/catalogs/megaraid-controllers"
                     raiddata = fit_common.rackhdapi(raidurl, action="get")
                     catalog = raiddata['json']
                     result = raiddata['status']
                     print " Basics: ", catalog["data"]["Controllers"][0]["Command Status"]
                     print " Version: ",
                     pprint.pprint(catalog["data"]["Controllers"][0]["Response Data"]["Version"])
                 else:
                     print "Info: monorail catalog did not contain megraid-controllers source"
                 # display controller data if available, no firmware revs are present in the output
                 device_ids = redfish_simple_storage_members(node)
                 for dev_id in device_ids:
                     devurl = "/redfish/v1/Systems/" + node + "/SimpleStorage/" + dev_id
                     devdata = fit_common.rackhdapi(url_cmd=devurl)
                     controller = devdata['json']
                     result = devdata['status']
                     if result == 200:
                         controller = devdata['json']
                         print "Controller: " + str(dev_id) + " Name: " + str(controller.get('Name', ""))
                         print "Description: ", json.dumps(controller.get('Description', ""), indent=4)
         inode += 1
     print "========================================================="
    def test_1_verify_pollers(self):
        msg = "Description: Check pollers created for node"
        if fit_common.VERBOSITY >= 2:
            print "\t{0}".format(msg)

        errorlist = []
        poller_list = [
            'driveHealth', 'sel', 'chassis', 'selInformation', 'sdr',
            'selEntries'
        ]
        if fit_common.VERBOSITY >= 2:
            print "Expected Pollers for a Node: ".format(poller_list)
        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                nodetype = test_api_utils.get_rackhd_nodetype(node)
                print "\nNode: {}  Type: {}".format(node, nodetype)
            mondata = fit_common.rackhdapi("/api/2.0/nodes/" + node +
                                           "/pollers")
            self.assertIn(
                mondata['status'], [200],
                "Incorrect HTTP return code, expecting 200, received {}".
                format(mondata['status']))

            poller_dict = test_api_utils.get_supported_pollers(node)
            if set(poller_list) == set(poller_dict):
                if fit_common.VERBOSITY >= 2:
                    print "Expected pollers instantiated on node"
                if fit_common.VERBOSITY >= 3:
                    print "Poller list retreived", poller_dict
            else:
                if list(set(poller_list) - set(poller_dict)):
                    errorlist.append(
                        "Error: Node {} Pollers not running {}".format(
                            node, list(set(poller_list) - set(poller_dict))))
                if list(set(poller_dict) - set(poller_list)):
                    errorlist.append(
                        "Error: Node {} Unexpected Pollers running {}".format(
                            node, list(set(poller_dict) - set(poller_list))))

        if errorlist != []:
            if fit_common.VERBOSITY >= 2:
                print "{}".format(fit_common.json.dumps(errorlist, indent=4))
            self.assertEqual(errorlist, [], "Error reported.")
Exemplo n.º 13
0
 def test_display_bmc_mc_info(self):
     # This test displays the BMC MC info from the compute node via
     # IPMI call ipmitool mc info
     # No asserts are used in this test, avoiding early exit on errors
     inode = 1
     for node in NODELIST:
         print "==== Displaying BMC MC info ===="
         nodetype = test_api_utils.get_rackhd_nodetype(node)
         print "\nNode " + str(inode) + ": " + node
         print "Type: ", nodetype
         if nodetype != "unknown" and nodetype != "Unmanaged":
             nodeurl = "/api/2.0/nodes/" + node
             nodedata = fit_common.rackhdapi(nodeurl, action="get")
             nodeinfo = nodedata['json']
             result = nodedata['status']
             if result != 200:
                 print "Error on node command" + nodeurl
             else:
                 try:
                     obmlist = nodeinfo["obmSettings"]
                 except:
                     print "ERROR: Node has no OBM settings configured"
                 else:
                     if obmlist:
                         bmc_ip = test_api_utils.get_compute_bmc_ip(node)
                         if bmc_ip in [1, 2]:
                             print "No BMC IP found"
                         elif bmc_ip.startswith('192.168'):
                             print "ERROR: BAD BMC Value: ", bmc_ip
                         else:
                             user_cred = test_api_utils.get_compute_node_username(node)
                             if user_cred in [1, 2, 3, 4]:
                                 print "Unable to get user credetials for node_id", node
                             else:
                                 mc_data = test_api_utils.run_ipmi_command(bmc_ip, 'mc info', user_cred)
                                 if mc_data['exitcode'] == 0:
                                     print "MC Data: "
                                     print mc_data['stdout']
                     else:
                         print "ERROR: Node has no OBM settings configured"
             inode += 1
     print "=========================================================\n"
    def test_get_current_poller_data(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Display most current data from poller"
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                print "\nNode: ", node
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    monurl = "/api/2.0/pollers/" + str(poller_id) + "/data/current"
                    mondata = fit_common.rackhdapi(url_cmd=monurl)
                    if fit_common.VERBOSITY >= 2:
                        print fit_common.json.dumps(mondata, indent=4)
    def test_verify_poller_data(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Check number of polls being kept for poller ID"
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                print "\nNode: ", node
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    poller_data = test_api_utils.get_poller_data_by_id(poller_id)
                    poll_len = len(poller_data)
                    print "Number of polls for "+ str(poller_id) + ": " + str(len(poller_data))
                    self.assertLessEqual(poll_len, 10, 'Number of cached polls should not exceed 10')
    def test_verify_poller_headers(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Verify header data reported on the poller"
            print "\t{0}".format(msg)

        for node in NODELIST:
            mon_data = fit_common.rackhdapi("/api/2.0/nodes/" + node + "/pollers")
            self.assertIn(mon_data['status'], [200], "Incorrect HTTP return code")
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            if fit_common.VERBOSITY >= 2:
                print "\nNode: {} Type: {}".format(node, nodetype)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    poller_data = test_api_utils.get_poller_data_by_id(poller_id)
                    if fit_common.VERBOSITY >= 3:
                        print fit_common.json.dumps(poller_data, indent=4)
Exemplo n.º 17
0
    def test_get_current_poller_data(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Display most current data from poller"
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                print "\nNode: ", node
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    monurl = "/api/2.0/pollers/" + str(
                        poller_id) + "/data/current"
                    mondata = fit_common.rackhdapi(url_cmd=monurl)
                    if fit_common.VERBOSITY >= 2:
                        print fit_common.json.dumps(mondata, indent=4)
    def test_get_poller_status_timestamp(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Display status and timestamp from current poll"
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                print "\nNode: ", node
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    monurl = "/api/2.0/pollers/" + str(poller_id) + "/data/current"
                    mondata = fit_common.rackhdapi(url_cmd=monurl)
                    print "Return status", mondata['status']
                    if mondata['status'] == 200:
                        print "Timestamp:", mondata['json'][0]['timestamp']
                        if fit_common.VERBOSITY >= 2:
                            print fit_common.json.dumps(mondata['json'][0], indent=4)
Exemplo n.º 19
0
    def test_verify_poller_headers(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Verify header data reported on the poller"
            print "\t{0}".format(msg)

        for node in NODELIST:
            mon_data = fit_common.rackhdapi("/api/2.0/nodes/" + node +
                                            "/pollers")
            self.assertIn(mon_data['status'], [200],
                          "Incorrect HTTP return code")
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            if fit_common.VERBOSITY >= 2:
                print "\nNode: {} Type: {}".format(node, nodetype)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    poller_data = test_api_utils.get_poller_data_by_id(
                        poller_id)
                    if fit_common.VERBOSITY >= 3:
                        print fit_common.json.dumps(poller_data, indent=4)
Exemplo n.º 20
0
    def test_verify_poller_data(self):
        if fit_common.VERBOSITY >= 2:
            msg = "Description: Check number of polls being kept for poller ID"
            print "\t{0}".format(msg)

        for node in NODELIST:
            if fit_common.VERBOSITY >= 2:
                print "\nNode: ", node
            nodetype = test_api_utils.get_rackhd_nodetype(node)
            # Run test against managed nodes only
            if nodetype != "unknown" and nodetype != "Unmanaged":
                poller_dict = test_api_utils.get_supported_pollers(node)

                for poller in poller_dict:
                    poller_id = poller_dict[poller]["poller_id"]
                    print "\nPoller: " + poller + " ID: " + str(poller_id)
                    poller_data = test_api_utils.get_poller_data_by_id(
                        poller_id)
                    poll_len = len(poller_data)
                    print "Number of polls for " + str(poller_id) + ": " + str(
                        len(poller_data))
                    self.assertLessEqual(
                        poll_len, 10,
                        'Number of cached polls should not exceed 10')
Exemplo n.º 21
0
    def test99_display_node_list_discovery_data(self):
        # This test displays a list of the nodes along with
        # the associated BMC, RMM, and OBM settings for the discovered compute nodes
        fit_common.VERBOSITY = 1  # this is needed for suppressing debug messages to make reports readable
        mondata = fit_common.rackhdapi("/api/2.0/nodes")
        nodes = mondata['json']
        result = mondata['status']

        if result == 200:
            log.info_1(" NODE INVENTORY")
            log.info_1(" Number of nodes found: %s", str(len(nodes)))
            i = 0
            for node in nodes:
                i += 1
                nn = node["id"]
                log.info_1(" ************************")
                log.info_1(" Node %s: %s", str(i), nn)
                # Check type of node and display info
                nodetype = node['type']
                if nodetype != "compute":
                    log.info_1(" Node Type: %s ", nodetype)
                    if nodetype == "enclosure":
                        log.info_1(" Node Name: %s", node['name'])
                        nodelist = test_api_utils.get_relations_for_node(nn)
                        if nodelist:
                            log.info_1(" Nodes contained in this enclosure: %s", nodelist)
                        else:
                            log.info_1(" No Nodes found in this enclosure")
                else:
                    # If compute node, display BMC, RMM and IP info
                    nodetype = test_api_utils.get_rackhd_nodetype(nn)
                    log.info_1(" Compute Node Type: %s", nodetype)
                    enclosure = test_api_utils.get_relations_for_node(nn)
                    if enclosure:
                        log.info_1(" In Enclosure: %s ", enclosure[0])
                    else:
                        log.info_1(" Not associated with a monorail enclosure")
                    # try to get the BMC info from the catalog
                    monurl = "/api/2.0/nodes/" + nn + "/catalogs/bmc"
                    mondata = fit_common.rackhdapi(monurl, action="get")
                    catalog = mondata['json']
                    bmcresult = mondata['status']
                    if bmcresult != 200:
                        log.info_1(" Error on catalog/bmc command")
                    else:
                        log.info_1(" BMC Mac: %s", catalog["data"]["MAC Address"])
                        log.info_1(" BMC IP Addr: %s", catalog["data"]["IP Address"])
                        log.info_1(" BMC IP Addr Src: %s", catalog["data"]["IP Address Source"])
                    # Get RMM info from the catalog, if present
                    rmmurl = "/api/2.0/nodes/" + nn + "/catalogs/rmm"
                    rmmdata = fit_common.rackhdapi(rmmurl, action="get")
                    rmmcatalog = rmmdata['json']
                    rmmresult = rmmdata['status']
                    if rmmresult != 200:
                        log.info_1(" No RMM catalog entry.")
                    else:
                        log.info_1(" RMM Mac: %s", rmmcatalog["data"].get("MAC Address", " "))
                        log.info_1(" RMM IP: %s", rmmcatalog["data"].get("IP Address", " "))
                        log.info_1(" RMM IP Addr source: %s", rmmcatalog["data"].get("IP Address Source", " "))

                    nodeurl = "/api/2.0/nodes/" + nn
                    nodedata = fit_common.rackhdapi(nodeurl, action="get")
                    nodeinfo = nodedata['json']
                    result = nodedata['status']
                    if result != 200:
                        log.info_1(" Error on node commandi %s http response %s", nodeurl, result)
                    else:
                        # Check BMC IP vs OBM IP setting
                        try:
                            obmlist = nodeinfo["obms"]
                        except:
                            log.info_1(" ERROR: Node has no OBM settings configured")
                        else:
                            try:
                                obmurl = obmlist[0]['ref']
                                obmdata = fit_common.rackhdapi(obmurl, action="get")
                            except:
                                log.info_1("   Invalid or empty OBM settings on Node")
                            else:
                                log.info_1(" obmhost: %s", obmdata['json']["config"].get("host", "Error: No Host in obmdata"))
                                log.info_1(" obmuser: %s", obmdata['json']["config"].get("user", "Error: No User defined!"))
        else:
            log.info_1("Cannot get RackHD nodes from stack, http response code: %s", result)
Exemplo n.º 22
0
    def test_display_node_list_discovery_data(self):
        # This test displays a list of the nodes along with
        # the associated BMC, RMM, and OBM settings for the discovered compute nodes
        mondata = fit_common.rackhdapi("/api/2.0/nodes")
        nodes = mondata['json']
        result = mondata['status']

        if result == 200:
            # print "result" + str(result)
            # Display node info
            print "\nNumber of nodes found: " + str(len(nodes)) + "\n"
            i = 0
            for node in nodes:
                i += 1
                print ""
                nn = node["id"]
                print "Node {0}: {1}".format(str(i), nn)
                # Check type of node and display info
                nodetype = node['type']
                if nodetype != "compute":
                    print "Node Type: ", nodetype
                    if nodetype == "enclosure":
                        print "Node Name: ", node['name']
                        nodelist = test_api_utils.get_relations_for_node(nn)
                        if nodelist:
                            print "Nodes contained in this enclosure: ", nodelist
                        else:
                            print "No Nodes found in this enclosure"
                else:
                    # If compute node, display BMC, RMM and IP info
                    nodetype = test_api_utils.get_rackhd_nodetype(nn)
                    print "Compute Node Type: ", nodetype
                    enclosure = test_api_utils.get_relations_for_node(nn)
                    if enclosure:
                        print "In Enclosure: ", enclosure[0]
                    else:
                        print "Not associated with a monorail enclosure"
                    # try to get the BMC info from the catalog
                    monurl = "/api/2.0/nodes/" + nn + "/catalogs/bmc"
                    mondata = fit_common.rackhdapi(monurl, action="get")
                    catalog = mondata['json']
                    bmcresult = mondata['status']
                    print "BMC MAC Address",
                    print "\tBMC IP Address",
                    print "\tBMC IP Source",
                    print "\tRMM MAC Address",
                    print "\tRMM IP Address",
                    print "\tRMM IP Source",
                    print "\tOBM Host",
                    print "\t\tOBM User"
                    if bmcresult != 200:
                        print "Error on catalog/bmc command",
                    else:
                        print catalog["data"]["MAC Address"],
                        print "\t" + catalog["data"]["IP Address"],
                        print "\t" + catalog["data"]["IP Address Source"],
                    # Get RMM info from the catalog, if present
                    rmmurl = "/api/2.0/nodes/" + nn + "/catalogs/rmm"
                    rmmdata = fit_common.rackhdapi(rmmurl, action="get")
                    rmmcatalog = rmmdata['json']
                    rmmresult = rmmdata['status']
                    if rmmresult != 200:
                        print "\tNo RMM catalog entry.\t\t\t\t\t",
                    else:
                        print "\t" + rmmcatalog["data"].get(
                            "MAC Address", "-"),
                        print "\t" + rmmcatalog["data"].get("IP Address", "-"),
                        print "\t" + rmmcatalog["data"].get(
                            "IP Address Source", "-") + "\t",

                    nodeurl = "/api/2.0/nodes/" + nn
                    nodedata = fit_common.rackhdapi(nodeurl, action="get")
                    nodeinfo = nodedata['json']
                    result = nodedata['status']
                    if result != 200:
                        print "Error on node command" + nodeurl + ", http response:  " + result
                    else:
                        # Check BMC IP vs OBM IP setting
                        try:
                            obmlist = nodeinfo["obmSettings"]
                        except:
                            print "ERROR: Node has no OBM settings configured"
                        else:
                            try:
                                obmhost = obmlist[0]["config"]["host"]
                            except:
                                print "Invalid or empty OBM setting"
                            else:
                                print obmhost,
                                print "\t" + obmlist[0]["config"].get(
                                    "user", "Error: No User defined!")
        else:
            print "Cannot get RackHD nodes from stack, http response code: ", result
Exemplo n.º 23
0
    def test_display_node_list_discovery_data(self):
        # This test displays a list of the nodes along with 
        # the associated BMC, RMM, and OBM settings for the discovered compute nodes 
        mondata = fit_common.rackhdapi("/api/1.1/nodes")
        nodes = mondata['json']
        result = mondata['status']

        if result == 200:
            #print "result" + str(result)
            # Display node info
            print "\nNumber of nodes found: "+str(len(nodes))+"\n"
            i = 0
            for node in nodes:
                i += 1
                print ""
                nn = node["id"]
                print "Node {0}: {1}".format(str(i), nn)
                # Check type of node and display info
                nodetype = node['type']
                if nodetype != "compute":
                    print "Node Type: ", nodetype
                    if nodetype == "enclosure":
                        print "Node Name: ", node['name']
                        nodelist = test_api_utils.get_relations_for_node(nn)
                        if nodelist:
                            print "Nodes contained in this enclosure: ", nodelist
                        else:
                            print "No Nodes found in this enclosure"
                else:
                    # If compute node, display BMC, RMM and IP info
                    nodetype = test_api_utils.get_rackhd_nodetype(nn)
                    print "Compute Node Type: ", nodetype
                    enclosure = test_api_utils.get_relations_for_node(nn)
                    if enclosure:
                        print "In Enclosure: ", enclosure[0]
                    else:
                        print "Not associated with a monorail enclosure"
                    # try to get the BMC info from the catalog
                    monurl = "/api/1.1/nodes/"+nn+"/catalogs/bmc"
                    mondata = fit_common.rackhdapi(monurl, action="get")
                    catalog = mondata['json']
                    bmcresult = mondata['status']
                    print "BMC MAC Address",
                    print "\tBMC IP Address",
                    print "\tBMC IP Source",
                    print "\tRMM MAC Address",
                    print "\tRMM IP Address",
                    print "\tRMM IP Source",
                    print "\tOBM Host",
                    print "\t\tOBM User"
                    if bmcresult != 200:
                        print "Error on catalog/bmc command",
                    else:
                        print catalog["data"]["MAC Address"],
                        print "\t" + catalog["data"]["IP Address"],
                        print "\t" + catalog["data"]["IP Address Source"],
                    # Get RMM info from the catalog, if present
                    rmmurl = "/api/1.1/nodes/"+nn+"/catalogs/rmm"
                    rmmdata = fit_common.rackhdapi(rmmurl, action="get")
                    rmmcatalog = rmmdata['json']
                    rmmresult = rmmdata['status']
                    if rmmresult != 200:
                        print "\tNo RMM catalog entry.\t\t\t\t\t",
                    else:
                        print "\t" + rmmcatalog["data"].get("MAC Address", "-"),
                        print "\t" + rmmcatalog["data"].get("IP Address", "-"),
                        print "\t" + rmmcatalog["data"].get("IP Address Source", "-") + "\t",

                    nodeurl = "/api/1.1/nodes/"+nn
                    nodedata = fit_common.rackhdapi(nodeurl, action="get")
                    nodeinfo = nodedata['json']
                    result = nodedata['status']
                    if result != 200:
                        print "Error on node command" + nodeurl + ", http response:  " + result
                    else:
                        # Check BMC IP vs OBM IP setting
                        try:
                            obmlist = nodeinfo["obmSettings"]
                        except:
                            print "ERROR: Node has no OBM settings configured"
                        else:
                            try:
                                obmhost = obmlist[0]["config"]["host"]
                            except:
                                print "Invalid or empty OBM setting"
                            else:
                                print obmhost,
                                print "\t" + obmlist[0]["config"].get("user","Error: No User defined!")
        else:
            print "Cannot get RackHD nodes from stack, http response code: ", result