INSTCMD and SET VAR status tracking implementation (#659)
* INSTCMD and SET VAR status tracking implementation
This commit implements the instant commands (instcmd) and variables settings
(setvar) status tracking, to get the actual execution status from the driver
Signed-off-by: Arnaud Quette <email address hidden>
* Missing Revision history
Signed-off-by: Arnaud Quette <email address hidden>
* Fix nut-names.txt modification that should not be here
Signed-off-by: Arnaud Quette <email address hidden>
* Augeas support: add CMDSETSTATUSDELAY for upsd.conf
Signed-off-by: Arnaud Quette <email address hidden>
* INSTCMD and SET VAR status tracking completion
Following Daniele Pezzini thorough review, sanitize and improve the code, and
also complete documentation
Signed-off-by: Arnaud Quette <email address hidden>
* INSTCMD and SET VAR status tracking completion
implement support for status tracking in upscmd and upsrw
Signed-off-by: Arnaud Quette <email address hidden>
* upscmd/upsrw: delay retries for status tracking
Signed-off-by: Arnaud Quette <email address hidden>
* Remove comment
There is no need to condition CMDSET_STATUS commands received by upsd from the
driver, on cmdset_status_enabled, since what matters is the presence of a list
and id
Signed-off-by: Arnaud Quette <email address hidden>
* Complete comment
Signed-off-by: Arnaud Quette <email address hidden>
* UUID v4 implementation
replaced the initial rxi/uuid4 library used by a cross platform version. Though
more basic, it is enough for our needs, at least for now
Signed-off-by: Arnaud Quette <email address hidden>
* status_info should be static
Signed-off-by: Arnaud Quette <email address hidden>
* No need for else, since fatalx is called before
Signed-off-by: Arnaud Quette <email address hidden>
* Suppress \n from debug output
Signed-off-by: Arnaud Quette <email address hidden>
* Group sanity checks
Signed-off-by: Arnaud Quette <email address hidden>
* Get rid of dynamic memory allocation
Signed-off-by: Arnaud Quette <email address hidden>
* Improve and enforce the use of UUID4_LEN
Signed-off-by: Arnaud Quette <email address hidden>
* Comment on the size of dest for nut_uuid_v4()
Signed-off-by: Arnaud Quette <email address hidden>
* Move structures and defines to more appropriate places
Signed-off-by: Arnaud Quette <email address hidden>
* Add functions with timeout
Add upscli_sendline_timeout and upscli_readline_timeout, beside from the
classic blocking versions. Also make a common define for timeout, and use it
in upsclient and nut-scanner
Signed-off-by: Arnaud Quette <email address hidden>
* upscmd/upsrw: add a timeout option
Signed-off-by: Arnaud Quette <email address hidden>
* Basic homebrew UUID v4 implementation
Signed-off-by: Arnaud Quette <email address hidden>
* Prefer to use static buffer for UUID
Signed-off-by: Arnaud Quette <email address hidden>
* log actual result of instcmd / setvar
Signed-off-by: Arnaud Quette <email address hidden>
* Fix tracking ID reporting due to static memory changes
Signed-off-by: Arnaud Quette <email address hidden>
* upsclient: use unsigned int for timeouts
Also, explicit that upscli_cleanup() takes no argument.
* upscmd/upsrw: use unsigned int for timeout + our str_to_uint() for it
Also, slightly reword the help message for `-t` (timeout) option, in order to clarify which is the unit (seconds) used for the provided value.
* upscmd/upsrw: don't sleep after receiving a non-PENDING CMDSET_STATUS
Also, remove some nesting in do_cmd() and do_set().
* net-protocol: clarify the format of GET CMDSET_STATUS + <status_id>
<status_id> is not optional to get the status of a command/setvar with CMDSET_STATUS, so drop the [square brackets] from it.
Also drop "quotes" in SET CMDSET_STATUS's <value>, since it's expected to be a single word.
Plus, fix markup of INSTMCD's <cmdparam> parameter.
* sock-protocol: align case and markup of command parameters
* dstate: fix handling of INSTCMD's optional parameters
We should still support the old `INSTCMD <cmdname> [<cmdparam>]` format, and not only consider <cmdparam> when also `STATUS_ID <id>` is provided.
Also, fix the format of our sock-protocol commands mentioned in comments, and add function names to debug info.
* common: document the recently added things
* upsd: in INSTCMD/SET handlers, also accept NULL for status_id
Plus:
- use a simpler approach to test if status_id is not empty,
- align the way the SET command is built to the one used for the INSTCMD command.
* upsd: drop unnecessary/unused global
* upsd: move sanity checks of cmdset_status_get() after declaration of vars
Also, drop some nesting in that function.
* Move from CMDSET_STATUS / STATUS_ID to TRACKING
This is just a big, big rename, no code changes.
* upsd: refine the tracking API
Add a couple of functions to change in a predictable way the value of the general enablement of tracking and make it visible only inside upsd.c.
Also, move the tracking type (tracking_t) and the list of items inside upsd.c.
* net-protocol: also return TRACKING between OK and <id>, for INSTCMD/SET VAR
* dstate: *really* fix handling of INSTCMD's optional parameters
Erroring out on `INSTCMD <cmdname>` doesn't seem like a good idea...
* common: massage default timeouts
Rename the default timeout used in network operations by upsclient and nut-scanner to be more specific: from DEFAULT_TIMEOUT to DEFAULT_NETWORK_TIMEOUT.
Plus, make the default timeout used when retrieving the result of an INSTCMD/SET VAR with TRACKING enabled a common #define'd value (DEFAULT_TRACKING_TIMEOUT), and use it also to publish the default value of the -t option in the help messages of upscmd and upsrw.
As suggested by Charles Lepple.
* upsd: ignore case of UUID4 in tracking API
Also, remove some nesting in tracking_del().
* libupsclient: generate manpages for upscli_{read,send}line_timeout()
To keep things simple, at least for now, only generate manpages and not html pages (and, as such, don't even think of using our linkman AsciiDoc macro with those functions, to avoid dead links).
* libupsclient: bump version as per recent changes
- addition of upscli_{read,send}line_timeout(),
- upscli_cleanup() -> upcli_cleanup(void)
Note: only increase 'current' and not 'age', because the upscli_cleanup() change could (potentially) make it not compatible with previous versions.
* upscmd/upsrw: warn that also the drivers need to support TRACKING, for -w
* Fix typo and spelling
Signed-off-by: Arnaud Quette <email address hidden>
* Add check around atoi() conversion
Signed-off-by: Arnaud Quette <email address hidden>