Split Luxi.hs into LUXI-specific functions and general ones

This will allow WConfD to use the general functions without importing
Luxi.hs.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Rename getClient/Server to getLuxiClient/Server

Later they will be split into LUXI-specific and general parts.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Encapsulate a server socket and its parameters

Instead of passing a bare server socket around, we pass it encapsulated
in a data type together with parameters such as read/write timeouts.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add the Unix domain socket path to the Server data type

This simplifies code for closing such a socket.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Generalize "validateCall" to be usable outside LUXI

Return the method (as any instance of JSON) and the arguments of a call.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add MonadPlus and MonadError instances for GenericResult

.. and ResultT.

While at it, generalize also the MonadPlus instance of GenericResult and
add some Functor/Applicative instances.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add an Error instance for GanetiException

This allows it to be used with MonadError.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add fromJResultE and fromJVal that uses MonadError

Using MonadError is more correct than just "fail" on an arbitrary
monad, and more scalable when using monad type classes or monad stacks.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add a MonadLog typeclass for monads that allow logging

This separates logging from IO, allowing to create unit tests in future
for functions that use it.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Add MonadLog instance for `ReaderT r m`

This allows to use logging with the ReaderT monad transformer.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Generalize the IO client handling in Luxi

... to be usable for WConfd as well. A daemon handler is encapsulated
into `Handler` data type, which is then passed to a generic `listener`.

The changes are done in Luxi.hs so that the differences are visible and
will be moved into UDSServer.hs later.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
Move the generalized IO client from Luxi to UDSServer

No code is changed in this patch (except imports and qualifiers), only
moved.

Signed-off-by: Petr Pudlak <pudlak@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>
OS installation redesign

Add the document describing a new design for the OS installation process for
new instances.

Signed-off-by: Michele Tartara <mtartara@google.com>
Signed-off-by: Jose A. Lopes <jabolopes@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
OS-redesign: change instance IP

Change the IP of the instance to make it correspond to the one used in the
example.

The .253 is chosen so that, if needed, in the future the network can be changed
from a /24 to a /28.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>
Generate a separate return type for the job queue update RPC

The instantiation of RPC requires a bidirectional functional dependency
between call type and return type. Hence we cannot use Unit everywhere.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
The time field for SetWatcherPause is optional

A JSON null value is used to indicate that the pause should be canceled.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Add the RPC-call set_watcher_pause

With luxid taking over responsibility for handling watcher-pause requests,
it needs to know about this RPC. So have it available in Haskell as well.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Implement SetWatcherPause in luxid

Make luxid handle SetWatcherPause correctly.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Provide path to watcher pause file

Extend Path.hs to also provide the path to the file indicating
whether watcher is paused.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>
Add a predicate for watcher pause

Add a predicate, in IO, to test whether the watcher is
paused.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Petr Pudlak <pudlak@google.com>