ganeti-local
16 years agopatch 4/4 extended HVM features for 1.2
Alexander Schreiber [Fri, 25 Apr 2008 13:34:28 +0000 (13:34 +0000)]
patch 4/4 extended HVM features for 1.2

This patch documents the extended HVM features.

Reviewed-by: imsnah

16 years agopatch 3/4 extended HVM features for 1.2
Alexander Schreiber [Fri, 25 Apr 2008 12:37:18 +0000 (12:37 +0000)]
patch 3/4 extended HVM features for 1.2

This patch adds hypervisor support for the extended HVM features.

Reviewed-by: iustinp

16 years agoIAllocator: some more info exported
Iustin Pop [Fri, 25 Apr 2008 12:06:10 +0000 (12:06 +0000)]
IAllocator: some more info exported

This patch adds the following information to the exported info:
  - hypervisor type (in the main dict)
  - total memory used by primary instances (in each node dict) (can be
    computed from the node+instance dicts, but it's cheap to compute
    from Ganeti) (this is not live data, just from the config)
  - total memory used by primary instances marked to be up, similar to
    the above

Reviewed-by: imsnah

16 years agoIAllocator: simplify node info computation
Iustin Pop [Fri, 25 Apr 2008 12:05:54 +0000 (12:05 +0000)]
IAllocator: simplify node info computation

Currently we try to convert the values returned by call_node_info to
ints, and if all succeed, we actually do the conversion. Simplify this
by doing it in one step.

The patch also adds exporting of node memory as 'reserved_memory'.

Reviewed-by: imsnah

16 years agopatch 2/4 extended HVM features for 1.2
Alexander Schreiber [Fri, 25 Apr 2008 11:38:58 +0000 (11:38 +0000)]
patch 2/4 extended HVM features for 1.2

This patch adds the commandline extensions and the code to store
and display the extended HVM features.

Reviewed-by: iustinp

16 years agoGeneralize RAPI request handling flow
Oleksiy Mishchenko [Fri, 25 Apr 2008 10:05:20 +0000 (10:05 +0000)]
Generalize RAPI request handling flow

All request we goin to hanle have similar prerun steps, lets keep them in the same bucket.

Reviewd-by: iustinp

16 years agoAdd iallocator documentation
Iustin Pop [Fri, 25 Apr 2008 09:53:26 +0000 (09:53 +0000)]
Add iallocator documentation

Reviewed-by: imsnah

16 years agoburnin: improve -t help message
Guido Trotter [Thu, 24 Apr 2008 19:45:17 +0000 (19:45 +0000)]
burnin: improve -t help message

Make the help message a bit more similar to the trunk version, which is
actually better ("Disk template" is a lot clearer than "Template type")

Reviewed-by: imsnah

16 years agoChage the rapi to conform to new OpDiagnoseOS
Iustin Pop [Thu, 24 Apr 2008 14:54:37 +0000 (14:54 +0000)]
Chage the rapi to conform to new OpDiagnoseOS

This patch modifies the remote api to conform to the new format for the
input and output of the OpDiagnoseOS opcode.

Reviewed-by: amishchenko

16 years agoBackport: Rework the results of OpDiagnoseOS opcode
Iustin Pop [Thu, 24 Apr 2008 14:54:24 +0000 (14:54 +0000)]
Backport: Rework the results of OpDiagnoseOS opcode

Currently, the opcode DiagnoseOS is the only opcode that return a
structure of objects.OS (which is a custom class, and not a simple
python object) and furthermore all the processing of OS validity across
nodes is left to the clients of this opcode.

It would be more logical to have this opcode be similar to list
instances/nodes, in the sense that:
  - it should return a table of results
  - the fields in the table should be selectable

This patch does the above. The possible fields are:
  - name (os name)
  - valid (bool representing validity across all nodes)
  - node_status, which is a complicated structure required for ‘gnt-os
    diagnose’

With this patch, gnt-os list becomes a very simple iteration over the
list of results, filtering out non-valid ones. gnt-os diagnose is still
complicated, but no more than before.

The burnin tool has also been modified to work with the modified
results, and is simpler because of this (it only needs to know if an OS
is valid or not, not the per-node details).

Reviewed-by: imsnah,ultrotter

16 years agoStyle fixes for the 1.2 branch
Iustin Pop [Thu, 24 Apr 2008 14:44:01 +0000 (14:44 +0000)]
Style fixes for the 1.2 branch

This patch fixes:
  - line too long
  - missing spaces around "=" or after commas
  - wrong position for a docstring
  - wrong indentation

Reviewed-by: imsnah

16 years agoImplement replace secondary via the iallocator
Iustin Pop [Thu, 24 Apr 2008 11:10:14 +0000 (11:10 +0000)]
Implement replace secondary via the iallocator

This patch implements secondary replace via the iallocator. The new
opcode parameter 'iallocator' behaves like this: if passed, it will
always compute and assign a new secondary, behaving in effect as if the
secondary node has been passed. It conflicts with actually giving the
secondary too.

[Note: not tested with remote_raid1, but the code should behave the
same, we only touch CheckPrereq and we assign a node.]

