Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_init(self):
with self.assertRaises(TypeError):
RisMonolithMember_v1_0_0()
RisMonolithMember_v1_0_0("test")
self.assertTrue(
issubclass(RisMonolithMember_v1_0_0, RisMonolithMemberBase)
)
self.assertTrue(issubclass(RisMonolithMember_v1_0_0, Dictable))
def test_redfish_client(self):
base_url = "http://foo.bar"
username = "rstallman"
password = "123456"
default_prefix = "/custom/redfish/v1/"
sessionkey = "fg687glgkf56vlgkf"
capath = "/path/to/the/dir"
cafile = "filename.test"
timeout = 666
max_retry = 42
# NOTE(hberaud) the client try to connect when we initialize the
# http client object so we need to catch the retries exception first.
# In a second time we need to mock the six.http_client to simulate
# server responses and do some other tests
with self.assertRaises(RetriesExhaustedError):
client = redfish_client(base_url=base_url)
# Check the object type
self.assertTrue(isinstance(client, HttpClient))
# Check the object attributes values.
# Here we check if the client object is properly initialized
self.assertEqual(client.base_url, base_url)
self.assertEqual(client.username, username)
self.assertEqual(client.password, password)
self.assertEqual(client.default_prefix, default_prefix)
self.assertEqual(client.sessionkey, sessionkey)
self.assertEqual(client.capath, capath)
self.assertEqual(client.cafile, cafile)
self.assertEqual(client.timeout, timeout)
self.assertEqual(client.max_retry, max_retry)
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex3_change_bios_setting(REDFISH_OBJ, "AdminName", "New Name")
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex14_sessions(REDFISH_OBJ, "admin", "admin123")
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex41_dump_eskm_event_log(REDFISH_OBJ)
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex30_get_powermetrics_average(REDFISH_OBJ)
state = dict(default='present', choices=['present', 'absent']),
name = dict(required=True),
enabled = dict(required=True, type='bool')
)
)
# When running on the server locally use the following commented values
# While this example can be run remotely, it is used locally to locate the
# iLO IP address
iLO_https_url = "blobstore://."
iLO_account = "None"
iLO_password = "None"
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
reset_ilo(REDFISH_OBJ)
module.exit_json(changed=True)
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex4_reset_server(REDFISH_OBJ)
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex47_clear_ahs_data(REDFISH_OBJ)
# iLO_account = "None"
# iLO_password = "None"
# When running remotely connect using the iLO secured (https://) address,
# iLO account name, and password to send https requests
# iLO_https_url acceptable examples:
# "https://10.0.0.100"
# "https://f250asha.americas.hpqcorp.net"
iLO_https_url = "https://10.0.0.100"
iLO_account = "admin"
iLO_password = "password"
# Create a REDFISH object
try:
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
except ServerDownOrUnreachableError, excp:
sys.stderr.write("ERROR: server not reachable or doesn't support " \
"RedFish.\n")
sys.exit()
except Exception, excp:
raise excp
ex32_set_bios_dhcp(REDFISH_OBJ, {'Ipv4Address':'192.168.0.1', \
'Ipv4Gateway':'192.168.0.2', \
'Ipv4PrimaryDNS':'192.168.0.3', \
'Ipv4SecondaryDNS':'192.168.0.4', \
'Ipv4SubnetMask':'192.168.0.5'})