networkupstools / nut

The Network UPS Tools repository. UPS management protocol Informational RFC 9271 published by IETF at https://www.rfc-editor.org/info/rfc9271 Please star NUT on GitHub, this helps with sponsorships!
https://networkupstools.org/
Other
2.07k stars 350 forks source link

NUT Dummy driver Gen3 #94

Open aquette opened 10 years ago

aquette commented 10 years ago

dummycons (1rst generation) and dummy-ups (2nd generation) have well served various purposes, such as:

The work on dummy-ups also permitted the creation of the NUT Devices Dumps Library (http://www.networkupstools.org/devdumps/).

However, time has come for a 3rd generation to address the following, either in definition files (.dev / . seq) and / or the driver:

clepple commented 10 years ago

Actually, the nutdrv-repeater driver might also be useful for modifying values from an UPS that is reporting predictably incorrect values. I think this was the original motivation behind the thread that inspired #97 (min/max reporting).

Obviously, if we can unambiguously detect that a driver should scale or offset a value, then we should do that in the driver, but if it is a calibration issue, or if the UPS hardware cannot be uniquely identified, then I think this should be handled by a repeater. That way, upsmon can still connect directly to the real driver, but graphing software can talk to the repeater.

The repeater might be best implemented in a high-level language like Python, where the scale/offset operations can be done with an 'eval' statement.

zykh commented 10 years ago

.dev/.seq files

what about something like this? https://github.com/zykh/nut-ddl-raw/blob/master/Manufacturer1/ModelFamily1/Manufacturer1__ModelFamily1__ActualModel1__driver-name__NUTVersion2.dev

If we want new dumps to be backward compatible we could:

However doing this would mean we won't be able to use parseconf (at least as it is now, since # lines are treated as comments and ignored) https://github.com/zykh/nut-ddl-raw/blob/master/Manufacturer1/ModelFamily1/Manufacturer1__ModelFamily1__ActualModel1__driver-name__NUTVersion2.backward_compatible.dev

ddl repo

We may want to split things down to Manufacturer/Model_Families/Models: https://github.com/zykh/nut-ddl-raw

nut-recorder

Since we want to record (both in dev and sec files) also rw vars and commands instead of relying on the output from upsc/upsrw/upscmd and then parse it we may want use directly NUT's net-protocol.

We could use PyNUT or maybe upsclient, just like ups{c,cmd,rw}.. and since we are there.. what about merging ups{c,cmd,rw}/nut-recorder in something like a 'nut-controller'?

Does this whole thing sound that bad?
zykh commented 10 years ago

.dev/.seq files - ..follow-up: If we don't care about it being backward compatible we could get rid of colons altogether: var.name var value RW var.name <type> <options> CMD command.name This would be easier to handle with parseconf.

aquette commented 10 years ago

@zykh: this doesn't sound bad at all, and we're definitely on the same page!

2) .dev/.seq files v2

nutdrv-simulation

ddl repo

nut-recorder

EmilienKia commented 10 years ago

Many considerations:

Dummy driver

The need to have a dummy driver is clearly to have a simulation driver. This needs to address three points, in order of importance:

  1. To reproduce a previously recorded sequence. This is for what current dummy driver is design for. I agree to say we need also a (or many - see after) way to record sequences.
  2. To reproduce a full device behavior. This imply to simulate a state-machine. Each state (OL, OB ...) will be associated to a specific sequence. Transition between sequences can be affected by SET commands. The used file format can be derivate from current format by adding subsequence sections with section header (like config files).
  3. To programmatically reproduce a device. This is an enhanced case of previous one. The new dummy driver can offer an API for a light language like LUA.

Recording data

We need to record data ... to replay them.

But we probably need to record different level of data.

I think we will have a complete correct vision of what is done in nut data flow when we will ready to have these 3 levels. So recording is not the job of a dedicated agent in the nut system. Such job must be addressed by different actors in nut system. (to be completed).

I think this needs some big rework and cannot be achieve soon. But it make sense to be considered.

nutclient

A strange thing is remaining in nut distribution is the presence of many executables to do similar requests: upsc/upsrw/upscmd. Why not ! But why ? Perhaps having a nutclient command that will process all commands can be a good idea. It can process commands from:

A such client can process commands like network commands:

GET UPS
GET VAR UPS1...
SET VAR ...

This can be nammed "nutclient". It is more in line with actual commands and library (like libnutclient). Moreover the "nut controller" will be used to the internal orchestrator for future nut system.

aquette commented 10 years ago

@clepple : on the repeater part and your above answer... a cleaner / simpler approach would be allowed through some scaling mechanism / directive and common code in main (as for the "override" for example).

clepple commented 10 years ago

@aquette,

a cleaner / simpler approach would be allowed through some scaling mechanism / directive and common code in main (as for the "override" for example).

I guess, although the common code should not have more than a multiplier and an offset.

If people need more powerful scripting capabilities to adjust reported values, it should not be in the driver core.