The patch also adds burnin support for the replace secondary operation;
with this in place, burnin can fully work with auto-assigned nodes.

Reviewed-by: ultrotter

16 years agoImplement memory size option for burnin
Iustin Pop [Thu, 24 Apr 2008 07:34:21 +0000 (07:34 +0000)]
Implement memory size option for burnin

This simple patch adds memory size for the burnin instances, which helps
testing allocator algorithm response based on the available node memory
and instance memory size values.

Reviewed-by: ultrotter

16 years agoFix generalized relocate mode of IAllocator
Iustin Pop [Thu, 24 Apr 2008 07:26:30 +0000 (07:26 +0000)]
Fix generalized relocate mode of IAllocator

The patch which generalized the IAllocator was half-true: it actually
put the selection of the node inside the IAllocator, so callers were not
able to specify replace primary node.

This patch does:
  - split the arguments to the constructor in three sets: mode and name
    are always passed, and then we differentiate between allocation
    parameters and relocation ones
  - add a new relocate_from option to the IAllocator constructor which
    is a list of nodes we want to move the instance off
  - rename the 'nodes' argument in the request object to 'relocate_from'
    since this is clearer and is not confused with the result field also
    called 'nodes'

Reviewed-by: ultrotter

16 years agopatch 1/4 extended HVM features for 1.2
Alexander Schreiber [Wed, 23 Apr 2008 15:26:41 +0000 (15:26 +0000)]
patch 1/4 extended HVM features for 1.2

This patch extends the config objects with the slots to handle
more HVM configuration items.

Reviewed-by: iustinp

16 years agoburnin: improve instance create message
Guido Trotter [Wed, 23 Apr 2008 14:48:11 +0000 (14:48 +0000)]
burnin: improve instance create message

When the allocator or a non-mirrored template are used the message shown by
burnin at instance creation time was wrong. Fixing it.

Reviewed-by: iustinp

16 years agoburnin: change the default disk type to drbd
Guido Trotter [Wed, 23 Apr 2008 14:47:59 +0000 (14:47 +0000)]
burnin: change the default disk type to drbd

We generally discourage people from using remote_raid1, so it makes sense to
use drbd as the default disk template for burning in 1.2.

Reviewed-by: iustinp

16 years agoburnin: remove created exports
Guido Trotter [Wed, 23 Apr 2008 14:47:46 +0000 (14:47 +0000)]
burnin: remove created exports

Make burnin remove exports after importing the instance back.

Reviewed-by: iustinp

16 years agoAdd gnt-backup remove functionality
Guido Trotter [Wed, 23 Apr 2008 13:55:37 +0000 (13:55 +0000)]
Add gnt-backup remove functionality

This patch also fixes the LUExportInstance Prereq docstring.

Reviewed-by: iustinp

16 years agoGeneralize the replace_secondary mode in iallocator
Iustin Pop [Wed, 23 Apr 2008 12:05:01 +0000 (12:05 +0000)]
Generalize the replace_secondary mode in iallocator

Currently the replace_secondary mode is too restrictive. This patch
changes this to a general 'relocate' mode where the node(s) to be
changed are specified via a new key in the request dict ('nodes') so
that we can change any of the instance's nodes.

Note that for the relocate mode, len(nodes) == required_nodes, so the
required nodes field is redundant, but it is provided for consistency
with the allocate mode.

Reviewed-by: ultrotter

16 years agoCorrectly filter out Domain-0 from domain list if requested.
Iustin Pop [Wed, 23 Apr 2008 11:38:40 +0000 (11:38 +0000)]
Correctly filter out Domain-0 from domain list if requested.

Author: schreiberal
Reviewed-by: ultrotter

16 years agoImplement replace_secondary in the dumb allocator
Iustin Pop [Wed, 23 Apr 2008 11:02:55 +0000 (11:02 +0000)]
Implement replace_secondary in the dumb allocator

This patch allows the dumb allocator to perform the replace secondary
request type. This is done simply by not allowing the current instances
nodes as a valid selection, and using the existing instance data instead
of the request (which doesn't have the instance info when doing the
replace_secondary).

Reviewed-by: ultrotter

16 years agoSend required_nodes field to the iallocator scripts
Iustin Pop [Wed, 23 Apr 2008 11:02:44 +0000 (11:02 +0000)]
Send required_nodes field to the iallocator scripts

This patch adds the 'required_nodes' field in the request dict for the
iallocator.

This means that the handmade-checks in the create instance can be
simplified, and that the dumb allocator can be made simple. Therefore
the patch also modifies it.

The patch also sends the disk_space_total to the script in realocate
mode and a small fix for showing errors (include stderr too).

Reviewed-by: ultrotter

16 years agoAllow burnin to use an iallocator in instance creation
Iustin Pop [Wed, 23 Apr 2008 10:58:53 +0000 (10:58 +0000)]
Allow burnin to use an iallocator in instance creation

This patch adds iallocator support to burnin, currently only in instance
creation. This means that, depending on the external algorithm, not all
nodes might get instances.

The patch also restricts node selection and iallocator options together.

Reviewed-by: ultrotter

