ganeti-local
14 years agoIntroduce utils.IsValidIP{4,6}()
Manuel Franceschini [Thu, 24 Jun 2010 09:49:54 +0000 (11:49 +0200)]
Introduce utils.IsValidIP{4,6}()

This patch introduces functions to check for valid IPv4 and IPv6
addresses and converts IsValidIP() to return True if it is either a IPv4
or a IPv6 address.

For now we do not change the functional behavior and replace IsValidIP
with IsValidIP4. This might change in the future.

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

14 years agoUser assertFalse instead of assert_(not ...)
Manuel Franceschini [Tue, 29 Jun 2010 07:43:06 +0000 (09:43 +0200)]
User assertFalse instead of assert_(not ...)

Signed-off-by: Manuel Franceschini <livewire@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

14 years agoFix osparams bug when gnt-cluster modify'ing
Manuel Franceschini [Wed, 30 Jun 2010 10:51:30 +0000 (12:51 +0200)]
Fix osparams bug when gnt-cluster modify'ing

Commit 625ac1135834c27a2e78fd61bf2df2ce29ad2966 introduced 'osparams'
slot in OPSetClusterParams which was not passed when invoked via
gnt-cluster modify.

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

14 years agoIntroduce IPv6 constants
Manuel Franceschini [Tue, 29 Jun 2010 08:26:06 +0000 (10:26 +0200)]
Introduce IPv6 constants

Signed-off-by: Manuel Franceschini <livewire@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

14 years agoReplace '0.0.0.0' with constant
Manuel Franceschini [Mon, 28 Jun 2010 16:58:16 +0000 (18:58 +0200)]
Replace '0.0.0.0' with constant

Signed-off-by: Manuel Franceschini <livewire@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

14 years agoRename some constants to facilitate IPv6 support
Manuel Franceschini [Thu, 24 Jun 2010 09:01:38 +0000 (11:01 +0200)]
Rename some constants to facilitate IPv6 support

Signed-off-by: Manuel Franceschini <livewire@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

14 years agoAdd missing pylint disable for "except:"
Guido Trotter [Wed, 30 Jun 2010 08:40:39 +0000 (09:40 +0100)]
Add missing pylint disable for "except:"

Why it's needed here but not a few lines above is a mistery that only
pylint understands.

Also fix an indentation error in another disable, for the same function.

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

14 years agoAdding design-doc for privilege separation work done on Ganeti 2.2
René Nussbaumer [Tue, 29 Jun 2010 12:56:08 +0000 (14:56 +0200)]
Adding design-doc for privilege separation work done on Ganeti 2.2

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

14 years agomasterd: use AsyncTerminatedMessageStream for luxi
Guido Trotter [Tue, 18 May 2010 11:13:34 +0000 (12:13 +0100)]
masterd: use AsyncTerminatedMessageStream for luxi

Each luxi connection now creates an asyncore MasterClientHandler (which
is an AsyncTerminatedMessageStream subclass, sending each message to a
client worker). This makes it harder to DOS the master daemon by just
creating luxi connections, as each of them will use memory and file
descriptors, but not a dedicated thread.

Each connection will only handle one message at a time.

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

14 years agoFix a few uncommon pylint errors in compat.py
Guido Trotter [Tue, 29 Jun 2010 12:07:21 +0000 (13:07 +0100)]
Fix a few uncommon pylint errors in compat.py

- It's ok if the optional modules functools, roman and hashlib are not there.
- It's ok to reference any and all before defining them. We're doing all
  this exactly because, under python 2.4, they are undefined.

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

14 years agoAsyncTerminatedMessageStream: limit message count
Guido Trotter [Fri, 25 Jun 2010 15:44:35 +0000 (17:44 +0200)]
AsyncTerminatedMessageStream: limit message count

Currently the message stream can process any number of messages in
parallel (if they get dispatched to different threads or processes).
In order to limit their number we only handle messages and read from
the socket if we're under a certain limit of unanswered ones.

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

14 years agoAsyncTerminatedMessageStream: send_message
Guido Trotter [Fri, 25 Jun 2010 15:43:21 +0000 (17:43 +0200)]
AsyncTerminatedMessageStream: send_message

This function adds the ability for a AsyncTerminatedMessageStream to
have a thread-safe message delivery function.

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

14 years agoAdd test script for cfgupgrade
Michael Hanselmann [Mon, 28 Jun 2010 13:47:12 +0000 (15:47 +0200)]
Add test script for cfgupgrade

This should catch cases where we update the configuration version, but
forget to adjust cfgupgrade accordingly.

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

14 years agocfgupgrade: Add option to override config verification
Michael Hanselmann [Mon, 28 Jun 2010 13:49:46 +0000 (15:49 +0200)]
cfgupgrade: Add option to override config verification

