ganeti-local
16 years agoImplement hooks infrastructure.
Michael Hanselmann [Thu, 8 Nov 2007 11:50:30 +0000 (11:50 +0000)]
Implement hooks infrastructure.

Reviewed-by: schreiberal

16 years agoEnhance secondary node replace for drbd8
Iustin Pop [Wed, 7 Nov 2007 15:53:50 +0000 (15:53 +0000)]
Enhance secondary node replace for drbd8

This (big) patch does two things:
  - add "local disk status" to the block device checks
    (BlockDevice.GetSyncStatus and the rpc calls that call this
    function, and therefore cmdlib._CheckDiskConsistency)
  - improve the drbd8 secondary replace operation using the above
    functionality

The "local disk status" adds a new variable to the result of
GetSyncStatus that shows the degradation of the local storage of the
device. Of course, not all device support this - for now, we only modify
LogicalVolumes and DRBD8 to return degraded in some cases, other devices
always return non-degraded. This variable should be a subset of
is_degraded - whenever this variable is true, the is_degraded should
also be true.

The drbd8 secondary replace uses this variable as we don't care if the
primary drbd device is network-degraded, only if it has good local disk
data (ldisk is False).

The patch also increases the protocol version (due to rpc changes).

Reviewed-by: imsnah

16 years agoIndentation fixes for docs.
Michael Hanselmann [Wed, 7 Nov 2007 14:33:09 +0000 (14:33 +0000)]
Indentation fixes for docs.

Reviewed-by: schreiberal

16 years agoUpdate docs for the removed --secondary-node option.
Michael Hanselmann [Wed, 7 Nov 2007 12:39:20 +0000 (12:39 +0000)]
Update docs for the removed --secondary-node option.

Reviewed-by: ultrotter

16 years agoCheck whether init.d script is executable.
Michael Hanselmann [Wed, 7 Nov 2007 11:48:30 +0000 (11:48 +0000)]
Check whether init.d script is executable.

Reviewed-by: schreiberal

16 years agoAdapt QA tests for removed --secondary-node option.
Michael Hanselmann [Tue, 6 Nov 2007 17:04:58 +0000 (17:04 +0000)]
Adapt QA tests for removed --secondary-node option.

16 years agoRemove --secondary-node option.
Michael Hanselmann [Tue, 6 Nov 2007 17:04:16 +0000 (17:04 +0000)]
Remove --secondary-node option.

Replace --secondary-node option with an optional parameter for --node.

16 years agoEnhance DBRD8 disk replacement (same nodes)
Iustin Pop [Tue, 6 Nov 2007 17:01:42 +0000 (17:01 +0000)]
Enhance DBRD8 disk replacement (same nodes)

This patch adds enhanced reporting and much more checks to the disk
replacement (when not switching the secondary).

Reviewed-by: imsnah

16 years agoImplement degraded status for logical volumes
Iustin Pop [Tue, 6 Nov 2007 17:01:32 +0000 (17:01 +0000)]
Implement degraded status for logical volumes

Logical volumes can be 'degraded' in a similar way to mirrored devices,
when their underlying storage has gone away (i.e. after a physical disk
failure and 'vgreduce --removemissing'). If we can detect this, we can
prevent mistaken replaces of disks that would use this LV (or its
parent) as source data.

This patch adds support for computing the degraded attribute and
modifies gnt-instance to warn if the LV is virtual.

Reviewed-by: imsnah

16 years agoAdd better error logging functions for LUs
Iustin Pop [Tue, 6 Nov 2007 17:01:20 +0000 (17:01 +0000)]
Add better error logging functions for LUs

Currently, some LUs use logger.Error, others just feedback_fn, etc. This
patch adds three functions to mcpu.Processor than can be used to log
messages to both the log and to the user.

These function will be used to enhance the output of replace-disks for
drbd8 (at least).

Reviewed-by: imsnah

16 years agoEnhance mirror operations for DRBD8
Iustin Pop [Tue, 6 Nov 2007 17:01:07 +0000 (17:01 +0000)]
Enhance mirror operations for DRBD8

Currently, the mirror operations (add and remove children) test against
the instance's attributes. This patch changes the check tests to work
against the actual status of the device (i.e. live data) which is more
realistic.

The changes are:
  - allow add children if the device doesn't have local storage (even if
    we believe it has)
  - early return from remove children if the device is already without
    local storage

Reviewed-by: imsnah

16 years agoAllow DRBD8 operation without backing storage
Iustin Pop [Tue, 6 Nov 2007 17:00:38 +0000 (17:00 +0000)]
Allow DRBD8 operation without backing storage

This patch adds the following functionality:
  - DRBD8 devices can assemble without local storage (done by allowing
    None in the list of children, and making DRBD8 to ignore all
    children if any is None)
  - DRBD8 devices can attach (i.e. identify a device) which is not
    connected to backing storage but to the correct network ports; this
    is a rare case in normal operation (it's what would happen if one
    manually detaches the local disk, and the backing LV still exists)

