ganeti-local
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>

11 years agoMake jqueue unittests more generic
Iustin Pop [Thu, 2 Aug 2012 11:16:47 +0000 (13:16 +0200)]
Make jqueue unittests more generic

This patch removes/abstracts some hardcoded values in the jqueue
unittests. Currently we have a per-resource type name field, but the
name field values are hardcoded at the call sites, instead of being
abstracted into separate variables.

This will become a problem later, so let's just introduce some new
vars holding these; modifying the tests later will be therefore
easier.

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

11 years agoExpand debug messages in gnt-debug test-jobqueue
Iustin Pop [Thu, 2 Aug 2012 10:50:23 +0000 (12:50 +0200)]
Expand debug messages in gnt-debug test-jobqueue

It wasn't clear for which tests we were ignoring the errors.

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

11 years agoFix uses of OpPrereqError without code info
Iustin Pop [Thu, 2 Aug 2012 09:37:46 +0000 (11:37 +0200)]
Fix uses of OpPrereqError without code info

A while back, we did cleanup the code and ensured (manually) that use
of OpPrereqError includes an errors.ECODE_* field as second
argument. Since we cannot automate the check for this, it turns out
that more and more such usage has crept over the years, including in
the master code (the use on the CLI side is not as important).

Note that this also uncovered a few errors in ovf.py where the errors
messages were wrongly constructed.

Still looking for a way to automate this check…

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

11 years agohtools: abstract function for parsing job ids
Iustin Pop [Wed, 25 Jul 2012 14:20:56 +0000 (16:20 +0200)]
htools: abstract function for parsing job ids

Both the job id and submit job result parsing are abstracted into
separate functions, so that later changes are more localised.

Also, this makes submitManyJobs itself easier to read.

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

11 years agoIntroduce a type for the ganeti job type
Iustin Pop [Wed, 25 Jul 2012 14:16:38 +0000 (16:16 +0200)]
Introduce a type for the ganeti job type

This will be used for easier change later.

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

11 years agoRelease version 2.6.0 (final) v2.6.0
Iustin Pop [Fri, 27 Jul 2012 10:59:54 +0000 (12:59 +0200)]
Release version 2.6.0 (final)

Phew, it wasn't easy, but…

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

11 years agoFix 'explicitely' common typo
Iustin Pop [Thu, 26 Jul 2012 19:53:26 +0000 (21:53 +0200)]
Fix 'explicitely' common typo

It seems that 'explicitely' is wrong, and that the right form is
'explicitly'. This is just fixing the typo plus adjusting affected
paragraphs.

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

11 years agoFix issue in LUClusterVerifyGroup with multi-group clusters
Iustin Pop [Thu, 26 Jul 2012 14:43:18 +0000 (16:43 +0200)]
Fix issue in LUClusterVerifyGroup with multi-group clusters

In case LUClusterVerifyGroup is run on a group which doesn't contain
the master node, the following could happen:

- master node is selected due to the explicit check
- if the order of nodes in the 'absent_nodes' list is such that the
  master node is the first in it, then we'll select (again) the master
  node
- passing duplicate nodes to RPC calls will break due to RPC
  internals; this should be fixed separately, but in the meantime we
  just refrain from passing such duplicates

This patch should not change the semantics of the code, since it
wasn't guaranteed even before that we find a vm_capable node.

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

11 years agoAdd QA test for node group modification of ndparams
Iustin Pop [Thu, 26 Jul 2012 11:24:58 +0000 (13:24 +0200)]
Add QA test for node group modification of ndparams

Additionally, we run hbal if the htools tests are enabled (new
key). Note that hbal will directly exit, since there are no instances,
but at least it will load and parse the group details.

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

11 years agoFix node group modification of node parameters
Iustin Pop [Thu, 26 Jul 2012 11:17:41 +0000 (13:17 +0200)]
Fix node group modification of node parameters

