Statistics
| Branch: | Tag: | Revision:

root / htools / Ganeti / THH.hs @ 37904802

History | View | Annotate | Download (38.7 kB)

# Date Author Comment
88609f00 11/12/2012 11:44 am Iustin Pop

Switch Luxi TH code from simple to custom fields

This is needed so that we have more flexibility in generating Luxi
serialisation code (deserialisation is still custom). Also, only
exceptions are now using the 'simple' field types, so we might be able
later to convert and remove that TH code as well....

92ad1f44 11/12/2012 11:44 am Iustin Pop

Make THH:genSaveOpCode a bit more general

This can be improved, by taking all hardcoded names as parameters, to
serve as a more-general "build save clause for a multi-constructor
data type". I'm not renaming the function as well, since I don't know
exactly how much we can abstract later....

471b6c46 11/06/2012 06:48 pm Iustin Pop

Add test for Luxi calls consistency hs/py

This tests that the same Luxi calls are defined in Python and
Haskell. It doesn't test yet that their serialisation is correct
though.

Signed-off-by: Iustin Pop <>
Reviewed-by: Guido Trotter <>

9b156883 10/26/2012 02:22 pm Iustin Pop

Add support for optional fields with null serialised

This follows a conversation we had for how to deal with
optional-but-required fields in JSON serialisations: fields which are
optional (can be either a given type or 'null'), but where the 'null'
value is required. There are just a few of these in the Python code,...

dce5d027 10/25/2012 06:43 pm Dato Simó

THH.hs: delete isOptional, no longer used

The isOptional function is no longer used after a150585 (“Convert
opcode TH code to the use of Field type”).

Signed-off-by: Dato Simó <>
Reviewed-by: Iustin Pop <>

ef3ad027 10/25/2012 12:38 pm Iustin Pop

Add an Errors module mirroring the Python one

As described in the module doc string, while writing this it dawned
upon me that we're mixing all errors together into a single hierarchy
(well, type on the Haskell side), which is not good. Some errors are
used purely within noded, some in the CLI frontends, etc. so these...

185b5b0d 10/25/2012 12:38 pm Iustin Pop

Abstract Luxi template functionality

These are almost generic, so let's change the signatures a bit a make
them fully so.

Signed-off-by: Iustin Pop <>
Reviewed-by: Adeodato Simo <>

2e202a9b 10/25/2012 12:38 pm Iustin Pop

Abstract a few types in THH.hs

This 'simple' way of defining objects will be used also for errors, so
let's make it less Luxi-specific.

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

18049dad 10/11/2012 01:03 pm Iustin Pop

Cleanup haddock documentation a bit

While grepping for htools imports in the non-htools subdirectory, I
saw that our haddock prologue and title are very very old and refer to
the old htools-only state. Let's cleanup a bit…

Signed-off-by: Iustin Pop <>...

9924d61e 09/05/2012 05:18 pm Iustin Pop

Add entire ConfigData serialisation tests

Using the recently-added genArbitrary, we can now implement Arbitrary
instances for even "huge" objects like Cluster, so let's use that to
implement entire ConfigData serialisation tests.

Note that, as we don't have yet proper types for some of the Params...

2af78b97 09/03/2012 04:45 pm Iustin Pop

Expand THH with more functionality for parameters

This adds two related improvements to THH:

- for parameters, we declare a list with all their fields, so that
Query2 can build the list of fields (e.g. for hvparams, or ndparams)
automatically

- we declare a new type class for "DictObjects", i.e. objects which...

12e8358c 08/28/2012 06:03 pm Iustin Pop

TH: one style fix and more docstrings

We were missing many docstrings in THH.hs, so let's add at least some
of them, and fix some unquoted '/'. Additionally one style change has
been done.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

a583ec5d 08/28/2012 06:03 pm Iustin Pop

OpCodes: build and export a list of all opcodes

This can be used for cross-checking with the Python code for
consistency on defined opcodes.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

94518cdb 08/28/2012 06:03 pm Iustin Pop

TH: Abstract function for computing constructor names

We'll need this in another place shortly, so let's abstract it and add
proper verification of whether we were passed a type name correctly;
the previous version would have failed with a pattern match failure,...

4b71f30c 08/28/2012 06:00 pm Iustin Pop

