ganeti-local
15 years agoLUCreateInstance: the node list as return value
Iustin Pop [Fri, 19 Jun 2009 12:27:44 +0000 (14:27 +0200)]
LUCreateInstance: the node list as return value

Currently LUCreateInstance has no result; this patch changes it so that
both the normal result and the dry-run result is the node list of the
selected instance.

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

15 years agoImplement dry-run mode at cli level (partially)
Iustin Pop [Fri, 19 Jun 2009 12:24:42 +0000 (14:24 +0200)]
Implement dry-run mode at cli level (partially)

This patch adds support for the dry-run mode for all command line
operations, and also makes use of this for commands using the
SubmitOrSend function. For the ones not using it, the flag has no
effect (future patches).

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

15 years agoLU execution: implement dry-run framework
Iustin Pop [Fri, 19 Jun 2009 12:09:19 +0000 (14:09 +0200)]
LU execution: implement dry-run framework

This patch adds a new (global) opcode flag 'dry_run' which, when True,
causes early exit from the LU workflow, returning a special value from
the LU object (initialized in the parent LogicalUnit class, and which if
not overriden from child LUs will be None).

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

15 years agoIntroduce __slots__ deriving in opcodes.py
Iustin Pop [Fri, 19 Jun 2009 11:58:38 +0000 (13:58 +0200)]
Introduce __slots__ deriving in opcodes.py

This simple patch adds to all opcodes extension of the base opcode
__slots__. This way we can add slots across all opcodes, for example
'dry-run'.

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

15 years agoFix some small epydoc warnings
Iustin Pop [Fri, 19 Jun 2009 10:36:18 +0000 (12:36 +0200)]
Fix some small epydoc warnings

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

15 years agognt-instance(8) one more batch-create update
Guido Trotter [Thu, 18 Jun 2009 13:34:51 +0000 (14:34 +0100)]
gnt-instance(8) one more batch-create update

Document the new nics list, as an alternative to the one nick which you
can create with the old mac, ip, mode, link/bridge keys.

Also specify that 'bridge' is still accepted as well.

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

15 years agoUpdate gnt-instance batch-create for NIC params
Guido Trotter [Tue, 16 Jun 2009 16:57:21 +0000 (17:57 +0100)]
Update gnt-instance batch-create for NIC params

This is compatible with the previous version, but also allows specifying
more than one nic, by giving a "nics" list of dicts. The two methods
(individual fields for the first nic, and list of all nics) are
incompatible with each other.

The default remains one nick with no parameters specified.

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

15 years agoFix various pylint warnings
Iustin Pop [Thu, 18 Jun 2009 10:11:10 +0000 (12:11 +0200)]
Fix various pylint warnings

There were multiple issues:
  - copy-paste resulted in wrong indentation
  - wrong function name
  - missing spaces around assignment
  - overriding built-in names (type, dir) or already defines ones
    (errors, hypervisor)

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

15 years agoDocument iallocator proposed improvements
Iustin Pop [Thu, 18 Jun 2009 09:41:08 +0000 (11:41 +0200)]
Document iallocator proposed improvements

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

15 years agoRAPI: move to nic parameters
Guido Trotter [Tue, 16 Jun 2009 14:40:22 +0000 (15:40 +0100)]
RAPI: move to nic parameters

In query we ask for nic.links, rather than nic.bridges
In create we accept both "link" and "bridge" and let the opcode deal
with it. Note that we still can create only one nic per instance.

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

15 years agoUpdate manpages for NIC parameters
Guido Trotter [Tue, 16 Jun 2009 10:42:47 +0000 (11:42 +0100)]
Update manpages for NIC parameters

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

15 years agoUpdate a forgot docstring for nic parameters
Guido Trotter [Tue, 16 Jun 2009 16:43:21 +0000 (17:43 +0100)]
Update a forgot docstring for nic parameters

Properly document the expected nic format.

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

15 years agoFix QueryInstanceData for nic parameters
Guido Trotter [Tue, 16 Jun 2009 16:44:31 +0000 (17:44 +0100)]
Fix QueryInstanceData for nic parameters

This CL updates QueryInstanceData to return NICs in the new format (mac,
ip, mode, link) and fixes gnt-instance info to properly display them.

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