Commit 904b3bfe tried to fix the deletion of custom ndparams from
group, but instead broke both modification and deletion: because we
run ForceDictType on self.op.ndparams instead of the updated
new_ndparams, we can neither delete nor set properly spindle_count
(since it won't be coerced to int).

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

11 years agoQA for allocator in recreate-disks
Bernardo Dal Seno [Wed, 27 Jun 2012 08:53:47 +0000 (10:53 +0200)]
QA for allocator in recreate-disks

QA for recreate-disks called it twice with a list of node; the first call
now uses an allocator.

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

11 years agoFront-end and doc to use allocator in recreate-disks
Adam Ingrassia [Wed, 22 Feb 2012 15:31:26 +0000 (10:31 -0500)]
Front-end and doc to use allocator in recreate-disks

The recreate-disks command no longer requires an explicit list of nodes.

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

11 years agoAllocator support in recreate-disks LU
Bernardo Dal Seno [Wed, 4 Apr 2012 17:50:05 +0000 (19:50 +0200)]
Allocator support in recreate-disks LU

This affects only the backend.

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

11 years agoAdded method to call an allocator for recreate-disks
Adam Ingrassia [Fri, 24 Feb 2012 17:28:49 +0000 (12:28 -0500)]
Added method to call an allocator for recreate-disks

Ideally this should have used relocation mode, but to due lacking of
support in current allocators, allocation mode has been used instead.

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

11 years agoSupport for checking the group of only the primary node
Adam Ingrassia [Tue, 24 Jul 2012 17:05:35 +0000 (13:05 -0400)]
Support for checking the group of only the primary node

_CheckInstanceNodeGroups behaves in the old way with the default value
of the new parameter.

Signed-off-by: Adam Ingrassia <api@google.com>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoMerge commit 'v2.5.2' into stable-2.6
Iustin Pop [Tue, 24 Jul 2012 16:44:59 +0000 (18:44 +0200)]
Merge commit 'v2.5.2' into stable-2.6

* commit 'v2.5.2':
  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

Conflicts:
        NEWS         (trivial, merged the entries)
        configure.ac (trivial, kept ours)

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

11 years agoFix RST formatting in NEWS file v2.5.2
Iustin Pop [Tue, 24 Jul 2012 16:02:33 +0000 (18:02 +0200)]
Fix RST formatting in NEWS file

*FileID is interpreted as a start-of-bold, without corresponding end
marker. Sorry for not catching it in the first place.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>

11 years agoUpdate NEWS and bump version for release 2.5.2
Iustin Pop [Tue, 24 Jul 2012 15:52:23 +0000 (17:52 +0200)]
Update NEWS and bump version for release 2.5.2

This is a trivial release, with just bug fixes, so a small change log.

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

11 years agoFix boot=on flag for CDROMs
Iustin Pop [Mon, 23 Jul 2012 12:46:08 +0000 (14:46 +0200)]
Fix boot=on flag for CDROMs

This generalises commit 4304964a to cdroms too, since they have
somewhat the same logic. We just abstract the needs_boot_flag into a
separate variable, and then reuse it in the cdrom section.

Note that the logic of what 'if=' type to pass to KVM was very
convoluted, and (I think) incorrect; I went and cleaned it to be more
consistent.

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

11 years agoKVM: only pass boot flag once
Iustin Pop [Mon, 23 Jul 2012 11:56:09 +0000 (13:56 +0200)]
KVM: only pass boot flag once

This addresses issue 230: passing two methods of booting to KVM can,
depending on the KVM version, confuse it.

Note that commit 4304964a introduced a partial fix for this (but only
for disks, and keyed on KVM versions). However, it didn't fix cdrom
booting, which still fails with the same error, so let's fix it more
generically; we still leave the per-disk check since that is about
-boot c versus -drive …,boot=on rather than two boot methods.

Patch is based on the one submitted by Vladimir Mencl, many thanks!

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

11 years agoBuild epydoc.conf using standard replace_vars_sed
Iustin Pop [Fri, 20 Jul 2012 18:58:57 +0000 (20:58 +0200)]
Build epydoc.conf using standard replace_vars_sed

This is just begging to be converted to a standard replace_vars_sed
rule, instead of custom sed calls.

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

11 years agoSimplify some make rules
Iustin Pop [Fri, 20 Jul 2012 18:49:33 +0000 (20:49 +0200)]
Simplify some make rules

A rule of type "a/%: a/%.in" will also match "a/b/%: a/b/%.in", so no
need for the explicit examples/hooks rule. As for the man rules, they
are identical and thus can be collapsed.

We still have the problem that globally, not all our %.in to %
transformations are identical; this is suboptimal and should be
cleaned sometime…

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

11 years agoExplicitly terminate some make rules
Iustin Pop [Fri, 20 Jul 2012 18:30:18 +0000 (20:30 +0200)]
Explicitly terminate some make rules

Generic rules like:

  %: %.in

have the downside that the source (%.in) itself matches the target
(via %.in: %.in.in). This leads to things like:

  Looking for a rule with intermediate file `doc/examples/hooks/ipsec.in.in'.
   Trying pattern rule with stem `ipsec.in.in'.
   Trying implicit prerequisite `doc/examples/hooks/ipsec.in.in.in'.
   Trying pattern rule with stem `ipsec.in.in'.
   Trying implicit prerequisite `doc/examples/hooks/ipsec.in.in.in'.
   Looking for a rule with intermediate file `doc/examples/hooks/ipsec.in.in.in'.
  Rejecting impossible implicit prerequisite `doc/examples/hooks/ipsec.in.in'.

To fix this, we need to tell make that such rules are terminating, so
that it doesn't recurse into them.

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

11 years agoRemove ancient implicit make rules
Iustin Pop [Fri, 20 Jul 2012 17:49:13 +0000 (19:49 +0200)]
Remove ancient implicit make rules

GNU Make contains some (ancient) implicit rules, that try to
_automatically_ extract source files from RCS/SCCS version control
systems. This is unneeded, and it pollutes the make -d output
significantly: after removing these rules (by defining empty targets
for their patterns), make -d line count goes from 5.3K to 3.3K.

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

11 years agoStop using BUILT_SOURCES
Iustin Pop [Fri, 20 Jul 2012 15:54:14 +0000 (17:54 +0200)]
Stop using BUILT_SOURCES

Commit dc7d2c49 introduced the use of BUILT_SOURCES to work around
missing dependencies. However, on closer reading of the gmake manual,
BUILT_SOURCES is mainly used in cases where the dependencies are not
know before the build starts (e.g. with auto-generated C header
files). Additionally, there are a number of drawbacks to
BUILT_SOURCES, which we already had to work around (e.g. in commit
eb732fb5).

Since we know all our dependencies statically, there's no need to use
this special variable. Let's rename it to GENERATED_FILES, which
doesn't have a special meaning to make, and add a few missing
dependencies (one of which was already broken by make -j on a clean
tree).

After this change, running make in a fully built tree is finally "clean":

  $ make
  make: Nothing to be done for `all'.

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

11 years agoChange how we create the 'ganeti' symlink
Iustin Pop [Fri, 20 Jul 2012 15:37:36 +0000 (17:37 +0200)]
Change how we create the 'ganeti' symlink

Currently, if one runs 'make' in an already fully-built tree, this is
the result:

  cd . && test -h "ganeti" || { rm -f ganeti && ln -s lib ganeti; }
  make  all-am
  make[1]: Entering directory `/tmp/test'
  cd . && test -h "ganeti" || { rm -f ganeti && ln -s lib ganeti; }
  make[1]: Leaving directory `/tmp/test'

This is because commit dc7d2c49 added 'ganeti' (which is a PHONY
target) to BUILT_SOURCES, and since that is a dependency of other,
real targets, it means the ganeti target is always remade.

To fix this, we keep ganeti as a PHONY target, but we remove it from
the 'built_base_sources' target, and instead we only remake it
manually in the stamp-directories target. A make run now is just:

  make  all-am
  make[1]: Entering directory `/tmp/test'
  make[1]: Nothing to be done for `all-am'.
  make[1]: Leaving directory `/tmp/test'

Note that we can't get rid of the all-am since we use BUILT_SOURCES.

We also remove the comment of BUILT_SOURCES since it no longer depends
on PHONY targets.

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

11 years agoPartial undo of "Makefile: Streamline directory creation"
Iustin Pop [Fri, 20 Jul 2012 14:58:20 +0000 (16:58 +0200)]
Partial undo of "Makefile: Streamline directory creation"

Commit c964d962 changed the way we create directories, by two things:

- unifying all dependencies and ad-hoc directory creation into a
  single target (all_dirfiles)
- changing how directories are created from a stamp file to .dir files
  in each directory

The first item is a very good one, but the second item is debatable:
there's no per-se advantage of .dir files versus a single one,
top-level, since both the .dir file and stamp-directories creation are
depending on Makefile, which is the only one which can introduce new
directories.

On the other hand, moving back from .dir files to stamp-directories
has an advantage: "make -d | wc -l" does from ~8.7K lines to ~5.3K
lines, because we eliminate the many .dir files and their multiple
implicit and explicit dependencies (the %/.dir files fall under
multiple patterns).

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

11 years agoA few style fixes in Makefile.am
Iustin Pop [Fri, 20 Jul 2012 19:35:37 +0000 (21:35 +0200)]
A few style fixes in Makefile.am

Seen while debugging make rules.

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

11 years agoEnsure a stable content of the bash completion file
Iustin Pop [Fri, 20 Jul 2012 20:14:40 +0000 (22:14 +0200)]
Ensure a stable content of the bash completion file

Currently, the order of commands in the bash completion file is
random, because the sub-commands are not sorted. This makes it harder
to investigate the differences in packaged Ganeti or in installed
Ganeti, since chunks in this file will have a random order.

To fix this, we sort the subcommands based on the first subcommand in
a given group ('first' also in sorted order); this results in a stable
contents of file, as tested by building it many times and checking for
differences.

The patch also does a few other minor changes to the file
(e.g. updating copyright years, etc.).

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

11 years agoCorrectly do sub-$(MAKE) invocations
Iustin Pop [Fri, 20 Jul 2012 14:06:08 +0000 (16:06 +0200)]
Correctly do sub-$(MAKE) invocations

Reading the automake documentation, it seems that explicit calls to
$(MAKE) need $(AM_MAKEFLAGS) passed, so let's do that.

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

11 years agoMake error classes more consistent
Iustin Pop [Fri, 20 Jul 2012 10:00:29 +0000 (12:00 +0200)]
Make error classes more consistent

This removes "pass" from a few definitions, making all errors
consistent.

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