Add comment
This commit is contained in:
parent
6bc483a465
commit
6b296a79a3
@ -62,11 +62,10 @@ remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartup", "Enab
|
|||||||
remote_mgmt.Systems.systems_list[0].bios.set_parameter("UefiShellStartupLocation", "NetworkLocation")
|
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].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": {"BootSourceOverrideTarget": "UefiShell"}}')
|
||||||
remote_mgmt.Systems.systems_list[0].set_parameter_json('{"Boot": {"BootSourceOverrideEnabled" : "Once"}}')
|
remote_mgmt.Systems.systems_list[0].set_parameter_json('{"Boot": {"BootSourceOverrideEnabled" : "Once"}}')
|
||||||
|
|
||||||
#Reset of the system is required to apply the changes
|
#Reset of the system is required to apply the changes
|
||||||
#remote_mgmt.Systems.systems_list[0].reset_system()
|
remote_mgmt.Systems.systems_list[0].reset_system()
|
||||||
|
|
||||||
remote_mgmt.logout()
|
remote_mgmt.logout()
|
||||||
|
109
redfish/types.py
109
redfish/types.py
@ -15,6 +15,7 @@ class Base(object):
|
|||||||
"""Abstract class to manage types (Chassis, Servers etc...)."""
|
"""Abstract class to manage types (Chassis, Servers etc...)."""
|
||||||
|
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
|
"""Class constructor"""
|
||||||
global TORTILLADEBUG
|
global TORTILLADEBUG
|
||||||
self.connection_parameters = connection_parameters # Uggly hack to check
|
self.connection_parameters = connection_parameters # Uggly hack to check
|
||||||
self.url = url
|
self.url = url
|
||||||
@ -91,7 +92,6 @@ class BaseCollection(Base):
|
|||||||
class Root(Base):
|
class Root(Base):
|
||||||
"""Class to manage redfish Root data."""
|
"""Class to manage redfish Root data."""
|
||||||
|
|
||||||
|
|
||||||
def get_api_version(self):
|
def get_api_version(self):
|
||||||
"""Return api version.
|
"""Return api version.
|
||||||
|
|
||||||
@ -109,6 +109,11 @@ class Root(Base):
|
|||||||
return(version)
|
return(version)
|
||||||
|
|
||||||
def get_api_UUID(self):
|
def get_api_UUID(self):
|
||||||
|
"""Return UUID version.
|
||||||
|
|
||||||
|
:returns: string -- UUID
|
||||||
|
|
||||||
|
"""
|
||||||
return self.data.UUID
|
return self.data.UUID
|
||||||
|
|
||||||
|
|
||||||
@ -127,6 +132,7 @@ class SessionService(Base):
|
|||||||
|
|
||||||
|
|
||||||
class Managers(Base):
|
class Managers(Base):
|
||||||
|
"""Class to manage redfish Managers."""
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
super(Managers, self).__init__(url, connection_parameters)
|
super(Managers, self).__init__(url, connection_parameters)
|
||||||
|
|
||||||
@ -149,37 +155,47 @@ class Managers(Base):
|
|||||||
class ManagersCollection(BaseCollection):
|
class ManagersCollection(BaseCollection):
|
||||||
"""Class to manage redfish ManagersCollection data."""
|
"""Class to manage redfish ManagersCollection data."""
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
|
"""Class constructor"""
|
||||||
super(ManagersCollection, self).__init__(url, connection_parameters)
|
super(ManagersCollection, self).__init__(url, connection_parameters)
|
||||||
|
|
||||||
self.managers_list = []
|
self.managers_list = []
|
||||||
|
|
||||||
for link in self.links:
|
for link in self.links:
|
||||||
self.managers_list.append(Managers(link, connection_parameters))
|
self.managers_list.append(Managers(link, connection_parameters))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Systems(Base):
|
class Systems(Base):
|
||||||
|
"""Class to manage redfish Systems data."""
|
||||||
# TODO : Need to discuss with Bruno the required method.
|
# TODO : Need to discuss with Bruno the required method.
|
||||||
# Also to check with the ironic driver requirement.
|
# Also to check with the ironic driver requirement.
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
|
"""Class constructor"""
|
||||||
super(Systems, self).__init__(url, connection_parameters)
|
super(Systems, self).__init__(url, connection_parameters)
|
||||||
self.bios = Bios(url+"Bios/Settings", connection_parameters)
|
self.bios = Bios(url+"Bios/Settings", connection_parameters)
|
||||||
|
|
||||||
def reset_system(self):
|
def reset_system(self):
|
||||||
|
"""Force reset of the system.
|
||||||
|
|
||||||
|
:returns: string -- http response of POST request
|
||||||
|
|
||||||
|
"""
|
||||||
# Craft the request
|
# Craft the request
|
||||||
action = dict()
|
action = dict()
|
||||||
action['Action'] = 'Reset'
|
action['Action'] = 'Reset'
|
||||||
action['ResetType'] = 'ForceRestart'
|
action['ResetType'] = 'ForceRestart'
|
||||||
|
|
||||||
# perform the POST action
|
#Debug the url and perform the POST action
|
||||||
print self.api_url
|
#print self.api_url
|
||||||
response = self.api_url.post(verify=self.connection_parameters.verify_cert,
|
response = self.api_url.post(verify=self.connection_parameters.verify_cert,
|
||||||
headers={'x-auth-token': self.connection_parameters.auth_token},
|
headers={'x-auth-token': self.connection_parameters.auth_token},
|
||||||
data=action
|
data=action
|
||||||
)
|
)
|
||||||
#TODO : treat response.
|
#TODO : treat response.
|
||||||
|
return response
|
||||||
|
|
||||||
def get_bios_version(self):
|
def get_bios_version(self):
|
||||||
|
"""Get bios version of the system.
|
||||||
|
|
||||||
|
:returns: string -- bios version
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
# Returned by proliant
|
# Returned by proliant
|
||||||
return self.data.Bios.Current.VersionString
|
return self.data.Bios.Current.VersionString
|
||||||
@ -189,6 +205,11 @@ class Systems(Base):
|
|||||||
return self.data.BiosVersion
|
return self.data.BiosVersion
|
||||||
|
|
||||||
def get_serial_number(self):
|
def get_serial_number(self):
|
||||||
|
"""Get serial number of the system.
|
||||||
|
|
||||||
|
:returns: string -- serial number
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
# Returned by proliant
|
# Returned by proliant
|
||||||
return self.data.SerialNumber
|
return self.data.SerialNumber
|
||||||
@ -198,31 +219,56 @@ class Systems(Base):
|
|||||||
return ""
|
return ""
|
||||||
|
|
||||||
def get_power(self):
|
def get_power(self):
|
||||||
|
"""Get power status of the system.
|
||||||
|
|
||||||
|
:returns: string -- power status or NULL if there is an issue
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.data.Power
|
return self.data.Power
|
||||||
except:
|
except:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
def get_parameter(self, parameter_name):
|
def get_parameter(self, parameter_name):
|
||||||
|
"""Generic function to get any system parameter
|
||||||
|
|
||||||
|
:param parameter_name: name of the parameter
|
||||||
|
:returns: string -- parameter value
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.data[parameter_name]
|
return self.data[parameter_name]
|
||||||
except:
|
except:
|
||||||
return "Parameter does not exist"
|
return "Parameter does not exist"
|
||||||
|
|
||||||
def set_parameter(self, parameter_name, value):
|
def set_parameter(self, parameter_name, value):
|
||||||
|
"""Generic function to set any system parameter
|
||||||
|
|
||||||
|
:param parameter_name: name of the parameter
|
||||||
|
:param value: value to set
|
||||||
|
:returns: string -- http response of PATCH request
|
||||||
|
|
||||||
|
"""
|
||||||
# Craft the request
|
# Craft the request
|
||||||
action = dict()
|
action = dict()
|
||||||
action[parameter_name] = value
|
action[parameter_name] = value
|
||||||
print(action)
|
print(action)
|
||||||
|
|
||||||
# perform the POST action
|
# Perform the POST action
|
||||||
print self.api_url
|
print self.api_url
|
||||||
response = self.api_url.patch(verify=self.connection_parameters.verify_cert,
|
response = self.api_url.patch(verify=self.connection_parameters.verify_cert,
|
||||||
headers={'x-auth-token': self.connection_parameters.auth_token},
|
headers={'x-auth-token': self.connection_parameters.auth_token},
|
||||||
data=action
|
data=action
|
||||||
)
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
def set_parameter_json(self, value):
|
def set_parameter_json(self, value):
|
||||||
|
"""Generic function to set any system parameter using json structure
|
||||||
|
|
||||||
|
:param value: json structure with value to update
|
||||||
|
:returns: string -- http response of PATCH request
|
||||||
|
|
||||||
|
"""
|
||||||
# perform the POST action
|
# perform the POST action
|
||||||
print self.api_url.url()
|
print self.api_url.url()
|
||||||
|
|
||||||
@ -243,23 +289,42 @@ class SystemsCollection(BaseCollection):
|
|||||||
self.systems_list.append(Systems(link, connection_parameters))
|
self.systems_list.append(Systems(link, connection_parameters))
|
||||||
|
|
||||||
class Bios(Base):
|
class Bios(Base):
|
||||||
|
"""Class to manage redfish Bios data."""
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
super(Bios, self).__init__(url, connection_parameters)
|
super(Bios, self).__init__(url, connection_parameters)
|
||||||
self.boot = Boot(re.findall(".+/Bios",url)[0]+"/Boot/Settings", connection_parameters)
|
self.boot = Boot(re.findall(".+/Bios",url)[0]+"/Boot/Settings", connection_parameters)
|
||||||
|
|
||||||
def get_parameters(self):
|
def get_parameters(self):
|
||||||
|
"""Generic function to get all system parameters
|
||||||
|
|
||||||
|
:returns: string -- parameter value
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.data
|
return self.data
|
||||||
except:
|
except:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def get_parameter(self, parameter_name):
|
def get_parameter(self, parameter_name):
|
||||||
|
"""Generic function to get any system parameter
|
||||||
|
|
||||||
|
:param parameter_name: name of the parameter
|
||||||
|
:returns: string -- parameter value
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.data[parameter_name]
|
return self.data[parameter_name]
|
||||||
except:
|
except:
|
||||||
return "Parameter does not exist"
|
return "Parameter does not exist"
|
||||||
|
|
||||||
def set_parameter(self, parameter_name, value):
|
def set_parameter(self, parameter_name, value):
|
||||||
|
"""Generic function to set any bios parameter
|
||||||
|
|
||||||
|
:param parameter_name: name of the parameter
|
||||||
|
:param value: value to set
|
||||||
|
:returns: string -- http response of PATCH request
|
||||||
|
|
||||||
|
"""
|
||||||
# Craft the request
|
# Craft the request
|
||||||
action = dict()
|
action = dict()
|
||||||
action[parameter_name] = value
|
action[parameter_name] = value
|
||||||
@ -270,23 +335,44 @@ class Bios(Base):
|
|||||||
headers={'x-auth-token': self.connection_parameters.auth_token},
|
headers={'x-auth-token': self.connection_parameters.auth_token},
|
||||||
data=action
|
data=action
|
||||||
)
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
class Boot(Base):
|
class Boot(Base):
|
||||||
|
"""Class to manage redfish Boot data."""
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
super(Boot, self).__init__(url, connection_parameters)
|
super(Boot, self).__init__(url, connection_parameters)
|
||||||
|
|
||||||
def get_parameters(self):
|
def get_parameters(self):
|
||||||
|
"""Generic function to get all system parameters
|
||||||
|
|
||||||
|
:returns: string -- parameter value
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.data
|
return self.data
|
||||||
except:
|
except:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
def get_parameter(self, parameter_name):
|
def get_parameter(self, parameter_name):
|
||||||
|
"""Generic function to get any system parameter
|
||||||
|
|
||||||
|
:param parameter_name: name of the parameter
|
||||||
|
:returns: string -- parameter value
|
||||||
|
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
return self.data[parameter_name]
|
return self.data[parameter_name]
|
||||||
except:
|
except:
|
||||||
return "Parameter does not exist"
|
return "Parameter does not exist"
|
||||||
|
|
||||||
def set_parameter(self, parameter_name, value):
|
def set_parameter(self, parameter_name, value):
|
||||||
|
"""Generic function to set any bios parameter
|
||||||
|
|
||||||
|
:param parameter_name: name of the parameter
|
||||||
|
:param value: value to set
|
||||||
|
:returns: string -- http response of PATCH request
|
||||||
|
|
||||||
|
"""
|
||||||
# Craft the request
|
# Craft the request
|
||||||
action = dict()
|
action = dict()
|
||||||
action[parameter_name] = value
|
action[parameter_name] = value
|
||||||
@ -296,8 +382,10 @@ class Boot(Base):
|
|||||||
headers={'x-auth-token': self.connection_parameters.auth_token},
|
headers={'x-auth-token': self.connection_parameters.auth_token},
|
||||||
data=action
|
data=action
|
||||||
)
|
)
|
||||||
|
return response
|
||||||
|
|
||||||
class EthernetInterfacesCollection(BaseCollection):
|
class EthernetInterfacesCollection(BaseCollection):
|
||||||
|
"""Class to manage redfish EthernetInterfacesColkection data."""
|
||||||
def __init__(self, url, connection_parameters):
|
def __init__(self, url, connection_parameters):
|
||||||
super(EthernetInterfacesCollection, self).__init__(url, connection_parameters)
|
super(EthernetInterfacesCollection, self).__init__(url, connection_parameters)
|
||||||
|
|
||||||
@ -310,4 +398,5 @@ class EthernetInterfacesCollection(BaseCollection):
|
|||||||
self.ethernet_interfaces_list.append(EthernetInterfaces(link, connection_parameters))
|
self.ethernet_interfaces_list.append(EthernetInterfaces(link, connection_parameters))
|
||||||
|
|
||||||
class EthernetInterfaces(Base):
|
class EthernetInterfaces(Base):
|
||||||
|
"""Class to manage redfish EthernetInterfaces data."""
|
||||||
pass
|
pass
|
Loading…
Reference in New Issue
Block a user