15 years agoUpdate instance query for NIC parameters
Guido Trotter [Tue, 16 Jun 2009 14:23:32 +0000 (15:23 +0100)]
Update instance query for NIC parameters

Compatibility with the old parameters is maintained, by allowing to
query for "bridge" "nic.bridges" and "nic.bridge/N", but None is
returned in that case for routed nics.

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

15 years agoRename _PreBuildNICHooksList to _NICListToTuple
Guido Trotter [Wed, 17 Jun 2009 10:59:09 +0000 (11:59 +0100)]
Rename _PreBuildNICHooksList to _NICListToTuple

We're going to use this helper function for more than just hooks, so
we'll give it a more generic name.

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

15 years agoMerge branch 'next' into branch-2.1
Guido Trotter [Tue, 16 Jun 2009 15:25:56 +0000 (16:25 +0100)]
Merge branch 'next' into branch-2.1

* next:
  gnt-cluster(8) fix --backend-parameters opt name
  LUQueryInstances: fix querying for nic data
  Specify the object type in two docstring

15 years agognt-cluster(8) fix --backend-parameters opt name
Guido Trotter [Tue, 16 Jun 2009 15:23:27 +0000 (16:23 +0100)]
gnt-cluster(8) fix --backend-parameters opt name

It was mistakenly called --backend

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

15 years agoLUQueryInstances: fix querying for nic data
Guido Trotter [Tue, 16 Jun 2009 14:47:25 +0000 (15:47 +0100)]
LUQueryInstances: fix querying for nic data

Currently we support querying for "mac" "ip" or "bridge", meaning "the
one of the first nic. We are not checking that there is a first nic,
though, and thus could incur in errors. This patch fixes it by returning
"None" should there be no such nic, as it's done when explicitely asking
for a nic via nic.<field>/<N>

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

15 years agoSpecify the object type in two docstring
Guido Trotter [Tue, 16 Jun 2009 14:22:23 +0000 (15:22 +0100)]
Specify the object type in two docstring

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

15 years agoKVMHypervisor, fix a bug in MigrateInstance
Guido Trotter [Tue, 16 Jun 2009 12:35:41 +0000 (13:35 +0100)]
KVMHypervisor, fix a bug in MigrateInstance

This was introduced as a typo in commit
7e66c35b5685525538dd65dd3dff75b5346d30d7 while removing duplicate code
from the KVM hypervisor.

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

15 years agoFix backend.{Start,Stop}Master
Guido Trotter [Tue, 16 Jun 2009 12:27:29 +0000 (13:27 +0100)]
Fix backend.{Start,Stop}Master

Commit c26a6bd21c17641f718369caed88ae16947fa774 changed GetMasterInfo
not to return a tuple anymore, but didn't update its two callers in
backend.py, which were trying to extract the values from the second
tuple element. This causes a stack trace in node-daemon.log.

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

15 years agoMerge branch 'next' into branch-2.1
Guido Trotter [Tue, 16 Jun 2009 11:28:25 +0000 (12:28 +0100)]
Merge branch 'next' into branch-2.1

* next: (22 commits)
  Update NEWS and version for 2.0.1 release
  gnt-{instance,backup}(8) --nic is actually --net
  Fix a wrong function name in backend.DrbdAttachNet
  GNT-CLUSTER(8) fix search-tags example
  Enable stripped LVs
  Add a lvm stripecount configure parameter
  Add more constants for DRBD and change sync tests
  Wait for a while in failed resyncs
  Assemble DRBD using the known size
  Fix two issues with exports and snapshot errors
  Set the size on new DRBDs in replace secondary
  Change the bdev init signatures
  Release 2.0.0 final
  watcher: automatically restart noded/rapi
  watcher: handle full and drained queue cases
  rapi: rework error handling
  Fix backend.OSEnvironment be/hv parameters
  rapi: make tags query not use jobs
  Change failover instance when instance is stopped
  Export more instance information in hooks
  ...

Conflicts:

lib/cmdlib.py
test/ganeti.utils_unittest.py

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

15 years agoMerge branch 'master' into next
Guido Trotter [Tue, 16 Jun 2009 11:25:35 +0000 (12:25 +0100)]
Merge branch 'master' into next

* master:
  Update NEWS and version for 2.0.1 release
  gnt-{instance,backup}(8) --nic is actually --net
  Fix a wrong function name in backend.DrbdAttachNet
  GNT-CLUSTER(8) fix search-tags example

