get_server_name() throwing xml.etree.ElementTree.ParseError
transce opened this issue · comments
Removed ip address, username, and password for privacy concerns.
import hpilo
ilo = hpilo.Ilo("{ip_address}", login='{username}', password="{password}")
ilo.get_fw_version()
{'firmware_date': 'Aug 16 2017', 'firmware_version': '2.55', 'license_type': 'iLO Advanced', 'management_processor': 'iLO4'}
ilo.get_server_name()
Traceback (most recent call last):
File "", line 1, in
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 1243, in get_server_name
return self._info_tag('SERVER_INFO', 'GET_SERVER_NAME', 'SERVER_NAME', process=lambda name: name['value'])
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 698, in _info_tag
header, message = self._request(root)
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 253, in _request
message = self._parse_message(data[:pos])
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 556, in _parse_message
message = etree.fromstring(data)
File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1333, in XML
parser.feed(text)
File "", line None
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 8, column 48
That smells like an iLO bug. Could you set ilo.debug=2
before calling get_server_name()
and share the debug output (after sanitizing out the sensitive info)?
ilo.get_server_name()
Connecting to {ip_address} port 443
Connecting to {ip_address} port 443
Sending XML request, 257 bytes
POST /ribcl HTTP/1.1
Host: localhost
Content-Length: 176
Connection: Close
<?xml version="1.0"?>
<RIBCL VERSION="2.0"><LOGIN PASSWORD="********" USER_LOGIN="{username}"><SERVER_INFO MODE="read"><GET_SERVER_NAME /></SERVER_INFO></LOGIN></RIBCL>
Received 1268 bytes
HTTP/1.1 200 OK
Content-Type: text/xml
Transfer-Encoding: chunked
Cache-Control: no-cache
Connection: close
Date: Tue, 24 Apr 2018 15:01:03 GMT
X-Frame-Options: sameorigin
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
<SERVER_NAME VALUE="{server_name}"/>
<SERVER_OSNAME VALUE="Oracle Linux Server" "/>
<SERVER_OSVERSION VALUE="6.9" "/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
<?xml version="1.0"?>
<RIBCL VERSION="2.23">
<RESPONSE
STATUS="0x0000"
MESSAGE='No error'
/>
</RIBCL>
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 1243, in get_server_name
return self._info_tag('SERVER_INFO', 'GET_SERVER_NAME', 'SERVER_NAME', process=lambda name: name['value'])
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 698, in _info_tag
header, message = self._request(root)
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 253, in _request
message = self._parse_message(data[:pos])
File "/home/apotts2/razors_edge/lib/python3.5/site-packages/hpilo.py", line 556, in _parse_message
message = etree.fromstring(data)
File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1333, in XML
parser.feed(text)
File "<string>", line None
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 8, column 48
That looks like you've stripped too much from the output. Between X-Frame-Options
and the traceback, there should be the actual XML data.
Weird. It showed all on the write pane, but not on the preview. Attached as a file.
Edited your comment to make sure all the data shows up, and we have an iLO bug indeed.
<SERVER_OSNAME VALUE="Oracle Linux Server" "/>
<SERVER_OSVERSION VALUE="6.9" "/>
That is not valid XML. This isn't the first time that iLO has bugs like this
Could you please report this bug to HP? I'll add a workaround in python-hpilo, but this should be fixed in the firmware.
We have a couple of HPE guys on site. I'll see if they know how to submit one for firmware fix. Thanks for looking.
I've added a workaround in 3c8e3db, but since my iLO's don't exhibit this behaviour, I can't actually test this workaround. Could you give it a spin?
Here is the end output. Everything above the traceback looks the same:
Traceback (most recent call last):
File "/home/apotts2/hpilo_check/lib/python3.5/site-packages/hpilo.py", line 569, in _parse_message
message = etree.fromstring(data)
File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1333, in XML
parser.feed(text)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 8, column 48
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/apotts2/PycharmProjects/check_hpilo/check_hpilo.py", line 8, in
ilo.get_server_name()
File "/home/apotts2/hpilo_check/lib/python3.5/site-packages/hpilo.py", line 1309, in get_server_name
return self._info_tag('SERVER_INFO', 'GET_SERVER_NAME', 'SERVER_NAME', process=lambda name: name['value'])
File "/home/apotts2/hpilo_check/lib/python3.5/site-packages/hpilo.py", line 713, in _info_tag
header, message = self._request(root)
File "/home/apotts2/hpilo_check/lib/python3.5/site-packages/hpilo.py", line 253, in _request
message = self._parse_message(data[:pos])
File "/home/apotts2/hpilo_check/lib/python3.5/site-packages/hpilo.py", line 571, in _parse_message
message = etree.fromstring(self._attempt_to_fix_broken_xml(data))
File "/usr/lib/python3.5/xml/etree/ElementTree.py", line 1333, in XML
parser.feed(text)
TypeError: a bytes-like object is required, not 'NoneType
That's why I hate not being able to test before committing, this was a dumb bug on my side. Try 451943c please 😁
I thought all good developers test in production. Hehehe.
No errors this time, but there was not output from get_server_name(). Is that what you are expecting?
Production is the best place for testing 😄
But I would expect something to be returned from get_server_name
. Are you sure you're printing the return value?
Ugh. My fault. That's what I get for doing three projects at the same time. I'm getting the servername now. Looks good.
Awesome! Thanks for reporting bugs