16 years agoMove all iallocator functions into a class
Iustin Pop [Wed, 23 Apr 2008 10:57:08 +0000 (10:57 +0000)]
Move all iallocator functions into a class

This patch moves all the iallocator function into a separate class that
is then somewhat easier to use. It doesn't bring any new functionality.

The patch also changes the way the iallocator is called - the
OpTestAllocator opcode is no longer needed, and all its parameters
should be passed directly to the IAllocator constructor.

Reviewed-by: ultrotter

16 years agoOnly change instance status if not already so
Iustin Pop [Mon, 21 Apr 2008 13:20:53 +0000 (13:20 +0000)]
Only change instance status if not already so

This patch makes the _SetInstanceStatus only change the status of the
instance (in the config file) if it's not already in the desired state.
This skips the increase of the config serial no without actual data
changes.

Reviewed-by: ultrotter

16 years agoReuse common code between MarkInstance{Up,Down}
Iustin Pop [Mon, 21 Apr 2008 13:20:30 +0000 (13:20 +0000)]
Reuse common code between MarkInstance{Up,Down}

This patch creates a new method ConfigWriter._SetInstanceStatus that
consists of the common code between MarkInstanceUp and MarkInstanceDown.
These two methods become wrappers over the _SetInstanceStatus.

Reviewed-by: ultrotter

16 years agoAbstract the json functions into a separate module
Iustin Pop [Mon, 21 Apr 2008 13:01:54 +0000 (13:01 +0000)]
Abstract the json functions into a separate module

This simple patch adds a new module that holds the simplejson functions
for serialization/deserialization. This reduces the amount of redundant
code.

The patch also adds some normalizations to the json output:
  - the output text will always have an EOL as last char
  - extra spaces before EOL are removed

Reviewed-by: ultrotter

16 years agoMove RAPI constants to ganeti.constants
Oleksiy Mishchenko [Mon, 21 Apr 2008 10:20:56 +0000 (10:20 +0000)]
Move RAPI constants to ganeti.constants
Reviewed-by: iustinp

16 years agoSwitch RAPI to default ganeti logging and Daemonize it with ganeti.utils
Oleksiy Mishchenko [Thu, 17 Apr 2008 08:08:24 +0000 (08:08 +0000)]
Switch RAPI to default ganeti logging and Daemonize it with ganeti.utils
Reviewed-by: insmah

16 years agoIAllocator part 3: LUCreateInstance changes
Iustin Pop [Wed, 16 Apr 2008 13:17:30 +0000 (13:17 +0000)]
IAllocator part 3: LUCreateInstance changes

This (final) patch allows the instance's nodes to be selected
automatically based on the passed allocator algorithm.

The patch changes the pnode opcode parameter from required to optional,
now either the pnode or the iallocator must be passed.

A possible improvement could be to organize all the _IAllocator
functions into a separate class, but that can come later and the current
version is functionally ok.

Reviewed-by: ultrotter

16 years agoReorder checks in instance create
Iustin Pop [Wed, 16 Apr 2008 13:17:01 +0000 (13:17 +0000)]
Reorder checks in instance create

This patch reorders the checks in the instance create prereq so that all
checks and normalisations that are not node-dependent are done before
the node dependent checks.

This is done so that, after the instance-related opcode parameters are
checked and fixed, we can run the allocator and compute the primary (and
any secondary) nodes, and only then proceed with node-related checks.

Reviewed-by: ultrotter

16 years agoImplement 'out' direction on allocator tests
Iustin Pop [Wed, 16 Apr 2008 13:16:40 +0000 (13:16 +0000)]
Implement 'out' direction on allocator tests

This patch adds the paths for searching for instance allocators and
makes the LUTestAllocator code run the allocator and return the results
if the direction specified is 'out'. 'out' means that the opcode will
return the result of the allocator run, instead of the allocator input
file ('in').

The patch unifies all names to refer to 'iallocator' instead of plain
allocator.

The patch also adds an example allocator that can be used for testing
this new functionality.

Reviewed-by: ultrotter

16 years agoBugfix: wrong identifier in CheckPrereq message
Guido Trotter [Tue, 15 Apr 2008 16:11:35 +0000 (16:11 +0000)]
Bugfix: wrong identifier in CheckPrereq message

Reviewed-by: iustinp

16 years agoMove the disk size computation to its own function
Iustin Pop [Tue, 15 Apr 2008 12:30:09 +0000 (12:30 +0000)]
Move the disk size computation to its own function

This is currently hard-coded for the two drive case and will need to be
reworked for multi-disk support.

The patch is needed to support passing the total required size to the
iallocator interface.

Reviewed-by: ultrotter

16 years agoFix a typo in rapi.RESTHTTPServer
Iustin Pop [Mon, 14 Apr 2008 11:54:43 +0000 (11:54 +0000)]
Fix a typo in rapi.RESTHTTPServer

Reviewed-by: amishchenko

16 years agoFix pylint errors for RAPI
Oleksiy Mishchenko [Fri, 11 Apr 2008 21:26:02 +0000 (21:26 +0000)]
Fix pylint errors for RAPI
Reviewed-by: imsnah