15 years agoUpdate NEWS and version for 2.0.1 release v2.0.1
Iustin Pop [Tue, 16 Jun 2009 09:14:55 +0000 (11:14 +0200)]
Update NEWS and version for 2.0.1 release

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

15 years agognt-{instance,backup}(8) --nic is actually --net
Guido Trotter [Tue, 16 Jun 2009 10:44:34 +0000 (11:44 +0100)]
gnt-{instance,backup}(8) --nic is actually --net

Fix a typo in the man pages that used the wrong option name.

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

15 years agoFix hooks unittests after RPC result changes
Iustin Pop [Mon, 15 Jun 2009 17:25:29 +0000 (19:25 +0200)]
Fix hooks unittests after RPC result changes

Patch "Simplify the RPC result framework in backend.py" changed all
RPCs, and thus the hooks results where also changed. This needs changes
to the hooks unittests too.

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

15 years agoSmall whitespace change
Iustin Pop [Thu, 11 Jun 2009 14:32:16 +0000 (16:32 +0200)]
Small whitespace change

Some indentation was wrong, and pylint rightfully complained.

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

15 years agoSimplify RPC call result check in cmdlib.py
Iustin Pop [Thu, 11 Jun 2009 14:14:45 +0000 (16:14 +0200)]
Simplify RPC call result check in cmdlib.py

Now that all results are the same, we can even more simplify the
handling in cmdlib more. Almost all if result.RemoteFailMsg()…
constructs are similar, and we resurect the RpcResult.Raise() function
to take a message argument, which it will process and raise an
appropriate exception.

This means a significant reduce in boilerplate code. Only the cases
which handle the error specially (e.g. by warning only) need to touch
directly the failure message, which was renamed on the RpcResult object
for more clarity.

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

15 years agoSimplify the RPC result framework in backend.py
Iustin Pop [Thu, 11 Jun 2009 13:18:44 +0000 (15:18 +0200)]
Simplify the RPC result framework in backend.py

Since now all functions fail via _Fail, the return True, … is redundant
as all normal return paths have it, and thus the True value can be added
in the ganeti-noded handler.

This means that all functions can now forget about the special result
type, and instead return normally, but signal all failures via _Fail().

Only a few functions must be handled specially (the recursive ones).

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

15 years agoConvert all backend function to exception
Iustin Pop [Thu, 11 Jun 2009 12:39:11 +0000 (14:39 +0200)]
Convert all backend function to exception

Instead of returning (False, msg) from rpc endpoints, we raise always
exceptions (the non-endpoint, internal functions can remain as is). This
means that the error paths are agnostic to how the failure is signalled
(i.e. by False, msg) and instead use only this method (exceptions) to
signal failures.

The patch also adds a log=False argument to _Fail so that trivial cases are not
logged (but usually it's a good idea to log all failures, for the record).

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

15 years agoSimplify usage of backend._FindDisks
Iustin Pop [Thu, 11 Jun 2009 12:37:47 +0000 (14:37 +0200)]
Simplify usage of backend._FindDisks

Since all users of _FindDisks now return new-style results, we can
simply make it raise an exception and not deal with the status field.

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

15 years agoPre-compute error status in RpcResult
Iustin Pop [Thu, 11 Jun 2009 12:24:26 +0000 (14:24 +0200)]
Pre-compute error status in RpcResult

Since now all RPCs have the new style result type, we can pre-compute
the error message at RpcResult() init time and not wait until it's
requested.

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

15 years agoImplement result-type restriction in ganeti-noded
Iustin Pop [Thu, 11 Jun 2009 09:59:57 +0000 (11:59 +0200)]
Implement result-type restriction in ganeti-noded

Since all rpc calls were converted, we can now:
  - enforce result type to (status, data)
  - convert all unhandled exceptions to (False, str(err))

This makes sure that all unhandled errors are reported to rpc users.

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

15 years agoRemove old invalid-os related functionality
Iustin Pop [Thu, 11 Jun 2009 09:55:22 +0000 (11:55 +0200)]
Remove old invalid-os related functionality

We no longer need OS objects to be able to represent invalid OSes. This
cleans up the code handling those cases.

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

15 years agoBig rewrite of the OS-related functions
Iustin Pop [Thu, 11 Jun 2009 09:46:39 +0000 (11:46 +0200)]
Big rewrite of the OS-related functions

Currently the OSes have a special, customized error handling: the OS
object can represent either a valid OS, or an invalid OS. The associated
function, instead of raising other exception or failing, create custom
OS objects representing failed OSes.

While this was good when no other RPC had failure handling, it's
extremely different from how other function in backend.py expect
failures to be signalled.

This patch reworks this completely:
  - the OS object always represents valid OSes (the next patch will
    remove the valid/invalid field and associated constants)
  - the call_os_diagnose returns instead of a list of OS objects, a list
    of (name, path, status, diagnose_msg); the status is then used in
    cmdlib to determine validity and the status and diagnose_msg values
    are used in gnt-os for display
  - call_os_get returns either a valid OS or a RPC remote failure (with
    the error message)
  - the other functions in backend.py now just call backend.OSFromDisk()
    which will return either a valid OS object or raise an exception
  - the bulk of the OSFromDisk was moved to _TryOSFromDisk which returns
    status, value for the functions which don't want an exception raised

The gnt-os list and diagnose commands still work after this patch.

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

15 years agoConvert the jobqueue rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 17:27:48 +0000 (19:27 +0200)]
Convert the jobqueue rpc to new style result

