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

143 Commits

Author SHA1 Message Date
Jarrod Johnson
cca6477509 Implement function to check SOL payload as keepalive
The IPMI layer keepalive is sufficient for most scenarios,
but SOL additionally cares about the SOL payload specifically.
During SOL session, use an SOL specific scheme for keepalive.

Change-Id: I23c5b8da4598696aa936274b3e6b527c8204b4db
2014-05-05 18:32:21 -04:00
Jarrod Johnson
f17ebf03dd Avoid zombie sessions corrupting living sessions
A logged out session failed to deregister it's keepalive.  As a result, the zombie
keepalive executed and failed.  The failure path then corrupts the bmc_handlers structure.
Correct this by both deregistering the erroneous keepalive and having the mark_broken
function be more careful about deleting a member of the class hash that it may have
nothing to do with.

Change-Id: I41251309dc27ffaca89cc7deef9bf16a61f1d07e
2014-05-05 10:56:18 -04:00
Jenkins
fd82b398df Merge "Do not reuse a session that is not logged" 2014-05-03 15:55:52 +00:00
Jarrod Johnson
95b1c15529 Do not reuse a session that is not logged
If a session was not logged, it would still be considered a candidate for
new session objects.  Disqualify such sessions so that new session
objects after a 'logout' or similar will be fulfilled.

Change-Id: I7af11a8a300b7aedcadcec7673d6308e3b08f27d
2014-05-03 11:52:46 -04:00
Jarrod Johnson
2115ed5c3b Break session objects on keepalive failures
If the keepalive fails, it was causing the library to spin
on expired keepalive attempts.  Call mark_broken in order to
avoid that spinning.

Change-Id: I1c7a06ebf7609989ebd6e90d26ac69f3fe7b8699
2014-05-02 13:36:06 -04:00
Jarrod Johnson
784b39d06e Use multiple sockets instead of one
Given the nature of SOL, it is impossible to control flow of incoming
traffic.  This means measures to mitigate the risk of exhausting buffer
memory on the socket cease to be effective.  Modify strategy to stop
throttling and instead allocate new sockets to acquire more network
buffer space.  This means the footprint of a small scale setup is
actually even lower and a larger setup does get more filehandles,
but still 1/64th the footprint of the usual strategy.

Change-Id: I10698393d31b0c04d0242ff85815239078c076e2
2014-05-02 10:08:45 -04:00
Jarrod Johnson
65f2a617d5 General cleanup of session
There are a number of issues flagged by code analysis.  None of them
are functional, but change to be happier by code analysis.

Change-Id: Id1c2fb9c32c1f7f45cc7cad77c09fb55fb40a8a3
2014-04-30 13:56:09 -04:00
Jarrod Johnson
238d5e22f8 Correct check for _sdr in command
In the attempt to clean up, one change broke how a command
object knows whether it has an SDR yet or not.  Correct that
mistake.

Change-Id: I76faaccf15c2dbfa2b7d5a3a4e1665e0cefe4c6d
2014-04-30 11:07:57 -04:00
Jenkins
9fb74f68b6 Merge "Clean up command.py" 2014-04-29 20:47:45 +00:00
Jarrod Johnson
0f8a3fd506 Clean up command.py
Command had a number of awkward style issues stemming from the original
design that was heavy in callbacks.  Clean up those issues.

Change-Id: I756e41ac7f909813ce6241f0889a85dd06599b2a
2014-04-29 16:31:54 -04:00
Jenkins
208b70e235 Merge "Correct mistakes in constants" 2014-04-29 20:10:16 +00:00
Jarrod Johnson
f3a8713356 Correct mistakes in constants
A number of copy/paste structural errors existed.  Correct them in
accordance with the specification.

Change-Id: I0984f85811744e3100f5990b0606dfbca98a69d4
2014-04-29 15:53:29 -04:00
Jarrod Johnson
aed5452279 Correct sensor offset for byte 5 state values
Code was erroneously adding 7 instead of 8.  Correct this
mistake.

Change-Id: I5a62c8c63e3a88b3150d0d67850ea0d339707295
2014-04-28 11:21:49 -04:00
Jarrod Johnson
9711d1edcf Fix mass thread initialization of sessions
There was a problem where the io thread could exist, but not yet
be ready.  Fix this by adding an iothreadready bool and a list of
events to fire when iothread is ready.

Change-Id: I4eb13e2210fa07bddbe717f56b12c736c99938dc
2014-04-22 09:43:28 -04:00
Jarrod Johnson
26f4ad8ec7 Add sensor information from IPMI 2.0 rev 1.1
IPMI 2.0 rev 1.1 adds support for modeling standby power supplies
and OS installation.  Add the appropriate constants.

Change-Id: I60ff394dad5209cedc6030afd740348db79c7f17
2014-04-18 07:52:10 -04:00
Jarrod Johnson
7228cd832d Add optical and bios aliases for boot devices
Notably, optical was the canonical output but not a recognized input.
'safe' and 'bios' added by request as well.

Change-Id: I061bbc6bce47fcdd2f3b7e9a3d3fb5f74569df15
2014-04-15 14:25:15 -04:00
Jarrod Johnson
cc8e5b56ab Auto degrade sessions to operator when admin is forbidden
In certain circumstances, the account desired for use with pyghmi will
be merely operator.  Accomodate this without configuration required by
going for admin and then falling back to operator by default.  For now
try to go no lower than operator.  It would be conceivable to go down
to user, but most everything one would want a service processor for
at that point isn't feasible anyway.