16 years agoFix pylint errors for RAPI
Oleksiy Mishchenko [Fri, 11 Apr 2008 16:18:06 +0000 (16:18 +0000)]
Fix pylint errors for RAPI

16 years agoInstall the rapi files at make install time
Iustin Pop [Fri, 11 Apr 2008 14:22:11 +0000 (14:22 +0000)]
Install the rapi files at make install time

Reviewed-by: imsnah

16 years agoImport first version of Ganeti Remote API
Oleksiy Mishchenko [Fri, 11 Apr 2008 13:40:03 +0000 (13:40 +0000)]
Import first version of Ganeti Remote API

Reviewed-by: iustinp

16 years agoVerify: make skipping checks possible
Guido Trotter [Thu, 10 Apr 2008 16:48:26 +0000 (16:48 +0000)]
Verify: make skipping checks possible

Add a general way to skip some checks at cluster-verify time and make the N+1
memory redundancy check optional.

Reviewed-by: iustinp

16 years agoVerify: add N+1 Memory redundancy verification
Guido Trotter [Thu, 10 Apr 2008 16:48:06 +0000 (16:48 +0000)]
Verify: add N+1 Memory redundancy verification

For every node we check that we can host all the instances it's currently
secondary for belonging to the same primary. This ensures that if a node fails
all its instances can fit on their secondary node. The code only works when
failover is forced to go to the secondary node, and cannot go to an arbitrary
node in the cluster, which is the case in Ganeti 1.2.

Reviewed-by: iustinp

16 years agoAllow utils.Daemonize() to not close some fds
Iustin Pop [Thu, 10 Apr 2008 14:59:54 +0000 (14:59 +0000)]
Allow utils.Daemonize() to not close some fds

This patch implements an optional parameter to utils.Daemonize() which
allows that function to not close some file descriptors.

This will allow the master daemon to open the listening socket before
fork - in order to be able to notify errors and return a meaningful exit
code, and then when we fork we don't close that fd.

Reviewed-by: imsnah

16 years agoMove the daemonize function to utils.py
Iustin Pop [Thu, 10 Apr 2008 14:58:46 +0000 (14:58 +0000)]
Move the daemonize function to utils.py

Currently, in ganeti-noded we have the createDaemon function. Since
we'll need the same in other daemons, we move this function to utils.py

With the move, a few changes were also done:
  - change the name to Daemonize()
  - add a parameter, logfile, as different daemons will want to log to
    different files
  - remove the try.. except.. around the fork calls, since they were
    only re-raising the OS exception with less data; unless we want to
    actually handle fork error (not just re-raising), these try blocks
    are not useful
  - change the return style at the end of the function

Reviewed-by: imsnah

16 years agoMove the OS search code into an abstract function
Iustin Pop [Thu, 10 Apr 2008 13:36:43 +0000 (13:36 +0000)]
Move the OS search code into an abstract function

Based on the previous OS search code changes, we can now move the OS
search code into a generic look-for-file function in utils.py. This
means that the allocator code can use the same function.

Reviewed-by: ultrotter

16 years agoChange backend._OSSearch return values
Iustin Pop [Thu, 10 Apr 2008 13:36:21 +0000 (13:36 +0000)]
Change backend._OSSearch return values

Currently, the function backend._OSSearch() returns the (first) base dir
in which this OS can be found. Thereafter the full actual path to the OS
dir is built in the backend.OSFromDisk() function.

This patch changes this so that _OSSearch() always returns the full path
to the OS directory, and OSFromDisk uses that as returned (it will only
build it if it gets a base dir in the first place).

This patch is needed before we can abstract the _OSSearch into a generic
'look for file object' functionality that can be used for allocator
plugins search too.

Reviewed-by: ultrotter

16 years agoFix example scripts build dependencies
Iustin Pop [Thu, 10 Apr 2008 12:58:00 +0000 (12:58 +0000)]
Fix example scripts build dependencies

Currently, the example scripts (the init.d and the cron script) do not
depend on the Makefile, so if configure is rerun with different
parameters these scripts are not rebuild.

The patch adds Makefile as a dependency so changes to installation paths
or other parameters trigger the rebuild.

Reviewed-by: imsnah

16 years agoVerify: save instance config
Guido Trotter [Thu, 10 Apr 2008 12:33:49 +0000 (12:33 +0000)]
Verify: save instance config

Save the instance config after we queried it in an instance_cfg dict.  This can
be used later by any function that wants it, without reloading it from the
configuration module. It will be used for N+1 memory resilience checking.

Reviewed-by: iustinp

16 years agoVerify: add more instance information to node_info
Guido Trotter [Thu, 10 Apr 2008 12:33:33 +0000 (12:33 +0000)]
Verify: add more instance information to node_info

The sisnt-by-pnode field contains all secondary instances of a node, grouped by
their primary node. This information allows us to see quickly if when a node
dies some of its instances cannot be started on their secondary node.

Reviewed-by: iustinp

16 years agoVerify: add instance information to node_info
Guido Trotter [Thu, 10 Apr 2008 12:33:18 +0000 (12:33 +0000)]
Verify: add instance information to node_info