This patch converts the job queue rpc calls to the new style result.
It's done in a single patch as there are helper function (in both jqueue
and backend) that are used by multiple rpcs and need synchronized
change.

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

15 years agoConvert the file storage rpcs to new style result
Iustin Pop [Wed, 10 Jun 2009 17:07:34 +0000 (19:07 +0200)]
Convert the file storage rpcs to new style result

This patch converts all three file-storage rpc (create, delete, rename)
to new style result. This is done in a single patch as they all use a
helper function which itself needs to/can be converted.

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

15 years agoConvert test_delay rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 16:56:37 +0000 (18:56 +0200)]
Convert test_delay rpc to new style result

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

15 years agoConvert iallocator_runner rpc to new result style
Iustin Pop [Wed, 10 Jun 2009 16:28:51 +0000 (18:28 +0200)]
Convert iallocator_runner rpc to new result style

This patch converts this rpc into the new style. Since the function
already had some error handling, we remove this custom error reporting
and replace it with our (new-style) result type. This allows significant
cleaning up of this code.

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

15 years agoConvert hooks_runner rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 16:23:50 +0000 (18:23 +0200)]
Convert hooks_runner rpc to new style result

This also converts (and fixes) unittests and mock objects to deal with
this change, and the custom hook verifier in cmdlib.LUClusterVerify.

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

15 years agoConvert os_diagnose rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 15:17:24 +0000 (17:17 +0200)]
Convert os_diagnose rpc to new style result

This also removes custom post-processing from rpc.py; since this call
has only one user, it was simple to move it back to the caller.

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

15 years agoConvert call_version rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 12:55:04 +0000 (14:55 +0200)]
Convert call_version rpc to new style result

This also cleans up its single use in cmdlib.py.

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

15 years agoConvert write_ssconf_files to new style
Iustin Pop [Wed, 10 Jun 2009 10:47:05 +0000 (12:47 +0200)]
Convert write_ssconf_files to new style

The patch also adds logging of errors from the ConfigWriter in case the
RPC fails (although today we don't have failure modes).

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

15 years agoConvert master_info rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 10:45:02 +0000 (12:45 +0200)]
Convert master_info rpc to new style result

This was more tricky as the backend function is used by other function
in backend.py. As such, it must be handled specially - it must raise
always an exception and not simply return False, err.

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

15 years agoConvert node_volumes rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 10:34:47 +0000 (12:34 +0200)]
Convert node_volumes rpc to new style result

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

15 years agoConver node_leave_cluster rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 10:09:07 +0000 (12:09 +0200)]
Conver node_leave_cluster rpc to new style result

This patch converts this rpc call to the new style result, and also
changes in the process the meaning of the QuitGanetiException's
arguments and the node daemon rpc call exception handler.

The problem with the exception handler is that we used a two-stage one,
and the inner used to catch all exception (including this one), so in
the logs we always had an exception logged, instead of the normal
'leaving cluster message'. The patch also adds logging of the
exception's arguments, so that we have a trail in the logs about the
shutdown mode.

The exception's arguments were reversed from the normal RPC results
style. While it makes somewhat more sense for this exception, we change
them such that they match the rpc result format.

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

