History | View | Annotate | Download (28.7 kB)
TH: Abstract function for computing constructor names
We'll need this in another place shortly, so let's abstract it and addproper verification of whether we were passed a type name correctly;the previous version would have failed with a pattern match failure,...
Remove obsolete conversion function for Luxi TH
Due to the (now removed) custom filter field, we needed a conversionfunction. Since now that field is gone, we can move to a simpler LuxiTH implementation.
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Agata Murawska <agatamurawska@google.com>
Remove container field special cases
Since we now handle Containers uniformly, we can remove all traces ofthe special handling for this field type.
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 aliasover the Data.Map type, which means:
- it's easy to use the Data.Map functions to change the type...
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...
Expand TH with tags field
Also add this new field and the other generic fields to the clusterobject.
Extend the Template Haskell loadFn model
Currently, we only allow field-by-field de-serialisation. Since wehave cases where information about how to un-serialise a field issplit across two JSON fields (e.g. disk type and disk logical_id,hypervisor and hvparams, etc.), we need to pass the entire object to...
Change how customFields are built
Instead of passing an expression (which cannot come from the currentmodule), we pass a name, which is allowed to reference functions fromthe module we're in. Since we currently don't have custom fields, wedon't need to modify any callers....
Remove an unused function
This is not used, as we need a more complex serialisation, which isdone in the saveObjectField function.
Add decoding of Luxi calls and unittests for LuxiOp
This patch adds a hand-coded decoder for LuxiCall arguments, as thedata-structure is not uniform enough for automated generation (evenfor the serialisation, we had to add hints for some fields,de-serialisation is even harder)....
Auto-define a LuxiReq data type
We currently auto-generate a LuxiOp data type, which holds the entireoperation (including parameters). However, having a data type just forthe method call would be useful, so let's change THH to alsodefineSADT for the Luxi constructors....
Change a type computation for compatibility with 6.12
This is the last warning related to TemplateHaskell that was 6.12specific; for some reason, it doesn't "see" that traw/tname were used.
The patch just replaces the quoting syntax with an explicit type...
Fix compatibility with TemplateHaskell from GHC 7.4
GHC 7.4 has updated the TemplateHaskell library, and it turns out thatthe way we built the JSON instance implementation for showJSON was notgood (probably this is why GHC 6.12 was generating some warnings)....
htools: add partial implementation of lib/objects.py
This is partial since not all object types can be easily converted fornow (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...
Enable Eq instances for TH-built objects
This is needed for the next patch.
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: René Nussbaumer <rn@google.com>
Add object definitions for the ispec and ipolicy
Convert opcode TH code to the use of Field type
This makes more explicit the field behaviour - previously an optionalfield was detected via a "Maybe" constructor, and an optional one viaa "Just defval" one. With this, field behaviour become more explicit...
htools: small change in error message in THH.hs
We should also display the value we can't parse, otherwise debuggingis very hard.
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...
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 nowcan say explicitly OptionalField ''Int). In the first phase, this willbe used for the equivalent of lib/objects.py, which has slightly...
htools: reindent the rest of the files
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
Generalize the generation of ADT from raw types
Signed-off-by: Agata Murawska <agatamurawska@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Luxi support for Query status in htools
Adjust htools code to new Luxi argument format
This partially undoes commit 92678b3, more specifically it removes theStore data type and the associated code, since all Luxi arguments arenow lists.
Furthermore, since the qfilter field on Query is complex (it's...
Haskell support for generic Query in Luxi
Untill now htools did not have support for generic Query in Luxi. Thispatch introduces Query as a supported Luxi operation and replacesQueryNodes, QueryInstances and QueryGroups with Query.
Signed-off-by: Agata Murawska <agatamurawska@google.com>...
TH simplification for Luxi
This patch simplifies the generation of save constructors for LuxiOpby always using showJSON over an array of JSValues, instead of havingto pass showJSON in most cases, except the 5-tuple case.
Dots in docstings and hlint error fixes for htools
Signed-off-by: Agata Murawska <agatamurawska@google.com>Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Skip application of 'id' in TH code
This is just beautification when dumping splices to stdout, as ghcwill 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)...
Use TemplateHaskell to create LUXI operations
Some TH simplifications
Now that the basic code works, let's use some aliases for simpler codeand less ))))))))).
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
Use TemplateHaskell to generate opcode serialisation
This replaces the hand-coded opcode serialisation code withauto-generation based on TemplateHaskell.
Use TemplateHaskell to build the opID function
This replaces the hand-coded opID with one automatically generatedfrom the constructor names, similar to the way Python does it, exceptit's done at compilation time as opposed to runtime.
Again, the code line delta does not favour this patch, but this...
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 basedon Template Haskell(http://www.haskell.org/haskellwiki/Template_Haskell)....