This is needed in a new test script for cfgupgrade where it's better
to only use the minimum parts necessary for testing cfgupgrade.
Including full configuration data to ensure verification doesn't fail
would make maintenance difficult.

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

14 years agocfgupgrade: Fix bug when checking configuration directory
Michael Hanselmann [Mon, 28 Jun 2010 13:50:24 +0000 (15:50 +0200)]
cfgupgrade: Fix bug when checking configuration directory

In the condition for checking the configuration directory, one “or” should have
been an “and”. This bug was in cfgupgrade since commit 95e4a8142 (June 2008).
Found thanks to a test script.

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

14 years agocfgupgrade: Add support for Ganeti 2.2
Michael Hanselmann [Mon, 28 Jun 2010 12:34:04 +0000 (14:34 +0200)]
cfgupgrade: Add support for Ganeti 2.2

Since configuration changes are now usually done in the configuration
writer class, cfgupgrade's only task is to change the config version.
This means we can easily support upgrading from Ganeti 2.0 and 2.1 to
2.2.

This patch also brings a couple of small cleanups.

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

14 years agoRemove dead code from cfgupgrade
Michael Hanselmann [Mon, 28 Jun 2010 12:09:48 +0000 (14:09 +0200)]
Remove dead code from cfgupgrade

Three constants were no longer user after commit 11c31f5cb5, which
removed support for upgrading from Ganeti 1.2.

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

14 years agoBetter specify old object slots removal policy
Guido Trotter [Mon, 28 Jun 2010 15:39:13 +0000 (16:39 +0100)]
Better specify old object slots removal policy

The comments seem to imply we can remove deprecated slots after 2.1 is
released. This is not quite true, if we still want to support upgrading
straight from 2.0. So let's specify better that they can be removed only
after upgrading from 2.0 can be deprecated.

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

14 years agoFix a type declaration error in LUTestAllocator
Iustin Pop [Mon, 28 Jun 2010 13:14:43 +0000 (15:14 +0200)]
Fix a type declaration error in LUTestAllocator

Also, improve logging of type errors, to ease debugging.

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

14 years agoFix _UpgradeConfig docstring
Guido Trotter [Mon, 28 Jun 2010 12:48:29 +0000 (13:48 +0100)]
Fix _UpgradeConfig docstring

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

14 years agojqueue: remove the _big_jqueue_lock module global
Guido Trotter [Fri, 25 Jun 2010 16:35:01 +0000 (18:35 +0200)]
jqueue: remove the _big_jqueue_lock module global

By using ssynchronized in the new way, we can remove the module-global
_big_jqueue_lock and revert back to an internal _lock inside the jqueue.

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

14 years agossynchronized: act on a class member
Guido Trotter [Fri, 25 Jun 2010 16:09:19 +0000 (18:09 +0200)]
ssynchronized: act on a class member

The ssynchronized decorator takes the lock to act on in input.
With this change we allow a string to be passed, and if so we assume the
function it protects is a class method, and we act on the member of the
class itself named as the string we got.

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

14 years agoShare the jqueue lock on job-local changes
Guido Trotter [Tue, 15 Jun 2010 16:39:58 +0000 (17:39 +0100)]
Share the jqueue lock on job-local changes

We can share the jqueue lock when we do per-job updates. These only
conflict with updates/checks on the same job from another thread (eg.
CancelJob, ArchiveJob, which keep the lock unshared, since they are less
frequent).

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

14 years ago_OpExecCallbacks abstract _AppendFeedback
Guido Trotter [Wed, 9 Jun 2010 16:24:15 +0000 (17:24 +0100)]
_OpExecCallbacks abstract _AppendFeedback

Move some code to a decorated function rather than explicitely
acquiring/releasing the lock in AppendFeedback.

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

14 years agoRemove utils.LockedMethod
Guido Trotter [Thu, 17 Jun 2010 10:49:25 +0000 (11:49 +0100)]
Remove utils.LockedMethod

All users of this function were converted to another method, hence we
can remove it.

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

14 years agojqueue: convert to a SharedLock()
Guido Trotter [Fri, 4 Jun 2010 16:33:42 +0000 (17:33 +0100)]
jqueue: convert to a SharedLock()

Remove the jqueue _lock member and convert to a _big_jqueue_lock
sharedlock. This allows smooth transition from the old single lock to a
more granular approach.

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

14 years agoMarkUnfinishedOps: update job file on disk
Guido Trotter [Thu, 24 Jun 2010 14:41:58 +0000 (16:41 +0200)]
MarkUnfinishedOps: update job file on disk

Every time we call MarkUnfinishedOps we do it in a try/finally block
that updates the job file. With this patch we move the try/finally
inside. CancelJobUnlocked is removed, because it just becomes a wrapper
over MarkUnfinishedOps with two constant values.

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