15 years agoConvert node_stop_master rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 09:11:56 +0000 (11:11 +0200)]
Convert node_stop_master rpc to new style result

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

15 years agoConvert node_start_master to new style result
Iustin Pop [Wed, 10 Jun 2009 09:08:40 +0000 (11:08 +0200)]
Convert node_start_master to new style result

This is used in multiple places outside cmdlib.py, so it's a more
interesting patch.

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

15 years agoConvert node_verify rpc to new result style
Iustin Pop [Wed, 10 Jun 2009 08:57:50 +0000 (10:57 +0200)]
Convert node_verify rpc to new result style

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

15 years agoRemove utils.CheckDict since it's no longer used
Iustin Pop [Wed, 10 Jun 2009 09:40:55 +0000 (11:40 +0200)]
Remove utils.CheckDict since it's no longer used

Only the custom handling in rpc.py for call_node_info used this, so now
it can be removed.

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

15 years agoConvert node_info rpc to new style result
Iustin Pop [Wed, 10 Jun 2009 08:46:08 +0000 (10:46 +0200)]
Convert node_info rpc to new style result

This patch also does some cleanup and enforces valid results (with
proper type, i.e. int for memory/disk values) from remote node,
otherwise we handle the result as failure.

We do this so that we can remove custom processing in rpc.py which is
very old and doesn't play with the new style result (and has bit me by
modifying the result received from the remote node).

After this change, the node_info rpc becomes a normal one.

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

15 years agoConvert node_has_ip_address rpc to new style
Iustin Pop [Wed, 10 Jun 2009 08:44:51 +0000 (10:44 +0200)]
Convert node_has_ip_address rpc to new style

This should actually have a function in backend, but it's fine for now.

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

15 years agoConvert instance_list rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 15:52:43 +0000 (17:52 +0200)]
Convert instance_list rpc to new style result

Since backend.GetInstanceList() is used both as RPC endpoint and as
internal function, it can't return (status, value). Instead it returns
only valid instance info, and failures are denoted by exceptions; and
the ganeti-noded function adds the (True,) status.

The patch also fixes a typo.

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

15 years agoConvert all_instances_info rpc to new result style
Iustin Pop [Tue, 9 Jun 2009 15:18:29 +0000 (17:18 +0200)]
Convert all_instances_info rpc to new result style

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

15 years agoConvert instance_info rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 14:00:28 +0000 (16:00 +0200)]
Convert instance_info rpc to new style result

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

15 years agoConvert instance_os_import rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 13:32:53 +0000 (15:32 +0200)]
Convert instance_os_import rpc to new style result

This changes from a list of booleans to «status, error messages». This
means that instead knowing which disk has failed (position based), we
get a list of all failures (with details how they failed).

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

15 years agoConvert bridges_exist to new style result
Iustin Pop [Tue, 9 Jun 2009 13:17:39 +0000 (15:17 +0200)]
Convert bridges_exist to new style result

This was a very simple (boolean) RPC, so converting it to actually have
more value with the new style results was more difficult.

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

15 years agoConvert vg_list rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 13:02:44 +0000 (15:02 +0200)]
Convert vg_list rpc to new style result

This doesn't have known failure modes but converting will help later.

We also now call directly utils.ListVolumeGroups() instead of the
backend.ListVolumeGroups() so that we don't have to undo the (status,
value) result type.

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

15 years agoConvert volume_list rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 12:45:49 +0000 (14:45 +0200)]
Convert volume_list rpc to new style result

This is a big change, because we need to cleanup its users too.

The call and thus LUVerifyDisks LU used to differentiate between failure
at node level and failure at LV level, by returning different types in
the RPC result. This is way too complicated for our needs.

The patch changes to new style result (easy change), and then:
  - changes LUVerifyDisks.Exec() to return a tuple of 3-elements
    instead of 4-elements; we collapse the «nodes not reachable» and
    «nodes with LVM errors» in a single dict
  - changes gnt-cluster to parse 3-element results and simplifies the
    different by-error handling code

Note that the status is added in ganeti-noded, and not in the function
itself, as the function is used in other places too.

This was tested with down nodes and broken VGs.

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

15 years agoConvert export_remove rpc to new style
Iustin Pop [Tue, 9 Jun 2009 10:13:02 +0000 (12:13 +0200)]
Convert export_remove rpc to new style

