2
0
mirror of https://opendev.org/x/pyghmi synced 2025-01-15 20:27:45 +00:00

175 Commits

Author SHA1 Message Date
Jenkins
9bf8258edf Merge "Force non-numeric for compact sensor records" 2014-08-08 12:52:55 +00:00
Jenkins
0ad769d9d4 Merge "Handle non-linear and unrecognized linearizations" 2014-08-06 13:58:35 +00:00
Jarrod Johnson
7a3096e07b Force non-numeric for compact sensor records
In the IPMI spec, compact sensors have the numeric format reserved
and mandate an implementation set it to '3'.  This mandate seems
to have been ignored by some implementations.  Force the value to be
3 for all compact sensor records and assume the reserved bits may never
be used in a compact sensor.

Change-Id: I88f5d7b533869809f213ab0c5379b276af50cd23
2014-08-06 09:49:28 -04:00
Jarrod Johnson
817998fe0a Change to name-only lookups in RAKP
In IPMI2, there are two modes the BMC can regard the Role parameter.
It can either consider it a 'max privilege' or 'match privilege'.
It defaulted to 'match privilege' in order to enhance compatibility
with some earlier BMC implementations that misinterpreted the
specification in a way that allowed 'match privilege' to work but
'max privilege' to break without a specific workaround for that BMC.
That BMC family is pretty much out of service and if the same issue
arises later, we can put in auto-detect and workaround pretty cheaply.
With this in mind, change the mode to look account up by name only
since that is how 99% of ipmitool invocations are done and it
also is a more straightforward model.

Change-Id: Ibf82b70e1b85e4e05c93365a684e21c434b4d5b4
2014-08-05 16:00:12 -04:00
Jarrod Johnson
7ceb22b8c4 Handle non-linear and unrecognized linearizations
Since we cannot hope to linearize a linearizable value without
understanding the formula (OEM or future spec), treat all unrecognized
linearizations and non-linearizable and rely upon get sensor reading
factors to determine the value.  Add the capability to actually get
the sensor reading factors and then pass the resultant data through
the same decode_formula that would have been use had the factors
been retrieved through the SDR record.

Change-Id: I4c3a6bbbd6c68f7a0d19c2a7a221eb5fb57c99de
2014-08-04 11:04:44 -04:00
Jarrod Johnson
94433a2ab5 Add 'persistent' to return dict of get_bootdev
This enables a caller to understand more about the nature of the boot device
parameter

Change-Id: Iec2e9b5be06a6340fbc1e3461532f749c972558e
2014-07-31 10:22:53 -04:00
Lucas Alvares Gomes
ee4cd47588 Use get() to avoid KeyError on get_bootdev()
The method get() returns a value for the given key. If key is not
available then returns default value None. I think that was the
intention of the initial code.

Change-Id: I974258822d54f7ac09bc4197eb4ec249784012e7
2014-07-23 10:22:01 +01:00
Jarrod Johnson
8740687e0f Reduce severity of generic discrete assert to 'Ok'
In practice, generic discrete sensors have not indicated good *or* bad
health They have most commonly been used to indicate something like a
particular option being available or user disabled.  This does mean
that something trying to use an utterly generic discrete sensor will
not trigger a health issue, but hopefully those cases leverage more
informative events that do have clear 'health' connotations.  There
remains the chance that a sensor will rely upon the vocabulary of
the text in SDR and that just cannot be avoided.

Change-Id: I777b2f1300301291ca5a3aa7a6b18de1de6f9d1a
2014-07-15 15:55:14 -04:00
Jarrod Johnson
4e04b07f6e Tolerate more privilege degradation scenarios
There is some inconsistency in the way BMCs may balk at pursuing a privilege level beyond
the user requesting.  Add code to cope with two scenarios:
-RAKP2 returning 0xd
-set session privilege level returning 0x80 or 0x81