With this patch node_info is changed to store information about which primary
and secondary instances are configured on a node. This information is useful to
check memory and disk allocation. A list of non-redundant instances is also
collected at this stage.

Reviewed-by: iustinp

16 years agoVerify: Add and populate node_info dict
Guido Trotter [Thu, 10 Apr 2008 12:33:05 +0000 (12:33 +0000)]
Verify: Add and populate node_info dict

During information gathering we collect information from call_node_info, and
then when we cycle trough the nodes add it into a node_info dict containing a
node's free memory and disk. This will be useful later to verify that the
cluster is N+1 redundant. The disk space is saved as well because it can be
useful for checks about disk space redundancy.

Reviewed-by: iustinp

16 years agoVerify: remove useless check in _VerifyInstance
Guido Trotter [Thu, 10 Apr 2008 10:07:58 +0000 (10:07 +0000)]
Verify: remove useless check in _VerifyInstance

The list of instances passed to _VerifyInstance is the one coming from
self.cfg.GetInstanceList(). So there's no point, inside that function, in
checking whether the current instance is a member of that list. Moreover
orphaned instance verification is already done in a separate step.

Reviewed-by: imsnah

16 years agoVerify: instance verification cleanup
Guido Trotter [Thu, 10 Apr 2008 10:07:44 +0000 (10:07 +0000)]
Verify: instance verification cleanup

The instance configuration is grabbed both in the _VerifyInstance function and
in the loop that calls it. Clean this up by passing the configuration as a
parameter.

Reviewed-by: imsnah

16 years agoVerify: fix crash when a node is down
Guido Trotter [Thu, 10 Apr 2008 10:07:25 +0000 (10:07 +0000)]
Verify: fix crash when a node is down

Currently if ganeti-noded doesn't respond on a node gnt-cluster verify will die
when verifying primary instances for that node. Fix this by just emitting an
error message if no information about running instances is returned from the
node.

Reviewed-by: iustinp

16 years agoVerify: fix ERROR message indentation
Guido Trotter [Thu, 10 Apr 2008 10:06:57 +0000 (10:06 +0000)]
Verify: fix ERROR message indentation

All ERROR messages in cluster verify are indented by four spaces, this one is
indented by two. Fixing this skew.

Reviewed-by: imsnah, iustinp

16 years agoFix spelling mistake in constants.py
Guido Trotter [Thu, 10 Apr 2008 10:06:40 +0000 (10:06 +0000)]
Fix spelling mistake in constants.py

Of course instance creation don't have any modem, and the comment was just
talking about modes. Sorry to everybody expecting whistles.

Reviewed-by: imsnah

16 years agoAllocator framework, 1st part: allocator input generation
Iustin Pop [Wed, 9 Apr 2008 13:01:34 +0000 (13:01 +0000)]
Allocator framework, 1st part: allocator input generation

In preparation for the introduction of automatic instance allocator,
this patch adds an allocator simulation opcode, that based on the input
parameters, will return either the input message to the allocator
(implemented) or the result of the allocator run (not yet implemented).

This allows algorithm tests against simulated allocations and the
current cluster state.

The patch adds the following:
  - a function that generates the generic cluster information for the
    allocator
  - a function that generates the 'new instance' information
  - a function that generates the 'replace_secondary' information

These three functions will be used by the allocator framework later to
generate the actual information for the external algorithms. Currently
we just return the json-serialized text.

Reviewed-by: imsnah

16 years agoAdd a gnt-debug tool
Iustin Pop [Wed, 9 Apr 2008 13:01:14 +0000 (13:01 +0000)]
Add a gnt-debug tool

This patch adds a script which submits a job consisting of the
OpTestDelay opcode. This can be helpful for debugging and can be
extended to execute other 'debug'-like tasks.

Reviewed-by: imsnah

16 years agoImprove disk consistency error message again
Guido Trotter [Wed, 2 Apr 2008 18:31:37 +0000 (18:31 +0000)]
Improve disk consistency error message again

This new version includes all the possible failure options.

Reviewed-by: iustinp

16 years agoFix misleading error message when checking disks
Guido Trotter [Wed, 2 Apr 2008 18:01:54 +0000 (18:01 +0000)]
Fix misleading error message when checking disks

_CheckDiskConsistency outputs "Can't get any data from node NODE" when no drbd
is found on the target node. This causes a misleading error message to be
output for example on failover (when the primary node is down, or the instance
is not running), stating that no data could be got from the secondary node,
which scares the user and misleads him. Changing this to "Disk degraded or not
found on node %s" still reports that something is missing, but on the other
hand doesn't make the user think the node is down, or has no data at all...

Reviewed-by: imsnah

16 years agoHandle better failing over non-running instances
Guido Trotter [Wed, 2 Apr 2008 18:00:27 +0000 (18:00 +0000)]
Handle better failing over non-running instances

Right now if you try to failover an instance which is not marked as up the
operation will fail unless you pass the --ignore-consistency flag because the
disks won't be considered to be consistent. Allow them to be if we know the
instance shouldn't be up.

Reviewed-by: imsnah