Reviewed-by: imsnah

16 years agoMake DRBD8 disks show 'degraded' status if diskless
Iustin Pop [Tue, 6 Nov 2007 17:00:24 +0000 (17:00 +0000)]
Make DRBD8 disks show 'degraded' status if diskless

This patch enables the bdev.DRBD8 class report a degraded status if the
local disk is missing. This allows `gnt-instance info` to report the
actual situation in this case.

Note that DRBD7 should also behave like this, however the diskless case
is less often met there and we also don't want to change behaviour.

The patch also fixes some docstrings for the GetSyncStatus methods.

Reviewed-by: imsnah

16 years agoChange the way remove children is called in bdev
Iustin Pop [Tue, 6 Nov 2007 17:00:13 +0000 (17:00 +0000)]
Change the way remove children is called in bdev

For some cases, we don't have to have access to the children of a device
in order to remove them (e.g. md over lvs, or drbd over lvs). In order
to ease the removal process, skip over finding the child if it provides
a static dev path.

This is needed in order to support removal of children when the
underlying storage has gone away.

Reviewed-by: imsnah

16 years agoAdd a support function to objects.Disk
Iustin Pop [Tue, 6 Nov 2007 16:55:28 +0000 (16:55 +0000)]
Add a support function to objects.Disk

This patch adds a function returning the device path if it is computable
from the disk object (and we don't need to instantiate a bdev object on
the target node in order to compute this). Only LVs support this.

Reviewed-by: imsnah

16 years agoSmall cleanup for error formatting
Iustin Pop [Mon, 5 Nov 2007 21:22:22 +0000 (21:22 +0000)]
Small cleanup for error formatting

Reviewed-by: ultrotter

16 years agoHandle missing init script at cluster init
Iustin Pop [Mon, 5 Nov 2007 17:59:53 +0000 (17:59 +0000)]
Handle missing init script at cluster init

This patch adds a check in the prereq of LUInitCluster for the existence
of the init script.  This allows a clean abort instead of a stack dump.

Based on a report by admin@steibei.net

Reviewed-by: ultrotter

16 years agoFix a unhandled error case in device creation
Iustin Pop [Mon, 5 Nov 2007 15:08:25 +0000 (15:08 +0000)]
Fix a unhandled error case in device creation

The block device creation process is the following:
  - device create
  - device assembly (on primary or depending on dev_type, on secondary
    too)
  - set sync speed
  - return