14 years agoRemove spurious empty line
Guido Trotter [Thu, 24 Jun 2010 15:51:54 +0000 (17:51 +0200)]
Remove spurious empty line

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

14 years agoRemove pred from compat.any/all
Guido Trotter [Wed, 23 Jun 2010 22:17:42 +0000 (00:17 +0200)]
Remove pred from compat.any/all

This makes it compatible with the python builtin, and we can even use
the builtin when running under the right version of python. The all and
any functions are renamed to _all and _any, so that they can be tested,
and (non)existing unittests are updated (translation: there are no unit
tests, so none are updated).

This patch also moves the code deciding which partial to use next to
the definition of the _partial function, rather than after TryToRoman.

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

14 years agoTwo more fixes for OS params and opcode defaults
Iustin Pop [Mon, 28 Jun 2010 10:32:11 +0000 (12:32 +0200)]
Two more fixes for OS params and opcode defaults

If the OS is not using API v20, the parameter verification should be
entirely skipped.

The second change is a simple typo.

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

14 years agoFix breakage due to OS parameters
Iustin Pop [Fri, 25 Jun 2010 15:19:11 +0000 (17:19 +0200)]
Fix breakage due to OS parameters

I was using wrong python installation path (thanks Guido!), so I was not
actually testing the new backend.py module. Two immediate things bugs
are fixed, and after these burnin passes again…

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

14 years agoIntroduce constants.DTS_MAY_ADOPT
Apollon Oikonomopoulos [Wed, 23 Jun 2010 13:47:36 +0000 (16:47 +0300)]
Introduce constants.DTS_MAY_ADOPT

DTS_MAY_ADOPT include disk templates that may use disk adoption and will be
used in all respective checks.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

14 years agoConvert TestDelay repeat to the type system
Guido Trotter [Wed, 23 Jun 2010 17:51:37 +0000 (19:51 +0200)]
Convert TestDelay repeat to the type system

Turns out with the current implementation of the type system a variable
can both be required and not required. Interesting (but perhaps worth a
further look).

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

14 years agoRename some constants and relax pylint rules
Iustin Pop [Wed, 23 Jun 2010 15:41:53 +0000 (17:41 +0200)]
Rename some constants and relax pylint rules

For the type system, we want a slightly relaxed rule for constant
naming, so we update the pylint rule. But the old _TPInt and _TNEString
were not clear enough, so we expand them.

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

14 years agoFix burnin's export test
Iustin Pop [Sun, 20 Jun 2010 06:37:21 +0000 (08:37 +0200)]
Fix burnin's export test

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

14 years agoIntroduce a micro type system for opcodes
Iustin Pop [Fri, 18 Jun 2010 15:45:15 +0000 (17:45 +0200)]
Introduce a micro type system for opcodes

Currently, we have one structual validation for opcode attributes: the
_OP_REQP, which checks that a given attribute is not 'None', and the
rest of the checks are done at runtime. This means our type system has
two types: None versus Not-None.

We have been hit many times by small, trivial bugs in this area, and
only a huge amount of unittest and/or hand-written checks would ensure
that we cover all possibilities. This patch attempts to redress the
needs for manual checks by introducing a micro-type system for the
validation of the opcode attributes. What we lose, from the start, are
the custom error messages (e.g. "Invalid reboot mode, choose one of …",
or "The disk index must be a positive integer"). What we gain is the
ability to express easily things as:

- this parameter must be None or an int
- this parameter must be a non-empty list
- this parameter must be either none or a list of dictionaries with keys
  from the list of valid hypervisors and the values dictionaries with
  keys strings and values either None or strings; furthermore, the list
  must be non-empty

These examples show that we have a composable (as opposed to just a few
static types) system, and that we can nest it a few times (just for
sanity; we could nest it up to stack depth).

We also gain lots of ))))))), which is not that nice :)

The current patch moves the existing _OP_REQP to the new framework, but
if accepted, a lot more validations should move to it. In the end, we
definitely should declare a type for all the opcode parameters
(eventually moving _OP_REQP directly to opcodes.py and validating in the
load/init case, and build __slots__ from it).

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

14 years agoSome more CheckPrereq/CheckArguments cleanup
Iustin Pop [Fri, 18 Jun 2010 12:40:17 +0000 (14:40 +0200)]
Some more CheckPrereq/CheckArguments cleanup

For a few LUs, a few tests in, or even the whole CheckPrereq, can be
moved to CheckArguments, as they don't touch state and only do a 'type'
validation.

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

14 years agoLU.CheckPrereq: do not require implementation
Iustin Pop [Fri, 18 Jun 2010 10:18:26 +0000 (12:18 +0200)]
LU.CheckPrereq: do not require implementation