16 years agoImprove export and fix export-on-norun bug
Guido Trotter [Wed, 2 Apr 2008 18:00:13 +0000 (18:00 +0000)]
Improve export and fix export-on-norun bug

Currently gnt-backup export chains the ShutdownInstance and StartupInstance
opcodes to itself. This works but (a) it's suboptimal, because there's no need
to deactivate the instance's disks as we are about to restart it anyway, and
(b) doesn't take care of instances which are already down (and should be). This
patch takes care of this by just calling the shutdown rpc function instead of
the whole opcode, and just starting up the instance if it's configured as up in
the first place.

Reviewed-by: imsnah

16 years agofailover: only start instance if we should
Guido Trotter [Wed, 2 Apr 2008 17:00:33 +0000 (17:00 +0000)]
failover: only start instance if we should

gnt-instance failover on an instance marked as down will mistakenly bring it
up. The watcher will then shut it down again, but it's a lot better (and safer)
not to start it at all.

Reviewed-by: imsnah

16 years agoUpdate the lock autocleanup log message
Iustin Pop [Wed, 2 Apr 2008 09:08:27 +0000 (09:08 +0000)]
Update the lock autocleanup log message

Reviewed-by: ultrotter

16 years agoAdd autocleanup of stale locks
Iustin Pop [Tue, 1 Apr 2008 16:02:22 +0000 (16:02 +0000)]
Add autocleanup of stale locks

This patch adds autocleanup of stale locks. This can be disabled by
passing --lock-noautoclean to the commands.

The autocleanup mechanism will only try to do five cleanups before
raising an exception, to protect against runaway processes or similar
conditions.

Reviewed-by: schreiberal

16 years agoFix gnt-instance failover help message
Guido Trotter [Tue, 1 Apr 2008 13:08:20 +0000 (13:08 +0000)]
Fix gnt-instance failover help message

The message used to misleadingly say that failover just works with remote_raid1
instances, while of course it works for drbd as well. Thanks to Jesus Climent
who spotted the bug.

Reviewed-by: imsnah

16 years agoChange the 'gnt-cluster command' execution order
Iustin Pop [Mon, 31 Mar 2008 14:45:54 +0000 (14:45 +0000)]
Change the 'gnt-cluster command' execution order

This patch makes the command execute last on the master (if the master
is selected). The order for the other nodes is unchanged.

The patch also updates the man page with some explanations and an
example.

Reviewed-by: imsnah

16 years agoChange the gnt-backup export help text
Iustin Pop [Mon, 31 Mar 2008 13:13:49 +0000 (13:13 +0000)]
Change the gnt-backup export help text

Reviewed-by: ultrotter

16 years agoChange the order of config updates in some LUs
Iustin Pop [Sun, 30 Mar 2008 14:55:45 +0000 (14:55 +0000)]
Change the order of config updates in some LUs

In the start and stop instance LUs, the configuration update is done
right at the end. This means that if, for example, the instance shutdown
succeeds, but the drive deactivation fails, the next run of the watcher
will start the instance again, as it's still marked in running mode.

This patch changes these two LUs so that first the update the
configuration to the desired state, and only then we proceed to update
the config. This ensures that the state saved is the desired state.

Because the config might be updated even though the LU failed, this
patch also modifies the mcpu.Processor.ExecOpCode method to run the
RunConfigUpdate hook in a finally: phase while the lu.Exec is done in
its try phase. This ensures that config update hooks (tries to) run at
all times when the config is updated.

Reviewed-by: schreiberal

16 years agoFix a bug in interactive confirmation of instances
Iustin Pop [Thu, 27 Mar 2008 15:52:58 +0000 (15:52 +0000)]
Fix a bug in interactive confirmation of instances

This oneliner fixes a bug in listing more than twenty instances for
multiple operations (shutdown, startup, etc.).

Reviewed-by: imsnah

16 years agoFix gnt-instance replace-disks online help
Iustin Pop [Wed, 19 Mar 2008 10:20:00 +0000 (10:20 +0000)]
Fix gnt-instance replace-disks online help

The "quick" online help just reported the option to change secondary node. Add
the ones to just replace the disk locally on-primary or on-secondary. It is of
course impossible to espress in one line everything needed to use this command,
but at least now the most common options are spelled out immediately.

Author: ultrotter
Reviewed-by: iustinp, imsnah

16 years agoMake ganeti-noded create BDEV_CACHE_DIR automatically
Iustin Pop [Wed, 19 Mar 2008 10:14:41 +0000 (10:14 +0000)]
Make ganeti-noded create BDEV_CACHE_DIR automatically

Currently in order to deal with tmpfs /var/run, we create the
BDEV_CACHE_DIR in the init script. However, that does not cover all the
cases, and it's not a proper place to deal with it: for example, dealing
with not initialized clusters and the master node is more complicated.

Therefore, this patch does:
  - make ganeti-noded create the directory automatically
  - make ganeti-noded error out if it can't create it or it's already
    there but not a directory
  - remove the creation from the init.d script

Reviewed-by: ultrotter

16 years agoSpecify better gnt-instance(8) replace-disks
Guido Trotter [Tue, 11 Mar 2008 10:33:48 +0000 (10:33 +0000)]
Specify better gnt-instance(8) replace-disks

