Closed alexp3518 closed 1 year ago
Hi @alexp3518 ,
Could you please elaborate the issue. Also please share the full log trace from your run.
If you are trying to run firmware update on server, Please see the example below.
# Perform a firmware update on server
# Firmware update can only be done on server hardware(Gen10 and later) with no server profile assigned, and server hardware
# should be in powered off state
compliance_configuration = {
"firmwareBaselineId": config['server_hardware']['firmware_baseline_id'],
"serverUUID": server.data['uuid']
}
firmware_update_configuration = [{"op": "replace", "value": {"baselineUri": "/rest/firmware-drivers/" + config['server_hardware']['firmware_baseline_id'],
"firmwareInstallType": "FirmwareOnlyOfflineMode", "installationPolicy": "LowerThanBaseline"}
}]
if server:
firmware_compliance = server.check_firmware_compliance(compliance_configuration)
if firmware_compliance['serverFirmwareUpdateRequired']:
print("Updating firmware for the server hardware..")
server.perform_firmware_update(firmware_update_configuration)
key should be firmwareBaselineId
instead of firmwareBaselineID
.
Thanks
Hello,
Im with Oneview v8 appliance I use Python in v3.9.6 Hardware target is DL380 GEN 10 The file programm is : server_hardware_firmware_update.py I got an key error with : firmwareBaselineID : ‘server_hardware’) The config file is loaded from the config file .json in the example folder. In the config file i ‘ve got the IP of oneview the session ID and the user login of the Oneview appliance. Can you please give an example of the config file.json that works with your script ?
Hi You may add firmware baseline id to "server_hardware" in your config as below.
"server_hardware": {
"server_hardware_hostname": "0000A66102, bay 5",
"server_hardware_username": "dcs",
"server_hardware_password": "dcs",
"multiple_hosts": [
"0000A66101, bay 5"
],
"variant": "Synergy",
"firmware_baseline_id": "<firmware_baseline_id>"
}
So i need to put in the config file .json the whole thing below :
"server_hardware": {
"server_hardware_hostname": "0000A66102, bay 5",
"server_hardware_username": "dcs",
"server_hardware_password": "dcs",
"multiple_hosts": [
"0000A66101, bay 5"
],
"variant": "Synergy",
"firmware_baseline_id": "<firmware_baseline_id>"
}
Or put it at the head of the script ?
The server-hardware hostname here: is the server targeted to upgrade?
The username is an user with admin rights to perform upgrade ?
What is Variant here ?
Do i need to replace "
I just want a script that check an server sees if he is compliant regarding the latest firmware upgrade file and if he is needs the upgrade perform it to the latest.
No. Examples files for the resources are just examples which you can change and use according to your requirement.
You can directly change the input values in server_hardware_firmware_update.py itself. Other fields like server hardware hostname and variant are not used here.
compliance_configuration = {
"firmwareBaselineId": "<input firmware baseline id here>",
"serverUUID": "<input uuid of the server you wanna update here>"
}
Ok thank you
I’ve got 2 SPP firmware files in one view. How can i get the input firmware baseline id ? And after this how can i check if the server is compliant with the good one to perform the upgrade to the latest one ?
If you have firmware bundles uploaded already, you can do get call on firmware driver to get firmwareBaselineId as below. And then proceed as below to check firmware compliance, update if required.
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
firmware_drivers = oneview_client.firmware_drivers
server_hardwares = oneview_client.server_hardware
firmware_driver = firmware_drivers.get_by_name("Gen10 Service Pack for ProLiant")
firmwareBaselineId = firmware_driver.data["resourceId"]
server = server_hardwares.get_by_name("<server name>")
# Perform a firmware update on server
# Firmware update can only be done on server hardware(Gen10 and later) with no server profile assigned, and server hardware
# should be in powered off state
compliance_configuration = {
"firmwareBaselineId": firmwareBaselineId,
"serverUUID": server.data['uuid']
}
firmware_update_configuration = [{"op": "replace", "value": {"baselineUri": "/rest/firmware-drivers/" + firmwareBaselineId,
"firmwareInstallType": "FirmwareOnlyOfflineMode", "installationPolicy": "LowerThanBaseline"}
}]
if server:
firmware_compliance = server.check_firmware_compliance(compliance_configuration)
if firmware_compliance['serverFirmwareUpdateRequired']:
print("Updating firmware for the server hardware..")
server.perform_firmware_update(firmware_update_configuration)
from hpeOneView.oneview_client import OneViewClient from config_loader import try_load_from_file
config = {
"ip": "
config = try_load_from_file(config) oneview_client = OneViewClient(config) firmware_drivers = oneview_client.firmware_drivers server_hardwares = oneview_client.server_hardware
firmware_driver = firmware_drivers.get_by_name("Gen10 Service Pack for ProLiant") firmwareBaselineId = firmware_driver.data["resourceId"]
server = server_hardwares.get_by_name("
compliance_configuration = { "firmwareBaselineId": firmwareBaselineId, "serverUUID": server.data['uuid'] } firmware_update_configuration = [{"op": "replace", "value": {"baselineUri": "/rest/firmware-drivers/" + firmwareBaselineId, "firmwareInstallType": "FirmwareOnlyOfflineMode", "installationPolicy": "LowerThanBaseline"} }] if server: firmware_compliance = server.check_firmware_compliance(compliance_configuration) if firmware_compliance['serverFirmwareUpdateRequired']: print("Updating firmware for the server hardware..") server.perform_firmware_update(firmware_update_configuration)
rq : firmwareBaselineId = firmware_driver.data["resourceId"]) : ")" to delete at the end.
server_hardware_firmware_update-V1.py", line 41, in
COMMENT :
firmwareBaselineId = firmware_driver.data["resourceId"]) : ")" to delete at the end.
ERROR :
server_hardware_firmware_update-V1.py", line 41, in
Please make sure that you have atleast one firmware bundle uploaded on your OneView. Then you will be able get the resourceId from firmware driver get call. Now the firmware_driver object is None.
i've got 2 SPP bundle upload on Oneview.
Are those in success state? Could you please upload a screenshot of your uploaded firmware bundle in OV.
prog.txt The firmware files were uploaded via the GUI not the CLI or API command
I can see that you have two firmware bundles with same name. Please pass version also along with name as below.
firmware_driver = firmware_drivers.get_by_name("HPE Synergy Service Pack", "SY-2023.03.01")
Not working. The full file is located here : /rest/firmware-drivers/P62619_gen10spp-2023_03_00_00-SPP2023030000_2023_27 prog2.txt
You may try:
firmware_driver = firmware_drivers.get_by_uri("/rest/firmware-drivers/P62619_gen10spp-2023_03_00_00-SPP2023030000_2023_27")
Done but it failed : File "C:\Program Files\Python39\lib\site-packages\hpeoneview-8.1.0-py3.9.egg\hpeOneView\connection.py", line 420, in __do_rest_call raise HPEOneViewException(body) hpeOneView.exceptions.HPEOneViewException: ('Not Found', {'errorSource': None, 'data': {}, 'details': 'The requested resource could not be found.', 'message': 'Not Found', 'messageParameters': [], 'nestedErrors': [], 'errorCode': 'GENERIC_HTTP_404', 'recommendedActions': ['Check the request URI, then resend the request.']})
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
firmware_drivers = oneview_client.firmware_drivers
# Get all firmwares
print("\nGet list of firmwares managed by the appliance.")
pprint(firmware_drivers)
all_firmwares = firmware_drivers.get_all()
for firmware in all_firmwares:
print(' - {}'.format(firmware['name']))
Can you send the output of above?
It worked :
Get list of firmwares managed by the appliance. <hpeOneView.resources.settings.firmware_drivers.FirmwareDrivers object at 0x000001BF09D9A9D0>
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
firmware_drivers = oneview_client.firmware_drivers
# Get all firmwares
print("\nGet list of firmwares managed by the appliance.")
pprint(firmware_drivers)
all_firmwares = firmware_drivers.get_all()
for firmware in all_firmwares:
print(' - {}'.format(firmware['name']))
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[0]['uri'])
print(firmware_driver.data)
Get list of firmwares managed by the appliance.
<hpeOneView.resources.settings.firmware_drivers.FirmwareDrivers object at 0x0000021755B4B9D0>
Gen10 Service Pack for ProLiant
Gen10 Service Pack for ProLiant
<hpeOneView.resources.settings.firmware_drivers.FirmwareDrivers object at 0x00000217562B5DC0>
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
firmware_drivers = oneview_client.firmware_drivers
# Get all firmwares
print("\nGet list of firmwares managed by the appliance.")
pprint(firmware_drivers)
all_firmwares = firmware_drivers.get_all()
for firmware in all_firmwares:
print(' - {}'.format(firmware['name']))
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[0]['uri'])
print(firmware_driver.data)
print(firmware_driver.data['resourceId'])
This is firmwareBaselineId which you should be passing to the firmware compliance check
Get list of firmwares managed by the appliance.
<hpeOneView.resources.settings.firmware_drivers.FirmwareDrivers object at 0x0000020F822FA9D0>
Gen10 Service Pack for ProLiant
Gen10 Service Pack for ProLiant
SQUEEZED TEXT HERE : 3007 lines
P52581_001_gen10spp-2022_09_01_00-SPP2022090100_2022_0930_1
# Try load config from a file (if there is a config file)
config = try_load_from_file(config)
oneview_client = OneViewClient(config)
server_hardwares = oneview_client.server_hardware
firmware_drivers = oneview_client.firmware_drivers
# Get all firmwares
print("\nGet list of firmwares managed by the appliance.")
all_firmwares = firmware_drivers.get_all()
for firmware in all_firmwares:
print(' - {}'.format(firmware['name']))
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[0]['uri'])
firmwareBaselineId = firmware_driver.data['resourceId']
server = server_hardwares.get_by_name("<server name>")
# Get list of all server hardware resources
servers = []
print("Get list of all server hardware resources")
server_hardware_all = server_hardwares.get_all()
for serv in server_hardware_all:
print(' %s' % serv['name'])
servers.append(serv['name'])
# Get recently added server hardware resource by name
if server_hardware_all:
server = server_hardwares.get_by_name(servers[0])
print(server.data)
# Request power operation to change the power state of the physical server.
configuration = {
"powerState": "Off",
"powerControl": "MomentaryPress"
}
if server:
server_power = server.update_power_state(configuration)
print("Successfully changed the power state of server '{name}' to '{powerState}'".format(**server_power))
# Perform a firmware update on server
# Firmware update can only be done on server hardware(Gen10 and later) with no server profile assigned, and server hardware
# should be in powered off state
compliance_configuration = {
"firmwareBaselineId": firmwareBaselineId,
"serverUUID": server.data['uuid']
}
firmware_update_configuration = [{"op": "replace", "value": {"baselineUri": "/rest/firmware-drivers/" + firmwareBaselineId,
"firmwareInstallType": "FirmwareOnlyOfflineMode", "installationPolicy": "LowerThanBaseline"}
}]
if server:
firmware_compliance = server.check_firmware_compliance(compliance_configuration)
if firmware_compliance['serverFirmwareUpdateRequired']:
print("Updating firmware for the server hardware..")
server.perform_firmware_update(firmware_update_configuration)
Please add server name also
The script goes well at the beginning
The first server from all those on oneview is selected
The data from the first server is prompted
The off signal is sended
And there is nothing more and the programm stop
can you paste the output here?
The output print the data of the server and the signal off sended nothing else.
You can put some print statements in between to see if it already did the compliance check. You can modify these examples according to your requirement. These are mere examples to show the usage of plugins.
Get list of firmwares managed by the appliance.
Gen10 Service Pack for ProLiant
Gen10 Service Pack for ProLiant
Get list of all server hardware resources
hostname xx1
hostname xx
hostname xx
Successfully changed the power state of server 'hostname xx1' to 'Off'
There is nothing more after launching the programm after sending to power state there is nothing after.
On the oneview appliance there is nothing on activity
It will update the firmware only if firmware update is required. In this server, firmware update may not be required. Are you trying on a server where firmware version is less than the firmware you are trying to upgrade to?
Hi @alexp3518 Are you able to run firmware update on server? Please let us know if you need any more help on this.
Thanks
Hello @alisha-k-kalladassery
It will update the firmware only if firmware update is required. In this server, firmware update may not be required. Are you trying on a server where firmware version is less than the firmware you are trying to upgrade to? : To answer your question :
The firmware update in Oneview is required because the server is flagged in the server compliance menu. The goal is to upgrade to the latest firmware bundle. The targeted server is ok to be upgraded but the script only send the power off signal but do nothing else. The upgrade signal is not sended. I see nothing else in the same time in Oneview. The targeted server needs to be upgraded with the SPP of April 2023.
Hi @alexp3518 , can you update the code after server power off as below and send output?
if server:
print("Checking if firmware compliance required..")
firmware_compliance = server.check_firmware_compliance(compliance_configuration)
print(firmware_compliance['serverFirmwareUpdateRequired'])
if firmware_compliance['serverFirmwareUpdateRequired']:
print("Updating firmware for the server hardware..")
server.perform_firmware_update(firmware_update_configuration)
else:
print("Firmware update is not required for this server")
Thanks
The script print this : Checking if firmware compliance required.. False Firmware update is not required for this server
Or in the firmware compliance the server is ok to be upgradable to the lastest firmware file. As you know i've got 2 versions of the SPP firmware file.
So that means the firmware you are trying to upgrade the sever to is less than the firmware on server. You need to try with a firmware baseline greater than what is existing on the server.
I've got 2 firmware files SPP one of 2022 and one of 2023. The server is upgradable wih the 2023 one. On the server compliance menu on oneview the server can be upgraded to the latest one file.( 2023 file ) The script needs to get the latest one between the two upgrade files. Take the lastest one regarding the server and apply it.
I can also try to delete the oldest firmware file and retry with the script
Thanks
You have got two firmware files. And both have same names. We tried the first one and it seems to be of old version. Please try the other one by changing firmware selection as below.
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[1]['uri'])
The script :
from hpeOneView.oneview_client import OneViewClient from config_loader import try_load_from_file
config = {
"ip": "
config = try_load_from_file(config) oneview_client = OneViewClient(config) server_hardwares = oneview_client.server_hardware firmware_drivers = oneview_client.firmware_drivers
print("\nGet list of firmwares managed by the appliance.") all_firmwares = firmware_drivers.get_all() for firmware in all_firmwares: print(' - {}'.format(firmware['name']))
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[0]['uri'])
firmwareBaselineId = firmware_driver.data['resourceId']
server = server_hardwares.get_by_name("
servers = [] print("Get list of all server hardware resources") server_hardware_all = server_hardwares.get_all() for serv in server_hardware_all: print(' %s' % serv['name']) servers.append(serv['name'])
if server_hardware_all: server = server_hardwares.get_by_name(servers[0]) print(server.data)
configuration = { "powerState": "Off", "powerControl": "MomentaryPress" } if server: server_power = server.update_power_state(configuration) print("Successfully changed the power state of server '{name}' to '{powerState}'".format(**server_power))
compliance_configuration = { "firmwareBaselineId": firmwareBaselineId, "serverUUID": server.data['uuid'] }
firmware_update_configuration = [{"op": "replace", "value": {"baselineUri": "/rest/firmware-drivers/" + firmwareBaselineId, "firmwareInstallType": "FirmwareOnlyOfflineMode", "installationPolicy": "LowerThanBaseline"} }]
if server: firmware_driver = firmware_drivers.get_by_uri(all_firmwares[1]['uri']) firmware_compliance = server.check_firmware_compliance(compliance_configuration) if firmware_compliance['serverFirmwareUpdateRequired']: print("Updating firmware for the server hardware..") server.perform_firmware_update(firmware_update_configuration) if server: print("Checking if firmware compliance required..") firmware_compliance = server.check_firmware_compliance(compliance_configuration) print(firmware_compliance['serverFirmwareUpdateRequired']) if firmware_compliance['serverFirmwareUpdateRequired']: print("Updating firmware for the server hardware..") server.perform_firmware_update(firmware_update_configuration) else: print("Firmware update is not required for this server")
Think i made a mistkae to the last loop if server. Don't know where to place firmware_driver = firmware_drivers.get_by_uri(all_firmwares[1]['uri']) in the code ;)
you have to change below line in your code
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[0]['uri'])
to
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[1]['uri'])
Ok ! Sorry for all the comment in this issue but I think we are going to the end ;) Now the script know wich one file it needs . It s true to perform the upgrade But it failed before the operation the script below Sorry again ;)
code :
from hpeOneView.oneview_client import OneViewClient from config_loader import try_load_from_file
config = {
"ip": "
config = try_load_from_file(config) oneview_client = OneViewClient(config) server_hardwares = oneview_client.server_hardware firmware_drivers = oneview_client.firmware_drivers
print("\nGet list of firmwares managed by the appliance.") all_firmwares = firmware_drivers.get_all() for firmware in all_firmwares: print(' - {}'.format(firmware['name']))
firmware_driver = firmware_drivers.get_by_uri(all_firmwares[1]['uri'])
firmwareBaselineId = firmware_driver.data['resourceId']
server = server_hardwares.get_by_name("
servers = [] print("Get list of all server hardware resources") server_hardware_all = server_hardwares.get_all() for serv in server_hardware_all: print(' %s' % serv['name']) servers.append(serv['name'])
if server_hardware_all: server = server_hardwares.get_by_name(servers[0]) print(server.data)
configuration = { "powerState": "Off", "powerControl": "MomentaryPress" } if server: server_power = server.update_power_state(configuration) print("Successfully changed the power state of server '{name}' to '{powerState}'".format(**server_power))
compliance_configuration = { "firmwareBaselineId": firmwareBaselineId, "serverUUID": server.data['uuid'] }
firmware_update_configuration = [{"op": "replace", "value": {"baselineUri": "/rest/firmware-drivers/" + firmwareBaselineId, "firmwareInstallType": "FirmwareOnlyOfflineMode", "installationPolicy": "LowerThanBaseline"} }]
if server: print("Checking if firmware compliance required..") firmware_compliance = server.check_firmware_compliance(compliance_configuration) print(firmware_compliance['serverFirmwareUpdateRequired']) if firmware_compliance['serverFirmwareUpdateRequired']: print("Updating firmware for the server hardware..") server.perform_firmware_update(firmware_update_configuration) else: print("Firmware update is not required for this server")
result :
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\idlelib\run.py", line 559, in runcode
exec(code, self.locals)
File "C:\Users\XXX\Documents\oneview-python-master\examples\server_hardware_firmware_update-V1.py", line 79, in
Could you send your program file?
Also the output please. Is it printing second firmware bundle name?
the output is : succesfully change state to off check if firmware compliance required True Updating for the server hardware
error output : Traceback (most recent call last): File "C:\Program Files\Python39\lib\idlelib\run.py", line 559, in runcode exec(code, self.locals) File "C:\Users\XXX\Documents\oneview-python-master\examples\server_hardware_firmware_update-V1.py", line 79, in server.perform_firmware_update(firmware_update_configuration) File "C:\Program Files\Python39\lib\site-packages\hpeoneview-8.1.0-py3.9.egg\hpeOneView\resources\resource.py", line 64, in call return self.method(obj, *args, **kwargs) File "C:\Program Files\Python39\lib\site-packages\hpeoneview-8.1.0-py3.9.egg\hpeOneView\resources\servers\server_hardware.py", line 400, in perform_firmware_update return self.patch_request(uri, configuration, timeout=timeout, custom_headers=custom_headers) File "C:\Program Files\Python39\lib\site-packages\hpeoneview-8.1.0-py3.9.egg\hpeOneView\resources\resource.py", line 905, in patch_request task, entity = self._connection.patch(uri, body, custom_headers=custom_headers) File "C:\Program Files\Python39\lib\site-packages\hpeoneview-8.1.0-py3.9.egg\hpeOneView\connection.py", line 396, in patch return self.do_rest_call('PATCH', uri, body, custom_headers=custom_headers) File "C:\Program Files\Python39\lib\site-packages\hpeoneview-8.1.0-py3.9.egg\hpeOneView\connection.py", line 420, in do_rest_call raise HPEOneViewException(body) hpeOneView.exceptions.HPEOneViewException: ('Not Found', {'errorSource': None, 'data': {}, 'details': 'The requested resource could not be found.', 'message': 'Not Found', 'messageParameters': [], 'nestedErrors': [], 'errorCode': 'GENERIC_HTTP_404', 'recommendedActions': ['Check the request URI, then resend the request.']})
Please send me the output which got printed before it reached the error.
Hello, im out of the office The output of the program is smotheing lake that succesfully change state to off check if firmware compliance required True Updating for the server hardware
And after this ligne there is nothing else And the bellow error in my last comment appear
have you got some news about the issue ?
Hi @alexp3518 We are trying to reproduce the same in our environment. We will get back to you.
Thanks
Hi @alexp3518
Firmware update on a server hardware without profile
feature is added in OV8.2 release. You need to have SDK 8.2 or above to use this feature. Also please make sure your OV api version is above 4600.
Changelog
From the error log above, I can see that your hpeOneView version is 8.1. Please upgrade your SDK and try the same script.
Thanks
I've just upgraded my Oneview appliance to the 8.3.00 and the SDK to the 8.3.0 and i 've got the same error ...
Successfully changed the power state of server 'SERVER_HOSTNAME' to 'Off'
Checking if firmware compliance required..
True
Updating firmware for the server hardware..
Traceback (most recent call last):
File "C:\Program Files\Python39\lib\idlelib\run.py", line 559, in runcode
exec(code, self.locals)
File "C:\Users\USER\Documents\oneview-python-master83\examples\ALEX_server_hardware_firmware_update-V1.py", line 78, in
Hi @alexp3518
We checked this in our environment. And we are not able to reproduce the issue. We are working on creating a patch version with detailed logs. We will keep you posted.
Thanks
key error Python : firmwareBaselineID : ‘server_hardware’