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

11 years agoAdd support for -cpu option in KVM
Nikita Staroverov [Wed, 11 Jul 2012 20:24:30 +0000 (13:24 -0700)]
Add support for -cpu option in KVM

This adds supports for the (non-validated) cpu parameter to KVM.

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

12 years agoAdd note in admin guide about drbd stacked devices
Johan Euphrosine [Thu, 19 Jul 2012 11:15:00 +0000 (13:15 +0200)]
Add note in admin guide about drbd stacked devices

Fixes: http://code.google.com/p/ganeti/issues/detail?id=251
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoMerge branch 'stable-2.6'
Iustin Pop [Thu, 19 Jul 2012 12:37:46 +0000 (14:37 +0200)]
Merge branch 'stable-2.6'

* stable-2.6: (21 commits)
  Release Ganeti 2.6.0 rc4
  Prepare NEWS for Ganeti 2.6.0rc4
  Add some rudimentary node group ipolicy checks
  Fix setting ipolicy on node groups
  Fix --no-headers for the new list-drbd command
  Add a simple QA test for gnt-node list-drbd
  Add a new gnt-node command list-drbd
  Implement a node to drbd minors query function
  Add a new unused confd query
  Add support for computing instance all/secondary nodes
  Add disk logical ID support in Objects.hs
  Fix a docstring in bdev's DRBD8 class
  Extend the Template Haskell loadFn model
  Change how customFields are built
  Implement lookup of partial names in Config.hs
  Reorganise the lookup functions
  Remove an unused function
  Ensure that disk.params is always defined (and a dict)
  Another small consistency fix with if branches
  Fix inconsistency in the LUXI protocol w.r.t. args
  ...

Conflicts:
        htools/Ganeti/HTools/QC.hs (imports changes, trivial)

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

12 years agoRe-indent kvm-ifup.in
Iustin Pop [Thu, 19 Jul 2012 12:03:34 +0000 (14:03 +0200)]
Re-indent kvm-ifup.in

By a strange accident, this file seems to be tabified, instead of our
own 2-space rule. Re-indent it and also break one long line.

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

12 years agoRelease Ganeti 2.6.0 rc4 v2.6.0rc4
René Nussbaumer [Thu, 19 Jul 2012 12:21:53 +0000 (14:21 +0200)]
Release Ganeti 2.6.0 rc4

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

12 years agoPrepare NEWS for Ganeti 2.6.0rc4
René Nussbaumer [Thu, 19 Jul 2012 11:56:59 +0000 (13:56 +0200)]
Prepare NEWS for Ganeti 2.6.0rc4

Another release candidate is coming.

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

12 years agoAdd some rudimentary node group ipolicy checks
René Nussbaumer [Thu, 19 Jul 2012 08:40:46 +0000 (10:40 +0200)]
Add some rudimentary node group ipolicy checks

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

12 years agoFix setting ipolicy on node groups
René Nussbaumer [Thu, 19 Jul 2012 08:26:13 +0000 (10:26 +0200)]
Fix setting ipolicy on node groups

On node groups we don't have the std field. However, the InstancePolicy
object always verifies that the std value is within a given range. As we
fill it up with defaults if not set (as it happens to be on node groups)
and the min value is higher than the default std value (taken from
constants.py) we fail.

We overcome this situation by simply let the function know if we want to
verify the std value at all. If we don't want to verify std, we just set
it to a compliant value (min_v) and continue.

We also slightly adapt the error message provided, as we don't have std
values on groups.

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

12 years agoForce tap's MAC prefix to "fe"
Simon Deziel [Fri, 11 May 2012 16:00:24 +0000 (12:00 -0400)]
Force tap's MAC prefix to "fe"

Setting a high prefix discourages the bridge from adopting the tap's
MAC. Xen is not affected by this since the MAC is forced to
"fe:ff:ff:ff:ff:ff".

This addresses issue #217.

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

12 years agoFix --no-headers for the new list-drbd command
Iustin Pop [Thu, 19 Jul 2012 08:31:52 +0000 (10:31 +0200)]
Fix --no-headers for the new list-drbd command

Sorry, I forgot that with GenerateTable this needs to be handled
manually. Fixed now and tested in both ways.

(But to be honest, this should be abstracted in GenerateTable, instead
of the 'if' test in all its callers.)

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

12 years agoAdd a simple QA test for gnt-node list-drbd
Iustin Pop [Wed, 18 Jul 2012 11:07:08 +0000 (13:07 +0200)]
Add a simple QA test for gnt-node list-drbd

This will be run only if 'haskell-confd' QA configuration has been
enabled.

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

12 years agoAdd a new gnt-node command list-drbd
Iustin Pop [Wed, 18 Jul 2012 09:44:48 +0000 (11:44 +0200)]
Add a new gnt-node command list-drbd

This uses confd to query the DRBD minors, which is very special; no
other command currently does so.

Since the backend is only implemented in the Haskell version of confd,
we have checks that 1) confd is enable, and 2) hs confd is also
enabled. If by mistake people do manage to query Python confd, the
error message will be clean:

  Query gave non-ok status '2': not implemented

So nothing breaks in an "ugly" way.

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