The -s option when changing secondary node on a drbd template is implied, and
thus optional. Specify this in the manpage.

Reviewed-by: iustinp

16 years agoDisable cluster init with a reachable IP
Iustin Pop [Mon, 10 Mar 2008 16:29:32 +0000 (16:29 +0000)]
Disable cluster init with a reachable IP

Make the cluster init fail if the IP to which the cluster name resolved
is already reachable by the master node. This is not a foolproof
solution, but it allows a cheap method of detecting simple mistakes.

It will also disallow using the master node name as cluster name (which
is something good).

The only drawbacks that I see are:
  - you are not allowed to do this, which might come in handy in cluster
    upgrades; but since we support rename, this is mitigated
  - cluster init takes longer now (+the timeout value, set to 5
    seconds), but since this is a one-off operation, it should be ok

Reviewed-by: ultrotter

16 years agoModify utils.TcpPing to make source address optional
Iustin Pop [Mon, 10 Mar 2008 16:29:10 +0000 (16:29 +0000)]
Modify utils.TcpPing to make source address optional

This patch modifies TcpPing and its callers to make the source address
selection optional. Usually, the kernel will know better what
source address to use, just in some cases we want to enforce a given
source address so it makes sense to make this optional.

Reviewed-by: ultrotter

16 years agoFix master role stop on cluster destroy
Iustin Pop [Fri, 29 Feb 2008 16:14:43 +0000 (16:14 +0000)]
Fix master role stop on cluster destroy

Currently the cluster destroy doesn't remove the master role, which
means that the IP address of the cluster remains assigned to the master
node.

This patch fixes this and also a docstring in backend.StopMaster().

Reviewed-by: imsnah

16 years agoImplement QA tests for gnt-cluster rename
Iustin Pop [Fri, 29 Feb 2008 15:34:20 +0000 (15:34 +0000)]
Implement QA tests for gnt-cluster rename

Reviewed-by: imsnah

16 years agoFix cluster rename operation
Iustin Pop [Fri, 29 Feb 2008 12:32:23 +0000 (12:32 +0000)]
Fix cluster rename operation

This one-liner fixes the cluster rename operation. As a side note, we
should have a QA test for this too.

Reviewed-by: imsnah

16 years agoReplace version number in install.sgml during build time
Guido Trotter [Thu, 28 Feb 2008 11:36:25 +0000 (11:36 +0000)]
Replace version number in install.sgml during build time

Reviewed-by: iustinp

16 years agoSmall comment fix.
Guido Trotter [Thu, 28 Feb 2008 11:36:11 +0000 (11:36 +0000)]
Small comment fix.

16 years agoFixes small spell mistakes and comments
Guido Trotter [Thu, 28 Feb 2008 11:35:57 +0000 (11:35 +0000)]
Fixes small spell mistakes and comments

16 years agoThis patch replaces some hardcoded strings with their corresponding constant in ...
Guido Trotter [Thu, 28 Feb 2008 11:35:36 +0000 (11:35 +0000)]
This patch replaces some hardcoded strings with their corresponding constant in `_GenerateDiskTemplate()`.

Reviewed-by: iustinp

16 years agoUse constants.ETC_HOSTS instead of string for /etc/hosts
Guido Trotter [Thu, 28 Feb 2008 11:35:11 +0000 (11:35 +0000)]
Use constants.ETC_HOSTS instead of string for /etc/hosts

Reviewed-by: iustinp

16 years agoFix the gnt-cluster init man page
Guido Trotter [Thu, 28 Feb 2008 11:34:49 +0000 (11:34 +0000)]
Fix the gnt-cluster init man page

Some options were missing in the gnt-cluster init man page.  This patch adds
them, removes an empty line, and clarifies a bit more some requirements.

Reviewed-by: schreiberal

16 years agoDon't allow renaming to an existing instance
Guido Trotter [Thu, 28 Feb 2008 11:34:36 +0000 (11:34 +0000)]
Don't allow renaming to an existing instance

Even if the target instance is down or we are not checking for IP conflicts
changing an instance name to a new one which is already in the cluster is
doomed to fail, because in a lot of places (among which figures the mind of
most users/admins) instance names are assumed to be unique.

Reviewed-by: imsnah

16 years agoClarify online help for xc-instance reinstall.
Guido Trotter [Thu, 28 Feb 2008 11:34:17 +0000 (11:34 +0000)]
Clarify online help for xc-instance reinstall.

Reviewed-by: imsnah

16 years agoImprove ganeti example cron file
Guido Trotter [Sat, 23 Feb 2008 10:51:58 +0000 (10:51 +0000)]
Improve ganeti example cron file

The cron file in ganeti's example directory is now static, and executes
ganeti-watcher in /usr/local/sbin no matter where it's really installed. With
this patch we generate it at build time substituting the right value of
@SBINDIR@ from ganeti.cron.in. We also make sure ganeti-watcher exists and is
executable before running it.

This is targeted at 1.2 as well.

Reviewed-by: iustinp