This converts the export_remove rpc to new style result and also fixes
and old TODO by adding exception handling (and conversion to failure).

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

15 years agoConvert export_list rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 10:02:48 +0000 (12:02 +0200)]
Convert export_list rpc to new style result

This is used in multiple places, so it has a little more changes than
the previous ones.

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

15 years agoConvert export_info rpc to new style result
Iustin Pop [Tue, 9 Jun 2009 09:50:00 +0000 (11:50 +0200)]
Convert export_info rpc to new style result

This also removes some code from ganeti-noded and rpc.py, which should
not do such processing of data (and be simply glue code). (Or
alternatively they could, if we had better infrastructure).

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

15 years agoConvert finalize_export rpc to new style results
Iustin Pop [Tue, 9 Jun 2009 09:41:29 +0000 (11:41 +0200)]
Convert finalize_export rpc to new style results

This rpc doesn't have explicit failure modes, but once all RPCs are
converted and we can catch and convert expceptions to failure in noded,
we will have meaningfull error messages.

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

15 years agoConvert snapshot_export rpc to new style
Iustin Pop [Tue, 9 Jun 2009 09:35:56 +0000 (11:35 +0200)]
Convert snapshot_export rpc to new style

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

15 years agoConvert blockdev_snapshot rpc to new result style
Iustin Pop [Tue, 9 Jun 2009 09:25:42 +0000 (11:25 +0200)]
Convert blockdev_snapshot rpc to new result style

This also slightly changes the code in cmdlib that uses it for more
clarity.

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

15 years agoConvert blockdev_getmirrorstatus rpc to new style
Iustin Pop [Tue, 9 Jun 2009 09:10:37 +0000 (11:10 +0200)]
Convert blockdev_getmirrorstatus rpc to new style

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

15 years agoFix a wrong function name in backend.DrbdAttachNet
Iustin Pop [Mon, 15 Jun 2009 08:38:02 +0000 (10:38 +0200)]
Fix a wrong function name in backend.DrbdAttachNet

Commit cf8df3f30c2dcd0ab398d835fa9f64d61578a4f7 "bdev: forward-port
ReAttachNet/DisconnectNet" forward-ported 1.2's bdev.DRBD8.ReAttachNet()
to 2.0 while renaming it to AttachNet(), but commit
6b93ec9d798ed53089a06bc0ced58ef1d8a9e4b0 "Forward-port DrbdNetReconfig"
didn't rename all the calls to it and left one ReAttachNet call in
backend.py.

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

15 years agoIallocator: NIC parameters
Guido Trotter [Wed, 10 Jun 2009 17:32:23 +0000 (18:32 +0100)]
Iallocator: NIC parameters

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

15 years agoXen: NIC parameters
Guido Trotter [Wed, 10 Jun 2009 16:46:47 +0000 (17:46 +0100)]
Xen: NIC parameters

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

15 years agoKVM: NIC parameters
Guido Trotter [Wed, 10 Jun 2009 15:28:36 +0000 (16:28 +0100)]
KVM: NIC parameters

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

15 years agoOSEnvironment: convert to NIC parameters
Guido Trotter [Wed, 10 Jun 2009 13:34:03 +0000 (14:34 +0100)]
OSEnvironment: convert to NIC parameters

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

15 years agorpc: fill in NIC parameters in instances
Guido Trotter [Wed, 10 Jun 2009 13:25:25 +0000 (14:25 +0100)]
rpc: fill in NIC parameters in instances

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

15 years agoRemove bridge and default_bridge from objects
Guido Trotter [Tue, 9 Jun 2009 12:29:40 +0000 (13:29 +0100)]
Remove bridge and default_bridge from objects

These values are deprecated, and not used in 2.1 anymore.
The slots are still there to allow auto-upgrading from 2.0.

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

15 years agoNIC Parameters: fix hooks environment generation
Guido Trotter [Wed, 10 Jun 2009 10:41:29 +0000 (11:41 +0100)]
NIC Parameters: fix hooks environment generation

In order to do that we change the way nics are espected to be passed to
the _BuildInstanceHookEnv function, from (ip, bridge, mac) to (ip, mac,
mode, link).

