2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-16 04:38:19 +00:00

112 Commits

Author SHA1 Message Date
Jarrod Johnson
ea810dfdda Fix session reuse stall for async usage
Previously, calling code had to manually force an event loop iteration
after making an asynchronous session creation request.  Address that
by making a non blocking iteration request happen automatically.

Change-Id: I64f814401cb5ac397ac9ca4a1ae1d434976a2b01
2014-02-06 09:53:42 -05:00
Jarrod Johnson
e9000313f2 Make pyghmi tolerate arbitrary threading models
When calling from various threading code strategies, pyghmi
would cause confusion and eventlet to print debug output.
Create a dedicated IO thread to isolate the shared socket
usage from calling code thread behavior.  Currently, it still
requires that calling code loop on wait_for_rsp to assure session
liveness and/or to do SOL.

Change-Id: I66164adbfd867200af53269553210a70a0619a85
2014-02-05 14:01:21 -05:00
Jarrod Johnson
e4c76de082 Do not count empty SOL data as keepalive data
If the console layer sends an SOL payload with zero data (which is
valid to do) the session object would treat that as keeping the
session alive on the BMC side.  Many BMCs do not consider empty
SOL payload packets toward session activity.  Accomodate by having
the keepalive deferral not be triggered by such packets.

Change-Id: I8d278dbc48fae296c754ce9bc8f05bc92b560374
2014-02-02 09:30:45 -05:00
Jarrod Johnson
02848d66b7 Use different timeout values for logon and retry
When establishing a session, there is not much to lose.
If three get channel authentication capabilities fail, it's
almost certainly because it just isn't going to work (bad IP,
rebooting BMC, something like that).  However, once signs of life
have been displayed, the likely cause of an outage shifts toward
a transient network outage (e.g. link speed negotiation after
rebooting a shared nic configured solution).  Particularly with SOL,
there is a high chance of inflight data worth trying to recover the
session to get.  For that we go to tolerating up to ~20 seconds of
outage.  Much longer than that and we are pretty much certain to run
afoul of BMC timeout anyway, so no hope of withstanding something like
spanning tree with blocking by default, but it can withstand moderately
well configured networks.

Change-Id: I783d13eaee4360cfd780e28b2b4cbf77cc980945
2014-02-01 19:08:04 -05:00
Jarrod Johnson
79efa5e1b4 Fix Console write race condition
If a caller tries to send data immediately after getting their
Console object, they can trigger a problem since the session is not
yet established.  Correct this by spinning in send_payload until
session is either established or fails.

Change-Id: Ia3a2582563d5385212202c036c0716a3cf36b80c
2014-02-01 10:38:59 -05:00
Jarrod Johnson
e0f34700ec Reasonably relay IPMI errors to console handlers
Previous changes resulted in construction of a new dict nesting the
dict of interest.  Correct this by passing through dict rather than
embedding it within another dict.

Change-Id: I77969097f530c866cb00d07844393676ac254907
2014-01-31 16:41:31 -05:00
Jarrod Johnson
46228d23a1 Allow special handling to preceed generic handler
The IPMI session layer now, with more constants defined, catches the SOL
error and populates 'error' message.  Move the generic handler code
to come after the specific condition handler to allow things like forced
sessions to work as expected.

Change-Id: I62ab5fc16a9af631317eff78b8445b06a76b56d8
2014-01-31 15:23:34 -05:00
Jarrod Johnson
ed220d6ebd Fix exception if login times out
If a client attempts connection to a BMC that is not there,
unusual KeyError would get thrown.  Correct this by only
attempting to deregister the element if it is registered.

Change-Id: I3febb92ae8bc40c2847758797f179e85d58d97b1
2014-01-31 15:15:23 -05:00
Jarrod Johnson
c18693ab3d Detect and notify Console users of disconnect
If a session becomes non viable, alert the calling code to the condition.
Calling code needs to be able to recognize non string data if registering
a callback for this to work.

Change-Id: I0bb921c5b88edd1ca2e4ba2594e28e9e0ce5ca81
2014-01-30 18:52:08 -05:00
Jarrod Johnson
d4f856ebb1 Detect broken sessions
When a session is broken for whatever reason, make it possible for
a long running user of the library to reasonably recover by
having a broken Session object detect the situation and disqualify
itself from the mechanisms to reuse sessions.

Change-Id: Id63c3490d6bbeab7d5de7f92c1eae012a648c416
2014-01-30 16:14:30 -05:00
Jarrod Johnson
ff3d56620d Fix keepalive behavior on broken Sessions
If a Session object is broken (e.g. BMC goes away or network outage),
then its keepalive timer would cause an application to be starved
of being able to do any IPMI related work.  Address this scenario
by having the instance deregister its keepalive at the point it
reports itself as broken.