Remove obsolete conversion function for Luxi TH

Due to the (now removed) custom filter field, we needed a conversion
function. Since now that field is gone, we can move to a simpler Luxi
TH implementation.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

d5a93a80 08/28/2012 05:59 pm Iustin Pop

Remove container field special cases

Since we now handle Containers uniformly, we can remove all traces of
the special handling for this field type.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

84835174 08/28/2012 05:59 pm Iustin Pop

Improve the TH 'Container' type

This is the first part of the changes related to the 'Container' type.

We currently handle this type as follows: it's a simple type alias
over the Data.Map type, which means:

- it's easy to use the Data.Map functions to change the type...

d8cb8e13 08/28/2012 05:59 pm Iustin Pop

Improve TH local variables naming

This patch addresses two issues with our TH code:

- using non-unique names (e.g. "std" for a local name, instead of
"std_XXXX" random names), which can leads to conflicts; on the other
hand, this makes the generated code a bit harder to parse...

02cccecd 08/28/2012 05:58 pm Iustin Pop

Expand TH with tags field

Also add this new field and the other generic fields to the cluster
object.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

1c7bda0a 07/19/2012 11:01 am Iustin Pop

Extend the Template Haskell loadFn model

Currently, we only allow field-by-field de-serialisation. Since we
have cases where information about how to un-serialise a field is
split across two JSON fields (e.g. disk type and disk logical_id,
hypervisor and hvparams, etc.), we need to pass the entire object to...

c2e60027 07/19/2012 11:01 am Iustin Pop

Change how customFields are built

Instead of passing an expression (which cannot come from the current
module), we pass a name, which is allowed to reference functions from
the module we're in. Since we currently don't have custom fields, we
don't need to modify any callers....

ab0edd8b 07/19/2012 11:00 am Iustin Pop

Remove an unused function

This is not used, as we need a more complex serialisation, which is
done in the saveObjectField function.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

cdd495ae 05/08/2012 01:37 pm Iustin Pop

Add decoding of Luxi calls and unittests for LuxiOp

This patch adds a hand-coded decoder for LuxiCall arguments, as the
data-structure is not uniform enough for automated generation (even
for the serialisation, we had to add hints for some fields,
de-serialisation is even harder)....

95d0d502 05/08/2012 01:37 pm Iustin Pop

Auto-define a LuxiReq data type

We currently auto-generate a LuxiOp data type, which holds the entire
operation (including parameters). However, having a data type just for
the method call would be useful, so let's change THH to also
defineSADT for the Luxi constructors....

d80e3485 03/26/2012 11:54 am Iustin Pop

Change a type computation for compatibility with 6.12

This is the last warning related to TemplateHaskell that was 6.12
specific; for some reason, it doesn't "see" that traw/tname were used.

The patch just replaces the quoting syntax with an explicit type...

ffbd9592 03/26/2012 11:53 am Iustin Pop

Fix compatibility with TemplateHaskell from GHC 7.4

GHC 7.4 has updated the TemplateHaskell library, and it turns out that
the way we built the JSON instance implementation for showJSON was not
good (probably this is why GHC 6.12 was generating some warnings)....

b1e81520 03/13/2012 02:48 pm Iustin Pop

htools: add partial implementation of lib/objects.py

This is partial since not all object types can be easily converted for
now (will need some changes on the Python side for this).

Most importantly, the *Params types do not have a good solution now:
the Python code, due to its dynamic typing, hides the fact that we...

3c3c796e 01/13/2012 03:17 pm Iustin Pop

Enable Eq instances for TH-built objects

This is needed for the next patch.

Signed-off-by: Iustin Pop <>
Reviewed-by: René Nussbaumer <>

a07343b2 01/13/2012 03:16 pm Iustin Pop

Add object definitions for the ispec and ipolicy

Signed-off-by: Iustin Pop <>
Reviewed-by: René Nussbaumer <>

a1505857 12/07/2011 12:00 pm Iustin Pop

Convert opcode TH code to the use of Field type

This makes more explicit the field behaviour - previously an optional
field was detected via a "Maybe" constructor, and an optional one via
a "Just defval" one. With this, field behaviour become more explicit...

6bd26f00 12/06/2011 11:38 am Iustin Pop