Change-Id: I775aee5db0ca5b8f18bebc2210d342e3d629016d
2014-04-14 16:03:53 -04:00
Jarrod Johnson
8fe8d11459 Add more missing sensor specific event information
Go through the IPMI spec and just add as much of table 42-3 as
is reasonable.  This should greatly improve usefulness of data
for a wider variety of circumstance.

Change-Id: I05693a609ddeecb49f18d7602403af72565b1a61
2014-04-14 14:26:42 -04:00
Jarrod Johnson
34a3f0fbaa Add version change sensor information
Add more information from table 42-3 to the codes understood by pyghmi.
A sensor reporting status on version/revision changes now resolves
to something meaningful.

Change-Id: Ib60b08e2762ece194c0905e4bf840b9a23257360
2014-04-14 13:27:11 -04:00
Jenkins
4d0eb62c47 Merge "Gracefully flag unrecognized discrete sensor states" 2014-04-14 13:19:21 +00:00
Jarrod Johnson
a3d4c42c5d Gracefully flag unrecognized discrete sensor states
Previously, pyghmi would incur a KeyError in the event of
something like sensor specific event not in the lookup tables.
Fix this by catching the error and putting in generic description
of state and flagging as 'warning'.  This sort of warning suggests
a bug in pyghmi that pyghmi needs to have its event descriptions
updated.

Change-Id: Ia5f4645e30a341a93456dae2b8d75d9fda542e1b
2014-04-11 16:44:32 -04:00
Jarrod Johnson
c9e76e4cd2 Add discrete states for event log status sensors
This allows pyghmi to accurately describe events pertaining to event log being
disabled for one reason or another.

Change-Id: Ieebbaa1d836ea115872e4bb6611ff1e9ade6e2c2
2014-04-11 16:31:22 -04:00
Jarrod Johnson
09f2b13793 Allow pyghmi to send break over IPMI SOL
Implement sending break over SOL.  A BMC may elect
to reply to this with a NACK saying 'break happened',
so have code treat that as 'ACK', since that was after all
the whole intent.

Change-Id: I84c85962fd80901bdef3fa22c3df4936420fb108
0.5.9.3
2014-04-09 15:13:53 -04:00
Jarrod Johnson
ff00327647 Switch from PyCrypto HMAC to standard python hmac
This seems to be a wash performance and functionality wise.  It does however
mean one less segment of code that incurs an external dependency.

Change-Id: I6691d95172d7d83eae4b4ed1265ba398b220f501
2014-04-03 12:42:19 -04:00
Jenkins
82883c4e10 Merge "Fix missing delay_xmit argument breaking power wait requests" 2014-03-25 19:07:52 +00:00
Jarrod Johnson
bf7dd29a2d Tolerate unicode strings as username and password
In case of unicode username and password values, just utf-8 encode them.
Here, the encoding shouldn't matter much.  All parties must agree
on encoding, but UTF-8 is fine.

Change-Id: Ia4a8a4fcbc5ea9b12ee45ebcc566abe4713b544a
2014-03-25 14:28:56 -04:00
Jarrod Johnson
67e7d84abd Fix missing delay_xmit argument breaking power wait requests
The 'command' variant of raw_command did not recognize the delay_xmit
parameter.  When code was changed to go through self instead of through
session, this facet was missed.  Fix the problem by adding hook to
pass through that information.

Change-Id: I6c5a13940e753c4300b18500bad60f216e08ad43
2014-03-24 14:08:52 -04:00
Jarrod Johnson
44370a9a0b Fix race condition in requesting delays
When something other than the IO worker thread requests a delay,
there was an interval between pending requests and the new
deadline being calculated during which the non-IO thread would
erroneously consider the old rather than upcoming deadline.
Address by creating a worst case deadline prior to evaluating
pending requests.

Change-Id: Iabde555eb81d2155f4bc4562f0b3a209e1be42a9
2014-03-06 16:53:07 -05:00
Jarrod Johnson
343deca5d9 Fix race condition on sending data
If data was sent prior to the activate payload response, the code
to calculate the maximum chunk could not suceed.  Correct this
by having sent data accumulate as pending until connected state reached.

Change-Id: I7c9aed67209b3526bd10cafeee0bae6b1b0ab85f
0.5.9.1
2014-02-14 09:42:29 -05:00
Jarrod Johnson
9eb13b9f8c Fix large paste to SOL session
While pyghmi was recording the maximum size the BMC advertised as accepting,
it was not honoring it.  Correct this by having the sendpendingpayload function
only send the first 'self.maxoutcount' bytes.  This actually turns into a loop
because the ACK coming back for the chunk of data triggers a send of pending
data, which includes the leftovers of the last attempt.

Change-Id: I8e443e08a6eb4ed89eb74412cca92e2138cf9d00
0.5.9
2014-02-14 08:52:56 -05:00
Jarrod Johnson
6e58eae301 Move previous fix out to command and console
console at least needed the assignment to the session to occur
prior to its callback working.  Move the responsibility of the
mandatory loop iteration up a layer so that pyghmi won't break,
but calling code won't have to worry about this either.

Change-Id: I6711acf97574581bb389259563e82e4430bb3f98
2014-02-06 10:04:54 -05:00
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