To translate new nics, which have the ip, mac and nicparams fields to
this new format we add an auxiliary _PreBuildNICHooksList function,
which is called both in _BuildInstanceHookEnvByObject and in
LUCreateInstance, where we don't have an Instance object created yet, at
hooks execution time.

LUSetInstanceParams hooks generation is also changed to provide the
right override to the nics field, should any nics be modified.

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

15 years agoRemove config.GetDefBridge
Guido Trotter [Wed, 10 Jun 2009 09:53:49 +0000 (10:53 +0100)]
Remove config.GetDefBridge

Default bridge is now handled with nic parameters, and this function is
unused.

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

15 years agoQueryClusterInfo: don't show default_bridge
Guido Trotter [Tue, 9 Jun 2009 12:56:26 +0000 (13:56 +0100)]
QueryClusterInfo: don't show default_bridge

Since default_bridge is deprecated, avoid displaying it when querying
for cluster information.

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

15 years agoconfig unittests: use nic params
Guido Trotter [Tue, 9 Jun 2009 13:07:39 +0000 (14:07 +0100)]
config unittests: use nic params

The target test cluster should have nic params, rather than a default
bridge.

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

15 years agoInitCluster: don't set default_bridge
Guido Trotter [Tue, 9 Jun 2009 12:57:26 +0000 (13:57 +0100)]
InitCluster: don't set default_bridge

And remove the -b option, as default nic parameters can be used instead.
We could support the option, but that would add more code, and since
cluster init is not a frequent operation, it's better to keep the code
clean.

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

15 years ago_CheckInstanceBridgesExist: move to NIC parameters
Guido Trotter [Tue, 9 Jun 2009 12:44:02 +0000 (13:44 +0100)]
_CheckInstanceBridgesExist: move to NIC parameters

Rather than checking all bridges, we check all links for bridged nics,
if any. Since this function is now slightly more complex than before,
it's been split into an auxiliary function, and more parameters are
used, so that it can be called from more places, rather than
reimplementing the same code there.

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

15 years agoLUSetInstanceParams: nic parameters
Guido Trotter [Tue, 9 Jun 2009 17:00:24 +0000 (18:00 +0100)]
LUSetInstanceParams: nic parameters

Hooks are dealt with in a later patch in the series.

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

15 years agoLUSetInstanceParams: abstract _GetUpdatedParams
Guido Trotter [Thu, 11 Jun 2009 12:40:28 +0000 (13:40 +0100)]
LUSetInstanceParams: abstract _GetUpdatedParams

There is some duplicated code between hv and be parameters to create the
updated parameters dict. This will need to be done also for nic
parameters, so we abstract this functionality in a function.

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

15 years agoLUSetInstanceParams: save cluster
Guido Trotter [Tue, 9 Jun 2009 16:25:46 +0000 (17:25 +0100)]
LUSetInstanceParams: save cluster

Rather than querying for the cluster multiple times, save it.

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

15 years agoLUCreateInstance: NIC parameters
Guido Trotter [Tue, 9 Jun 2009 12:34:53 +0000 (13:34 +0100)]
LUCreateInstance: NIC parameters

Instance creation is changed to support the new nic parameters.

Hooks are dealt with in a later patch in the series.

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

15 years agoAdd nicparams to the NIC object
Guido Trotter [Tue, 9 Jun 2009 12:25:34 +0000 (13:25 +0100)]
Add nicparams to the NIC object

Also populate nicparams with a sensible default for imported instances.
Unfortunately we don't know if the bridge set up in old nics is the
default one or not, and we don't have access to the config cluster
object here to verify, so we'll just copy it without questions.

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

15 years agoGNT-CLUSTER(8) fix search-tags example
Guido Trotter [Thu, 11 Jun 2009 14:32:36 +0000 (15:32 +0100)]
GNT-CLUSTER(8) fix search-tags example

Reported in issue 59.

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

15 years agoFix gnt-instance reinstall
Iustin Pop [Wed, 10 Jun 2009 15:37:51 +0000 (17:37 +0200)]
Fix gnt-instance reinstall

Commit 55efe6dabe48e5c37dc1ff6099e0bb8afde7a468 "Convert instance
reinstall to multi instance model" actually broke instance reinstall for
single-instance cases. This one-liner fixes it.

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

15 years agoFix ConfigWriter._DistributeConfig error handling
Iustin Pop [Wed, 10 Jun 2009 10:53:18 +0000 (12:53 +0200)]
Fix ConfigWriter._DistributeConfig error handling