htools: small change in error message in THH.hs

We should also display the value we can't parse, otherwise debugging
is very hard.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

706f7f51 12/06/2011 11:38 am Iustin Pop

htools: improvements to JSON deserialisation

This fixes two problems:

- first, when we deserialise a big object, showing its value is not
useful, as it will hide the actual error message
- second, we shouldn't deserialise a container at once, because then...

879273e3 12/06/2011 11:37 am Iustin Pop

htools: add new template haskell system

This system based on explicit types instead of ad-hoc rules
(e.g. instead of deducing from "Maybe Int" an optional field, we now
can say explicitly OptionalField ''Int). In the first phase, this will
be used for the equivalent of lib/objects.py, which has slightly...

ebf38064 11/17/2011 03:49 pm Iustin Pop

htools: reindent the rest of the files

Signed-off-by: Iustin Pop <>
Reviewed-by: Michael Hanselmann <>

5f828ce4 10/26/2011 05:35 pm Agata Murawska

Generalize the generation of ADT from raw types

Signed-off-by: Agata Murawska <>
Reviewed-by: Iustin Pop <>

260d0bda 10/26/2011 05:35 pm Agata Murawska

Luxi support for Query status in htools

Signed-off-by: Agata Murawska <>
Reviewed-by: Iustin Pop <>

b20cbf06 10/14/2011 01:37 pm Iustin Pop

Adjust htools code to new Luxi argument format

This partially undoes commit 92678b3, more specifically it removes the
Store data type and the associated code, since all Luxi arguments are
now lists.

Furthermore, since the qfilter field on Query is complex (it's...

92678b3c 10/12/2011 11:47 am Iustin Pop

Haskell support for generic Query in Luxi

Untill now htools did not have support for generic Query in Luxi. This
patch introduces Query as a supported Luxi operation and replaces
QueryNodes, QueryInstances and QueryGroups with Query.

Signed-off-by: Agata Murawska <>...

9d74cb04 10/12/2011 11:47 am Agata Murawska

TH simplification for Luxi

This patch simplifies the generation of save constructors for LuxiOp
by always using showJSON over an array of JSValues, instead of having
to pass showJSON in most cases, except the 5-tuple case.

Signed-off-by: Agata Murawska <>...

05ff7a00 10/12/2011 10:49 am Agata Murawska

Dots in docstings and hlint error fixes for htools

Signed-off-by: Agata Murawska <>
Signed-off-by: Iustin Pop <>
Reviewed-by: Iustin Pop <>

60de49c3 10/11/2011 11:23 am Iustin Pop

Skip application of 'id' in TH code

This is just beautification when dumping splices to stdout, as ghc
will optimise the 'id' away anyway.

Original generate code:

opToArgs QueryTags kind name = J.showJSON (id kind, id name)

Afterwards:

opToArgs QueryTags kind name = J.showJSON (kind, name)...
a0090487 10/06/2011 11:21 am Agata Murawska

Use TemplateHaskell to create LUXI operations

Signed-off-by: Agata Murawska <>
Reviewed-by: Iustin Pop <>

53664e15 10/03/2011 12:17 pm Iustin Pop

Some TH simplifications

Now that the basic code works, let's use some aliases for simpler code
and less ))))))))).

Signed-off-by: Iustin Pop <>
Reviewed-by: Guido Trotter <>

12c19659 10/03/2011 12:17 pm Iustin Pop

Use TemplateHaskell to generate opcode serialisation

This replaces the hand-coded opcode serialisation code with
auto-generation based on TemplateHaskell.

Signed-off-by: Iustin Pop <>
Reviewed-by: Agata Murawska <>

6111e296 10/03/2011 12:17 pm Iustin Pop

Use TemplateHaskell to build the opID function

This replaces the hand-coded opID with one automatically generated
from the constructor names, similar to the way Python does it, except
it's done at compilation time as opposed to runtime.

Again, the code line delta does not favour this patch, but this...

e9aaa3c6 10/03/2011 12:17 pm Iustin Pop

Use TemplateHaskell instead of hand-coded instances

This patch replaces the current hard-coded JSON instances (all alike,
just manual conversion to/from string) with auto-generated code based
on Template Haskell
(http://www.haskell.org/haskellwiki/Template_Haskell)....