Change-Id: I500e5bbdf88b569b1f1c3f8476033be080770871
2014-06-20 15:10:12 -04:00
Jarrod Johnson
e167ee6a47 Fix concurrent raw_command calls to Session
If two contexts call raw_command concurrently, there was a scenario
where the first to transmit has its result overwritten by the next to
send and corrupts the results of the first command.  One scenario
where this was encountered was when a get health call was being
serviced at the same moment SOL attempted to open a console, causing
one of the get sensor readings to complain that 'SOL was already
active'.  Address it by storing away lastresponse in a more context
specific place before deasserting 'incommand' and remove instances
that deasserted it earlier.

Change-Id: I504da3f54562a4b65b8f4e9e20c19aed9d21a09f
2014-06-13 09:38:59 -04:00
Jarrod Johnson
3bb4e3ac09 Don't defer custom keepalive expiry on all payloads
pyghmi was using any activity to defer any keepalive.  If
a caller has a custom keepalive, only keepalive activity
should advance the keepalive expiry.  Modify code to defer
keepalive only if it is the generic keepalive.

Change-Id: I852ad7a5de65af60fb8e11580bd2ef32896b71f6
2014-06-10 10:45:06 -04:00
Jarrod Johnson
26e8e4fdf0 Fix infinitely recursing custom keepalives
Custom keepalives are called regardless of whether a command is issued
or not.  The rationale being that custom keepalives are checking for
something specific rather than just assuring session state.  Notably,
SOL uses a custom keepalive to see if the payload is still active.
The resultant problem was that if keepalive expired just at the time
something was in the midst of a command, a session would infinitely
recurse into its own keepalive.  The issue was that the keepalive
expiry incorrectly omitted _monotonic_time, causing expiry to
always be far in the past.  It normally did not break because if
not incommand, send_payload was setting an appropriate value after
the incorrect setting.

Change-Id: Ie86e49890a6ac96ddf07206fb1b8558161c00a20
2014-06-10 09:56:36 -04:00
Jarrod Johnson
37bfae70c4 Fix IPv4 operations where v6only behavior is default
Some configurations disable dual stack sockets.  For example
if net.ipv6.bindv6only is 1 in linux, pyghmi was failing.
Address by explicitly requesting the converse behavior
on the socket since we explicitly do want to not care
whether a particular socket is engaged in ipv4 or ipv6
activity.

Change-Id: I17a16f0ebe4752ca743f115af39a367670691507
2014-06-02 16:03:58 -04:00
Jenkins
8c66abb200 Merge "Added password file support" 2014-06-02 18:03:55 +00:00
Jarrod Johnson
da83354a97 Fix pyghmicons script crash on idle
After 10 minutes of idle, the wrong exception was caught.  Correct
it to correctly handle errno 11

Change-Id: I91feea97c3442dec1fc30bd813e99da05a1ef329
2014-05-30 15:03:24 -04:00
linggao
082617af1b Added password file support
Allow the BMC password being passed in to pyghmicons as a
command paremeter.

Change-Id: I696691701622802f228befff9e43a8169657f27b
2014-05-29 19:50:38 +00:00
Jarrod Johnson
9e31a70f5f Correct pool usage count on failed login
If trying to establish a session and an error occurs, pyghmi
was not decrementing the usage count on the pool, leading for
more than expected filehandles being created over time.  Fix
this by correctly decrementing the count in the case where
something is not yet broken, but is also not yet logged in.

Change-Id: I1b27f9b3b902a253d38293182305cc4dac26b765
2014-05-22 13:37:46 -04:00
Jarrod Johnson
ad934dc1e3 Correct console behavior when open session fails
When open session fails, console continued trying to use the session
even though it is a lost cause.  Correct this by bailing out in time.

Change-Id: Icc09514201c948edf21cf7e9e36f0cfe0520a2c9
2014-05-22 09:52:32 -04:00
Jarrod Johnson
d64b19a292 Deregister timeout on broken
When broken for whatever reason, we do not want timeout handling
to continue trying to heal the session.  Notably bad when login fails
and a _relog is triggered continually.

Change-Id: Id342a7fc1274fe95483f2e5392b04f86d23c2b1a
2014-05-20 16:05:26 -04:00
Jarrod Johnson
ff05c2dd57 Correct ignoring socket when inappropriate
When fixing the performance by declining to select() on a socket
until a recvfrom() explictly occurs to clear the socket, a problem
was injected where a socket could be made ignored by particular
timing of incoming traffic on the socket.  Correct this by having
the _poller function forcefully return True if any sockets
are ignored (which also implies they are ready since they
should be discarded on read).

