diff --git a/examples/simple-proliant.py b/examples/simple-proliant.py index e8e863c..a129cba 100644 --- a/examples/simple-proliant.py +++ b/examples/simple-proliant.py @@ -50,19 +50,23 @@ print("Get bios parameters : {}\n".format(remote_mgmt.Systems.systems_list[0].bi print("Get boot parameters : {}\n".format(remote_mgmt.Systems.systems_list[0].bios.boot.get_parameters())) -print("Get bios parameter 'AdminPhone' : {}\n".format(remote_mgmt.Systems.systems_list[0].bios.get_parameter("AdminPhone"))) -print("Set bios parameter 'AdminPhone' to '' : {}\n".format(remote_mgmt.Systems.systems_list[0].bios.set_parameter("AdminPhone",""))) +#print("Get bios parameter 'AdminPhone' : {}\n".format(remote_mgmt.Systems.systems_list[0].bios.get_parameter("AdminPhone"))) +#print("Set bios parameter 'AdminPhone' to '' : {}\n".format(remote_mgmt.Systems.systems_list[0].bios.set_parameter("AdminPhone",""))) #Boot server with script -#remote_mgmt.Systems.systems_list[0].bios.set_parameter("PreBootNetwork","Auto") #remote_mgmt.Systems.systems_list[0].bios.set_parameter("Dhcpv4","Enabled") -#remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartup","Enabled") -#remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartupLocation","NetworkLocation") -#remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartupUrl","http://192.168.1.1/deploy/startup.nsh") +remote_mgmt.Systems.systems_list[0].bios.set_parameter("PreBootNetwork", "Auto") +remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartup", "Enabled") +remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartupLocation", "NetworkLocation") +remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartupUrl", "http://10.3.222.88/deploy/startup.nsh") +remote_mgmt.Systems.systems_list[0].set_parameter_json('{"Boot": {"BootSourceOverrideTarget": "UefiShell"}}') +remote_mgmt.Systems.systems_list[0].set_parameter_json('{"Boot": {"BootSourceOverrideEnabled" : "Once"}}') + +#Reset of the system is required to apply the changes #remote_mgmt.Systems.systems_list[0].reset_system() remote_mgmt.logout() diff --git a/redfish/types.py b/redfish/types.py index 01a1d91..9ef5427 100644 --- a/redfish/types.py +++ b/redfish/types.py @@ -209,6 +209,29 @@ class Systems(Base): except: return "Parameter does not exist" + def set_parameter(self, parameter_name, value): + # Craft the request + action = dict() + action[parameter_name] = value + print(action) + + # perform the POST action + print self.api_url + response = self.api_url.patch(verify=self.connection_parameters.verify_cert, + headers={'x-auth-token': self.connection_parameters.auth_token}, + data=action + ) + + def set_parameter_json(self, value): + # perform the POST action + print self.api_url.url() + + response = requests.patch(self.api_url.url(), + verify=self.connection_parameters.verify_cert, + headers={'x-auth-token': self.connection_parameters.auth_token, 'Content-type': 'application/json'}, + data=value) + print(response.reason) + class SystemsCollection(BaseCollection): """Class to manage redfish ManagersCollection data.""" def __init__(self, url, connection_parameters):