Currently, the base class LogicalUnit's CheckPrereq will raise
NotImplementedError, which means that the child LUs have to implement
it. However, many LUs don't actually have a need for this function
(hence the many "pass" statements as the only body).

By changing the base class behaviour, we can simplify many LUs.

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

14 years agoRemove the obsolete EvacuateNode OpCode/LU
Iustin Pop [Fri, 18 Jun 2010 09:58:12 +0000 (11:58 +0200)]
Remove the obsolete EvacuateNode OpCode/LU

All code has been switched to the new-style LU… time for cleanup.

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

14 years agoRAPI: switch evacuate node to the new model
Iustin Pop [Fri, 18 Jun 2010 09:55:52 +0000 (11:55 +0200)]
RAPI: switch evacuate node to the new model

This patch removes the last use of the old-style OpEvacuateNode. It also
fixes the dry-run mode for this RAPI resource - the dry-run parameter
was not used at all before.

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

14 years agoAbstract export mode validity check
Iustin Pop [Fri, 18 Jun 2010 09:36:14 +0000 (11:36 +0200)]
Abstract export mode validity check

The export mode is checked in two places with the exact same code…

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

14 years agoCleanup LU.ExpandNames versus CheckArguments
Iustin Pop [Fri, 18 Jun 2010 09:22:30 +0000 (11:22 +0200)]
Cleanup LU.ExpandNames versus CheckArguments

When LogicalUnit.CheckArguments was introduced, not all code dealing
with static argument checking was moved to it; many of these checks were
left in ExpandNames. With time, most of them migrated, and this patch
does the final cleanups.

The patch is straightforward, with the exception of LURebootInstance,
where an old style ParameterError exception is converted to the new
OpPrereqError with ECODE_INVAL.

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

14 years agoMove opcode attribute defaults to data structures
Iustin Pop [Fri, 18 Jun 2010 06:17:00 +0000 (08:17 +0200)]
Move opcode attribute defaults to data structures

LUExportInstance had two opcode fields set to default via both
_CheckBooleanOpField and getattr(…, False).

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

14 years agoAdd OS verification support to cluster verify
Iustin Pop [Tue, 15 Jun 2010 22:40:44 +0000 (00:40 +0200)]
Add OS verification support to cluster verify

For this, we needed to extend the NodeImage class with a few extra
variables, and we do a trick in the node verification where we pick the
first node that returned valid OS data as the reference node, and then
we compare all other nodes against it.

The checks added are:

- consistency of DiagnoseOS responses
- multiple paths for an OS
- inconsistent OS between a reference node and the current node

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

14 years agoSimplify gnt-os diagnose output
Iustin Pop [Wed, 16 Jun 2010 02:56:48 +0000 (04:56 +0200)]
Simplify gnt-os diagnose output

Currently, we always list the api/variants, even if these are empty.
This patch changes so that we make clear distiction for empty values
("[no variants]" versus "[variants: ]"), and we only list variants and
parameters when the OS API indicates they should be supported.

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

14 years agoAdd a new gnt-os info command
Iustin Pop [Mon, 14 Jun 2010 17:42:15 +0000 (19:42 +0200)]
Add a new gnt-os info command

This can be used to show the actual OS parameters and supported
variants, in a global manner (rather than per-node as gnt-os diagnose).

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

14 years agoLUDiagnoseOS: add more fields, cleanup
Iustin Pop [Mon, 14 Jun 2010 23:45:20 +0000 (01:45 +0200)]
LUDiagnoseOS: add more fields, cleanup

This patch exports all the way from backend a new field ‘api_version’
which holds the list of support API versions, and exposes the (already
computed) ‘parameters’ field.

The patch also reworks (again) the field calculation in its Exec()
method. All callers of LUDiagnoseOS pass in the 'valid' and 'variants'
parameters, thus having the special casing of whether to compute or not
the validity seems overkill. We move to a model where we always compute
these across-nodes arguments, in order to simplify the code, and we also
change the parameters set to be intersection of all node's values (which
means a change in description will drop the parameter from the list of
parameters).

Additionally, we update scripts/gnt-os, which was broken for multi-dir
OSes since the introduction of variants…

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

14 years agoAdd support for OS parameters during import/export
Iustin Pop [Sun, 13 Jun 2010 06:18:52 +0000 (08:18 +0200)]
Add support for OS parameters during import/export

Nothing special here, just copy/adjust the beparams code.

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

14 years agoAdd support for modifying instance OS parameters
Iustin Pop [Sun, 13 Jun 2010 05:57:15 +0000 (07:57 +0200)]
Add support for modifying instance OS parameters

We move the instance OS rename checks earlier, as we need to run the
validation against the new OS, if it has changed.

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

