New classes in types.py: Bios & Boot
Creating Bios class to manage System/Bios: - get_parameters() - get_parameter(parameter_name) - set_parameter(parameter_name, value) Creating Boot class to manage System/Bios/Boot: - get_parameters() - get_parameter(parameter_name) - set_parameter(parameter_name, value) New tests in simple-porliant.py file
This commit is contained in:
parent
394aee2f2b
commit
69122fa26d
@ -6,6 +6,7 @@ import os
|
||||
import sys
|
||||
import json
|
||||
import redfish
|
||||
from time import sleep
|
||||
|
||||
# Get $HOME environment.
|
||||
HOME = os.getenv('HOME')
|
||||
@ -43,7 +44,25 @@ print ("Redfish API version : %s \n" % remote_mgmt.get_api_version())
|
||||
print("Bios version : {}\n".format(remote_mgmt.Systems.systems_list[0].get_bios_version()))
|
||||
print("Serial Number : {}\n".format(remote_mgmt.Systems.systems_list[0].get_serial_number()))
|
||||
print("Power State : {}\n".format(remote_mgmt.Systems.systems_list[0].get_power()))
|
||||
print("Parameter 'Model' : {}\n".format(remote_mgmt.Systems.systems_list[0].get_parameter("Model")))
|
||||
print("Parameter 'SystemType' : {}\n".format(remote_mgmt.Systems.systems_list[0].get_parameter("SystemType")))
|
||||
|
||||
print("Get bios parameters : {}\n".format(remote_mgmt.Systems.systems_list[0].bios.get_parameters()))
|
||||
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","")))
|
||||
|
||||
|
||||
#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].reset_system()
|
||||
|
||||
remote_mgmt.logout()
|
||||
|
@ -6,6 +6,7 @@ import requests
|
||||
import tortilla
|
||||
import config
|
||||
import mapping
|
||||
import re
|
||||
|
||||
# Global variable
|
||||
|
||||
@ -162,6 +163,7 @@ class Systems(Base):
|
||||
# Also to check with the ironic driver requirement.
|
||||
def __init__(self, url, connection_parameters):
|
||||
super(Systems, self).__init__(url, connection_parameters)
|
||||
self.bios = Bios(url+"Bios/Settings", connection_parameters)
|
||||
|
||||
def reset_system(self):
|
||||
# Craft the request
|
||||
@ -174,7 +176,7 @@ class Systems(Base):
|
||||
response = self.api_url.post(verify=self.connection_parameters.verify_cert,
|
||||
headers={'x-auth-token': self.connection_parameters.auth_token},
|
||||
data=action
|
||||
)
|
||||
)
|
||||
#TODO : treat response.
|
||||
|
||||
def get_bios_version(self):
|
||||
@ -206,8 +208,7 @@ class Systems(Base):
|
||||
return self.data[parameter_name]
|
||||
except:
|
||||
return "Parameter does not exist"
|
||||
|
||||
|
||||
|
||||
class SystemsCollection(BaseCollection):
|
||||
"""Class to manage redfish ManagersCollection data."""
|
||||
def __init__(self, url, connection_parameters):
|
||||
@ -217,8 +218,62 @@ class SystemsCollection(BaseCollection):
|
||||
|
||||
for link in self.links:
|
||||
self.systems_list.append(Systems(link, connection_parameters))
|
||||
|
||||
|
||||
|
||||
class Bios(Base):
|
||||
def __init__(self, url, connection_parameters):
|
||||
super(Bios, self).__init__(url, connection_parameters)
|
||||
self.boot = Boot(re.findall(".+/Bios",url)[0]+"/Boot/Settings", connection_parameters)
|
||||
|
||||
def get_parameters(self):
|
||||
try:
|
||||
return self.data
|
||||
except:
|
||||
return -1
|
||||
|
||||
def get_parameter(self, parameter_name):
|
||||
try:
|
||||
return self.data[parameter_name]
|
||||
except:
|
||||
return "Parameter does not exist"
|
||||
|
||||
def set_parameter(self, parameter_name, value):
|
||||
# Craft the request
|
||||
action = dict()
|
||||
action[parameter_name] = value
|
||||
|
||||
# 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
|
||||
)
|
||||
class Boot(Base):
|
||||
def __init__(self, url, connection_parameters):
|
||||
super(Boot, self).__init__(url, connection_parameters)
|
||||
|
||||
def get_parameters(self):
|
||||
try:
|
||||
return self.data
|
||||
except:
|
||||
return -1
|
||||
|
||||
def get_parameter(self, parameter_name):
|
||||
try:
|
||||
return self.data[parameter_name]
|
||||
except:
|
||||
return "Parameter does not exist"
|
||||
|
||||
def set_parameter(self, parameter_name, value):
|
||||
# Craft the request
|
||||
action = dict()
|
||||
action[parameter_name] = value
|
||||
|
||||
# perform the POST action
|
||||
response = self.api_url.patch(verify=self.connection_parameters.verify_cert,
|
||||
headers={'x-auth-token': self.connection_parameters.auth_token},
|
||||
data=action
|
||||
)
|
||||
|
||||
class EthernetInterfacesCollection(BaseCollection):
|
||||
def __init__(self, url, connection_parameters):
|
||||
super(EthernetInterfacesCollection, self).__init__(url, connection_parameters)
|
||||
@ -231,6 +286,5 @@ class EthernetInterfacesCollection(BaseCollection):
|
||||
for link in self.links:
|
||||
self.ethernet_interfaces_list.append(EthernetInterfaces(link, connection_parameters))
|
||||
|
||||
|
||||
class EthernetInterfaces(Base):
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user