Change-Id: I6be39d39e4d2ed3b05af9a4c954fb64c993ffb50
2014-05-16 12:52:05 -04:00
Jarrod Johnson
61c3bfd867 Fix coping with incoming packet in incomplete state
If a session is partially ready to go, but not fully, drop packets.
This can occur if just the right packets drop such that the remote
end gets going but the local end does not receive them.

Change-Id: I63ac506484a1792db673f6e90e13cc4b0132719c
2014-05-12 10:10:13 -04:00
Jenkins
f69716506c Merge "Fix unregister_keepalive when no keepalives registered" 2014-05-09 20:08:30 +00:00
Jarrod Johnson
5454ab855e Fix unregister_keepalive when no keepalives registered
If no keepalives are registered, return cleanly from an
attempt to unregister rather than raise an exception.

Change-Id: I0064714af4ba8f1b62f9061dc0dc481116c871fe
2014-05-09 15:58:46 -04:00
Jarrod Johnson
5e604af2be Fix attribute error on particularly bad connections
When simulating 80% packet loss, it was discovered that a console
being close() due to inability to complete session establishment
will not have keepaliveid registered yet.

Change-Id: I839645b13cbe30ae71e104c44e63896a4802befe
2014-05-09 15:52:20 -04:00
Jarrod Johnson
0115a3d79b Handle packet loss correctly in logout/logon
Session establishment would fail to restart on loss due to deciding to
append to pending payload.  Fix by having the establishment phase
reset the payload situation.  On logout, the false to retry caused
raw_command to wait forever.  Fix by having raw_command not bother
waiting for such things.

Change-Id: I26d2116bf78440b3ccfc319094283c5d7a58cc5e
2014-05-09 14:13:13 -04:00
Jenkins
9f3c72a030 Merge "Avoid looping select() on sockets repeatedly" 2014-05-09 16:58:07 +00:00
Jarrod Johnson
de8e63883d Avoid looping select() on sockets repeatedly
When select() would identify a a socket, it would
potentially call select() on the same socket
before a recvfrom() would happen.  In python 2.7,
this caused the IO thread to block other threads
waiting on something the other threads needed to
do.  Resolve by explicitly ignoring a socket
where recvfrom() will be pending until recvfrom()
is next called.  This reduces one test case from
42,000-47,000 select() calls to just 86.

Change-Id: Ic8ebecfc61d048e537b5d76a6a3f0665fd340a3d
2014-05-09 12:52:29 -04:00
Jarrod Johnson
d3ea606d71 Correct return value of set_bootdev
command would return a number rather than a string for set_bootdev.
Correct this by returning the string passed in on success rather
than the resulting number.

Change-Id: I8e76b1ac9d0222630abe6b160e6271b13ef4987d
2014-05-08 14:29:17 -04:00
Jenkins
0dd388686e Merge "Remove references to custom keepalives on logout" 2014-05-08 18:10:52 +00:00
Jarrod Johnson
6d2a44a868 Install scripts as well as library
This installs the samples as utilities that can be invoked in the path.
With this, some testing and exploration may be made easier.

Change-Id: I5b7ae5b6e30eea3070dfbcb93d23802b8308d281
2014-05-08 14:06:01 -04:00
Jarrod Johnson
0e64fa5bd2 Remove references to custom keepalives on logout
Since they will not be used on a dead session, remove the reference to
mitigate risk of dead references keeping python from recovering used
memory.

Change-Id: Ib33ea32c02d3cc89b0aa62532e51fc1351e26a79
2014-05-08 13:52:57 -04:00
Jarrod Johnson
af815eee55 Slow down to chunk-wise retrieval of SDR as needed
Some BMCs cannot fetch whole SDRs in one chunk.  When faced
with such a scenario, back off exponentially until things can work.

Change-Id: Ifd9df93af56e6fedfeb4d46b662937bf8db80b01
0.6.1
2014-05-08 11:51:47 -04:00
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