14 years agoAdd support for modifying cluster OS parameters
Iustin Pop [Sun, 13 Jun 2010 00:48:34 +0000 (02:48 +0200)]
Add support for modifying cluster OS parameters

We use _GetUpdatedParams in order to support removal too, and then
validate the OS parameters if the OS exists.

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

14 years ago_GetUpdatedParams: enhance value removal options
Iustin Pop [Sun, 13 Jun 2010 22:01:53 +0000 (00:01 +0200)]
_GetUpdatedParams: enhance value removal options

This patch adds controls for whether we recognize
constants.VALUE_DEFAULT or not as a default value, and also adds
dash-prefixes as another way for parameter removal.

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

14 years agoAdd support for OS parameters during instance add
Iustin Pop [Sat, 12 Jun 2010 07:11:50 +0000 (09:11 +0200)]
Add support for OS parameters during instance add

This is not yet complete, as it lacks proper support for instance
import.

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

14 years agoShow OS parameters in cluster/instance info
Iustin Pop [Sat, 12 Jun 2010 06:49:29 +0000 (08:49 +0200)]
Show OS parameters in cluster/instance info

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

14 years agoAdd OS parameters to cluster and instance objects
Iustin Pop [Sat, 12 Jun 2010 02:17:20 +0000 (04:17 +0200)]
Add OS parameters to cluster and instance objects

The patch also modifies the instance RPC calls to fill the osparameters
correctly with the cluster defaults, and exports the OS parameters in
the instance/OS environment.

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

14 years agoIntroduce an RPC call for OS parameters validation
Iustin Pop [Sat, 12 Jun 2010 02:13:29 +0000 (04:13 +0200)]
Introduce an RPC call for OS parameters validation

