def setUpClass(cls): # Get the list of nodes NODECATALOG = fit_common.node_select() # Select one node at random cls.__NODE = NODECATALOG[random.randint(0, len(NODECATALOG) - 1)] # delete active workflows for specified node fit_common.cancel_active_workflows(cls.__NODE)
def setUpClass(cls): # run all OS install workflows first nodeindex = 0 for item in OSLIST: # if OS proxy entry exists in RackHD config, run bootstrap against selected node if nodeindex < len(NODECATALOG): # delete active workflows for specified node fit_common.cancel_active_workflows(NODECATALOG[nodeindex]) # base payload common to all Linux payload_data = {"options": {"defaults": { "version": item['version'], "repo": rackhdhost + item['path'], "rootPassword": "******", "hostname": "rackhdnode", "users": [{"name": "rackhduser", "password": "******", "uid": 1010}]}}, "reboot": "ipmi-obm-service", "set-boot-pxe": "ipmi-obm-service"} # OS specific payload requirements if item['workflow'] == "Graph.InstallUbuntu": payload_data["options"]["defaults"]["baseUrl"] = "install/netboot/ubuntu-installer/amd64" payload_data["options"]["defaults"]["kargs"] = {"live-installer/net-image": rackhdhost + item['path'] + "/ubuntu/install/filesystem.squashfs"} # run workflow result = fit_common.rackhdapi('/api/2.0/nodes/' + NODECATALOG[nodeindex] + '/workflows?name=' + item['workflow'], action='post', payload=payload_data) if result['status'] == 201: # this saves the task and node IDs NODE_STATUS[NODECATALOG[nodeindex]] = \ {"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], "id": result['json']['instanceId'], "nodeID": NODECATALOG[nodeindex], "StartTime": fit_common.time.time(), "EndTime": 0} log.info_5(" Workflow: %s TaskID: %s", item['workflow'], result['json']['instanceId']) log.info_5(" Payload: " + fit_common.json.dumps(payload_data)) else: # if no task ID is returned put 'failed' in ID field NODE_STATUS[NODECATALOG[nodeindex]] = \ {"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], 'id': "failed", "wf_stime": "", "wf_etime": ""} log.error(" OS install %s on node %s failed!", item['workflow'], NODECATALOG[nodeindex]) log.error(" Error text: %s", result['text']) log.error(" Payload: " + fit_common.json.dumps(payload_data)) # increment node index to run next bootstrap nodeindex += 1
def test_redfish_v1_updateservice_actions_updateservicesimpleupdate_post(self): nodeid = NODECATALOG[0] fit_common.cancel_active_workflows(nodeid) on_payload = {"ImageURI": "/dummy.exe", "Targets": [nodeid]} api_data = fit_common.rackhdapi('/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate', action='post', payload=on_payload) self.assertEqual(api_data['status'], 201, 'Incorrect HTTP return code, expected 201, got:' + str(api_data['status'])) task_data = fit_common.rackhdapi(api_data['json']['@odata.id']) self.assertEqual(task_data['status'], 200, "No task ID found ") task_state = task_data['json']['TaskState'] self.assertIn(task_state, ["Running", "Pending", "Completed", "Exception"], "Bad task state for node:" + nodeid + " state:" + task_state)
def setUpClass(cls): # run all OS install workflows first nodeindex = 0 for item in OSLIST: # if OS proxy entry exists in RackHD config, run bootstrap against selected node if proxy_select(item['path']) and nodeindex < len(NODECATALOG): # delete active workflows for specified node fit_common.cancel_active_workflows(NODECATALOG[nodeindex]) # base payload common to all Linux payload_data = {"options": {"defaults": { "version": item['version'], "kvm": item['kvm'], "repo": statichost + proxy_select(item['path']), "rootPassword": "******", "hostname": "rackhdnode", "dnsServers": [rackhdconfig['apiServerAddress']], "users": [{"name": "rackhduser", "password": "******", "uid": 1010}]}}} # OS specific payload requirements if item['workflow'] == "Graph.InstallUbuntu": payload_data["options"]["defaults"]["baseUrl"] = "install/netboot/ubuntu-installer/amd64" payload_data["options"]["defaults"]["kargs"] = {"live-installer/net-image": statichost + proxy_select(item['path']) + "/ubuntu/install/filesystem.squashfs"} # run workflow result = fit_common.rackhdapi('/api/2.0/nodes/' + NODECATALOG[nodeindex] + '/workflows?name=' + item['workflow'], action='post', payload=payload_data) if result['status'] == 201: # this saves the task and node IDs NODE_STATUS[NODECATALOG[nodeindex]] = \ {"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], "id": result['json']['instanceId']} log.info_5(" TaskID: " + result['json']['instanceId']) log.info_5(" Payload: " + fit_common.json.dumps(payload_data)) else: # if no task ID is returned put 'failed' in ID field NODE_STATUS[NODECATALOG[nodeindex]] = \ {"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], 'id': "failed"} log.error(" OS install " + item['workflow'] + " on node " + NODECATALOG[nodeindex] + " failed! ") log.error(" Error text: " + result['text']) log.error(" Payload: " + fit_common.json.dumps(payload_data)) # increment node index to run next bootstrap nodeindex += 1
def setUpClass(cls): # run all OS install workflows first nodeindex = 0 for item in OSLIST: # if OS proxy entry exists in RackHD config, run bootstrap against selected node if proxy_select(item['path']) and nodeindex < len(NODECATALOG): # delete active workflows for specified node fit_common.cancel_active_workflows(NODECATALOG[nodeindex]) payload_data = { "osName": item['os'], "version": item['version'], "kvm": item['kvm'], "repo": rackhdhost + proxy_select(item['path']), "rootPassword": "******", "hostname": "rackhdnode", "dnsServers": [rackhdconfig['apiServerAddress']], "users": [{ "name": "rackhd", "password": "******", "uid": 1010 }] } result = fit_common.rackhdapi('/redfish/v1/Systems/' + NODECATALOG[nodeindex] + '/Actions/RackHD.BootImage', action='post', payload=payload_data) if result['status'] == 202: # this branch saves the task and node IDs NODE_STATUS[NODECATALOG[nodeindex]] = \ {"os": item['os'], "version": item['version'], "id": result['json']['@odata.id']} log.info_5(" TaskID: " + result['text']) log.info_5(" Payload: " + fit_common.json.dumps(payload_data)) else: # this is the failure case where there is no task ID NODE_STATUS[NODECATALOG[nodeindex]] = \ {"os": item['os'], "version": item['version'], 'id': "/redfish/v1/taskservice/tasks/failed"} log.error(" TaskID: " + result['text']) log.error(" Payload: " + fit_common.json.dumps(payload_data)) # increment node index to run next bootstrap nodeindex += 1
def setUpClass(cls): # Get the list of nodes NODECATALOG = fit_common.node_select() assert (len(NODECATALOG) != 0), "There are no nodes currently discovered" # Select one node at random cls.__NODE = NODECATALOG[random.randint(0, len(NODECATALOG) - 1)] # Print node Id, node BMC mac ,node type nodeinfo = fit_common.rackhdapi('/api/2.0/nodes/' + cls.__NODE)['json'] nodesku = fit_common.rackhdapi(nodeinfo.get('sku'))['json']['name'] monurl = "/api/2.0/nodes/" + cls.__NODE + "/catalogs/bmc" mondata = fit_common.rackhdapi(monurl, action="get") catalog = mondata['json'] bmcresult = mondata['status'] if bmcresult != 200: log.info_1(" Node ID: " + cls.__NODE) log.info_1(" Error on catalog/bmc command") else: log.info_1(" Node ID: " + cls.__NODE) log.info_1(" Node SKU: " + nodesku) log.info_1(" Node BMC Mac: %s", catalog.get('data')['MAC Address']) log.info_1(" Node BMC IP Addr: %s", catalog.get('data')['IP Address']) log.info_1(" Node BMC IP Addr Src: %s", catalog.get('data')['IP Address Source']) # delete active workflows for specified node result = fit_common.cancel_active_workflows(cls.__NODE) assert (result is True), "There are still some active workflows running against the node"
def setUpClass(cls): # Get the list of nodes NODECATALOG = fit_common.node_select() assert (len(NODECATALOG) != 0), "There are no nodes currently discovered" # Select one node at random cls.__NODE = NODECATALOG[random.randint(0, len(NODECATALOG) - 1)] # Print node Id, node BMC mac ,node type nodeinfo = fit_common.rackhdapi('/api/2.0/nodes/' + cls.__NODE)['json'] nodesku = fit_common.rackhdapi(nodeinfo.get('sku'))['json']['name'] monurl = "/api/2.0/nodes/" + cls.__NODE + "/catalogs/bmc" mondata = fit_common.rackhdapi(monurl, action="get") catalog = mondata['json'] bmcresult = mondata['status'] if bmcresult != 200: log.info_1(" Node ID: " + cls.__NODE) log.info_1(" Error on catalog/bmc command") else: log.info_1(" Node ID: " + cls.__NODE) log.info_1(" Node SKU: " + nodesku) log.info_1(" Node BMC Mac: %s", catalog.get('data')['MAC Address']) log.info_1(" Node BMC IP Addr: %s", catalog.get('data')['IP Address']) log.info_1(" Node BMC IP Addr Src: %s", catalog.get('data')['IP Address Source']) # delete active workflows for specified node result = fit_common.cancel_active_workflows(cls.__NODE) assert ( result is True ), "There are still some active workflows running against the node"
def setUpClass(cls): # class method run once per script # default base payload for Rediscovery Graph cls.__payload = { "name": "Graph.Refresh.Immediate.Discovery", "options": { "reset-at-start": { "nodeId": "NODEID" }, "discovery-refresh-graph": { "graphOptions": { "target": "NODEID" }, "nodeId": "NODEID" }, "generate-sku": { "nodeId": "NODEID" }, "generate-enclosure": { "nodeId": "NODEID" }, "create-default-pollers": { "nodeId": "NODEID" }, "run-sku-graph": { "nodeId": "NODEID" }, "nodeId": "NODEID" } } # Get the list of nodes nodelist = fit_common.node_select(no_unknown_nodes=True) assert (len(nodelist) != 0), "No valid nodes discovered" # Select one node at random cls.__nodeid = nodelist[random.randint(0, len(nodelist) - 1)] # Delete active workflows for specified node fit_common.cancel_active_workflows(cls.__nodeid) cls.__previous_ipmi_user = None
def test_redfish_v1_updateservice_actions_updateservicesimpleupdate_post( self): nodeid = NODECATALOG[0] fit_common.cancel_active_workflows(nodeid) on_payload = {"ImageURI": "/dummy.exe", "Targets": [nodeid]} api_data = fit_common.rackhdapi( '/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate', action='post', payload=on_payload) self.assertEqual( api_data['status'], 201, 'Incorrect HTTP return code, expected 201, got:' + str(api_data['status'])) task_data = fit_common.rackhdapi(api_data['json']['@odata.id']) self.assertEqual(task_data['status'], 200, "No task ID found ") task_state = task_data['json']['TaskState'] self.assertIn( task_state, ["Running", "Pending", "Completed", "Exception"], "Bad task state for node:" + nodeid + " state:" + task_state)
def setUpClass(cls): # run all OS install workflows first nodeindex = 0 for item in OSLIST: # if OS proxy entry exists in RackHD config, run bootstrap against selected node if proxy_select(item['path']) and nodeindex < len(NODECATALOG): # delete active workflows for specified node fit_common.cancel_active_workflows(NODECATALOG[nodeindex]) payload_data = {"osName": item['os'], "version": item['version'], "kvm": item['kvm'], "repo": statichost + proxy_select(item['path']), "rootPassword": "******", "hostname": "rackhdnode", "dnsServers": [rackhdconfig['apiServerAddress']], "users": [{"name": "rackhd", "password": "******", "uid": 1010}]} result = fit_common.rackhdapi('/redfish/v1/Systems/' + NODECATALOG[nodeindex] + '/Actions/RackHD.BootImage', action='post', payload=payload_data) if result['status'] == 202: # this branch saves the task and node IDs NODE_STATUS[NODECATALOG[nodeindex]] = \ {"os": item['os'], "version": item['version'], "id": result['json']['@odata.id']} log.info_5(" TaskID: " + result['text']) log.info_5(" Payload: " + fit_common.json.dumps(payload_data)) else: # this is the failure case where there is no task ID NODE_STATUS[NODECATALOG[nodeindex]] = \ {"os": item['os'], "version": item['version'], 'id': "/redfish/v1/taskservice/tasks/failed"} log.error(" TaskID: " + result['text']) log.error(" Payload: " + fit_common.json.dumps(payload_data)) # increment node index to run next bootstrap nodeindex += 1
def setUp(self): for node in NODELIST: fit_common.cancel_active_workflows(node)
def setUp(self): #delete active workflows for specified node fit_common.cancel_active_workflows(NODE)
def setUpClass(cls): # run all OS install workflows first nodeindex = 0 for item in OSLIST: # if OS proxy entry exists in RackHD config, run bootstrap against selected node if nodeindex < len(NODECATALOG): # delete active workflows for specified node fit_common.cancel_active_workflows(NODECATALOG[nodeindex]) # base payload common to all Linux payload_data = {"options": {"defaults": { "version": item['version'], "kvm": item['kvm'], "repo": statichost + item['path'], "rootPassword": "******", "hostname": "rackhdnode", "users": [{"name": "rackhduser", "password": "******", "uid": 1010}]}}} # OS specific payload requirements if item['workflow'] == "Graph.InstallUbuntu": payload_data["options"]["defaults"]["baseUrl"] = "install/netboot/ubuntu-installer/amd64" payload_data["options"]["defaults"]["kargs"] = {"live-installer/net-image": statichost + item['path'] + "/ubuntu/install/filesystem.squashfs"} if item['workflow'] == "Graph.InstallWindowsServer": payload_data["options"]["defaults"]["productkey"] = item['productkey'] payload_data["options"]["defaults"]["smbUser"] = item['smbUser'] payload_data["options"]["defaults"]["smbPassword"] = item['smbPassword'] payload_data["options"]["defaults"]["smbRepo"] = "\\\\" + str(rackhdconfig['apiServerAddress']) + \ item['smbRepo'] payload_data["options"]["defaults"]["username"] = "******" payload_data["options"]["defaults"]["password"] = "******" payload_data["options"]["defaults"].pop('rootPassword', None) payload_data["options"]["defaults"].pop('users', None) payload_data["options"]["defaults"].pop('kvm', None) payload_data["options"]["defaults"].pop('version', None) # run workflow result = fit_common.rackhdapi('/api/2.0/nodes/' + NODECATALOG[nodeindex] + '/workflows?name=' + item['workflow'], action='post', payload=payload_data) if result['status'] == 201: # this saves the task and node IDs NODE_STATUS[NODECATALOG[nodeindex]] = \ {"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], "id": result['json']['instanceId']} log.info_5(" TaskID: " + result['json']['instanceId']) log.info_5(" Payload: " + fit_common.json.dumps(payload_data)) else: # if no task ID is returned put 'failed' in ID field NODE_STATUS[NODECATALOG[nodeindex]] = \ {"workflow": item['workflow'], "version": item['version'], "kvm": item['kvm'], 'id': "failed"} log.error(" OS install " + item['workflow'] + " on node " + NODECATALOG[nodeindex] + " failed! ") log.error(" Error text: " + result['text']) log.error(" Payload: " + fit_common.json.dumps(payload_data)) # increment node index to run next bootstrap nodeindex += 1