12 years agoImplement a node to drbd minors query function
Iustin Pop [Wed, 18 Jul 2012 09:35:05 +0000 (11:35 +0200)]
Implement a node to drbd minors query function

This can be queried remotely since it's a pure configuration query.

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

12 years agoAdd a new unused confd query
Iustin Pop [Mon, 16 Jul 2012 13:49:04 +0000 (15:49 +0200)]
Add a new unused confd query

This is not implemented currently.

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

12 years agoAdd support for computing instance all/secondary nodes
Iustin Pop [Mon, 16 Jul 2012 12:59:40 +0000 (14:59 +0200)]
Add support for computing instance all/secondary nodes

This fixes an old FIXME. Since we now how actual DRBD configuration
data, we can finally compute the instance's secondary nodes.

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

12 years agoAdd disk logical ID support in Objects.hs
Iustin Pop [Mon, 16 Jul 2012 12:11:03 +0000 (14:11 +0200)]
Add disk logical ID support in Objects.hs

This is a complex field, so we have to do a lot of manual work for now.

The complexity arises from the fact that the contents of the field,
and the way to parse it, depends on the disk type field, so we don't
have a single, static way of parsing it. Hence we needed the
extensions to the Template Haskell code.

Since we now can both load and save the disk type, we can remove the
in-memory (duplicate) disk type from the disk objects, relying only on
the logical ID to hold the type information.

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

12 years agoFix a docstring in bdev's DRBD8 class
Iustin Pop [Mon, 16 Jul 2012 11:51:20 +0000 (13:51 +0200)]
Fix a docstring in bdev's DRBD8 class

It seems this was not updated since the move to static minors…

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

12 years agoExtend the Template Haskell loadFn model
Iustin Pop [Mon, 16 Jul 2012 11:37:09 +0000 (13:37 +0200)]
Extend the Template Haskell loadFn model

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

Furthermore, since we will have to generate two actual fields from the
single in-memory field, we need to extend the custom save function so
that they can generate additional fields beyond the "main" field value
they currently generate.

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

12 years agoChange how customFields are built
Iustin Pop [Mon, 16 Jul 2012 11:31:18 +0000 (13:31 +0200)]
Change how customFields are built

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

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

12 years agoImplement lookup of partial names in Config.hs
Iustin Pop [Wed, 18 Jul 2012 09:31:39 +0000 (11:31 +0200)]
Implement lookup of partial names in Config.hs

This uses the recently-moved functions to implement partial lookup of
names on getNode and getInstance, similar to the Python codebase.

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

12 years agoReorganise the lookup functions
Iustin Pop [Wed, 18 Jul 2012 09:03:31 +0000 (11:03 +0200)]
Reorganise the lookup functions

Currently, the LookupResult, MatchPriority and related functions are
locate in Loader.hs, since (so far) only hbal needs them in the
selection of instances. However, with the new functionality on confd
side, we need these functions there too, but we don't want to import
Loader.hs (which pulls in lots of balancing-related code). So we move
all these function to BasicTypes.hs, since that module is a leaf one,
with no other dependencies.

Unittests are slightly adjusted (but they are still tested under the
'Loader' group).

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

12 years agoRemove an unused function
Iustin Pop [Mon, 16 Jul 2012 11:30:04 +0000 (13:30 +0200)]
Remove an unused function

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

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

12 years agoEnsure that disk.params is always defined (and a dict)
Iustin Pop [Wed, 18 Jul 2012 12:18:12 +0000 (14:18 +0200)]
Ensure that disk.params is always defined (and a dict)

Commit cce46164 fixed upgrading from other 2.6 versions, but
accidentally broke upgrading from 2.5 (disk.params was left as None,
which breaks FillDict). The simplest way to handle params is to always
set them to an empty dict (disregarding what they currently contain).

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

12 years agoAnother small consistency fix with if branches
René Nussbaumer [Wed, 18 Jul 2012 11:34:36 +0000 (13:34 +0200)]
Another small consistency fix with if branches

While looking at the testability of this piece of code, I found another
consistency problem. We have two if branches instead of one, with
elif's.

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

12 years agoFix inconsistency in the LUXI protocol w.r.t. args
René Nussbaumer [Wed, 18 Jul 2012 09:13:09 +0000 (11:13 +0200)]
Fix inconsistency in the LUXI protocol w.r.t. args

This inconsistency was found during rebalancing. Hbal failed because,
Ganeti couldn't load the opcode. After digging through the cause, an
inconsistency with the "args" field in the LUXI protocol was triggered
by the TemplateHaskell side where it's done uniformed.

For SubmitJob and SubmitManyJobs we treat args as one argument,
containing the job definition. In every other LUXI call args is actually
a list of arguments. This patch fixes this consistency.

This change is NOT backwards compatible.

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

12 years agoFix UpgradeConfig of Disk object regards disk params
René Nussbaumer [Tue, 17 Jul 2012 08:18:41 +0000 (10:18 +0200)]
Fix UpgradeConfig of Disk object regards disk params

This bug was found during disk parameter debugging. While looking at the
config some values seem present on the disk parameters, but that's not
expected behaviour. This patch fixes this, and also fixes the "broken"
configs automatically upon masterd restart.

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