16 years agoAdd another 1.1->1.2 compatibility alias
Guido Trotter [Wed, 20 Feb 2008 11:18:51 +0000 (11:18 +0000)]
Add another 1.1->1.2 compatibility alias

gnt-instance replace-disks used to be called replace_disks.

Reviewed-by: iustinp

16 years agoSome more corrections on gnt-node help output v1.2.3
Iustin Pop [Mon, 18 Feb 2008 11:29:32 +0000 (11:29 +0000)]
Some more corrections on gnt-node help output

Reviewed-by: schreiberal

16 years agoUpdate online help and manpage to include drbd disk type.
Iustin Pop [Mon, 18 Feb 2008 11:28:55 +0000 (11:28 +0000)]
Update online help and manpage to include drbd disk type.

Author: schreiberal
Reviewed-by: imsnah

16 years agoAdd docdir to the tools/Makefile.am
Iustin Pop [Mon, 18 Feb 2008 11:28:36 +0000 (11:28 +0000)]
Add docdir to the tools/Makefile.am

Note: The other alternative would be to move the readme to the 'doc'
top-level dir, however I like it better to have the readme here.

Reviewed-by: ultrotter

16 years agoFix gnt-instance info i1 i2 ...
Guido Trotter [Sat, 16 Feb 2008 13:09:24 +0000 (13:09 +0000)]
Fix gnt-instance info i1 i2 ...

Due to an indentation error only the last instance queried got returned by
LUQueryInstanceData. Moving the append() call inside the for cycle to fix this
issue.

This is a one-liner targeted at 1.2.3

Reviewed-by: iustinp

16 years agoCode style fixes for drbd8-upgrade tool
Michael Hanselmann [Fri, 15 Feb 2008 15:13:11 +0000 (15:13 +0000)]
Code style fixes for drbd8-upgrade tool

Reviewed-by: ultrotter

16 years agoInclude the DRBD upgrade tool in the dist archive
Iustin Pop [Fri, 15 Feb 2008 15:06:06 +0000 (15:06 +0000)]
Include the DRBD upgrade tool in the dist archive

This patch adds the DRBD upgrade tool in the archive and in the
installed tools dir, and its associated README in the doc_DATA target.

Reviewed-by: ultrotter

16 years agoUpdate version numbers for the 1.2.3 release
Iustin Pop [Fri, 15 Feb 2008 12:31:03 +0000 (12:31 +0000)]
Update version numbers for the 1.2.3 release

Note: we don't update for now the install.sgml file with the new version
number, as there are no other changes. We'll update the web site to
indicate that the current install.html document is valid for 1.2.3 too.

Reviewed-by: imsnah,ultrotter

16 years agoFurther fixes for the 'export MAC in hooks' change
Iustin Pop [Fri, 15 Feb 2008 09:53:41 +0000 (09:53 +0000)]
Further fixes for the 'export MAC in hooks' change

QA suite which tests gnt-instance modify has uncovered another issue related to
mac export.

Reviewed-by: imsnah

16 years agoAlter the device activation code
Iustin Pop [Thu, 14 Feb 2008 15:51:34 +0000 (15:51 +0000)]
Alter the device activation code

This tiny patch fixes the breakage that the previous patch about
activation did by removing the Close() call after activation.

The initial reason for that call was that if the device is already
active and open, but we need it closed, we close it automatically.

This however conflicts with the 2-step open in the case the instance is
already open.

It makes sense to remove the call since in the current Ganeti setup,
just doing Close() is not enough to change the device from (e.g.)
primary to secondary, as some devices (e.g. md) might need Shutdown not
Close.

It also gets rid of a Close() in the CreateBlockDevice function, due to
the same reasoning (although in Create the child should not have a
different status anyway).

Reviewed-by: imsnah

16 years agoTwo small improvements to burnin
Iustin Pop [Thu, 14 Feb 2008 15:51:16 +0000 (15:51 +0000)]
Two small improvements to burnin

This tiny patch fixes the verbose option to actually work, and also when
creating instances it logs the secondary node too (even if this doesn't
apply for plain templates, it doesn't create an error).

Reviewed-by: imsnah

16 years agoModify the default output of gnt-instance list
Iustin Pop [Thu, 14 Feb 2008 15:47:56 +0000 (15:47 +0000)]
Modify the default output of gnt-instance list

This patch adds a new field available for selection in gnt-instance list
names "status" which represents the combined value of "admin_state" and
"oper_state". Since this is much easier to parse (e.g. gnt-instance list
|grep ERROR), we also modify the default field list to use this instead
of the admin/oper state fields.

Reviewed-by: imsnah

16 years agoParse double protocol version in drbd8.2
Guido Trotter [Tue, 12 Feb 2008 17:07:17 +0000 (17:07 +0000)]
Parse double protocol version in drbd8.2

DRBD 8.2 uses a double integer field ad protocol version, rather than a single
one. This patch fixes the ganeti parsing code, allowing both the old and the
new version type. In order to do so the internal _GetVersion function is
changed to return a dict, rather than a list, and the second protocol field is
added, only if present, as proto2.

This is a fix for issue 24.

Reviewed-by: iustinp