ganeti-local
12 years agoFix printSolutionLine to handle big scores
Iustin Pop [Mon, 5 Mar 2012 13:11:15 +0000 (14:11 +0100)]
Fix printSolutionLine to handle big scores

Currently we don't set a boundary on the length of the score field,
which breaks all our nicely-aligned output efforts.

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

12 years agoFix printSolutionLine to handle non-DRBD steps
Iustin Pop [Mon, 5 Mar 2012 13:06:57 +0000 (14:06 +0100)]
Fix printSolutionLine to handle non-DRBD steps

Currently Cluster.printSolutionLine function always wants to print the
old and new secondary, and as such it fails (ugly) for moves of
non-DRBD instances. Change it so that it looks explicitly for
noSecondary nodes, and format the output different in that case.

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

12 years agoAdd a helper type and function for the mirror type
Iustin Pop [Mon, 5 Mar 2012 12:55:54 +0000 (13:55 +0100)]
Add a helper type and function for the mirror type

Currently we track the mirroring type as simply yes/no, with "yes"
meaning DRBD. This is not enough for handling shared storage, so we
need to add a type that gives the exact mirroring type (none,
internal, external), and a function that ties the disk template type
to the mirroring type.

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

12 years agoSmall simplification in tryBalance
Iustin Pop [Mon, 5 Mar 2012 12:09:24 +0000 (13:09 +0100)]
Small simplification in tryBalance

Instead of computing the bad/good node lists separately (in effect
iterating twice over the all_nodes list and also creating that list
twice from the container), let's use 'partition' and do a small
improvement.

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

12 years agoMark Rbd as a movable disk template
Iustin Pop [Mon, 5 Mar 2012 11:58:47 +0000 (12:58 +0100)]
Mark Rbd as a movable disk template

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

12 years agoDo not rely on no-secondary for movable tests
Iustin Pop [Sun, 19 Feb 2012 21:15:17 +0000 (22:15 +0100)]
Do not rely on no-secondary for movable tests

Currently, the code in Loader.hs marks as un-movable any instances
which don't have a secondary. This is not valid for any shared storage
templates, so let's remove that check completely. The initial state of
the instance will reflect correctly the movable status, based on the
disk template of the instance, so we don't need to re-do this check.

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

12 years agoHandle nodes without local storage
Iustin Pop [Sun, 19 Feb 2012 20:59:48 +0000 (21:59 +0100)]
Handle nodes without local storage

Our current cluster model is based on per-node storage, and as such we
don't handle shared disk templates. Until we can improve the model,
let's handle nodes without local storage better: in order to still
compute a valid cluster score, we need to handle nodes with tDsk == 0.

For this, we abstract the in-line computation of pDsk (which is used
in the cluster score) to a separate function which, for tDsk == 0,
returns instead 1 (i.e. disk fully used).

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

12 years agoFix tempfile reset code & test on newer Python
Iustin Pop [Tue, 6 Mar 2012 19:38:18 +0000 (21:38 +0200)]
Fix tempfile reset code & test on newer Python

Python 2.7.3 (rc status) and 3.2.3/3.3 (rc, respectively alpha status)
have fixed http://bugs.python.org/issue12856 which we worked around
ourselves.

This means two things:

- we don't need to manually reset the module
- we can't test for the no-reset case

Unfortunately current Debian Sid has the 2.7.3 RC but still labeled as
2.7.2+ ☹, so we have to manually do an extra check (in the unit test
only); I expect Debian will update to official 2.7.3 as soon as it's
released, and then we can remove this override.

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

12 years agoMerge remote-tracking branch 'origin/devel-2.5'
Iustin Pop [Mon, 5 Mar 2012 21:48:16 +0000 (23:48 +0200)]
Merge remote-tracking branch 'origin/devel-2.5'

Conflicts:
        Makefile.am    (trivial, test data files added on both branches)
        lib/opcodes.py (trivial, master renamed filter→qfilter, 2.5
                        fixed the type of the parameter)

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

12 years agoSplit check-man-warnings into two
Iustin Pop [Mon, 5 Mar 2012 10:49:41 +0000 (11:49 +0100)]
Split check-man-warnings into two

This moves the dashes check to a new check-man-dashes script.

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

12 years agoRename check-man to check-man-warnings
Iustin Pop [Mon, 5 Mar 2012 10:44:51 +0000 (11:44 +0100)]
Rename check-man to check-man-warnings

Currently the check-man test is dependent on the MAN_HAS_WARNINGS
test, which made sense as long as the script only did the warnings
check.

However, we should run the [em] tests always, and in general we could
run other tests too, even if man doesn't support --warnings; so let's
split the check man. As a first prerequisite, we rename check-man to
check-man-warnings (and the respective Makefile variables).

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