While we only support the 'parameters' check today, the RPC call is
generic enough that will be able to support other checks in the future.
The backend function will both validate the parameters list (so as to
make sure we don't pass in extra parameters that the OS validation
doesn't care about) and the parameter values, via the OS verify script.

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

14 years agoAdd reading of OS parameters from disk
Iustin Pop [Sat, 12 Jun 2010 02:02:06 +0000 (04:02 +0200)]
Add reading of OS parameters from disk

The patch also modifies the internal methods in LUDiagnoseOS and gnt-os
to deal with the format change of call_os_diagnose.

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

14 years agoAdd os api v20 and related fields to the OS object
Iustin Pop [Sat, 12 Jun 2010 01:55:59 +0000 (03:55 +0200)]
Add os api v20 and related fields to the OS object

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

14 years agoSilence a pylint warning
Iustin Pop [Wed, 16 Jun 2010 02:22:51 +0000 (04:22 +0200)]
Silence a pylint warning

The OS parameters code will bump the number of lines over 10K, and thus
we need to silence this (no, we don't want any other module to become
this big…, so we use a targeted silence only).

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

14 years agoUpdate the 2.2 design doc with OS parameters
Iustin Pop [Wed, 23 Jun 2010 04:29:57 +0000 (06:29 +0200)]
Update the 2.2 design doc with OS parameters

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

14 years agoRemove job object condition
Guido Trotter [Tue, 22 Jun 2010 09:46:05 +0000 (11:46 +0200)]
Remove job object condition

We don't need it anymore, since nobody waits on it.

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

14 years agoParallelize WaitForJobChanges
Guido Trotter [Tue, 15 Jun 2010 16:39:30 +0000 (17:39 +0100)]
Parallelize WaitForJobChanges

As for QueryJobs we rely on file updates rather than condition
notification to acquire job changes. In order to do that we use the
pyinotify module to watch files. This might make the client a bit slower
(pending planned improvements, such as subscription-based
WaitForJobChanges) but detaches it from the job execution.

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

14 years agoUpdate the job file on feedback
Guido Trotter [Tue, 22 Jun 2010 09:02:10 +0000 (11:02 +0200)]
Update the job file on feedback

This is needed to convert waitforjobchanges to use inotify and the
on-disk version and decouple it from the job queue lock. No replication
to remote nodes is done, to keep the operation fast.

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

14 years agoDon't lock on QueryJobs, by using the disk version
Guido Trotter [Mon, 14 Jun 2010 10:23:52 +0000 (11:23 +0100)]
Don't lock on QueryJobs, by using the disk version

We move from querying the in-memory version to loading all jobs from the
disk. Since the jobs are written/deleted on disk in an atomic manner, we
don't need to lock at all. Also, since we're just looking at the
contents of a directory, we don't need to check that the job queue is
"open".

If some jobs are removed between when we listed them and us loading
them, we need to be able to cope: if we were asked to load those jobs
specifically, we must report the failure, but if we were just asked to
"load all" we shall just not consider them as part of the "all" set,
since they were deleted.

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

14 years agoAdd JobQueue.SafeLoadJobFromDisk
Guido Trotter [Tue, 22 Jun 2010 09:35:32 +0000 (11:35 +0200)]
Add JobQueue.SafeLoadJobFromDisk

This will be used to read a job file without having to deal with
exceptions from _LoadJobFromDisk.

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

14 years agojqueue._LoadJobFromDisk: remove safety archival
Guido Trotter [Tue, 22 Jun 2010 09:19:47 +0000 (11:19 +0200)]
jqueue._LoadJobFromDisk: remove safety archival

Currently _LoadJobFromDisk archives job files it finds corrupted. Since
we want to use it to load files without holding locks, this could cause
a conflict: we just move the feature to _LoadJobUnlocked which is always
called with the lock held.

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

14 years agoAdd repetition count to the TestDelay opcode
Guido Trotter [Wed, 23 Jun 2010 07:50:26 +0000 (09:50 +0200)]
Add repetition count to the TestDelay opcode

If the repetition count is not passed or is passed as 0 we sleep exactly
one time, otherwise we sleep "repeat" times and log in between.

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

14 years agoMerge branch 'devel-2.1'
Iustin Pop [Tue, 22 Jun 2010 13:25:55 +0000 (15:25 +0200)]
Merge branch 'devel-2.1'

* devel-2.1:
  Add "adopt" to the allowed disk parameters
  Improve pylintrc for pylint 0.21+
  Fix warnings with Python 2.6
  Fix a small bug introduced in cf26a87a
  Fix the type of 'valid' attribute in LUDiagnoseOS

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

14 years agoAdd "adopt" to the allowed disk parameters
Apollon Oikonomopoulos [Fri, 18 Jun 2010 14:52:05 +0000 (17:52 +0300)]
Add "adopt" to the allowed disk parameters

"adopt" was missing from bd061c3, thus breaking disk adoption.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

14 years agoImprove pylintrc for pylint 0.21+
Iustin Pop [Tue, 22 Jun 2010 09:48:36 +0000 (11:48 +0200)]
Improve pylintrc for pylint 0.21+

While we'll need to update the source files too, at least this change
makes pylint 0.21 not fail on the current source tree.

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

14 years agoFix warnings with Python 2.6
Iustin Pop [Tue, 22 Jun 2010 09:38:23 +0000 (11:38 +0200)]
Fix warnings with Python 2.6

'format' is a new built-in function, and 'bytes' is a new builtin type.
We rename this to make pylint happy (and remove potential bugs).

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

14 years agoFix a small bug introduced in cf26a87a
Iustin Pop [Fri, 18 Jun 2010 12:30:48 +0000 (14:30 +0200)]
Fix a small bug introduced in cf26a87a

Commit cf26a87a added a tiny typo, which would break non-FQDN arguments
to modify node storage.

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

14 years agoFix the type of 'valid' attribute in LUDiagnoseOS
Iustin Pop [Mon, 14 Jun 2010 20:09:23 +0000 (22:09 +0200)]
Fix the type of 'valid' attribute in LUDiagnoseOS

The update of the valid status in LUDiagnoseOS says:

  valid = valid and osl and osl[0][1]

However, in Python, “True and []” (which '[]' we get for an invalid OS)
will result in “[]”, and thus the valid field for an OS will be either
True or an empty list. Which is not what we want…

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

14 years agoAdd "adopt" to the allowed disk parameters
Apollon Oikonomopoulos [Fri, 18 Jun 2010 14:52:05 +0000 (17:52 +0300)]
Add "adopt" to the allowed disk parameters

"adopt" was missing from bd061c3, thus breaking disk adoption.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

14 years agoMerge branch 'stable-2.1'
Guido Trotter [Fri, 18 Jun 2010 10:41:30 +0000 (11:41 +0100)]
Merge branch 'stable-2.1'

* stable-2.1:
  Bump up version for the 2.1.4 release
  Update NEWS about the latest 2.1 change
  Fix handling of errors from socket.gethostbyname
  Update a comment in qa-sample.json
  RAPI client: Add support for Python 2.6
  Update NEWS for Ganeti 2.1.4

Conflicts:
NEWS: keep both
configure.ac: keep the 2.2 version
qa/qa-sample.json: merge nearby changes

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

14 years agoBump up version for the 2.1.4 release v2.1.4
Guido Trotter [Thu, 17 Jun 2010 15:09:26 +0000 (16:09 +0100)]
Bump up version for the 2.1.4 release

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

14 years agoUpdate NEWS about the latest 2.1 change
Guido Trotter [Thu, 17 Jun 2010 17:06:22 +0000 (18:06 +0100)]
Update NEWS about the latest 2.1 change

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

14 years agoFix handling of errors from socket.gethostbyname
Iustin Pop [Wed, 16 Jun 2010 03:16:05 +0000 (05:16 +0200)]
Fix handling of errors from socket.gethostbyname

Socket functions can raise more than just gaierror. Most of the times,
socket.gethostbyname_ex will return gaierror, but rarely it will also
raise herror. For completeness, we catch all socket exceptions with data
of type (code, description).

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

14 years agoUpdate a comment in qa-sample.json
Guido Trotter [Thu, 17 Jun 2010 16:53:56 +0000 (17:53 +0100)]
Update a comment in qa-sample.json

Fix the sentence to say what it means.

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

14 years agognt-debug: remove @todo from GenericOpCodes
Guido Trotter [Thu, 17 Jun 2010 14:46:09 +0000 (15:46 +0100)]
gnt-debug: remove @todo from GenericOpCodes

- the function is not broken, and we're using in nowadays
- we have example json files and all, which show its usage
=> the todo is incorrect

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

14 years agojqueue.AddManyJobs: use AddManyTasks
Guido Trotter [Thu, 17 Jun 2010 13:02:20 +0000 (14:02 +0100)]
jqueue.AddManyJobs: use AddManyTasks

Rather than adding the jobs to the worker pool one at a time, we add
them all together, which is slightly faster, and ensures they don't get
started while we loop.

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

14 years agoWorkerpool.AddManyTasks: check tasks type
Guido Trotter [Thu, 17 Jun 2010 13:32:55 +0000 (14:32 +0100)]
Workerpool.AddManyTasks: check tasks type

Each task has to be a sequence, or the RunTask call will fail.

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

14 years agocount the number of tasks done in the wp unittest
Guido Trotter [Thu, 17 Jun 2010 13:02:32 +0000 (14:02 +0100)]
count the number of tasks done in the wp unittest

Currently there's no way to know if something actually gets done.
After this check we actually test that the threads do their job.

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

14 years agoRAPI client: Add support for Python 2.6
Michael Hanselmann [Thu, 17 Jun 2010 14:48:43 +0000 (16:48 +0200)]
RAPI client: Add support for Python 2.6

The httplib module used by urllib2 requires its sockets to have a
makefile() method to provide a file-like interface (or rather
file-in-Python-like) to the socket. PyOpenSSL doesn't implement
makefile() as the semantics require files to call dup(2) on the
underlying file descriptors, something not easily done on SSL sockets.

Python up to and including 2.5 have a class to simulate makefile(),
httplib.FakeSocket. With the addition of SSL support in Python 2.6, this
class was deprecated and no longer functions.

This patch adds a new, simpler wrapper class which is used in Python 2.6
and above only. It's good enough for this use.

There are general problems in these generic wrapper classes--none of
them handles SSL I/O properly. They break, for example, when the server
requests a renegotiation. This will need more work.

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

14 years agoRAPI client: Add support for Python 2.6
Michael Hanselmann [Thu, 17 Jun 2010 14:48:43 +0000 (16:48 +0200)]
RAPI client: Add support for Python 2.6

The httplib module used by urllib2 requires its sockets to have a
makefile() method to provide a file-like interface (or rather
file-in-Python-like) to the socket. PyOpenSSL doesn't implement
makefile() as the semantics require files to call dup(2) on the
underlying file descriptors, something not easily done on SSL sockets.

Python up to and including 2.5 have a class to simulate makefile(),
httplib.FakeSocket. With the addition of SSL support in Python 2.6, this
class was deprecated and no longer functions.

This patch adds a new, simpler wrapper class which is used in Python 2.6
and above only. It's good enough for this use.

There are general problems in these generic wrapper classes--none of
them handles SSL I/O properly. They break, for example, when the server
requests a renegotiation. This will need more work.

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

14 years agoBump RPC protocol version to 40
Michael Hanselmann [Thu, 17 Jun 2010 12:14:19 +0000 (14:14 +0200)]
Bump RPC protocol version to 40

Many RPC calls have changed in Ganeti 2.2, hence bumping the RPC protocol
version.

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

14 years agoChange ganeti-cleaner unittest to not use random values
Michael Hanselmann [Thu, 17 Jun 2010 12:12:16 +0000 (14:12 +0200)]
Change ganeti-cleaner unittest to not use random values

Using random values in unittests isn't good. This one broke exactly
when building the 2.2.0~beta0 release. I suspect there were duplicate
job IDs generated (due to $large being not so large).

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

14 years agoUpdate NEWS for Ganeti 2.1.4
Guido Trotter [Thu, 17 Jun 2010 11:06:36 +0000 (12:06 +0100)]
Update NEWS for Ganeti 2.1.4

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

14 years agoBump version to 2.2.0~beta0 v2.2.0beta0
Michael Hanselmann [Thu, 17 Jun 2010 09:40:03 +0000 (11:40 +0200)]
Bump version to 2.2.0~beta0

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

14 years agoFix parameter names in SimpleFillBE/NIC docstrings
Guido Trotter [Thu, 17 Jun 2010 10:08:53 +0000 (11:08 +0100)]
Fix parameter names in SimpleFillBE/NIC docstrings

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

14 years agoAsyncAwaker: use shutdown on the socketpair
Guido Trotter [Thu, 17 Jun 2010 08:42:36 +0000 (09:42 +0100)]
AsyncAwaker: use shutdown on the socketpair

This makes sure the out_socket can only be used for writing, and the
in_socket for reading.

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

14 years agoWorkerPool.AddManyTasks
Guido Trotter [Thu, 17 Jun 2010 08:15:17 +0000 (09:15 +0100)]
WorkerPool.AddManyTasks

Useful if we want to add many tasks at once, without contention with the
previous one we added starting.

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

14 years agojqueue: make replication on job update optional
Guido Trotter [Thu, 17 Jun 2010 07:44:25 +0000 (08:44 +0100)]
jqueue: make replication on job update optional

Sometimes it's useful to write to the local filesystem, but immediate
replication to all master candidates is not needed.

The _WriteAndReplicateFileUnlocked function gets renamed to
_UpdateJobQueueFile, as calling "write and replicate, but don't
replicate" seemed a bit strange.

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

14 years agos/queue._GetJobInfoUnlocked/job.GetInfo/
Guido Trotter [Tue, 15 Jun 2010 11:08:41 +0000 (12:08 +0100)]
s/queue._GetJobInfoUnlocked/job.GetInfo/

The job queue currently has a static _GetJobInfoUnlocked method.
Changing it to be a normal method of _QueuedJob, which makes more sense.

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

14 years agoAbstract loading job file from disk
Guido Trotter [Tue, 15 Jun 2010 10:17:24 +0000 (11:17 +0100)]
Abstract loading job file from disk

Move the work from _LoadJobUnlocked to _LoadJobFileFromDisk, which can
then be used in other contexts as well. Also, if we fail to deserialize
the job, archive it as well (before we archived it only if we failed to
create the related object, but kept it there if deserialization failed.

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

14 years agoMakefile: Add support for local Makefile additions
Michael Hanselmann [Thu, 17 Jun 2010 09:25:56 +0000 (11:25 +0200)]
Makefile: Add support for local Makefile additions

With the recent addition of a check for directories listed in Makefile
local custom directories are always reported as unlisted. This patch
adds support for a “Makefile.local” file, which can adjust settings in
Makefile. Example: “DIRCHECK_EXCLUDE += xyz .mydata doc/manhtml”.

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

14 years agoListVisibleFiles: do not sort output
Guido Trotter [Fri, 11 Jun 2010 20:23:33 +0000 (21:23 +0100)]
ListVisibleFiles: do not sort output

Among all users, turns out just one *may* need the output to be sorted.
All the others can cope without.

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

14 years agojqueue: simplify removal from _nodes
Guido Trotter [Mon, 14 Jun 2010 12:17:33 +0000 (13:17 +0100)]
jqueue: simplify removal from _nodes

Somewhere we do try/del/except and somewhere just pop. Using pop
everywhere saves lines of code.

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

14 years agoImprove gnt-debug man page
Manuel Franceschini [Mon, 14 Jun 2010 11:59:15 +0000 (13:59 +0200)]
Improve gnt-debug man page

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

14 years agoRemove a TODO
Iustin Pop [Sun, 13 Jun 2010 06:05:24 +0000 (08:05 +0200)]
Remove a TODO

Since OS objects are not stored in the configuration, we cannot put
os_hvp there, therefore the TODO is obsolete…

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

14 years agoRework LUSetInstanceParams._GetUpdatedParams
Iustin Pop [Sun, 13 Jun 2010 05:45:27 +0000 (07:45 +0200)]
Rework LUSetInstanceParams._GetUpdatedParams

Currently, this function does three things:
- special handling of constants.VALUE_DEFAULT
- type enforcing of the resulting dict
- filling the dictionary with defaults

However, except for the first one, the second two do not belong in this
function:
- in the future, not all parameter dictionaries will be able to be
  enforced
- filling the dictionary with defaults cannot be done via a defaults
  dict in all cases, and should be done by the specialized functions
  (ideally we'd pass a partial function instance here, but we don't have
  that yet…)

As such, we remove the last items, and move them to the callers; this is
overall the same complexity, as we were calling this function in just
three places and constructing the many arguments was also complicated.

Furthermore, we move the function out of LUSetInstanceParams, as in the
future it will be used by LUSetClusterParams too.

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