Commit 1b54fc6c2fd92b614c029cc5312d02f9f1526253 added a typo (due to
copy-paste) in the error handling path of this function.

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

15 years agoFix node add and RedistributeAncillaryFiles
Iustin Pop [Wed, 10 Jun 2009 09:48:47 +0000 (11:48 +0200)]
Fix node add and RedistributeAncillaryFiles

Commit 28eddce5249f35c2c330a04da07b74950877dcf5 added the
RedistributeAncillaryFiles, but it calls it with a wrong parameter and thus
makes node add fail.

This one-liner fixes it.

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

15 years agorpc: Add a simple failure reporting framework
Iustin Pop [Mon, 8 Jun 2009 16:38:00 +0000 (18:38 +0200)]
rpc: Add a simple failure reporting framework

This patch adds a simple failure reporting tool, similar to bdev's
_ThrowError. In backend, we move towards the new-style RPC results (of
type (status, payload)) and thus functions which use this style can very
easily log and return the error message using this new function.

The exception is declared here and not in errors.py since it's local to
the node-daemon/backend combination.

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

15 years agoShow nic parameters in cluster info
Guido Trotter [Mon, 8 Jun 2009 13:09:00 +0000 (14:09 +0100)]
Show nic parameters in cluster info

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

15 years agoAllow modifying of default nic parameters
Guido Trotter [Fri, 5 Jun 2009 15:09:11 +0000 (16:09 +0100)]
Allow modifying of default nic parameters

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

15 years agoAllow setting NIC parameters at gnt-cluster init
Guido Trotter [Fri, 5 Jun 2009 15:08:23 +0000 (16:08 +0100)]
Allow setting NIC parameters at gnt-cluster init

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

15 years agognt-cluster init, simplify parameter checks
Guido Trotter [Fri, 5 Jun 2009 15:04:45 +0000 (16:04 +0100)]
gnt-cluster init, simplify parameter checks

Don't check for non-existant BE parameters, ForceDictType will do it
Use utils.FillDict to populate the defaults

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

15 years agoCluster: add nicparams, and update them on upgrade
Guido Trotter [Mon, 8 Jun 2009 10:32:51 +0000 (11:32 +0100)]
Cluster: add nicparams, and update them on upgrade

This also migrates the default bridge from the cluster object to the nic
params, at load time. Since we don't support changing the default bridge
after cluster init, this is ok for now. In the future we'll make
gnt-cluster init --bridge to the right thing, after the nic parameter
implementation is finished.

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

15 years agoAdd NIC.CheckParameterSyntax
Guido Trotter [Mon, 8 Jun 2009 11:36:14 +0000 (12:36 +0100)]
Add NIC.CheckParameterSyntax

This function will be used to check the NIC parameters for validity.
Unittests are included.

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

15 years agonic parameters: constants
Guido Trotter [Fri, 5 Jun 2009 14:38:38 +0000 (15:38 +0100)]
nic parameters: constants

Introducing the constants used for implementing nic parameters in
Ganeti, according to the 2.1 design.

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

15 years agoAbstract Param upgrade from cluster.UpgradeConfig
Guido Trotter [Mon, 8 Jun 2009 10:27:26 +0000 (11:27 +0100)]
Abstract Param upgrade from cluster.UpgradeConfig

A new UpgradeGroupedParams is used to upgrade all the profiles for one
parameter filling in the default values, or creating the whole dict
anew, should it be missing. This is used only for beparams, currently,
but will be used at least for nicparams and diskparams as well.

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

15 years agoChange BEGR_DEFAULT to PP_DEFAULT
Guido Trotter [Mon, 8 Jun 2009 09:58:59 +0000 (10:58 +0100)]
Change BEGR_DEFAULT to PP_DEFAULT

This way the same constant can represent the default profile also for
nic, disk and OS parameters.

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

15 years agoMove FillDict at module level
Guido Trotter [Fri, 5 Jun 2009 14:57:22 +0000 (15:57 +0100)]
Move FillDict at module level

This way it can be also used by scripts and other object types.

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

15 years agoFix a typo in InitCluster
Guido Trotter [Mon, 8 Jun 2009 13:23:52 +0000 (14:23 +0100)]
Fix a typo in InitCluster

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