12 years agoMakefile: improve the fix for .DELETE_ON_ERROR
Iustin Pop [Mon, 5 Mar 2012 10:38:35 +0000 (11:38 +0100)]
Makefile: improve the fix for .DELETE_ON_ERROR

I've investigated more and it seems that .DELETE_ON_ERROR not working
is a bug/regression in some versions of make; testing with make 3.82
from Debian experimental makes this special target work as
expected. Also, make 3.81 works on trivial Makefiles, but not on our
complex one.

In the meantime, let's improve the fix for the building of man pages:
make the removal implicit, instead of explicit, via the use of 'trap'
on EXIT. I just hope this behaves consistently across all bash
versions :)

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

12 years agohtools/ExtLoader: Bring the pieces together
René Nussbaumer [Fri, 2 Mar 2012 10:52:30 +0000 (11:52 +0100)]
htools/ExtLoader: Bring the pieces together

This make it possible to load from an Ialloc file

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

12 years agohtools/CLI: Adding new options to use ialloc as source
René Nussbaumer [Fri, 2 Mar 2012 10:51:32 +0000 (11:51 +0100)]
htools/CLI: Adding new options to use ialloc as source

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

12 years agohtools/IAlloc: Adding loadData method for use as backend
René Nussbaumer [Fri, 2 Mar 2012 10:50:55 +0000 (11:50 +0100)]
htools/IAlloc: Adding loadData method for use as backend

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

12 years agohtools: Refactor some of IAlloc.readRequest to Hail
René Nussbaumer [Fri, 2 Mar 2012 10:49:34 +0000 (11:49 +0100)]
htools: Refactor some of IAlloc.readRequest to Hail

This makes it possible to reuse that function when we want to use IAlloc
as a data source backend

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

12 years agohinfo: Adjust the verbosity
René Nussbaumer [Thu, 1 Mar 2012 09:54:54 +0000 (10:54 +0100)]
hinfo: Adjust the verbosity

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

12 years agohinfo: Gather and print group statistics
René Nussbaumer [Wed, 29 Feb 2012 15:29:44 +0000 (16:29 +0100)]
hinfo: Gather and print group statistics

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

12 years agoExplicitly remove the .x.in man pages on failure
Iustin Pop [Wed, 29 Feb 2012 14:55:58 +0000 (15:55 +0100)]
Explicitly remove the .x.in man pages on failure

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

12 years agoMore -- fixes
Iustin Pop [Wed, 29 Feb 2012 14:55:18 +0000 (15:55 +0100)]
More -- fixes

Because .DELETE_ON_ERROR doesn't work consistently (works when the
target we're talking about is a final target, but not for
intermediates), I missed a lot of man checks.

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

12 years agohtools: Adding printTable helper
René Nussbaumer [Wed, 29 Feb 2012 13:33:49 +0000 (14:33 +0100)]
htools: Adding printTable helper

This helper abstract away all the unlines and unwords call you've to do
after you got a formatTable back.

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

12 years agoFixup a Node unittest
Iustin Pop [Tue, 21 Feb 2012 09:42:32 +0000 (10:42 +0100)]
Fixup a Node unittest

This fixes the prop_Node_rMem test, which cares about memory only;
otherwise we could fail due to other problems (e.g. not enough disk).

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

12 years agoAllow overriding the target test count
Iustin Pop [Mon, 20 Feb 2012 12:45:24 +0000 (13:45 +0100)]
Allow overriding the target test count

This is not perfect, as the override applies identical target test
values to both the 'fast' and 'slow' tests (making the slow tests take
a long time), but it allows a quick override for manual runs.

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

12 years agoAdd two more unittests for Node add/remove
Iustin Pop [Mon, 20 Feb 2012 12:30:04 +0000 (13:30 +0100)]
Add two more unittests for Node add/remove

These just test that add/remove are idempotent. This is not perfect,
as we use unsorted lists for some values (instead of sets), so when
using non-empty nodes this would break (but for empty nodes, a
1-element list is sorted, so it's fine).

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

12 years agoUse the spindles metric in cluster scores
Iustin Pop [Mon, 20 Feb 2012 12:14:27 +0000 (13:14 +0100)]
Use the spindles metric in cluster scores

This makes balancing use the new metric.

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

12 years agoTrack instance-used spindles in node set/add/remove
Iustin Pop [Mon, 20 Feb 2012 11:18:15 +0000 (12:18 +0100)]
Track instance-used spindles in node set/add/remove

This simply tracks the instance-used spindles (using hard-coded '1'
per instance), and additionally prevents additions in soft-mode when
we go over the limit.

Note: there's an assymetry between addSec and removeSec (basically
secondaries should only exist with DTDrbd8, so the check for uses_disk
is superflous), will be cleaned up later.

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