The problem is that device assembly after creation was not checked for
errors, and as this is a very unusual case, we did not have problems
with it (or we didn't detect them). The recent DevCacheManager however
tripped on this case (because the dev_path of the device is None if the
assembly fails) and the creation aborted with an unclear error message.

The patch adds a check for the assembly success and aborts the creation
of the device in this case - the error is quite clear in the instance
add, for example. The patch also changes DevCacheManager to log the
cases when dev_path is None but not raise an error (keeping consistent
with the goal that the cache manager should be transparent to the code).

For the record, this error case was detected with a mismatch between
drbd kernel module and utilities.

Reviewed-by: imsnah

16 years agoMiscellaneous style fixes
Iustin Pop [Mon, 5 Nov 2007 15:06:24 +0000 (15:06 +0000)]
Miscellaneous style fixes

This patch fixes some minor pylint warnings (unused variables, wrong
indentation, etc.) and a real bug in the recovery for drbd8 rename
procedure.

Reviewed-by: imsnah

16 years agoTest tag functionality.
Michael Hanselmann [Mon, 5 Nov 2007 12:19:31 +0000 (12:19 +0000)]
Test tag functionality.

Reviewed-by: schreiberal

16 years agoMerge three small cluster tests into one.
Michael Hanselmann [Mon, 5 Nov 2007 12:18:49 +0000 (12:18 +0000)]
Merge three small cluster tests into one.

Reviewed-by: schreiberal

16 years agoRename utils.GetUUID to utils.NewUUID.
Michael Hanselmann [Mon, 5 Nov 2007 12:14:00 +0000 (12:14 +0000)]
Rename utils.GetUUID to utils.NewUUID.

Reviewed-by: schreiberal

16 years agoBump protocol version up
Guido Trotter [Mon, 5 Nov 2007 00:44:11 +0000 (00:44 +0000)]
Bump protocol version up

The OS cleanup patches change the wire protocol. Increment the protocol number
by one.

Reviewed-By: iustinp

16 years agoConvert os_get to use OS rather than InvalidOS
Guido Trotter [Mon, 5 Nov 2007 00:43:55 +0000 (00:43 +0000)]
Convert os_get to use OS rather than InvalidOS

In order to do this for simplicity we leave the OSFromDisk function as-is and
we convert the eventual exception to an OS object in ganeti-noded. The
unmangling gets simplified and so does the code for checking whether the OS is
valid.

Reviewed-By: iustinp

16 years agoSimplify diagnose mangling/unmangling functions
Guido Trotter [Mon, 5 Nov 2007 00:43:34 +0000 (00:43 +0000)]
Simplify diagnose mangling/unmangling functions

The functions in ganeti-noded and rpc.py still deal with the fact that an
InvalidOS error could be returned by DiagnoseOS. As this is not the case
anymore simplify their code for the current behavior.

Reviewed-By: iustinp

16 years agoMake DiagnoseOS use the modified OS objects
Guido Trotter [Mon, 5 Nov 2007 00:43:14 +0000 (00:43 +0000)]
Make DiagnoseOS use the modified OS objects

Modify backend.py so that DiagnoseOS only returns OS objects rather than
InvalidOS errors, and make sure gnt-os understands the new objects. Also delete
the deprecated helper functions from gnt-os.

Reviewed-By: iustinp

16 years agoCreate OS from an InvalidOS error
Guido Trotter [Mon, 5 Nov 2007 00:42:50 +0000 (00:42 +0000)]
Create OS from an InvalidOS error

Add a new FromInvalidOS static function to objects.OS that makes it easy to
create an object representing a broken OS starting from the relevant exception.

Reviewed-By: iustinp

16 years agoMake the OS object able to represent broken OSes
Guido Trotter [Mon, 5 Nov 2007 00:42:03 +0000 (00:42 +0000)]
Make the OS object able to represent broken OSes

Till now the OS object just represents a correct OS instance.  Change it so it
can represent a broken one too, by adding a "status" field: if this field is
different from the OS_VALID_STATUS constant the object is considered to be an
invalid OS, the "status" field to be a debugging message, and its boolean
status is set to false.

Reviewed-By: iustinp

16 years agoAdd option to burnin only a given set of nodes
Iustin Pop [Sun, 4 Nov 2007 23:26:43 +0000 (23:26 +0000)]
Add option to burnin only a given set of nodes

This patch adds a '-n' option to burnin that takes a comma-separated
list of nodes to perform the burnin on.

Reviewed-by: ultrotter

16 years agoMake call_os_get a single node function
Guido Trotter [Sun, 4 Nov 2007 04:10:44 +0000 (04:10 +0000)]
Make call_os_get a single node function

call_os_get is never called with a real list of nodes, so there's no point in
it being multi-node. Making it single-node till a usage for multi-node call is
found.

Reviewed-By: iustinp

16 years agoFix two typos in a doc string
Guido Trotter [Sun, 4 Nov 2007 03:37:15 +0000 (03:37 +0000)]
Fix two typos in a doc string

Remove a wrong "i" and add a missing ")" to the DiagnoseOS function doc string.

Reviewed-By: iustinp

16 years agoImplement tag searching
Iustin Pop [Sat, 3 Nov 2007 06:55:50 +0000 (06:55 +0000)]
Implement tag searching

This patch adds a search command for locating tags on all objects of the
cluster using a regex pattern.

Reviewed-by: aat

16 years agoTest “gnt-cluster command”.
Michael Hanselmann [Fri, 2 Nov 2007 15:51:35 +0000 (15:51 +0000)]
Test “gnt-cluster command”.

Also check whether file contents are correct for both “gnt-cluster command” and
“gnt-cluster copyfile”.

Reviewed-by: iustinp

16 years agoImplement device to instance mapping cache
Iustin Pop [Fri, 2 Nov 2007 13:44:29 +0000 (13:44 +0000)]
Implement device to instance mapping cache

Currently, troubleshooting DRBD problems involves a manual process of going
backwards from the DRBD device to the instance that owns it.

This patch adds a weak (i.e. not guaranteed to be correct or up-to-date)
cache of device to instance. The cache should be, in normal operation,
having correct information as the only time when devices change paths
are when they are started/stopped, and the code in backend.py adds cache
updates to exactly these operations.

The only drawback of this implementation is that we don't fully update
the cache on renames of devices (we clean the old entries but we don't
add new ones). Since the rename changes the path only for LVs (and not
drbd and md), this is less of a problem as the target of this code is
debugging DRBD and MD issues.

The patch writes files named bdev_drbd<N> (or bdev_md<N>,
bdev_xenvg_...) in /var/run/ganeti (more exactly, LOCALSTATEDIR/ganeti).
The files start with 'bdev_' and continue with the path of the device
under /dev/ (this prefix stripped), and contain the following values,
space separated:
  - instance name
  - primary or secondary (depending on how the device is on the primary
    or secondary node)
  - instance visible name: sda or sdb or not_visible, the latter case
    when the device is not the top-level device (i.e. remote_raid1
    templates will have sd[ab] for the md, but not_visible for drbd and
    logical volumes)

The cache is designed to not raise any errors, if there is an I/O error
it will only be logged in the node daemon log file. This is in order to
reduce the possible impact of the cache on the block device activation
and shutdown code.

Reviewed-by: imsnah

16 years agoImprove burnin with regard to drbd8
Iustin Pop [Fri, 2 Nov 2007 13:43:51 +0000 (13:43 +0000)]
Improve burnin with regard to drbd8

Allow burnin to use the new drbd8 template (for which case one needs to
disable replacement of disks, burnin does yet support that with drbd8).

The patch also changes do-replace[12] to no-replace[12] as that is what
they actually do.

Reviewed-by: imsnah

16 years agoUpdate the dev_path on LVs on rename
Iustin Pop [Fri, 2 Nov 2007 13:43:29 +0000 (13:43 +0000)]
Update the dev_path on LVs on rename

When renaming a logical volume, we should change the dev_path (and other
internal variables) in order to be consistent.

Reviewed-by: imsnah

16 years agoRevision 302 is broken, this fixes it
Iustin Pop [Fri, 2 Nov 2007 01:10:16 +0000 (01:10 +0000)]
Revision 302 is broken, this fixes it

I forgot a pair of parentheses in that revision which break the common
case. This patch adds them.

Reviewed-by: ultrotter

16 years agoFix printing of unconfigured DRBD devices
Iustin Pop [Thu, 1 Nov 2007 21:40:21 +0000 (21:40 +0000)]
Fix printing of unconfigured DRBD devices

If the device is unconfigured (not yet did SetDiskID for it ever), it
might have a physical_id of None. This patch fixes that case.

Reviewed-by: ultrotter

16 years agoRemove two trailing whitespaces
Guido Trotter [Thu, 1 Nov 2007 17:51:34 +0000 (17:51 +0000)]
Remove two trailing whitespaces

Ok, I've been battling with those for a while but it seems
in the end I forgot to get rid of them! :( Doing it explicitely now.

Reviewed-By: iustinp

16 years agoMove blank lines inside function messages
Guido Trotter [Thu, 1 Nov 2007 17:48:29 +0000 (17:48 +0000)]
Move blank lines inside function messages

This patch changes whitespace only. It fixes all the functions in script/gnt-os
by putting a white line at the end of all the function descriptions and
removing it from just before the code.

Reviewed-By: iustinp

16 years agoAdd empty line after each diagnose OS-Node set
Guido Trotter [Thu, 1 Nov 2007 17:48:07 +0000 (17:48 +0000)]
Add empty line after each diagnose OS-Node set

Reviewed-By: imsnah

16 years agoModify the displayed format for gnt-os diagnose
Guido Trotter [Thu, 1 Nov 2007 17:46:48 +0000 (17:46 +0000)]
Modify the displayed format for gnt-os diagnose

Get rid of the tabulated form and create a simplier indented structure.
Now a valid OS looks something like:

OS: foo [global status: partial valid]
  Node: gsdtest4.euw.corp.google.com, status: valid (path: /usr/local/lib/ganeti/os/foo)
  Node: gsdtest5.euw.corp.google.com, status: valid (path: /usr/local/lib/ganeti/os/foo)
    [hidden] path: /usr/local/lib/ganeti/os2/foo, status: 'ganeti_api_version' file not found (ENOENT)
  Node: gsdtest3.euw.corp.google.com, status: 'ganeti_api_version' file not found (ENOENT) (path: /usr/local/lib/ganeti/os/foo)

Reviewed-By: imsnah

16 years agoChange the way to compute the first os status message
Guido Trotter [Thu, 1 Nov 2007 17:44:52 +0000 (17:44 +0000)]
Change the way to compute the first os status message

Use both _DiagnoseOSStatus and  _DiagnoseOSPath to calculate the message
associated with the first entry found on a node for an OS. Also call the rename
the relevant variables to _msg rather than just _status to reflect that they
contain a bit more than just the bare status message.

Reviewed-By: imsnah

16 years agoSeparate OS status and path
Guido Trotter [Thu, 1 Nov 2007 17:44:28 +0000 (17:44 +0000)]
Separate OS status and path

Make _DiagnoseOSStatus only return a status message for the OS diagnose object
and create a new _DiagnoseOSPath function to get the path out. This will let us
be more flexible in the messages we display to the user.

Reviewed-By: imsnah

16 years agoWhitespace fixes
Iustin Pop [Thu, 1 Nov 2007 17:22:55 +0000 (17:22 +0000)]
Whitespace fixes

Reviewed-by: ultrotter

16 years agoCleanup colouring functions.
Michael Hanselmann [Thu, 1 Nov 2007 14:31:56 +0000 (14:31 +0000)]
Cleanup colouring functions.

Make the code somewhat smaller. Disable disk failure test for master for now.

Reviewed-by: schreiberal

16 years agoCleanup QA scripts.
Michael Hanselmann [Thu, 1 Nov 2007 13:54:42 +0000 (13:54 +0000)]
Cleanup QA scripts.

- Split main() function into several small ones.
- Current work on disk failure tests. This is not yet finished.
- Fix small typo in qa_node.py.

Reviewed-by: schreiberal

16 years agoRevert "Implement multi-failover options"
Iustin Pop [Wed, 31 Oct 2007 20:12:53 +0000 (20:12 +0000)]
Revert "Implement multi-failover options"

This reverts commit 289, as the node failover functionality was already
implemented in gnt-node (as opposed to gnt-instance). My mistake.

Reviewed-by: ultrotter

16 years agoFix usage of OpReplaceDisks.
Michael Hanselmann [Wed, 31 Oct 2007 15:19:18 +0000 (15:19 +0000)]
Fix usage of OpReplaceDisks.

Reviewed-by: iustinp

16 years agoSmall improvements to multi-instance selections
Iustin Pop [Wed, 31 Oct 2007 14:57:05 +0000 (14:57 +0000)]
Small improvements to multi-instance selections

This patch fixes the documentation in a few cases and adds handling of
the situation where no instance is selected due to too restrictive
options given.

Reviewed-by: imsnah

16 years agoImplement multi-failover options
Iustin Pop [Wed, 31 Oct 2007 14:56:44 +0000 (14:56 +0000)]
Implement multi-failover options

This patch adds the same style of multi-instance selection as in
shutdown/startup to the failover subcommand, with the exception that we
cannot failover with --node or --all (it doesn't make sense).

Reviewed-by: imsnah

16 years agoMore sane handling of errors during failover
Iustin Pop [Wed, 31 Oct 2007 14:56:18 +0000 (14:56 +0000)]
More sane handling of errors during failover

Currently we ignore errors on instance shutdown (on the source node)
during instance failover. We should do this only if the user gave a
command line options allowing this, as it's a dangerous thing to do.

This patch fixes this by using the same "--ignore-consistency" option
for deciding whether to continue or abort. It also expands a bit the man
page.

Reviewed-by: imsnah

16 years agoFix bridge checking in instance failover
Iustin Pop [Wed, 31 Oct 2007 14:55:01 +0000 (14:55 +0000)]
Fix bridge checking in instance failover

The current code checks the bridge on the primary node of the instance,
but we need to check it on the destination node.

This was caught by testing failover with a down primary node.

Reviewed-by: imsnah

16 years agoFix _UpdateEtcHosts to understand empty lines.
Michael Hanselmann [Tue, 30 Oct 2007 15:09:57 +0000 (15:09 +0000)]
Fix _UpdateEtcHosts to understand empty lines.

Reviewed-by: schreiberal

16 years agoChange the signature of some methods of mcpu.Processor
Iustin Pop [Mon, 29 Oct 2007 20:09:25 +0000 (20:09 +0000)]
Change the signature of some methods of mcpu.Processor

This patch moves the passing of the feedback_fn argument from the
(Exec|Chain)OpCode to the initialization of the Processor instance.

Reviewed-by: imsnah

16 years agoRemove a redundant assignment
Iustin Pop [Mon, 29 Oct 2007 17:05:41 +0000 (17:05 +0000)]
Remove a redundant assignment

The major is declared in the base class, we do not need to overwrite it.

Reviewed-by: imsnah

16 years agoFix some style issues (whitespace changes only)
Iustin Pop [Mon, 29 Oct 2007 17:05:22 +0000 (17:05 +0000)]
Fix some style issues (whitespace changes only)

Reviewed-by: imsnah

16 years agoFix a non-clear error message
Iustin Pop [Mon, 29 Oct 2007 16:02:35 +0000 (16:02 +0000)]
Fix a non-clear error message

Reviewed-by: imsnah

16 years agoImplement replace-disks for drbd8 devices
Iustin Pop [Mon, 29 Oct 2007 15:49:36 +0000 (15:49 +0000)]
Implement replace-disks for drbd8 devices

This patch adds three modes of disk replacement for drbd8:
  - replace the disk on the primary node
  - replace the disk on the secondary node
  - replace the secondary node

It also adds some debugging code to backend.py and increments the
protocol version for the recent changes of the rpc layer.

Reviewed-by: imsnah

16 years agoAllow drbd8 devices to work without local storage
Iustin Pop [Mon, 29 Oct 2007 15:47:23 +0000 (15:47 +0000)]
Allow drbd8 devices to work without local storage

This patch adds functionality to drbd8 for:
  - removing local storage
  - initializing without local storage
  - adding local storage

This is needed for the being able to replace disks for drbd8.

Reviewed-by: imsnah

16 years agoImplement block device renaming
Iustin Pop [Mon, 29 Oct 2007 15:44:32 +0000 (15:44 +0000)]
Implement block device renaming

This patch add code for renaming a device; more precisely, for changing
the unique_id of the device. This means:
  - logical volumes, rename the volume
  - drbd8, change the remote peer

This is needed for the being able to replace disks for drbd8.

Reviewed-by: imsnah

16 years agoConvert ListOS to use the all helper function.
Guido Trotter [Mon, 29 Oct 2007 15:20:29 +0000 (15:20 +0000)]
Convert ListOS to use the all helper function.

The predicate function gets build by a lambda function.
Also add a bit of debugging information to the 'unknown OS diagnose type'.

Reviewed-by: iustinp

16 years agoImport two itertools recipes
Guido Trotter [Sun, 28 Oct 2007 14:32:25 +0000 (14:32 +0000)]
Import two itertools recipes

The two function 'any' and 'all' are copied as-is from the python 2.4
documentation for the itertools module. They are useful (and are already
builtin function in python 2.5).

Reviewed-by: iustinp

16 years agoAdd a custom str() method for objects.Disk
Iustin Pop [Fri, 26 Oct 2007 10:25:18 +0000 (10:25 +0000)]
Add a custom str() method for objects.Disk

This is done in order to easy debugging of disk-related issues.

Reviewed-by: imsnah

16 years agoModify two mirror-device related rpc calls
Iustin Pop [Thu, 25 Oct 2007 11:22:39 +0000 (11:22 +0000)]
Modify two mirror-device related rpc calls

The two calls mirror_addchild and mirror_removechild take only one child
for addition/removal. While this is enough for our md usage, for local
disk replacement in drbd8, we need to be able to specify both the data
and metadata device. This patch modifies these two rpc calls (and their
backend implementation and their usage in cmdlib) to take a list of
children to add/remove.

Reviewed-by: imsnah

16 years agoInitial implementation of drbd8 template type
Iustin Pop [Wed, 24 Oct 2007 14:43:24 +0000 (14:43 +0000)]
Initial implementation of drbd8 template type

This is a partially working drbd8 template type. It does:
  - add/remove
  - startup/failover/shutdown

Not working is replace disks, which needs custom code for this template.

Reviewed-by: imsnah

16 years agoAllow DRBD8 to sync after sb1-pri with no changes
Iustin Pop [Wed, 24 Oct 2007 14:41:54 +0000 (14:41 +0000)]
Allow DRBD8 to sync after sb1-pri with no changes

Currently the way we shutdown or startup disks seems to make DRBD8
unhappy. Until we rewrite the sequence of (de)activation, allow DRBD to
connect after a sb1-pri condition with no changes to the data.

Reviewed-by: imsnah

16 years agoFix a disk handling bug triggered by failover
Iustin Pop [Wed, 24 Oct 2007 14:23:41 +0000 (14:23 +0000)]
Fix a disk handling bug triggered by failover

This leaves an instance's disks configured for the primary node as after
disk activation we want to start the instance anyway. As such,
_GatherBlockDevs in backend.py will need the disks configured for the
primary.

Reviewed-by: imsnah

16 years agoAdd DRBD8 class for handling drbd version 8.x
Iustin Pop [Wed, 24 Oct 2007 13:30:40 +0000 (13:30 +0000)]
Add DRBD8 class for handling drbd version 8.x

This duplicates some code from the DRBDev class, but not very much, and
it will be expanded with the new functionality available for the 8.x
version. Currently the code is not accessible outside the module.

This patch introduces a dependency on the pyparsing module.

Reviewed-by: imsnah

16 years agoMove/rename _IsValidMeta to base drbd class
Iustin Pop [Wed, 24 Oct 2007 13:30:17 +0000 (13:30 +0000)]
Move/rename _IsValidMeta to base drbd class

The DRBDev._IsValidMeta only checks for the metadata device size. Since
this is a useful check (but not complete) for DRBD8, move it to the base
class and name it _CheckMetaSize.

Reviewed-by: imsnah

16 years agoMore abstractions from DRBD7 to base class
Iustin Pop [Wed, 24 Oct 2007 13:24:20 +0000 (13:24 +0000)]
More abstractions from DRBD7 to base class

This moves the _SetFromMinor and _MassageProcData to the base class.

Reviewed-by: imsnah

16 years agoImprove out-of-minors handling
Iustin Pop [Wed, 24 Oct 2007 13:24:02 +0000 (13:24 +0000)]
Improve out-of-minors handling

Currently, the out-of-minors handling is not very good: though both MD
and DRBD functions for finding an unused minor can return None, only the
DRBD code checks for this case.

This patch improves this by making the functions _FindUnusedMinor raise
an error instead of None, and gets rid of the one manual check for the
return value.

Reviewed-by: imsnah

16 years agoMove some methods from DRBDev to BaseDRBD
Iustin Pop [Wed, 24 Oct 2007 13:23:35 +0000 (13:23 +0000)]
Move some methods from DRBDev to BaseDRBD

Since some of the methods and constants are valid for both 0.7 and 8.x
versions, we move them to the base class.

Reviewed-by: imsnah

16 years agoSome tiny style fixes
Iustin Pop [Fri, 19 Oct 2007 11:49:19 +0000 (11:49 +0000)]
Some tiny style fixes

Reviewed-by: imsnah

16 years agoSplit some DRBD functionality based on versions
Iustin Pop [Fri, 19 Oct 2007 11:48:17 +0000 (11:48 +0000)]
Split some DRBD functionality based on versions

This is a small split of some functionality from the DRBDev class into a
base drbd class that holds just a few things, in order to make migration
to drbd 8.x easier.

Reviewed-by: imsnah

16 years agoAbstract more strings values into constants
Iustin Pop [Fri, 19 Oct 2007 11:48:00 +0000 (11:48 +0000)]
Abstract more strings values into constants

Currently, the disk types are defined using constants in the code.
Convert those into constants so that we can easily find them and check
their usage.

Note that we don't rename the values of the constants as they are used
in the configuration file, and as such it's best to leave them as they
are.

Reviewed-by: imsnah

16 years agoImplement disk failure QA test.
Michael Hanselmann [Thu, 18 Oct 2007 13:02:03 +0000 (13:02 +0000)]
Implement disk failure QA test.

Testing failure on the primary node is currently disabled due to drbd problems.

Reviewed-by: iustinp

16 years agoPatch series for reboot feature, part 3
Alexander Schreiber [Thu, 18 Oct 2007 10:26:34 +0000 (10:26 +0000)]
Patch series for reboot feature, part 3

This patch series implements the reboot command for gnt-instance. It
supports three types of reboot: soft (hypervisor reboot), hard (instance
config rebuild and reboot) and full (full instance shutdown and startup
again).

This patch contains the gnt-instance script and the man page for it.

Reviewed-by: iustinp

16 years agoPatch series for reboot feature, part 2
Alexander Schreiber [Thu, 18 Oct 2007 10:25:50 +0000 (10:25 +0000)]
Patch series for reboot feature, part 2

This patch series implements the reboot command for gnt-instance. It
supports three types of reboot: soft (hypervisor reboot), hard (instance
config rebuild and reboot) and full (full instance shutdown and startup
again).

This patch contains the opcode and lu part.

Reviewed-by: iustinp

16 years agoPatch series for reboot feature, part 1
Alexander Schreiber [Wed, 17 Oct 2007 15:00:59 +0000 (15:00 +0000)]
Patch series for reboot feature, part 1

This patch series implements the reboot command for gnt-instance. It
supports three types of reboot: soft (hypervisor reboot), hard (instance
config rebuild and reboot) and full (full instance shutdown and startup
again).

This patch contains the backend and rpc part of the patch.

Reviewed-by: iustinp

16 years agoFix unit tests for hooks.
Alexander Schreiber [Wed, 17 Oct 2007 14:36:02 +0000 (14:36 +0000)]
Fix unit tests for hooks.

Reviewed-by: imsnah

16 years agoMake “gnt-cluster verify” exit 0 if there's no problem with instances.
Michael Hanselmann [Tue, 16 Oct 2007 15:27:07 +0000 (15:27 +0000)]
Make “gnt-cluster verify” exit 0 if there's no problem with instances.

Reviewed-by: schreiberal

16 years agotiny typing fixup
Alexander Schreiber [Tue, 16 Oct 2007 14:45:32 +0000 (14:45 +0000)]
tiny typing fixup

Reviewed-by: imsnah

16 years agoAdd the number of VCPUs in gnt-instance info
Iustin Pop [Tue, 16 Oct 2007 14:30:24 +0000 (14:30 +0000)]
Add the number of VCPUs in gnt-instance info

Reviewed-by: imsnah

16 years agoAllow force removal of instances
Iustin Pop [Tue, 16 Oct 2007 13:51:51 +0000 (13:51 +0000)]
Allow force removal of instances

This patch adds a new option to the instance removal command
"--ignore-failures" that forces the removal of the instance from the
configuration even if the removal process encounters errors.

In order to be able to do this when the remote node(s) is(are) down, we
need to restrict the execution of the instance removal hook to the
master only. I think this is a reasonable trade-off (but I'm not sure).

Reviewed-by: imsnah

16 years agoReplace more ssh paths with proper constants
Iustin Pop [Tue, 16 Oct 2007 08:28:26 +0000 (08:28 +0000)]
Replace more ssh paths with proper constants

The node's ssh keys filenames are now provided as constants; this should
allow easier customization.

Also, the user's ssh key computing has been abstracted into ssh.py

Reviewed-by: imsnah

16 years agoTrivial typing fixups.
Alexander Schreiber [Mon, 15 Oct 2007 13:06:15 +0000 (13:06 +0000)]
Trivial typing fixups.

Reviewed-by: iustinp

16 years agoFix node daemon log file permissions
Iustin Pop [Mon, 15 Oct 2007 13:04:35 +0000 (13:04 +0000)]
Fix node daemon log file permissions

The creation of the log file for the node daemon lacks the mode
parameter, so after applying the current umask, the file got 0700
permissions. Restrict this to the correct 0600.

Reviewed-by: schreiberal

16 years agoDo QA tests on “gnt-os“, including partially valid OSes.
Michael Hanselmann [Mon, 15 Oct 2007 12:16:17 +0000 (12:16 +0000)]
Do QA tests on “gnt-os“, including partially valid OSes.

Reviewed-by: iustinp

16 years agoDon't take unused parameter in qa_utils.py:Print{Info,Error}.
Michael Hanselmann [Mon, 15 Oct 2007 12:08:43 +0000 (12:08 +0000)]
Don't take unused parameter in qa_utils.py:Print{Info,Error}.

Reviewed-by: iustinp

16 years agoMake “gnt-os diagnose” exit 1 if not all OSes are valid.
Michael Hanselmann [Mon, 15 Oct 2007 11:45:13 +0000 (11:45 +0000)]
Make “gnt-os diagnose” exit 1 if not all OSes are valid.

Reviewed-by: iustinp

16 years agoSmall wording changes and fix checks.
Michael Hanselmann [Fri, 12 Oct 2007 15:41:12 +0000 (15:41 +0000)]
Small wording changes and fix checks.

Reviewed-by: iustinp

16 years agoRemove some hardcoded names/paths from backend.py
Iustin Pop [Fri, 12 Oct 2007 14:53:16 +0000 (14:53 +0000)]
Remove some hardcoded names/paths from backend.py

This patch does the following:
  - add constants.GANETI_RUNAS = "root", which is used to compute
    the homedir (and thus the .ssh directory) instead of hardcoding
    "/root/.ssh" in backend.AddNode and backend.LeaveCluster
  - add constants.SSH_CONFIG_DIR (currently hardcoded to /etc/ssh) that
    is used in backend instead of hardcoding it (preparation for
    selecting that at ./configure time)
  - some more internal cleanup in backend.AddNode

Reviewed-by: imsnah

16 years agoTest “gnt-node evacuate” and “gnt-node failover” in QA.
Michael Hanselmann [Fri, 12 Oct 2007 14:33:26 +0000 (14:33 +0000)]
Test “gnt-node evacuate” and “gnt-node failover” in QA.

Reviewed-by: schreiberal

16 years agoAdd a generic write file function
Iustin Pop [Fri, 12 Oct 2007 13:02:15 +0000 (13:02 +0000)]
Add a generic write file function

Currently there are a few version of "write a file safely" in the code.
This patch adds a generic function that should be able to replace all
the other versions.

The "take attributes from the target file" option, while useful, is not
implemented by this patch.

Reviewed-by: imsnah,ultrotter

16 years agoDo not walk the whole DATA_DIR on node leave
Iustin Pop [Fri, 12 Oct 2007 12:30:42 +0000 (12:30 +0000)]
Do not walk the whole DATA_DIR on node leave

Since we remove only files from DATA_DIR and not from subdirectories,
let's not walk the entire tree, a simple listdir suffices. Also switch
to utils.RemoveFile from simple os.unlink.

Reviewed-by: imsnah

16 years agoEnhance GetHomeDir to accept either names or UIDs
Iustin Pop [Fri, 12 Oct 2007 12:27:11 +0000 (12:27 +0000)]
Enhance GetHomeDir to accept either names or UIDs

Currently GetHomeDir accepts UIDs only. Enhance it to accept either a
user name or a user id, to allow for nicer usage.

Reviewed-by: imsnah

16 years agoReorder gnt-os simplify _GetAllOS and call it _DiagnoseByOS
Guido Trotter [Fri, 12 Oct 2007 12:26:30 +0000 (12:26 +0000)]
Reorder gnt-os simplify _GetAllOS and call it _DiagnoseByOS

Put some order in gnt-os putting helper functions above and command functions
below. Also add a new _DiagnoseOSName() function and use it to make _GetAllOS
simplier to understand. Change its name to _DiagnoseByOS which makes more clear
what it does.

Reviewed-by: iustinp

16 years agoFix ListOS which was broken
Guido Trotter [Fri, 12 Oct 2007 11:19:15 +0000 (11:19 +0000)]
Fix ListOS which was broken

To do this we abstract the creation of the all_os dictionary, which was
produced in DiagnoseOS and use it both for listing and diagnosing.

Reviewed-by: iustinp

16 years agoSome small improvements to the hooks environment
Iustin Pop [Thu, 11 Oct 2007 15:23:31 +0000 (15:23 +0000)]
Some small improvements to the hooks environment

For the configuration update hook, it's useful to have a consistent name
for the target of the operation. As such, the LU code is modified to
include an GANETI_OP_TARGET that points either to the cluster (name),
node name or instance name depending on the opcode.

Also, the NoHooksLU is modified such that its build env method returns
an empty (but conformant) result. This should improve things in case by
mistake this class' BuildHooksEnv is called.

Reviewed-by: imsnah