Skip to content

Commit 0a5a39d

Browse files
committed
Updating to version 2.3
1 parent 9dc767d commit 0a5a39d

File tree

17 files changed

+1315
-2967
lines changed

17 files changed

+1315
-2967
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: python
22
python:
33
- "2.7"
4+
- "3.6"
45

56
# command to install dependencies
67
install: "pip install -r requirements.txt"

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ Inband communication
5151
To enable support for inband communications, you must download the DLL/SO for your system from: windows_ / linux_. It must be placed in your working environment path.
5252

5353

54-
.. _windows: https://downloads.hpe.com/pub/softlib2/software1/pubsw-windows/p1463761240/v146412/ilorest_chif.dll
55-
.. _linux: https://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1093353304/v146413/ilorest_chif.so
54+
.. _windows: https://downloads.hpe.com/pub/softlib2/software1/pubsw-windows/p1463761240/v145660/ilorest_chif.dll
55+
.. _linux: https://downloads.hpe.com/pub/softlib2/software1/pubsw-linux/p1093353304/v145585/ilorest_chif.so
5656

5757
Usage
5858
----------
@@ -144,6 +144,8 @@ History
144144
* 04/12/2017: Release of v1.9.1
145145
* 07/17/2017: Release of v2.0.0
146146
* 10/30/2017: Release of v2.1.0
147+
* 02/20/2018: Release of v2.2.0
148+
* 06/11/2018: Release of v2.3.0
147149

148150
Copyright and License
149151
---------------------

examples/Redfish/ex07_change_boot_order.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
def ex7_change_boot_order(redfishobj, bios_password=None):
2020
sys.stdout.write("\nEXAMPLE 7: Change Boot Order (UEFI)\n")
2121
instances = redfishobj.search_for_type("ServerBootSettings.")
22+
if not len(instances) and redfishobj.typepath.defs.isgen9:
23+
sys.stderr.write("\nNOTE: This example requires the Redfish schema "\
24+
"version TBD in the managed iLO. It will fail against iLOs"\
25+
" with the 2.50 firmware or earlier. \n")
2226

2327
for instance in instances:
2428
response = redfishobj.redfish_get(instance["@odata.id"])

examples/Redfish/ex45_get_license_key.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def ex45_get_license_key(redfishobj):
2323
else:
2424
instances = redfishobj.search_for_type("HpeiLOLicense.")
2525
license_result = dict()
26-
licenseproperties = ["License", "LicenseKey", "LicenseType"]
26+
licenseproperties = ["License", "LicenseType"]
2727

2828
for instance in instances:
2929
response = redfishobj.redfish_get(instance["@odata.id"])
@@ -32,8 +32,14 @@ def ex45_get_license_key(redfishobj):
3232
for licenseproperty in licenseproperties:
3333
sys.stdout.write("\t" + licenseproperty + ": " + \
3434
str(response.dict[licenseproperty]) + "\n")
35+
try:
36+
lickey = response.dict["ConfirmationRequest"]["EON"]["LicenseKey"]
37+
except KeyError:
38+
lickey = response.dict["LicenseKey"]
39+
sys.stdout.write("\t" + "LicenseKey" + ": " + lickey + "\n")
40+
3541
redfishobj.error_handler(response)
36-
42+
3743
return (license_result)
3844