12 years agoShorten some function names
Iustin Pop [Mon, 20 Feb 2012 10:43:50 +0000 (11:43 +0100)]
Shorten some function names

Since we use the functions always module-qualified, let's drop the
`instance` prefix and use a shorter one.

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

12 years agoSimplify logic in Node operations
Iustin Pop [Sun, 19 Feb 2012 20:43:40 +0000 (21:43 +0100)]
Simplify logic in Node operations

This patch adds two helper functions and uses them for a somewhat
simplified logic in the add/remove pri/sec node functions.

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

12 years agohtools: support spindles in simu backend
Iustin Pop [Thu, 16 Feb 2012 12:43:01 +0000 (13:43 +0100)]
htools: support spindles in simu backend

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

12 years agohtools: support spindles in text load/save
Iustin Pop [Thu, 16 Feb 2012 12:34:02 +0000 (13:34 +0100)]
htools: support spindles in text load/save

If missing, we'll default to 1 spindle.

This also updates the text file format with the ipolicy, which was
forgotten.

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

12 years agohtools: add support for listing spindles for nodes
Iustin Pop [Thu, 16 Feb 2012 11:57:51 +0000 (12:57 +0100)]
htools: add support for listing spindles for nodes

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

12 years agohtools: add spindle-related attribute to nodes
Iustin Pop [Thu, 16 Feb 2012 11:52:54 +0000 (12:52 +0100)]
htools: add spindle-related attribute to nodes

This adds the spindleCount, hiSpindles and instSpindles attributes.

The spindleCount is equivalent to spindle_count on the ganeti side (a
node parameter). hiSpindles is the maximum instance-used spindles, and
instSpindles will be used to track spindles as used by instances (in
later patches).

The patch also reads spindleCount from the live backends. The text and
simu backends currently set it to 1, hard-coded.

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

12 years agoAdd spindle ratio to htool's IPolicy
Iustin Pop [Fri, 27 Jan 2012 16:21:24 +0000 (17:21 +0100)]
Add spindle ratio to htool's IPolicy

Just the usual data/type declarations, read/save in the text backend,
etc. Also does a bit of unit-test cleanup (the way we build
ipolicies).

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

12 years agohinfo: Adding man page
René Nussbaumer [Wed, 29 Feb 2012 09:59:22 +0000 (10:59 +0100)]
hinfo: Adding man page

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

12 years agohinfo: Reorganize the code to separate functions
René Nussbaumer [Tue, 28 Feb 2012 14:39:24 +0000 (15:39 +0100)]
hinfo: Reorganize the code to separate functions

Also rename some functions as they don't reflect their actions anymore

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

12 years agoTwo tiny fixed related to runtime functionality
Iustin Pop [Tue, 28 Feb 2012 12:50:14 +0000 (13:50 +0100)]
Two tiny fixed related to runtime functionality

Adds an assert and fixes a typo.

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

12 years agohinfo: Adding basic skeleton based on hbal
René Nussbaumer [Mon, 27 Feb 2012 09:33:08 +0000 (10:33 +0100)]
hinfo: Adding basic skeleton based on hbal

It prints the information which hbal prints in a nice formatted manner and of
course without doing any actions. An example output looks like this:

$ hinfo -m xen.example.com
Loaded 4 nodes, 2 instances
Cluster has 1 node group(s)
Cluster coefficients:
   Field                Value Weight
   free_mem_cv     0.00195342  x1.00
   free_disk_cv    0.00000000  x1.00
   n1_cnt          0.00000000  x1.00
   reserved_mem_cv 0.00195342  x1.00
   offline_all_cnt 0.00000000  x4.00
   offline_pri_cnt 0.00000000 x16.00
   vcpu_ratio_cv   0.12500000  x1.00
   cpu_load_cv     0.50000000  x1.00
   mem_load_cv     0.50000000  x1.00
   disk_load_cv    0.00000000  x1.00
   net_load_cv     0.50000000  x1.00
   pri_tags_score  0.00000000  x2.00
Cluster score: 1.62890685

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

12 years agoAdd automated checking for non-escaped --
Iustin Pop [Mon, 27 Feb 2012 14:51:15 +0000 (15:51 +0100)]
Add automated checking for non-escaped --

This checks to see if any man output has [em] in it, as that will not
be correctly show in ASCII. Unfortunately the check will depend on
whether the other man check is done, but I didn't want to introduce
yet another short script for this (can be done, no issue).

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