Change-Id: I6b7af8ad03759c676110fb4f0b7bfa41642152f3
2014-01-29 15:34:47 -05:00
Jenkins
ba5bbe1fc4 Merge "Add BMC bridge request extension" 2014-01-24 14:57:05 +00:00
Jarrod Johnson
3cd40c5f1c Add support for discrete sensors
Previously support was added for 'analog' sensors.  This incorporates
support for 'discrete' sensors.  Those are sensors without a particular
numeric value, but a set of states to assert.

Change-Id: Ia8087ded8699f6f59853ffc93cc1842f8867faca
2014-01-21 17:32:35 -05:00
Fengqian Gao
c1d4252743 Add BMC bridge request extension
Support BMC bridge request, users can specify
target slave address and channel number for the command

Change-Id: Idf4c4567013e769ab71350db4cea947b2dc820ed
2014-01-21 14:46:54 +08:00
Jarrod Johnson
7ac880f3f8 Add 'get_health' to Command class
Provide a convenience function that summarizes the overall health
of the managed system based.  Currently, it just enumerates all
SDR indicated sensors seeking unhealthy readings.

Change-Id: Ifce6d05623acc86b6bf42ceb57824b65eefa36ae
2014-01-20 18:31:40 -05:00
Jarrod Johnson
fe7539ab83 Add 'get_sensor_data' to Command class
Have Command class provide access to the sensor data
as enabled by the SDR commit.

Change-Id: I2eede764597cff74409370230cc5d3f120c4ed65
2014-01-20 15:54:25 -05:00
Jarrod Johnson
3a4338365b Add support for retrieving SDR data
This patch implements SDR retrieval and the foundation to use the data
to translate raw sensor reading data to usable information.

Change-Id: Ic77fcde6a283a2ee7745a9c159038d2655911b0a
2014-01-20 15:09:33 -05:00
Jarrod Johnson
0897e0d408 Remove surviving 'callback' code
Having previously forgotten about the callback option in logout, programs
could generally not actually complete.  Fix it so that logout() works as
intended.

Change-Id: I04394821646074c734438b7de6970c8282e2c761
2014-01-03 13:42:39 -05:00
Jarrod Johnson
9290111ba7 Remove callback from session.py
In the private session module, there was originally a thought
that a callback model was going to be the path for code to implement
interleaved execution.  However, since that point a coroutine pattern
has proven to afford the same benefits with simpler looking calling code.
With this in mind, remove some of the disused code in order to make
the session module a little easier to follow.

Change-Id: Ice697df409dd188d7e3361d278f8b1ce1358a419
2014-01-03 12:01:58 -05:00
Jenkins
7dc8d5f532 Merge "Remove callback usage from console.py" 2014-01-03 16:46:14 +00:00
Jarrod Johnson
9157628f01 Add errors for activate session response codes
Change-Id: If29da4f6ae0acdfb40077aeb1a5b2f276fa00aa1
2014-01-03 10:33:59 -05:00
Jarrod Johnson
41c549d0e9 Remove callback usage from console.py
In command.py, settled on coroutine structure as the sole design
pattern to support.  To be consistent, abolish the use of callback
from console.py as well so that SOL does not needlessly act so different
from command.py in the scenarios where it can act the same.

Change-Id: I7a26a7c9b929ef7e63ca23c595a28baeb7f1e1b9
2014-01-03 10:29:11 -05:00
Jarrod Johnson
352a2faf8a Fix some reentrant scenarios
If a command payload is pending, fix calls to raw_command by
deferring instance modification until the last command was settled.

Fix a deadlock scenario where packet transmit gets blocked by
waiting on incoming packets that will never come by avoiding
calling out to caller custom handlers which might expect to be
submitting new requests during transmit.

Fix a problem if command is requested while awaiting for an SOL
acknowledgement.

Change-Id: Ia352566819cce06c6e4e5279afeb6191838e0488
2013-10-16 10:07:16 -04:00
Jarrod Johnson
5a1182042d Have ipmi session objects reuse themselves
When multiple session objects would be created by calling code,
avoid creating a conflict on bmc_handlers that would result
in trying to use a corrupt instance.  Either it reuses the
existing object, or else it detects that some parameters are
different and erases old pointers to the now defunct instance.

