ganeti-local
11 years agoMove haskell test code to htest/
Iustin Pop [Wed, 29 Aug 2012 11:53:48 +0000 (13:53 +0200)]
Move haskell test code to htest/

This is the first commit of a series that will attempt to cleanup the
test code organisation, which evolved somewhat organically from the
initial pure htools functionality.

The proposed organisation of the tree will be as follows:

- htools (or maybe renamed to haskell or hs): only production code
- htest: top-level test directory, containing test.hs, static helper
  scripts, etc.
- htest/Ganeti/*.hs: modules implementing the actual test properties
  and test cases for the correspondingly-named production code modules
- htest/data: containing test data files for the test cases

This particular patch moves all the test code (test.hs, hpc-htools.hs
symlink) and helper scripts (offline-test.sh, etc.) from htools/ to
htest/, while updating the files themselves (if they had paths
mentioning htools/), .gitignore and the Makefile.

The only special mention is that in Makefile, we used to have a BINARY
shell variable in binary build rule; that was computed via stripping
`htools/' prefix; I've cleaned that and replaced with $(notdir $@);
even though it's duplicated a few times, it leads to more readable
make output (and easier to copy-paste).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImplement compilation of regexes at creation time
Iustin Pop [Mon, 27 Aug 2012 15:56:41 +0000 (17:56 +0200)]
Implement compilation of regexes at creation time

This means that the verification of the correctness of the regex is
done once, at the deserialisation/creation time, as in the Python
code. To do this, we have to change the FilterRegex type from an alias
to String to a more complex data type, and we have to create manual
read/show/eq instance (phew!).

Unittests are added which test these instances, since it's the first time I do
this manually.

An additional improvement is that we now check that regex-pcre has
been compiled correctly, per the documentation (otherwise we get
runtime errors).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

11 years agoRename the Qlang and Queryd modules
Iustin Pop [Sun, 26 Aug 2012 18:43:06 +0000 (20:43 +0200)]
Rename the Qlang and Queryd modules

Per the new query module hierarchy, rename Qlang to Query/Language and
Queryd to Query/Server. This way, all query-related functionality is
now "contained" in the Query/ directory.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd filtering support in Query
Iustin Pop [Sun, 26 Aug 2012 18:22:44 +0000 (20:22 +0200)]
Add filtering support in Query

This adds basic infrastructure for filtering (fully functional except,
as usual, for runtime data), and then uses it for node queries.

Since the filtering exports regex matching as an external
functionality, we have to use a regex library. There are many flavours
of these in Haskell (see
http://www.haskell.org/haskellwiki/Regular_expressions), but since we
want to be as compatible as we can with Python's, we use the
regex-pcre one, which is a wrapper to the widely used 'pcre' library.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd an Applicative instance for our Result type
Iustin Pop [Sun, 26 Aug 2012 16:18:59 +0000 (18:18 +0200)]
Add an Applicative instance for our Result type

This will allow us to run generic computations in an Applicative
context, if a monadic one is not needed (or not applicable due to
class constraints).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoParameterize the Filter type
Iustin Pop [Sun, 26 Aug 2012 13:00:31 +0000 (15:00 +0200)]
Parameterize the Filter type

In preparation for introducing filtering functionality, we convert the
'Filter' type from a '*' kind to a '* -> *' kind.

This allows us to define some general properties for the filter, and
for example introduce later an easy filter compilation, etc.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImplement QueryFields for Nodes
Iustin Pop [Fri, 24 Aug 2012 22:46:32 +0000 (00:46 +0200)]
Implement QueryFields for Nodes

Since we have all the definitions already, we can easily enable
this. Manual testing shows no difference between the Python and the
Haskell versions of node list-fields.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoMerge branch 'devel-2.6'
Iustin Pop [Tue, 4 Sep 2012 10:56:21 +0000 (12:56 +0200)]
Merge branch 'devel-2.6'

* devel-2.6:
  Fix warnings/errors with newer pylint
  Fix decorator uses which crash newer pylint

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

11 years agoMerge branch 'stable-2.6' into devel-2.6
Iustin Pop [Tue, 4 Sep 2012 10:04:10 +0000 (12:04 +0200)]
Merge branch 'stable-2.6' into devel-2.6

* stable-2.6:
  Fix warnings/errors with newer pylint
  Fix decorator uses which crash newer pylint

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

11 years agoPutting the multiallocate pieces together
René Nussbaumer [Mon, 27 Aug 2012 11:15:07 +0000 (13:15 +0200)]
Putting the multiallocate pieces together

This is the final part:

* Parsing the new request type
* Feed it to allocList
* Format the result

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdding allocList function
René Nussbaumer [Mon, 27 Aug 2012 11:13:55 +0000 (13:13 +0200)]
Adding allocList function

This function iterates over the tryMGAlloc function, updates the node
list and instance list, and refeeds it recursively until no new
instances are left.

This allows us then to allocate multiple instances and see if they would
fit together.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdding new IAllocator mode to constants
René Nussbaumer [Mon, 27 Aug 2012 11:13:19 +0000 (13:13 +0200)]
Adding new IAllocator mode to constants

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix warnings/errors with newer pylint
Iustin Pop [Tue, 28 Aug 2012 23:12:19 +0000 (01:12 +0200)]
Fix warnings/errors with newer pylint

To help developing Ganeti on newer distributions, let's try to fix
pylint warnings/errors. I'm using pylint from current Debian wheezy:
pylint 0.25.1, astng 0.23.1, common 0.58.0, and we have 3 things that
needs fixing.

First, a really wide "except", with the silencing in the wrong
place. I'm not sure why this doesn't have "except Exception", so let's
add it. However, pylint still complains about "Catching too general
exception", even though we do want to catch both system and our
exception, so let's add a silence for W0703. It's true that we
shouldn't catch KeyboardInterrupt and friends, but that should be
cleaned up on the master branch.

Second, pylint complains about "redefining name builtin tuple",
because we do some pattern matching in the except blocks in
netutils. This seems to be a false positive, but let's clean the code
around this.

And finally, type inference again goes bad, so let's silence E1103
with its "boolean doesn't have 'get' method".

After this, I can run "make lint", and by extension "make
commit-check" on Debian Wheezy, yay! We might be able to bump our
required pylint versions to something not ancient…

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

11 years agoMerge branch 'devel-2.6'
Guido Trotter [Mon, 3 Sep 2012 15:09:17 +0000 (16:09 +0100)]
Merge branch 'devel-2.6'

* devel-2.6:
  Instance autorepair design

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix decorator uses which crash newer pylint
Iustin Pop [Tue, 28 Aug 2012 22:59:00 +0000 (00:59 +0200)]
Fix decorator uses which crash newer pylint

Pylint version:

  pylint 0.25.1,
  astng 0.23.1, common 0.58.0

crashes when passing the fully-qualified decorator name with:

  File "/usr/lib/pymodules/python2.7/pylint/checkers/base.py", line 161, in visit_function
    if not redefined_by_decorator(node):
  File "/usr/lib/pymodules/python2.7/pylint/checkers/base.py", line 116, in redefined_by_decorator
    decorator.expr.name == node.name):
AttributeError: 'Getattr' object has no attribute 'name'

I found out that simply using a shortened name will 'fix' this issue,
so let's do this to allow running newer pylint versions.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

11 years agoInstance autorepair design
Guido Trotter [Mon, 23 Jul 2012 15:09:36 +0000 (16:09 +0100)]
Instance autorepair design

This design describes a tool that will perform automatic repairs on
instances when they are detected to be unhealthy (living on offline or
drained nodes, at the moment). These repairs can be scheduled
automatically or requested as a one-off by a tool or person.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd missing luxi query 'QueryFields'
Iustin Pop [Fri, 24 Aug 2012 22:27:19 +0000 (00:27 +0200)]
Add missing luxi query 'QueryFields'

This was missed; we add the definition and the de-serialisation
support.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd Query support for Nodes (no filtering, no RPC)
Iustin Pop [Fri, 24 Aug 2012 22:18:16 +0000 (00:18 +0200)]
Add Query support for Nodes (no filtering, no RPC)

This is the initial support for Query2: basic infrastructure (except
filtering) and node query support (without RPC).

It implements all the fields (tests by comparison with list-fields on
the Python side), except that:

- filter is not done
- since RPC is not integrated yet, the runtime gathering/computing is
  simply stubbed out

However, the infrastructure seems pretty reasonable, so I'm sending as
is.

Note that I've split the functions/declarations into multiple files,
to keep each file clean and readable.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoMove parameter title definitions to constants
Iustin Pop [Fri, 24 Aug 2012 23:04:29 +0000 (01:04 +0200)]
Move parameter title definitions to constants

This fixes an old TODO for moving these; now they can be reused in the
Haskell Query2 implementation.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoOne more SADT type - VType
Iustin Pop [Fri, 24 Aug 2012 22:15:14 +0000 (00:15 +0200)]
One more SADT type - VType

This adds the VTYPE_* conversion to VType, used for QFT equivalence
later.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoExtend convert-constants support for dicts
Iustin Pop [Fri, 24 Aug 2012 22:04:27 +0000 (00:04 +0200)]
Extend convert-constants support for dicts

This enhances convert-constants to not flatten dicts completely, but
also generate a so-called association list for them.

This allows either direct use of the 'lookup' function, or (for
performance) conversion to Data.Map and optimised lookup later.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoExpand THH with more functionality for parameters
Iustin Pop [Fri, 24 Aug 2012 18:38:43 +0000 (20:38 +0200)]
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
  can be converted to a [(String, JSValue)] list of pairs; while this
  applies to all our objects, it will be used first for filled
  parameters, so that we can implement the lookup functions
  generically

Note that we re-export the new class from Objects.hs, so that other
modules don't have to import THH.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd more node-related data types and functions
Iustin Pop [Fri, 24 Aug 2012 12:48:12 +0000 (14:48 +0200)]
Add more node-related data types and functions

This is a simple type declaration for NodeRole, a NdParamObject type
class, and a few related helper functions for nodes and node groups.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoFix typo in node role description
Iustin Pop [Fri, 24 Aug 2012 22:47:16 +0000 (00:47 +0200)]
Fix typo in node role description

I'd rather not introduce this typo in the Haskell code too, and also
not having them identical is not good.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd type classes for common objects
Iustin Pop [Fri, 24 Aug 2012 12:44:26 +0000 (14:44 +0200)]
Add type classes for common objects

These mirror the TaggableObject in Python, in the sense that we will
be able to define generic functions for querying such fields.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoStub query2 call integration into QueryD
Iustin Pop [Thu, 23 Aug 2012 21:12:30 +0000 (23:12 +0200)]
Stub query2 call integration into QueryD

This patch corrects the definitions in Qlang.hs to match what Python
expects on the wire; this means replacing some manual data type
definitions with 'buildObject' so that we get serialisation (and field
names) for free, adding (manually) JSON instances for types which are
not represented as objects in JSON, etc. Due to more TH usage, I had
to shift some definitions around, since TH breaks the "define in any
order" property (☹).

After that, we simply add a call into the stub Query/Query.hs module
which, for all queries, responds with "query not supported". The
reason for the deep directory structure is because I want to separate
the functionality into multiple submodules, for smaller module size
and readability.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoFix error reporting for bad Luxi arguments in QueryD
Iustin Pop [Sun, 26 Aug 2012 16:22:15 +0000 (18:22 +0200)]
Fix error reporting for bad Luxi arguments in QueryD

Currently, the query daemon would simply close the connection to the
client without issuing a response, if parsing the arguments failed;
the error was just logged.

Since this is very ugly from the client's point of view, we change it
so that the error is both logged and sent back to the
client. Furthermore, the execution block reporting is also cleaned up
a bit, to make the code more uniform.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImprove error reporting in our JSON conversions
Iustin Pop [Sun, 26 Aug 2012 16:20:08 +0000 (18:20 +0200)]
Improve error reporting in our JSON conversions

Reporting things such as the following in our error messages
(indentation added by me, not originally present, so it's even worse):

  JSArray [JSArray [JSRational False (1 % 1),JSString
                    (JSONString {fromJSString = "a"})],
           JSArray [JSRational False (2 % 1),
                    JSString (JSONString {fromJSString = "b"})]]

Is not really nice. This patch adds more 'pp_value' conversions so
that the above becomes:

  [[1, "a"], [2, "b"]]

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoCleanup query socket before attempting to bind
Iustin Pop [Thu, 23 Aug 2012 20:53:20 +0000 (22:53 +0200)]
Cleanup query socket before attempting to bind

This patch adds a simple function to ensure a socket doesn't exist
before binding to it. Additionally, we cleanup the exports of
Queryd.hs.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoComplete and enable the haskell QueryClusterInfo call
Iustin Pop [Wed, 22 Aug 2012 16:53:34 +0000 (18:53 +0200)]
Complete and enable the haskell QueryClusterInfo call

Since we have now access to all cluster parameters, we can "fill" the
parameters, and can finally enable it in CLI/RAPI.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoExpand Objects.hs definitions
Iustin Pop [Wed, 22 Aug 2012 16:48:56 +0000 (18:48 +0200)]
Expand Objects.hs definitions

This patch adds the missing parameters in the cluster/group objects,
for now as simple maps (dictionaries), without type safety. The
rationale for adding them as such is:

- we need something to enable query functionality
- since we don't modify the values, we don't risk introducing bugs
- we can improve the types later, once we find a good way to declare
  them

Also, I renamed a few of the parameters, dropping capitalisation of
acronyms (NIC → Nic, etc.).

At this point, I believe that the definitions are complete, with any
missing items being just oversight, and not intentionally removed (due
to lack of types, etc.).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd a fillDict function
Iustin Pop [Wed, 22 Aug 2012 16:44:19 +0000 (18:44 +0200)]
Add a fillDict function

This is similar to the Python version, objects.py:FillDict.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoFix qualified import of Data.Map in QC.hs
Iustin Pop [Wed, 22 Aug 2012 16:42:04 +0000 (18:42 +0200)]
Fix qualified import of Data.Map in QC.hs

As opposed to all other places in the code, we imported this as
Data.Map, leaving to longer names. Let's make it similar to the rest
of the code (import qualified Data.Map as Map).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoEnhance convert-constants list generation
Iustin Pop [Wed, 22 Aug 2012 15:57:33 +0000 (17:57 +0200)]
Enhance convert-constants list generation

While looking at the hypervisor types in Constants.hs, I saw that the
'hyperTypes' list is using strings instead of names. This is due to
the fact that we require the entire elements in the list to be
identified (homogeneous lists), but the string "xen-pvm" is declared
by both 'defaultEnabledHypervisor' and 'htXenPvm'.

We can improve convert-constants by adding a list of names that we
know (statically) don't declare, but instead reuse values. Unless we
have an ADT parser, this is the best we can do, I think.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd two confd library tests
Iustin Pop [Mon, 20 Aug 2012 19:44:52 +0000 (21:44 +0200)]
Add two confd library tests

These test that we encode requests correctly and decode good messages,
that a message with a too old/new timestamp is never accepted, and
that a message signed with a different key is never accepted.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoReduce some more code duplication and split code
Iustin Pop [Mon, 20 Aug 2012 18:18:37 +0000 (20:18 +0200)]
Reduce some more code duplication and split code

The Qlang module defines ResultStatus, but it was already defined in
Ganeti/Luxi.hs; let's remove the duplicate definition from there since
the proper place is in the newer module.

Also, in order to ease testing, we split some confd functions into a
separate module; this can be imported easily into QC for testing.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd test for checking Haskell/Python opcode equivalence
Iustin Pop [Mon, 20 Aug 2012 17:22:24 +0000 (19:22 +0200)]
Add test for checking Haskell/Python opcode equivalence

This is a very big hack for testing the equivalence of Python and
Haskell opcode definitions. See the docstring for details; I'm not
very happy with the solution but it does the job.

An alternate option would be to launch the Python code when
initialising the tests, pass (somehow) the resource through all of the
test suite to this function, and then use normal QuickCheck
properties. Or maybe we find a better solution later; for now, this
does the job.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoCreate a custom type for disk indices
Iustin Pop [Mon, 20 Aug 2012 17:13:15 +0000 (19:13 +0200)]
Create a custom type for disk indices

While (again) trying to test Python/Haskell encoding interoperability,
I found another bug: the disk index is declared in Python as
ht.TPositiveInt, but in Haskell just as Int, so it can take negative
values too. Clearly we can do better, so let's add a wrapper type that
protects creation of invalid indices via a smart constructor
(http://www.haskell.org/haskellwiki/Smart_constructors, the runtime
checking variant).

This means that outside of OpCodes.hs, it's not possible to load
invalid values, and this also applies to de-serialisation from JSON
data.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoHandle better 'null' values in optional fields
Iustin Pop [Mon, 20 Aug 2012 11:53:09 +0000 (13:53 +0200)]
Handle better 'null' values in optional fields

While testing Haskell⇔Python interoperability for opcode
serialisation, I found this bug: the Haskell code doesn't treat
optional fields with 'null' values as missing, which the Python code
does, leading to differences.

Investigating all uses of 'maybeFromObj' and the single use of
'fromObjWithDefault' shows that these are only used in cases where we
the rules are indeed "null == missing", so let's update the functions
and their docstrings accordingly.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd test case for OpCode list equivalence
Iustin Pop [Sun, 19 Aug 2012 22:42:58 +0000 (00:42 +0200)]
Add test case for OpCode list equivalence

For now, we only test that we don't define extra opcodes in the
Haskell code; once we have parity, we can enable the (for now)
commented-out lines that check the reverse.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd infrastructure for reading Python command output
Iustin Pop [Sun, 19 Aug 2012 22:41:26 +0000 (00:41 +0200)]
Add infrastructure for reading Python command output

This will be used in the future to make tests/assertions for
Python/Haskell codebase equivalence (e.g. checking that the same
opcodes are defined, etc.).

(Side-note: this might not work in VPATH builds; I'll see how it goes)

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoQCHelper: add support for defining HUnit test cases
Iustin Pop [Sun, 19 Aug 2012 22:25:49 +0000 (00:25 +0200)]
QCHelper: add support for defining HUnit test cases

This will allow us to use exactly the same method as for defining and
using QuickCheck properties. The differentiation is based on name,
which is not very nice but is the same method used in
test-framework-th, for example (so we will be able to switch
trivially).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRename tests for nicer names in test output
Iustin Pop [Sun, 19 Aug 2012 21:41:18 +0000 (23:41 +0200)]
Rename tests for nicer names in test output

With the change to test-framework, where individual tests are listed,
QCHelper tries to remove a "prop_$group_" prefix from the function
names, for shorter names. However, some test groups (LUXI) and test
functions are not uniform, leading to long names, so we should fix
them.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoSwitch Haskell test harness to test-framework
Iustin Pop [Sun, 19 Aug 2012 21:33:45 +0000 (23:33 +0200)]
Switch Haskell test harness to test-framework

This patch replaces our home-grown, and quite limited, test runner
infrastructure with test-framework
(http://batterseapower.github.com/test-framework/). The rationale for
doing so is as follows:

- we will need to add support for HUnit tests, so either we add more
  custom code or we switch to an existing library
- test-framework is mature and already packaged, at least in
  Debian/Ubuntu
- it supports more features: parallel test running, better test
  selection, etc.

As you can see, the changes are trivial, and don't touch the tests at
all; if/when we split the QC.hs file into per-module files, then we
could drop QCHelper too, and replace it with test-framework-th, which
does the same, but even more automated (auto-discovery, without having
to list the tests at all).

Dependencies are updated in devnotes.rst; note that I've already added
the hunit dependencies since we're going to use that soon.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoSimplify the Luxi client-server test
Iustin Pop [Sun, 19 Aug 2012 21:17:26 +0000 (23:17 +0200)]
Simplify the Luxi client-server test

Since now we have the recvMsgExt, we can remove the handleEOF
function.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoFix bug in the Luxi client-server test
Iustin Pop [Sun, 19 Aug 2012 21:16:32 +0000 (23:16 +0200)]
Fix bug in the Luxi client-server test

We didn't close the server correctly, so for test sizes bigger than
the max-open-files ulimit, the tests were failing in accept().

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoTH: one style fix and more docstrings
Iustin Pop [Sun, 19 Aug 2012 18:01:18 +0000 (20:01 +0200)]
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 <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoOpCodes: build and export a list of all opcodes
Iustin Pop [Sun, 19 Aug 2012 13:22:49 +0000 (15:22 +0200)]
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 <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoTH: Abstract function for computing constructor names
Iustin Pop [Sun, 19 Aug 2012 13:20:48 +0000 (15:20 +0200)]
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,
instead of an explicit message.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoEnable tags query over the query socket
Iustin Pop [Sun, 19 Aug 2012 00:13:43 +0000 (02:13 +0200)]
Enable tags query over the query socket

This patch adds the tags field to the objects which were missing it
(all except Cluster), implements handling the LuxiCall QueryTags, and
then enables the use of the query socket in cli.ListTags, used by all
commands, and in the RAPI client.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoSwitch RAPI to use same tags listing as CLI
Iustin Pop [Sun, 19 Aug 2012 00:44:44 +0000 (02:44 +0200)]
Switch RAPI to use same tags listing as CLI

Currently, RAPI uses queries (as in QueryNode with field tags) for
getting the tags, whereas the CLI uses the QueryTags Luxi
command. Since this discrepancy is not good, let's switch RAPI to use
the same method as the CLI.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoConfig.hs: Add a function to lookup group
Iustin Pop [Sun, 19 Aug 2012 00:11:49 +0000 (02:11 +0200)]
Config.hs: Add a function to lookup group

Like in the python code, this is a bit more complex since groups are
indexed by UUID, so we must fallback to lookup via the name (slow; but
the number of groups should be small).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd a Functor instance for our Result type
Iustin Pop [Sat, 18 Aug 2012 23:48:54 +0000 (01:48 +0200)]
Add a Functor instance for our Result type

This will allow us to use the simpler applicative form (<$>, <*>)
instead of monadic liftM, liftM2, etc.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoChange the Luxi tags kind from String to a custom type
Iustin Pop [Sat, 18 Aug 2012 23:31:32 +0000 (01:31 +0200)]
Change the Luxi tags kind from String to a custom type

This will allow safer code when we implement the tags query.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRemove obsolete QrViaLuxi type
Iustin Pop [Sat, 18 Aug 2012 23:22:37 +0000 (01:22 +0200)]
Remove obsolete QrViaLuxi type

The actual query definitions are now in Qlang.hs, so let's use the
ItemType from there instead of luxi-defined type (which is also
incomplete).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImplement support for query only clients in Rapi
Iustin Pop [Sun, 19 Aug 2012 00:32:20 +0000 (02:32 +0200)]
Implement support for query only clients in Rapi

This implements the same query=True|False functionality as in
GetClient for cli.py, however since the RAPI code is much more
unit-tested (and the unit-test clients are mocked, for the most part,
without support for addresses) we have to do many adaptations in the
tests.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd configure-time switch for split queries
Iustin Pop [Sat, 18 Aug 2012 23:06:08 +0000 (01:06 +0200)]
Add configure-time switch for split queries

And expand cli.GetClient() to allow opening the query socket, instead
of the main master socket.

Finally, enable the query socket use in gnt-cluster version, since
that is already implemented fully in Queryd.hs/hconfd.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRemove obsolete conversion function for Luxi TH
Iustin Pop [Sat, 18 Aug 2012 22:34:54 +0000 (00:34 +0200)]
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 <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRename Query2.hs to Qlang.hs
Iustin Pop [Sat, 18 Aug 2012 22:33:08 +0000 (00:33 +0200)]
Rename Query2.hs to Qlang.hs

While starting to use the new filter types, I realised that what is
currently implemented is the equivalent of `lib/qlang.py', not
`lib/query.py', since we only deal with data types for now and not the
actual query runtime functionality (RPC, config, etc.).

Let's rename the file to be more consistent with the Python code base.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoSwitch Luxi Query operation to use a proper filter
Iustin Pop [Sat, 18 Aug 2012 22:04:45 +0000 (00:04 +0200)]
Switch Luxi Query operation to use a proper filter

Until now, since we didn't have a proper type for the encoded query
filters, we were ignoring the filters and handled them as null values
(JSNull and respectively ()). With the current Query2 implementation,
we can actually use correct filters (we can send filters the client
side, and on server side we can decode them).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImplement Query2 filter JSON (de)serialisation
Iustin Pop [Sat, 18 Aug 2012 20:49:50 +0000 (22:49 +0200)]
Implement Query2 filter JSON (de)serialisation

This adds support for encoding/decoding Query2 filters to/from JSON,
in (hopefully) the same format as the Python code generates.

It also adds a simple unit-test to check that this conversion is
idempotent. Of note here is that, since the Filter data type is
recursive, we have to manually ensure that the generator for it
correctly "shrinks" at each step (first version crashed hard my
workstation after eating ~8GB of ram :).

Compared to the current Query2 implementation, the following changes
were done:

- style: shortened some names to match the Python ones (LessEqualThan
  → LE, etc.)
- changed FilterValue from string to an ADT that can encode both
  quoted strings and numeric values, since this is actually what
  qlang.py generates
- added support for EmptyField, which in hindsight it's an obvious
  missing part :)

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoconvert-constants: also export qlang.py constants
Iustin Pop [Sat, 18 Aug 2012 20:43:13 +0000 (22:43 +0200)]
convert-constants: also export qlang.py constants

Since these will be needed for Haskell's implementation of query2.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRe-enable standard hlint warnings
Iustin Pop [Sat, 18 Aug 2012 18:52:20 +0000 (20:52 +0200)]
Re-enable standard hlint warnings

Commit 5a1e31b4 (Add infrastructure for, and two extra hlint rules)
was intended to add two *extra* hlint rules, but I didn't realise at
that time that "--hint" when first used overrides the built-in
lints. As such, since then we were basically running with just those
two rules, which resulted in many uncaught warnings/errors.

This patch fixes that (by importing the standard lint rules in our
custom hints file), and then goes to fix all the warnings that a
current hlint gives me. Compared to our current style, we have just a
few additions:

- zipWithM instead of map foo . zip …
- 'exitSuccess' instead of 'exitWith ExitSuccess'
- more uses of '.'

Additionally, we have to silence a case where hlint doesn't realise
why we are using '\e -> const (return False (e :: IOError)' instead of
just '\e -> return False' or even 'const (return False').

One warning that is generated by hlint ("Use void") can't be fixed
until we deprecate GHC 6.x, as only GHC 7 has the 'void' function in
Control.Monad.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRun the query thread from confd
Iustin Pop [Sat, 18 Aug 2012 18:26:13 +0000 (20:26 +0200)]
Run the query thread from confd

This enables the query functionality in confd.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoInitial query daemon implementation
Iustin Pop [Sat, 18 Aug 2012 18:24:27 +0000 (20:24 +0200)]
Initial query daemon implementation

This is just a new module that exports a runQueryD function, that can
be imported to run a separate thread handling the luxi requests.

Currently it needs access just to the configuration, in the future it
will need access to an RPC runner too.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoEnhance the Luxi interface implementation
Iustin Pop [Sat, 18 Aug 2012 15:16:25 +0000 (17:16 +0200)]
Enhance the Luxi interface implementation

This makes the implementation a bit nicer for both for server and
client side: we add a wrapper function with a better result type, and
a few extra functions for building the response.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd Objects definitions for the ispec/ipolicy types
Iustin Pop [Sat, 18 Aug 2012 14:54:54 +0000 (16:54 +0200)]
Add Objects definitions for the ispec/ipolicy types

Note that since we don't have yet a way to nicely handle two-level
optional parameters, the Filled/Partial types and filling function are
all manually built.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImprove Objects.hs definitions
Iustin Pop [Sat, 18 Aug 2012 14:54:08 +0000 (16:54 +0200)]
Improve Objects.hs definitions

This adds a few missing/incomplete definitions. We're still missing
the special parameters (disk params, hvparams, os_hvp).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoRemove container field special cases
Iustin Pop [Tue, 14 Aug 2012 21:22:24 +0000 (23:22 +0200)]
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 <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImprove the TH 'Container' type
Iustin Pop [Tue, 14 Aug 2012 20:54:35 +0000 (22:54 +0200)]
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
- however, since Data.Map already has a JSON instance, we have to very
  carefully always use custom show/read routines to handle this type

The second point leads to potential bugs which are not caught by the
type system, so let's improve the situation by making it a proper
newtype, which can have its own JSON instance (with our desired
behaviour). Once we do this change, accessing the type requires an
extra function call, but it's as safe as before. On the positive side,
we can use the implicit read/show JSON, which means we can remove (in
the next patch) the "container" special casing.

The patch also moves the type to outside of THH, since not all users
of this will want to import that (as opposed to JSON.hs, which is
smaller).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoImprove TH local variables naming
Iustin Pop [Tue, 14 Aug 2012 20:45:46 +0000 (22:45 +0200)]
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
- since only a few Python/JSON names have dashes in them, we didn't
  handle those, resulting in variables named like "disk-templates",
  which is not good; we now handle it the same as '_', i.e. we use it
  as a breaker for camel-casing

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoExpand TH with tags field
Iustin Pop [Tue, 14 Aug 2012 20:43:40 +0000 (22:43 +0200)]
Expand TH with tags field

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

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd new definition for query socket
Iustin Pop [Mon, 13 Aug 2012 16:40:11 +0000 (18:40 +0200)]
Add new definition for query socket

This is not used yet, but is helpful when developing the Luxi endpoint
for hconfd.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoSimple QC tests for RPC calls
Agata Murawska [Fri, 24 Aug 2012 12:17:56 +0000 (14:17 +0200)]
Simple QC tests for RPC calls

Right now we're only able to test if when a node is offline, the call
fails with an appropriate errror.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoImplementation of NodeInfo call and result
Agata Murawska [Thu, 23 Aug 2012 14:01:44 +0000 (16:01 +0200)]
Implementation of NodeInfo call and result

node_info call takes hypervisors and vgs to ask for information about
node and returns bootid and results from hypervisors and volume groups.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoImplementation of InstanceList call and result
Agata Murawska [Thu, 23 Aug 2012 14:01:20 +0000 (16:01 +0200)]
Implementation of InstanceList call and result

instance_list call takes a list of hypervisors and returns a list
of running instances.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoImplementation of AllInstancesInfo call and result
Agata Murawska [Tue, 21 Aug 2012 11:55:44 +0000 (13:55 +0200)]
Implementation of AllInstancesInfo call and result

all_instances_info call takes a list of hypervisors and returns a list
of (name, memory, state, vcpus, time) - one element for each
instance.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoInfrastructure to execute RPC calls
Agata Murawska [Mon, 20 Aug 2012 15:39:00 +0000 (17:39 +0200)]
Infrastructure to execute RPC calls

Prepare and execute RPC call, prepare result for the call. These
procedures are generic in the sense that they only require the
Call and Result types to be connected.
We use curl library for sending http requests for RPC; as the library's
usage can be disabled, we need to use CPP preprocessor macros for some parts
of the code.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoDatatypes for haskell RPC calls
Agata Murawska [Mon, 20 Aug 2012 15:00:15 +0000 (17:00 +0200)]
Datatypes for haskell RPC calls

We introduce typeclasses for RPC call and result and create a typeclass
that binds the two together. For that we need to use
MultiParamTypeClasses and FunctionalDependencies language pragmas, which
allow us to ensure that RPC result type can be deduced based on the
RPC call type.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd Hypervisor and start exporting AdminState
Agata Murawska [Tue, 7 Aug 2012 09:01:12 +0000 (11:01 +0200)]
Add Hypervisor and start exporting AdminState

Very simple Hypervisor object, that we want to pass in some of RPC
calls is added. We also export AdminState data type, as it is used
in one of the calls that will be implemented in this patch series.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoMove necessary constants from rpc & rpc_defs to constants
Agata Murawska [Tue, 31 Jul 2012 13:49:49 +0000 (15:49 +0200)]
Move necessary constants from rpc & rpc_defs to constants

As timeout constants will now be used also on Haskell side, they have
been moved from rpc_defs and rpc to constants. The same is true for
connection timeout for connecting to nodes.

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoMerge branch 'devel-2.6'
Iustin Pop [Mon, 27 Aug 2012 14:17:06 +0000 (16:17 +0200)]
Merge branch 'devel-2.6'

* devel-2.6:
  Make stable-2.6 compatible with newer pep8
  Fix computation of disk sizes in _ComputeDiskSize
  Add verification of RPC results in _WipeDisks
  Add test for checking that all gnt-* subcommands run OK
  Fix double use of PRIORITY_OPT in gnt-node migrate
  Add new Makefile target to rebuild the whole dist
  rapi client: accept arbitrary shutdown arguments
  Handle offline nodes for "instance down" checks
  Add missing rst files to Makefile.am
  Release version 2.6.0 (final)
  Fix 'explicitely' common typo
  Fix issue in LUClusterVerifyGroup with multi-group clusters
  Add QA test for node group modification of ndparams
  Fix node group modification of node parameters
  Fix RST formatting in NEWS file
  Update NEWS and bump version for release 2.5.2
  Fix boot=on flag for CDROMs
  KVM: only pass boot flag once
  Ensure a stable content of the bash completion file

Conflicts (all trivial):
        Makefile.am  (design drafts on both sides, pep8 changes)
        autotools/build-bash-completion (copyright years)

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoMerge branch 'stable-2.6' into devel-2.6
Iustin Pop [Mon, 27 Aug 2012 14:15:01 +0000 (16:15 +0200)]
Merge branch 'stable-2.6' into devel-2.6

* stable-2.6:
  Make stable-2.6 compatible with newer pep8
  Fix computation of disk sizes in _ComputeDiskSize
  Add verification of RPC results in _WipeDisks
  Add test for checking that all gnt-* subcommands run OK
  Fix double use of PRIORITY_OPT in gnt-node migrate
  Add new Makefile target to rebuild the whole dist

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoMake stable-2.6 compatible with newer pep8
Iustin Pop [Mon, 27 Aug 2012 13:45:24 +0000 (15:45 +0200)]
Make stable-2.6 compatible with newer pep8

This is done so that all current branches can run with newer pep8;
note that instead of fixing the problems (like I did on master), I've
just silenced more. These should *not* be merged onto master!

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoMore descriptive Constants.hs header
Agata Murawska [Tue, 31 Jul 2012 12:57:37 +0000 (14:57 +0200)]
More descriptive Constants.hs header

Signed-off-by: Agata Murawska <agatamurawska@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoBump pep8 version to 1.2
Iustin Pop [Thu, 23 Aug 2012 11:10:41 +0000 (13:10 +0200)]
Bump pep8 version to 1.2

Debian Wheezy will ship with this version, and it has many improved checks compared to 0.6, so let's:

- bump version in the docs
- silence some new checks that are wrong due to our indent=2 instead of 4
- fix lots of errors in the code where the indentation was wrong by 1
  or 2 spaces
- fix a few cases of == True, False, None and replace with 'is'
- re-indent some cases where the code is OK, but pep8 complains

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoChange node parameter oob_program to VTYPE_STRING
Iustin Pop [Tue, 21 Aug 2012 14:52:07 +0000 (16:52 +0200)]
Change node parameter oob_program to VTYPE_STRING

Since this is an inheritable parameter, having it as a MABYE_STRING
creates only problems (per our derivation rules). We change it to
STRING, with the default "", meaning no program. Note that most of the
code already accepts this as valid for "no program", and some comments
even say that this is the expected value.

We have some other parameters like this, I'll have to investigate
whether they need to be changed too. But right now I need this for the
hconfd changes (it's a prerequisite for them, I forgot to send it in
that patch series).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoFix computation of disk sizes in _ComputeDiskSize
Constantinos Venetsanopoulos [Wed, 22 Aug 2012 11:16:48 +0000 (14:16 +0300)]
Fix computation of disk sizes in _ComputeDiskSize

Currently, hail fails with FailDisk when trying to add an instance
of type: 'file', 'sharedfile' and 'rbd'.

This is due to a "0" or None value in the corresponding dict inside
_ComputeDiskSize, which results in a "O" or non Int value of the
exported 'disk_space_total' parameter. This in turn makes hail fail,
when trying to process the value:

 - with "Unable to read Int" if value is None (file)
 - with FailDisk if value is 0 (sharedfile, rbd)

The latter happens because the 0 value doesn't match the instance's
IPolicy, since it is lower than the minimum disk size.

The second problem still exists when using adoption with 'plain'
and 'blockdev' template and will be addressed in another commit.

Signed-off-by: Constantinos Venetsanopoulos <cven@grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd verification of RPC results in _WipeDisks
Iustin Pop [Wed, 15 Aug 2012 09:46:30 +0000 (11:46 +0200)]
Add verification of RPC results in _WipeDisks

Due to an oversight, the pause/resume sync RPC calls in _WipeDisks
lack the verification of the overall RPC status, and directly iterate
over the payload. The code actually doing the wipe does verify
correctly the results. This can result in jobs failing with a hard to
diagnose:

OpExecError ['NoneType' object is not iterable]

instead of proper "RPC failed" message.

This patch adds a hard check on the pause call, but for the resume
call it just logs a warning if the RPC failed; the rationale being
that if we can't contact the node for pausing the sync, it's likely
wiping will fail too, but after the wipe has been done, we can
continue.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoAdding design doc for bulk instance create
René Nussbaumer [Wed, 11 Jul 2012 11:31:24 +0000 (13:31 +0200)]
Adding design doc for bulk instance create

This is the design doc for the bulk instance creation. You can more
details in the doc itself.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoAdd a server-side Luxi implementation
Iustin Pop [Mon, 13 Aug 2012 13:05:55 +0000 (15:05 +0200)]
Add a server-side Luxi implementation

This is a trivial code change, but it allows us to finally test the
send-receive code on both client and server sides via a simple
in-process server.

The unittest works, but it won't handle timeouts very nicely; it will
wait until the actual Luxi timeout expires, instead of using much
shorter timeouts as we could in the same process.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

11 years agoSwitch the Luxi interface from Strings to ByteStrings
Iustin Pop [Tue, 7 Aug 2012 09:26:00 +0000 (11:26 +0200)]
Switch the Luxi interface from Strings to ByteStrings

I'm doing this change for future performance optimisations. Currently
we use the Luxi interface just as a client, so not in the hot path,
but when we'll use this as a server interface, we're interested to
both reduce the space and time consumption of the interface.

We have to simultaneous changes here:

- switch from using socket-related function (sendto, recv, etc.) to
  handle-based functions, since the standard network library doesn't
  work with sockets
- switch from using Strings for the internal buffer to strict
  ByteStrings; the only downside is that we now have the issue of
  decoding/encoding from binary to UTF-8 strings, a fact which brings
  its own issues into the mix (we have to check for failed decodings,
  etc.); but this is similar to what we'll have to handle on the
  Python side when moving to Python 3.x

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

11 years agoAdd test for checking that all gnt-* subcommands run OK
Iustin Pop [Fri, 10 Aug 2012 09:49:09 +0000 (11:49 +0200)]
Add test for checking that all gnt-* subcommands run OK

This is a bit of a shell munging trickery, but works for now. Making
it more generic can be done later.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoFix double use of PRIORITY_OPT in gnt-node migrate
Iustin Pop [Fri, 10 Aug 2012 09:38:12 +0000 (11:38 +0200)]
Fix double use of PRIORITY_OPT in gnt-node migrate

This breaks the command, as optparse considers that an error.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoAdd new Makefile target to rebuild the whole dist
René Nussbaumer [Wed, 8 Aug 2012 14:43:13 +0000 (16:43 +0200)]
Add new Makefile target to rebuild the whole dist

Due to the fact how the automake system works it doesn't rebuild already
prebuild files in distcheck. This lead to a bug, where a rebuild of the
documentation was failing because we missed the fact that the files were
missing from the archive.

By adding distrebuildcheck we workaround that issue by running a
maintainer-clean which also removes prebuild files.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agorapi client: accept arbitrary shutdown arguments
Guido Trotter [Tue, 24 Jul 2012 12:13:06 +0000 (13:13 +0100)]
rapi client: accept arbitrary shutdown arguments

The "ignore_offline_nodes" parameter is unsupported. Rather than
explicitely adding it, just pass all keyword arguments in the body of
the query, and rapi on the other side will do the right thing.

Supports for old arguments that were passed via the query is unchanged.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoHandle offline nodes for "instance down" checks
Guido Trotter [Thu, 19 Jul 2012 12:28:46 +0000 (13:28 +0100)]
Handle offline nodes for "instance down" checks

When offlining an instance because its primary node is down, we must be
able to cope with the situation.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd missing rst files to Makefile.am
René Nussbaumer [Tue, 7 Aug 2012 13:40:59 +0000 (15:40 +0200)]
Add missing rst files to Makefile.am

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoSwitch job IDs to numeric
Iustin Pop [Thu, 2 Aug 2012 11:47:53 +0000 (13:47 +0200)]
Switch job IDs to numeric

This has been a long-standing cleanup item, which we've always
refrained from doing due to the high estimated effort needed.

In reality, it turned out that after some infrastructure improvements
(the previous patches), the actual job queue-related changes are quite
small.

We will need to update the NEWS file later, but so far the RAPI
documentation doesn't mention that the job ID is a string (it only
says it is "a number"), so it doesn't look like it needs update.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

11 years agoAdd infrastructure for building numeric namefield filters
Iustin Pop [Thu, 2 Aug 2012 11:29:04 +0000 (13:29 +0200)]
Add infrastructure for building numeric namefield filters

Currently, all the CLI helpers in qlang.py and cli.py assume that all
namefields are string, which leads to various breakage in case the're
actually not.

To improve the flexibility of the helpers, we add a bit of
infrastructure for accepting so called "numeric" namefields; this is a
bit of a hack, as a proper fix would actually add QFT_* support to the
helpers, and case for example the regex/globbing on QFT_TEXT, etc. But
that's left for (eventual) later improvement.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>