12 years agoFix man pages to not use unescaped --
Iustin Pop [Mon, 27 Feb 2012 14:48:05 +0000 (15:48 +0100)]
Fix man pages to not use unescaped --

I've seen that man pages, as generated by the version of pandoc we
use, show single dashes in option names instead of double ones (-
versus --). After bringing it up with upstream
(http://groups.google.com/group/pandoc-discuss/browse_thread/thread/9c4589a4001d42f9/95ee8dae8932dc93),
it seems that this is a known behaviour of pandoc that has been
improved in newer versions.

Until then, let's use correctly double dashes; from the two options in
the above thread, I chose to use \-- as that doesn't change the actual
output; whereas ``--nodes`` make this a code block, which will look
differently from a short option and could change how the output looks
(e.g. when in a bold span).

Additionally, I've removed two cases where unescape em was explicitly
intended, as that makes automated checking harder and we can use other
formatting.

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

12 years agoAdd job result descriptions to RAPI documentation
Michael Hanselmann [Fri, 24 Feb 2012 11:22:02 +0000 (12:22 +0100)]
Add job result descriptions to RAPI documentation

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

12 years agoRemove a superfluous warning in LUNodeRemove
Iustin Pop [Mon, 27 Feb 2012 13:40:44 +0000 (14:40 +0100)]
Remove a superfluous warning in LUNodeRemove

Since we run the post-hooks explicitly in the Exec() function (via
_RunPostHook) after we removed the target node from the config, we
will get a:

  WARNING Node 'node2', which is about to be removed, was not found in
  the list of all nodes

in the logs every time we remove a node. The patch just removes the
warning, as actually invalid configurations (for the pre hook) will be
checked correctly elsewhere.

Additionally, the docstrings for BuildHooksEnv and BuildHooksNodes are
corrected/switched.

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

12 years agoopcodes: Remove dependency on query module
Michael Hanselmann [Thu, 23 Feb 2012 15:43:35 +0000 (16:43 +0100)]
opcodes: Remove dependency on query module

There's no need to verify the field definitions on every query. They are
static for all intents and purposes anyway and verified at module load
time.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoMerge branch 'stable-2.5' into devel-2.5
Michael Hanselmann [Thu, 23 Feb 2012 15:48:18 +0000 (16:48 +0100)]
Merge branch 'stable-2.5' into devel-2.5

* stable-2.5:
  Fix Makefile.am compatibility with automake 1.11.2

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

12 years agohttp.server: Factorize request handling even more
Michael Hanselmann [Tue, 21 Feb 2012 19:14:46 +0000 (20:14 +0100)]
http.server: Factorize request handling even more

This splits even more parts of the request handling code into a separate
class. Doing so allows us to reuse this part of the code for tests (e.g.
mocks). Unlike before now the error handling can also be reused.

The patch became a bit more convoluted than intended, but the end result
is easier to read than the original code.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohttp.server: Move error message formatting to handler class
Michael Hanselmann [Tue, 21 Feb 2012 17:23:37 +0000 (18:23 +0100)]
http.server: Move error message formatting to handler class

Like before this patch moves more functionality from the actual server
class into a separate handler class. At the same time the function is
changed to return both content-type and body instead of relying on a
class attribute.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

12 years agonoded: Shorter docstring for mlockall(2) executor
Michael Hanselmann [Tue, 21 Feb 2012 16:40:20 +0000 (17:40 +0100)]
noded: Shorter docstring for mlockall(2) executor

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoSplit handling HTTP requests into separate class
Michael Hanselmann [Tue, 21 Feb 2012 16:39:46 +0000 (17:39 +0100)]
Split handling HTTP requests into separate class

Until now HTTP requests were handled in the same class as incoming
connections (http.server.HttpServer). With this change the request
handling is delegated to a separate class which can be re-used in tests
without creating a socket, etc.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohttp.server: Factorize request handling
Michael Hanselmann [Tue, 21 Feb 2012 16:13:50 +0000 (17:13 +0100)]
http.server: Factorize request handling

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoRemove deprecated “QueryLocks” LUXI request
Michael Hanselmann [Wed, 22 Feb 2012 11:58:05 +0000 (12:58 +0100)]
Remove deprecated “QueryLocks” LUXI request

This has been deprecated since Ganeti 2.4 and hasn't been used by
Ganeti's code since. I'm not aware of any external users.

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

12 years agoAdd result checks for OpTags*
Michael Hanselmann [Tue, 21 Feb 2012 15:19:48 +0000 (16:19 +0100)]
Add result checks for OpTags*

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoopcodes: Annotate the OP_RESULT of query operations
René Nussbaumer [Tue, 21 Feb 2012 09:05:29 +0000 (10:05 +0100)]
opcodes: Annotate the OP_RESULT of query operations

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

12 years agoReplace single- with double-quotes
Michael Hanselmann [Tue, 21 Feb 2012 13:37:58 +0000 (14:37 +0100)]
Replace single- with double-quotes

In at least two cases "%s" is replaced with str(), too.

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

12 years agoFix asyncnotifier unit tests
Iustin Pop [Tue, 21 Feb 2012 08:36:04 +0000 (09:36 +0100)]
Fix asyncnotifier unit tests

On my workstation, if I run the following two tests in this exact
order:

- TestSingleFileEventHandler.testError
- TestSingleFileEventHandler.testReplace

the second test will fail, because there is no "unregister" of
previous tests (and the poll() done by asyncore will fire on the
previous files which are now removed, etc. etc.).

While investigating this, I realised that we don't do any cleanup of
the various handlers/notifiers we setup for this test, so if we simply
add a proper cleanup, the tests will work nicely (in any order :).

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

12 years agoSmall fixup to rapi docstrings
Iustin Pop [Tue, 21 Feb 2012 07:42:09 +0000 (08:42 +0100)]
Small fixup to rapi docstrings

The fast that most classes don't override the @cvars means that direct
references to FillOpcode can fail (they do on my workstation, but not
on buildbot?). Anyway, for safety, it's best to qualify the name.

Additionally a small typo is fixed.

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

12 years agoSmall update to LogicalUnit.ExpandNames docstring
Iustin Pop [Mon, 20 Feb 2012 14:40:46 +0000 (15:40 +0100)]
Small update to LogicalUnit.ExpandNames docstring

… to make even more obvious what's the difference between a declared
lock level with an empty list of locks and no lock level.

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

12 years agoExport ndparams in RAPI node query
Iustin Pop [Thu, 16 Feb 2012 09:56:40 +0000 (10:56 +0100)]
Export ndparams in RAPI node query

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

12 years agoAdd ndp/* fields to group/node query
Iustin Pop [Fri, 3 Feb 2012 15:55:01 +0000 (16:55 +0100)]
Add ndp/* fields to group/node query

Also change the meaning of group ndparams to mean the actual (not
custom) nd params, and add custom_ndparams for the current meaning of
ndparams.

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

12 years agoExport ndparams in iallocator
Iustin Pop [Fri, 27 Jan 2012 13:45:10 +0000 (14:45 +0100)]
Export ndparams in iallocator

Strangely, these were not exported at all before.

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

12 years agoAdd ipolicy parameter spindle_ratio
Iustin Pop [Fri, 27 Jan 2012 13:38:31 +0000 (14:38 +0100)]
Add ipolicy parameter spindle_ratio

This will represent the instance (count) per spindle_count of their
node(s). Debatable whether we need to add a per-instance
spindle_weight.

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

12 years agoAdd new spindle_count node parameter
Iustin Pop [Fri, 27 Jan 2012 13:29:31 +0000 (14:29 +0100)]
Add new spindle_count node parameter

Currently this is not handled by Ganeti, just recorded.

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

12 years agoFix upgrading of ndparams
Iustin Pop [Fri, 27 Jan 2012 13:26:35 +0000 (14:26 +0100)]
Fix upgrading of ndparams

Currently, we only upgrade the ndparams if they are missing
completely, which creates problems if we add any new parameters on an
already-upgraded cluster.

Fix this by adding an UpgradeNDParams function.

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

12 years agoSmall fixes to objects.UpgradeDiskParams
Iustin Pop [Fri, 27 Jan 2012 13:25:03 +0000 (14:25 +0100)]
Small fixes to objects.UpgradeDiskParams

Fix a typo, and cleanup the code a bit.

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

12 years agoopcodes: Add result checks for OpBackup*
Michael Hanselmann [Mon, 20 Feb 2012 16:21:51 +0000 (17:21 +0100)]
opcodes: Add result checks for OpBackup*

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

12 years agoImprove opcode result check test to have a whitelist
Michael Hanselmann [Mon, 20 Feb 2012 12:29:38 +0000 (13:29 +0100)]
Improve opcode result check test to have a whitelist

Only whitelisted opcodes may not have a result check.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoconfig: Add check for disk's “iv_name”
Michael Hanselmann [Fri, 17 Feb 2012 16:49:35 +0000 (17:49 +0100)]
config: Add check for disk's “iv_name”

This check verifies “iv_name” of all instance disks. If one is wrong
(which shouldn't happen in the first place), cluster verification will
warn:

“ERROR: cluster: Instance 'inst.example.com' has wrongly named disks:
name of disk 1 should be 'disk/1', but is 'disk/4'”

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

12 years agoopcodes: Fix OP_RESULT for OobCommand
René Nussbaumer [Mon, 20 Feb 2012 10:35:11 +0000 (11:35 +0100)]
opcodes: Fix OP_RESULT for OobCommand

The result is a list of a list with elements with size of 2.

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

12 years agoFix Makefile.am compatibility with automake 1.11.2
Iustin Pop [Sun, 19 Feb 2012 19:58:42 +0000 (20:58 +0100)]
Fix Makefile.am compatibility with automake 1.11.2

Automake 1.11.2 made the following change:

* Long-standing bugs:
  - Automake now warns about more primary/directory invalid combinations,
    such as "doc_LIBRARIES" or "pkglib_PROGRAMS".

Unfortunately, this breaks our Makefile.am (issue 216) exactly because
we were relying on pkglib_SCRIPTS.

This patch works around this by adding a new myexeclibdir variable
(exec so that it is intalled at `install-exec` time, the same as the
pkglibdir), and switches to that.

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

12 years agocli: Handle negative numbers when parsing key-value assignments
Michael Hanselmann [Fri, 17 Feb 2012 10:49:00 +0000 (11:49 +0100)]
cli: Handle negative numbers when parsing key-value assignments

To remove the last disk, or to add a NIC to the end, one can use the
index -1. This wouldn't work as intended as “-” is a special prefix.

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

12 years agoutils.text: Add function to truncate string
Michael Hanselmann [Fri, 17 Feb 2012 12:42:04 +0000 (13:42 +0100)]
utils.text: Add function to truncate string

The function adds an ellipse if the string was actually truncated. Also
start using it in mcpu for result checks (where the message is also
slightly changed to use a colon).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoFix breakage introduced by fa6dd6bb56
Michael Hanselmann [Fri, 17 Feb 2012 12:46:55 +0000 (13:46 +0100)]
Fix breakage introduced by fa6dd6bb56

Forgot “enumerate”.

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

12 years agoLUInstanceSetParams: Update disk's “iv_name”
Michael Hanselmann [Wed, 15 Feb 2012 16:52:47 +0000 (17:52 +0100)]
LUInstanceSetParams: Update disk's “iv_name”

When modifications are made, disks may not have the same index anymore.
Updating all disks fixes this.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoApplyContainerMods: Fix issues with indices
Michael Hanselmann [Wed, 15 Feb 2012 17:50:08 +0000 (18:50 +0100)]
ApplyContainerMods: Fix issues with indices

When adding an item the index given to the callback function would be
incorrect under certain conditions. This patch also adds assertions and
more tests.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agocmdlib: Remove some users of “iv_name”
Michael Hanselmann [Wed, 15 Feb 2012 16:36:36 +0000 (17:36 +0100)]
cmdlib: Remove some users of “iv_name”

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoConfigWriter: Stop using “iv_name”
Michael Hanselmann [Wed, 15 Feb 2012 16:09:20 +0000 (17:09 +0100)]
ConfigWriter: Stop using “iv_name”

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoConfigWriter.RenameInstance: Stop using iv_name, safer operation
Michael Hanselmann [Wed, 15 Feb 2012 16:06:29 +0000 (17:06 +0100)]
ConfigWriter.RenameInstance: Stop using iv_name, safer operation

Stop using the disk index encoded in “iv_name” when renaming an instance.

This patch also changes the code to operate on a copy of the instance
until the major changes have been applied. In the case of a failure we
won't loose the instance object anymore.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agognt-instance modify: Support new-style NIC/disk modifications
Michael Hanselmann [Tue, 14 Feb 2012 12:41:57 +0000 (13:41 +0100)]
gnt-instance modify: Support new-style NIC/disk modifications

This patch adds support for adding/removing NICs/disks at arbitrary
indices on the command line. To add a disk at a specified index, use
“--disk 3:size=16G”. To remove the second disk, use “--disk 2:remove”.
Unittests are included.

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

12 years agoopcodes: Adding missing OP_RESULTs
René Nussbaumer [Fri, 10 Feb 2012 14:51:53 +0000 (15:51 +0100)]
opcodes: Adding missing OP_RESULTs

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

12 years agomcpu: Make the op result exception more verbose
René Nussbaumer [Mon, 13 Feb 2012 09:14:49 +0000 (10:14 +0100)]
mcpu: Make the op result exception more verbose

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

12 years agoReconcile Makefile.am and test data files
Iustin Pop [Wed, 15 Feb 2012 16:02:33 +0000 (17:02 +0100)]
Reconcile Makefile.am and test data files

Sorry, forgot this in previous commit.

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

12 years agoWorkaround changed LVM behaviour
Iustin Pop [Wed, 15 Feb 2012 12:14:04 +0000 (13:14 +0100)]
Workaround changed LVM behaviour

The vgreduce command has changed behaviour from when we initially
wrote the code (2.02.02 versus 2.02.66, 4 years delta):

- if there are LVs which will be impacted, it requires --force
- otherwise refuses to proceed, but it still returns exit code 0

We handle this by looking to see if it returns "Wrote out consistent
volume group" (behaviour unchanged), or if it complains about
"--force"; in the case it didn't complete, we retry the operation.

We improve a bit the checking of "vgs", as it uses to fail silently
and we didn't detect it.

New tests for this function should test, I believe, all the expected
variations; at the least we now have data files with the expected
output.

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

12 years agocmdlib: De-duplicate code in _GenerateDiskTemplate
Michael Hanselmann [Wed, 15 Feb 2012 13:23:49 +0000 (14:23 +0100)]
cmdlib: De-duplicate code in _GenerateDiskTemplate

There has been a lot of duplicated code in _GenerateDiskTemplate,
and some cases of very similar, but not quite same duplicates. This
patch merges them.

Generating a disk's “logical_id” attribute is done via a
lambda/function. Maybe the ID's could be pre-computed and stored in a
list.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAdd unittest for cmdlib._GenerateDiskTemplate
Michael Hanselmann [Tue, 14 Feb 2012 13:53:28 +0000 (14:53 +0100)]
Add unittest for cmdlib._GenerateDiskTemplate

This is in preparation to de-duplicating significant chunks of code in
cmdlib._GenerateDiskTemplate.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agorapi.testutils: Add exported functions to verify opcode input/result
Michael Hanselmann [Tue, 14 Feb 2012 16:11:41 +0000 (17:11 +0100)]
rapi.testutils: Add exported functions to verify opcode input/result

These can be used by third-party code to verify mock code. Further work
on mocks is forthcoming, so this is only a start.

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

12 years agocmdlib: Fix “unpack non-sequence” error
Michael Hanselmann [Tue, 14 Feb 2012 11:47:47 +0000 (12:47 +0100)]
cmdlib: Fix “unpack non-sequence” error

The callback is expected to return a two-valued tuple.

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

12 years agoFix doc bug introduced in 12637df
Iustin Pop [Fri, 3 Feb 2012 16:22:05 +0000 (17:22 +0100)]
Fix doc bug introduced in 12637df

Commit 12637df changed/generalised how we build fields in the sphinx
extension, however it resulted in this uncaught-so-far result:

$ echo @QUERY_FIELDS_GROUP@ | ./autotools/docpp
<generator object BuildValuesDoc at 0x28fd370>

There's no point in yield-ing a single value (as opposed to a stream
of values), so let's just "return" it.

By the way, there's no test for this kind of error, but I don't think
it would happen too often, so I didn't add one (e.g. grep "<.* at
0x[0-9a-f]+>" man/*.[178]).

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

12 years agohtools: allow rbd disk template
Guido Trotter [Mon, 13 Feb 2012 16:56:39 +0000 (16:56 +0000)]
htools: allow rbd disk template

Notes:
  - it'd be nice if there was a way to automatically generate the
    DiskTemplate list instead of manually specifying it. After all we
    have C.diskTemplates
  - Of course this actually does nothing, as for other
    "half-implemented" templates :(

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

12 years agoApplyContainerMods: Return changes from callbacks
Michael Hanselmann [Mon, 13 Feb 2012 16:47:08 +0000 (17:47 +0100)]
ApplyContainerMods: Return changes from callbacks

… instead of passing the list of changes as a parameter.

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

12 years agoUse the ipolicy constants for key names
Iustin Pop [Fri, 27 Jan 2012 15:59:04 +0000 (16:59 +0100)]
Use the ipolicy constants for key names

Sorry, I missed this when I wrote the code originally.

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

12 years agoLUInstanceSetParams: Convert to generic algorithm for NIC/disk changes
Michael Hanselmann [Fri, 10 Feb 2012 16:59:55 +0000 (17:59 +0100)]
LUInstanceSetParams: Convert to generic algorithm for NIC/disk changes

Unfortunately this got a bit messier than I intended, but then again it
cleans up a lot of messy code with heaps of local variables
(“this_nic_override”) and LU attributes (“nic_pnew”, “nic_pinst”). Most
of these variables were index by a number, or one of the
constants.DDM_* constants.

This patch moves the code for adding/modifying/removing a NIC/disk to
dedicated, small functions. The previously added generic algorithm for
applying changes to containers is then used to actually change the
instance's network interfaces or disks based on the requested
modifications. The LU now supports adding/removing disks/NICs in
arbitrary positions.

The compuation of all network interface changes has been moved to
CheckPrereq, so that its result can be used for hooks. For this to work
without side-effects, the NIC objects need to be copied (only done if
there are actual changes).

The command line utility still needs to be updated.

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

12 years agocmdlib: Add generic algorithm for modifying NICs/disks
Michael Hanselmann [Fri, 10 Feb 2012 16:57:23 +0000 (17:57 +0100)]
cmdlib: Add generic algorithm for modifying NICs/disks

While preparing this patch series I identified at least three different
implementations of the algorithm for adding/removing/changing
NICs/disks. These two functions and corresponding unittests provide a
generic implementation with added support for adding/removing arbitrary
disks or NICs.

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

12 years agoFix unittest breakage after commit a2aadb34b
Michael Hanselmann [Mon, 13 Feb 2012 13:57:39 +0000 (14:57 +0100)]
Fix unittest breakage after commit a2aadb34b

Thou shalt run “make check” before sending patches.

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

12 years agoLUInstanceSetParams: Assertion on disk template/disk changes
Michael Hanselmann [Fri, 10 Feb 2012 16:59:40 +0000 (17:59 +0100)]
LUInstanceSetParams: Assertion on disk template/disk changes

Disk changes aren't allowed at the same time as a disk template change.

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

12 years agoOpInstanceSetParams: Make two type checks public
Michael Hanselmann [Fri, 10 Feb 2012 17:04:38 +0000 (18:04 +0100)]
OpInstanceSetParams: Make two type checks public

They'll be used for tests in cmdlib.py.

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

12 years agoOpInstanceSetParams: Accept more flexible NIC/disk modifications
Michael Hanselmann [Fri, 10 Feb 2012 16:55:39 +0000 (17:55 +0100)]
OpInstanceSetParams: Accept more flexible NIC/disk modifications

Start accepting a new form of NIC/disk modifications for adding/removing
arbitrary NICs/disks. Unlike before the index must always be given. An
index of “-1” stands for the last item.

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

12 years agoconstants: Add constant for modifying existing NIC/disk
Michael Hanselmann [Fri, 10 Feb 2012 16:56:26 +0000 (17:56 +0100)]
constants: Add constant for modifying existing NIC/disk

Until now it would not be possible to add/remove a NIC/disk in an
arbitrary position. This constant will be used in the data structures
necessary to add/remove arbitrary NICs/disks.

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

12 years agoopcodes: Add comments to two parameter tests
Michael Hanselmann [Fri, 10 Feb 2012 16:54:51 +0000 (17:54 +0100)]
opcodes: Add comments to two parameter tests

These comments appear in the RAPI documentation.

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

12 years agorbd disk template documentation and manpages
Stratos Psomadakis [Fri, 10 Feb 2012 10:29:13 +0000 (12:29 +0200)]
rbd disk template documentation and manpages

Add documentation and modify manpages for the RBD disk template.

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

12 years agoAccept both PUT and POST in noded
Iustin Pop [Fri, 21 Oct 2011 21:51:39 +0000 (23:51 +0200)]
Accept both PUT and POST in noded

This is a partial cherry-pick from
7530364ddbe949bc34fc26f25ba3f5d921beb021 on master:

Currently, noded requires PUT, even though the semantics of the RPC
calls do not match a PUT. We change the code accept both PUT and POST,
with the intention to remove the PUT support in a later version.

Additionally, we add a message to the HttpBadRequest exception to make
clear the failure mode (not seeing any error message was what made me
send this patch…). This was the only description-less use of this
exception, by the way.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>
(cherry picked from commit 7530364ddbe949bc34fc26f25ba3f5d921beb021)

What was not cherry-picked is the rpc change (to switch to PUT). The
reason I want to backport this to devel-2.5 is that when upgrading to
2.6, having noded accept both makes for an easier upgrade path.

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

12 years agoMerge branch 'stable-2.5' into devel-2.5
Michael Hanselmann [Wed, 1 Feb 2012 06:26:47 +0000 (07:26 +0100)]
Merge branch 'stable-2.5' into devel-2.5

* stable-2.5:
  Fix type check for OpQuery.filter
  Fix explanation of gnt-node evacuate --primaries-only
  Makefile.am: fix permissions for Python scripts on install
  devel/upload: Fix permissions for installed directories
  Fix cluster verification issues on multi-group clusters

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoRe-added constant mistakenly removed in 58f0ce16873
Michael Hanselmann [Wed, 1 Feb 2012 07:41:22 +0000 (08:41 +0100)]
Re-added constant mistakenly removed in 58f0ce16873

“INSTANCE_DOWN” is still being used.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>