Change-Id: I883934ae984b2ad0369458bea15f62862c6e97ca
2013-10-13 19:50:53 -04:00
Jarrod Johnson
9dadfe0efe Stop waiting on logout during atexit
During atexit time, do not wait for BMCs to acknowledge logout.
This is generally a waste of time and can cause things like eventlet
to complain since atexit won't exit in a coordinated way with
greenthread context

Change-Id: I295215614ee6a20ce63f5a9ac37bbe3d9b2d9848
2013-10-13 16:00:20 -04:00
Jarrod Johnson
b86e197210 Change SOL code to not send empty data to caller
If a SOL target sends a packet with no new data (e.g. spurious retry), do not
bother the caller with such empty data.  It's a waste of their attention at
best and if the caller is doing something like trying to write the data
straight to a TLS socket, it will trigger EOF exception.

Change-Id: I1d751331bc0fa0087bf671de12507b7fe011f5fa
2013-10-11 14:59:51 -04:00
Jarrod Johnson
ffe493df0f Use distinct exceptions for many cases
Caller is likely going to want to catch certain conditions.  For those,
use more specific exception classes.  Exceptions indicating either TODO
or usage errors are being left as 'Exception' for the time being.

Change-Id: I4d68a2dbc394b534d54586b9f770160c1409f720
0.5.8
2013-09-25 09:04:43 -04:00
Jarrod Johnson
ccac817f2b Enhance filehandle registration
Previously, pyghmi only could have file objects registered.  Accept
and adjust as appropriate to accomodate plain int filedescriptors.
This allows, for example, os.pipe() construct to be hooked.

Change-Id: Ie5e81a2276c68e9235d373d4a662f7b1aef153f5
2013-09-14 21:36:44 -04:00
Jarrod Johnson
35b50fb705 Fix pyghmi behavior on BMC NACK
When BMC sent NACK, pyghmi incorrectly attempted to construct new payload
by concatenating a tuple and str.  Fix by converting the tuple to
str prior to sending.

Change-Id: Ia07384651870bf01e7dc24757e1e00018ab84556
2013-09-14 10:03:56 -04:00
Monty Taylor
781a7829be Update from requirements
Trying to remove usage of d2to1 - it can cause breakages.
Also, had to fix hacking 102. Turns out it expects copyright headers in
comments, not docstrings.

Change-Id: I3494349ffe2d4cba9c8bcb73408d60bbc12eff5e
0.5.7
2013-09-13 11:28:28 -05:00
Jarrod Johnson
317417987f Correct concatenation of string and int object
Straightforward change, a mistake was made with a string and an int
was concatenated.

Change-Id: I96de0f32b387e524c90d42acb5dcf6c808448b14
0.5.6
2013-09-12 10:08:14 -04:00
Jarrod Johnson
bdbb6aa018 Expose wait_for_rsp class method via public classes.
In complicated uses of pyghmi, it becomes useful to call into the
otherwise private event loop iteration.  This exposes the
wait_for_rsp method so that it may be consumed without violating
the expectations of private.

Change-Id: Iee64615f0577b00895f8c3db25676c877107b0be
0.5.5 0.5.4 0.5.3
2013-09-11 16:34:10 -04:00
Jarrod Johnson
f24395bbee Fix mistake with external filehandle and solconnect
In changing to select, the nature of the return value failed.
When using poll(), we got file descriptor number.  However select
provides the object and so we have to consult the fileno() method.

Change-Id: Ic525b315024b164eed22238ad1e4a89eed0fcf0c
0.5.2
2013-09-11 15:21:36 -04:00
Jarrod Johnson
5832db6a30 Change from poll() to select()
poll is not available in all platforms.  Additionally, eventlet
does not handle poll in a monkey patching scenario.  Use select()
as the greatest common factor.

Change-Id: I170d6efb1636249df4b7ed42eac6378ae317cb35
0.5.1
2013-09-10 09:18:36 -04:00
Jarrod Johnson
5c5c6770ea Have callback recognize any callable
Previously, callback had to be a function.  This misses a lot of things,
notably instance methods.  Change to recognize any callable.

Change-Id: I9d2a00fe53f7e8039f0badeb4af0fdd3c6339b89
2013-09-09 16:49:16 -04:00
Jenkins
ef22636766 Merge "Add function to send sol data" 2013-08-22 21:20:30 +00:00
Jarrod Johnson
c2ee99eb0d Add function to send sol data
In the case of using function callin/callout, the console module was missing
a callin.  Correct that omission.

Change-Id: I233b43eadf115ad617958148878b96f38bff1971
2013-08-22 16:50:59 -04:00
Jenkins
e6d0e2ae0d Merge "Finalize rename to pyghmi" 2013-08-22 20:08:25 +00:00
Jarrod Johnson
c13a5a375d Add support for non standard ports.
It is possible and in some cases required for an implementation to deviate
from the IPMI standard port of 623.  This enables the library to actually
support that case.