3945
if __name__ == "__main__":
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2016 Hewlett Packard Enterprise Development LP
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4+
# not use this file except in compliance with the License. You may obtain
5+
# a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12+
# License for the specific language governing permissions and limitations
13+
# under the License.
14+
15+
import sys
16+
from _redfishobject import RedfishObject
17+
from redfish.rest.v1 import ServerDownOrUnreachableError
18+
19+
def ex54_expand_data(redfishobj, expand_url=None):
20+
sys.stdout.write("\nEXAMPLE 54: Expand Data Syntax\n")
21+
if redfishobj.typepath.defs.isgen9:
22+
sys.stderr.write("\nNOTE: Expand Syntax is not available on iLO 4 "\
23+
"systems. \n")
24+
else:
25+
response = REDFISH_OBJ.redfish_get(expand_url)
26+
exp_response = REDFISH_OBJ.redfish_get(expand_url+'?$expand=.')
27+
sys.stdout.write('Standard response:\n')
28+
sys.stdout.write('\t'+str(response.dict)+'\n')
29+
sys.stdout.write('Expanded response:\n')
30+
sys.stdout.write('\t'+str(exp_response.dict)+'\n')
31+
32+
if __name__ == "__main__":
33+
# When running on the server locally use the following commented values
34+
# iLO_https_url = "blobstore://."
35+
# iLO_account = "None"
36+
# iLO_password = "None"
37+
38+
# When running remotely connect using the iLO secured (https://) address,
39+
# iLO account name, and password to send https requests
40+
# iLO_https_url acceptable examples:
41+
# "https://10.0.0.100"
42+
# "https://f250asha.americas.hpqcorp.net"
43+
iLO_https_url = "https://10.0.0.100"
44+
iLO_account = "admin"
45+
iLO_password = "password"
46+
47+
# Create a REDFISH object
48+
try:
49+
REDFISH_OBJ = RedfishObject(iLO_https_url, iLO_account, iLO_password)
50+
except ServerDownOrUnreachableError as excp:
51+
sys.stderr.write("ERROR: server not reachable or doesn't support " \
52+
"RedFish.\n")
53+
sys.exit()
54+
except Exception as excp:
55+
raise excp
56+
57+
ex54_expand_data(REDFISH_OBJ, "/redfish/v1/systems/")
58+
REDFISH_OBJ.redfish_client.logout()

makeandinstallzip.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
python setup.py sdist --formats=zip
22
cd dist
3-
pip install --upgrade python-ilorest-library-2.2.0.zip
3+
pip install --upgrade python-ilorest-library-2.3.0.zip

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ requires = jsonpatch >= 1.3
77
jsonpointer >= 1.1
88
urlparse2 >= 1.1.1
99
validictory >= 1.0.1
10-
ilorest_chif >= 2.1.0
10+
ilorest_chif >= 2.3.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22

33
setup(name='python-ilorest-library',
4-
version='2.2.0',
4+
version='2.3.0',
55
description='iLO Rest Python Library',
66
author = 'Hewlett Packard Enterprise',
77
author_email = 'kocurek@hpe.com',

src/redfish/hpilo/risblobstore2.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
from ctypes import c_char_p, c_ubyte, c_uint, cdll, POINTER, \
2929
create_string_buffer, c_ushort
3030

31-
from redfish.hpilo.rishpilo import HpIlo
31+
from redfish.hpilo.rishpilo import HpIlo, HpIloInitialError
32+
from redfish.hpilo.rishpilo import BlobReturnCodes as hpiloreturncodes
3233

3334
if os.name == 'nt':
3435
from ctypes import windll
@@ -799,10 +800,11 @@ def _send_receive_raw(self, indata):
799800
try:
800801
resp = self.channel.send_receive_raw(indata, 10)
801802
return resp
802-
except Exception as excp:
803+
except Exception as exp:
803804
self.channel.close()
804805
lib = self.gethprestchifhandle()
805806
self.channel = HpIlo(dll=lib)
807+
excp = exp
806808
if excp:
807809
raise excp
808810

@@ -858,11 +860,15 @@ def initializecreds(username=None, password=None):
858860
passnew = create_string_buffer(password.encode('utf-8'))
859861

860862
dll.initiate_credentials(usernew, passnew)
861-
862-
if not dll.ChifVerifyCredentials() == BlobReturnCodes.SUCCESS:
863-
raise Blob2SecurityError()
863+
credreturn = dll.ChifVerifyCredentials()
864+
if not credreturn == BlobReturnCodes.SUCCESS:
865+
if credreturn == hpiloreturncodes.CHIFERR_AccessDenied:
866+
raise Blob2SecurityError()
867+
else:
868+
raise HpIloInitialError("Error %s occurred while trying " \
869+
"to open a channel to iLO" % credreturn)
864870
else:
865-
#so we don't have extra overhead if we don't have to
871+
#so we don't have extra overhead if we don't have to
866872
dll.ChifDisableSecurity()
867873
BlobStore2.unloadchifhandle(dll)
868874

src/redfish/hpilo/rishpilo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#---------Imports---------
2121

2222
import os
23-
import sys
2423
import time
2524
import struct
2625
import logging
@@ -76,7 +75,7 @@ class HpIlo(object):
7675
def __init__(self, dll=None):
7776
fhandle = c_void_p()
7877
self.dll = dll
79-
if '-d' in sys.argv:
78+
if LOGGER.isEnabledFor(logging.DEBUG):
8079
self.dll.enabledebugoutput()
8180
self.dll.ChifInitialize(None)
8281

0 commit comments

Comments
 (0)