Change-Id: I62e322410924153cebde9827d7ba0d0583aa1d83
2013-08-22 16:04:48 -04:00
Monty Taylor
cfe88ab875 Finalize rename to pyghmi
Change-Id: I11999d644c6f583a458eaa504b46f1b0eba24b21
2013-08-17 22:29:25 -04:00
Jarrod Johnson
3ed2ef8494 Fix raw handling by ipmictl.py
The test harness was incorrectly throwing string values at the library.
Correct that by explicitly converting from hex string to int.

Additionally, command.py was failing to pass data through.

Change-Id: Iceda4c3b4a382992d445f90dfbc19f6c75b528df
2013-08-15 13:58:29 -04:00
Jarrod Johnson
04a9b89d15 Rework set_power handling of errors and noops
set_power failed to raise when error encountered.  The behavior is
amended to be consistent with other functions.

set_power requested on/off state even if system already was in requested
state.  Change to simply report success in that scenario.

Change-Id: I6feb8f4384705136a5ab1fae0899ea27b2d3511c
0.5.0
2013-08-12 16:10:00 -04:00
Jenkins
7e4f5a381f Merge "Rename package from python-ipmi to pyghmi" 2013-08-08 20:34:50 +00:00
Jenkins
5ac560d720 Merge "Change long timeout to select() from poll()" 2013-08-08 20:34:38 +00:00
Jarrod Johnson
ebbf8c94e4 Rename package from python-ipmi to pyghmi
Some have expressed a concern that ipmi is both too generic a term
and too limiting in scope.  Change python-ipmi to pyghmi to more
easily allow the project to be specifically be referenced and denote
the likelihood of non-ipmi protocols being supported

Change-Id: I9c96f2154050a2970fc217e0eeae733605a38bde
2013-08-08 14:31:45 -04:00
Jarrod Johnson
c0f4959ed7 Change long timeout to select() from poll()
Change from poll() to select() for the potentially long wait in ipmi
event loop.  This is to facilitate interop with being monkey patched
with eventlet, as eventlet does not currently monkey patch poll(), but
does monkey patch select()

Change-Id: I8d6f42193ee82e2c5de7ad112232c2c77ef78825
2013-08-08 14:19:09 -04:00
Jarrod Johnson
939ebea0f3 Enhance wait behavior of set_power
Previously, wait would always be indefinite and act in many ways like
a busy wait.  The check for completion now takes one second between
every check.  The default behavior now goes for 300 seconds, but
wait can now take an int to indicate a different preference by the
caller.  300 seconds may seem like a lot, but the 'softoff' request
in particular suggests waiting for OS shutdown process to complete.

Additionally, some bugs in the retry logic were noted in the process
of having the retry timer drive the delay and are corrected.

Change-Id: Ibe34e87c2a58f13981d60e5f80b4b636e67ac3f9
2013-08-08 14:08:35 -04:00
Jarrod Johnson
7371a58aba Rename to pyghmi
It has been expressed as a concern that 'ipmi' is too generic a name.
Additionally, it is also the case that non-ipmi capability is likely
to be incorporated as it goes along (e.g. Enclosure management and
virtual media are frequently not IPMI based).

Move existing content under the 'pyghmi' namespace.  pyghmi stands for
'python general hardware management infrastructure' and is pronounced
'pygmy'

Change-Id: Ib549a9f5b7dd549c7dc5ddbab251a2e06c572e41
2013-08-07 13:51:05 -04:00
Jarrod Johnson
b985624a4b Remove callback arguments from most functions.
After some contemplation, I realized that given the underlying behavior of 'wait_for_rsp', that
synchronous and asynchronous calls play well with each other.  The pattern of considering an 'onlogon'
function as running in a sort of greenthread works well and leads to much more comprehensible code
for the average person.  While removing those arguments, the module contents were reorganized to
serve as an example of how more straightforward code written in this fashion may be.

Change-Id: I9c83660e4d3c68ad8ae0c016a3377b2a0e7ee6ec
2013-07-25 15:23:06 -04:00
Jarrod Johnson
86a2d39db7 Change session timer to monotonic when possible
Previously the ipmi session was using time.time().  This means
that retries and keepalives could be thrown off by things like ntp
or manual time corrections.

Ideally, we'd use the baked in time.monotonic(), but that doesn't exist
aside from python 3.3

Change-Id: Ia00026cef6df214f9463909309de44767c3752b5
2013-07-23 15:23:20 -04:00