A few style fixes
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Luca Bigliardi <shammash@google.com>
Add RAPI resource to redistribute config
Add simple unittest for remote API docs
rapi doc: Add …/nodes/[name] and …/instances/[name]/reinstall
Add simple unittest for hooks documentation
Update hooks documentation
Move LoadModule function to utils
It can be used by unittests for daemons/* or scripts/*.
utils.CalculateDirectorySize: Don't redefine builtin
Use ReadFile/WriteFile in more places
This survived QA, burnin and unittests.
Makefile: add IPsec hook
Enable creation and dist for IPsec hook.
Signed-off-by: Luca Bigliardi <shammash@google.com>
Example IPsec hook
This hook is a simple example which automatically configures a basic IPsec linkamong all the nodes of a cluster.
gnt-cluster watcher: Show more information
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
confd: add cluster master query
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
confd/querylib: fix docstrings
They were cut&paste from the first example queries, rather thandocumenting the current ones.
confd: avoid spamming the logfile
When confd is disabled we don't want to be noticed every timer interval.
Remove SimpleConfigReader.GetHypervisorType
We haven't had that config file entry for a while.
Merge commit 'origin/next' into branch-2.1
Conflicts: lib/cmdlib.py: Trivial
Replace BINDIR variable as well
Add bindir to the list of variables replaced at make time.
Signed-off-by: Luca Bigliardi <shammash@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
Return cluster tags from LUQueryClusterInfo
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Olivier Tharan <olive@google.com>
devel/upload: Build in parallel
Merge branch 'next' into branch-2.1
Add more bash completion metadata for options
Bash completion: Implement dynamic option value completion
Bash completion: Add function to get all iallocators
Bash completion: Simplify option completion
This makes the output file quite a bit smaller and is neededin preparation for non-static option completion (e.g. list ofnodes).
Bash completion: Support for --foo=bar option format
That is with the equal sign.
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Bash completion: Small optimizations
$2 doesn't contain the correct value when completing something like"--disk-template=…". Getting it via COMP_WORDS is better.
Short options (e.g. -I) can't have an equal sign.
Also add useful debugging commands for development....
Fix QA test for “gnt-node evacuate”
Before the arguments weren't valid.
Move SimpleConfigReader creation to ConfdProcessor
This will be useful to make ConfdProcessor aware of a config failure,without quitting confd.
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
ConfdProcessor: add disabled state
This is a state the processor will get in, if it fails to load theconfig.
confd: start in polling mode
This allows us not to enable the inotify handler immediately, and thusto make it easier for us should the config file not exist at all.
Confd: don't fail if the config doesn't load
Rather than quitting we'll just continue to poll the config at a slowrate, hoping that sooner or later we'll get it back. This allows alsoworking on non-MC nodes, and smoothly transitioning from MC to non-MC,...
confd: s/confd_event_handler/inotify_handler/
In a case we don't encounter frequently (file modified but notoverwritten) the notify handler we use is called with a wrong name.
Add script to clean archived jobs after 21 days
Implement timers in confd
Timers are used both for checking for inotify failures, and for polling,should inotify notices become too frequent.
constants: add confd reload and rate limit times
ConfdInotifyEventHandler.enable: use InotifyError
Rather than raising ConfdFatalError directlyConfdInotifyEventHandler.enable raises InotifyError should it not beable to configure inotify, allowing the caller to decide what to do.
Signed-off-by: Guido Trotter <ultrotter@google.com>...
Add errors.InotifyError
ConfdInotifyEventHandler, move to a callback
ConfdInotifyEventHandler used to reload the config whenever anotification arrived. Moving to a callback system, so thatConfdConfigurationReloader can be responsible for that functionality.
Additionally the inotify class no longer reenables itself automatically,...
Move creation of inotify handler to a new class
This class will be responsible for managing inotify notifications,timers, and rate-limiting reloads. For now none of these features isimplemented. :)
ConfdInotifyEventHandler: add enable/disable
Make possible to enable and disable the inotify event handler. Theinotify handler will remain enabled, unless explicitely told to disableitself.
SimpleConfigReader: handle stat() errors
Also, catch EnvironmentError, rather than IOError, when trying to readthe file.
Encode the actual exception raised by LU execution
Currently, the actual exception raised during an LU execution (one ofOpPrereqError, OpExecError, HooksError, etc.) is lost because thejqueue.py code simply sets that to a str(err), and the code in cli.py...
Move the luxi error handling into errors.py
Currently the luxi error handling is hardcoded as special encoding onthe masterd-side and special decoding on the client side. This patchmoves it to errors.py such that other parts of the code can reuse thesame encoding....
Remove watcher pause file 1h past end time
ganeti-watcher: Don't run if paused
gnt-cluster: Add CLI for watcher pause
Add file to pause watcher for a certain duration
This can be used during maintenance work.
cli._Argument: Remove unused, optional “suggest” parameter
bash completion: Allow arguments with min < max arguments
ganeti-masterd: Master voting in separate process
One shouldn't fork a Python process after using threads. Mastervoting is done before forking (utils.Daemonize), but it also usesthreads. Hence it's now called from a separate process.
This patch also fixes the check function to actually exit if...
ganeti-masterd: Add helper to run function in separate process
This will be used to do the master voting.
GenerateSecret: specify the length of the secret
Add a parameter to specify the length of the bytes sequence represented by thereturned hex string. Defaulting to 20 so it's compatible with previous SHA1hash.
Signed-off-by: Luca Bigliardi <shammash@google.com>...
cmdlib: Add some messages to LUExportInstance
Style fixes for ganeti-*
ganeti-noded: Close listening socket in child
LUDestroyCluster: hooks support
We're going to call hooks from its Exec method so LUDestroyCluster has tosupport them.
LUDestroyCluster: run hooks
Run post hooks on master node before it's removed.
Signed-off-by: Luca Bigliardi <shammash@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Document cluster destroy hook
Add documentation about new cluster-destroy-post hook.
Run unittests in a temporary directory
Fix building in a different directory
Also add build-bash-completion to EXTRA_DIST.
Add script to run build commands in temporary directory
Python always compiles imported modules. By running these targetsin a temporary directory we don't pollute the source tree.
Makefile: Use BUILT_SOURCES
These are always built before anything else.
Simplify manpage building
This eliminates one temporary directory in the process.
Makefile: Fix docbook2man error message
Handle more errors in bash completion
Don't print error messages if cluster hasn't been initialized yet.
HooksMaster: fix RunPhase logging
In case of complete failure results is empty, return immediately(tnx unittests).
LURemoveNode: no logs running post on removed node
Do not log results from hooks ran on the removed node as now it's done byRunPhase.
HooksMaster: logging hooks in RunPhase
Extend RunPhase so it will log hooks results in POST phase.
rapi: export more static node information
Currently not all static node information is exported over rapi, andthis makes it less complete than gnt-node list. This patch attempts toreduce the difference.
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
Document post cluster initialization LU
Update hooks documentation with the new opcode (not deleting OP_INIT_CLUSTERfrom obsolete operations because the name is different).
node-remove post on removed node
Run post phase of node-remove on the removed node as well.
HooksMaster: document raised exception
HooksAbort is raised, but not documented.
HooksMaster: list of nodes override
Allow the caller of HooksMaster.RunPhase() to specify an alternative list ofnodes.
Add burnin support for instance moves
This patch adds support for instance moves in burnin. This means thatnon-drbd instances finally get support for being moved.
Fix error output in LUSetClusterParams
Before: gnt-cluster modify --enabled-hypervisors=xen-hvm,xem-pvm Failure: command execution error: Enabled hypervisors contains invalid entries: set([u'xem-pvm'])
After: gnt-cluster modify --enabled-hypervisors=xen-hvm,xem-pvm...
Add ArgHost class
It expands to the hostnames known by bash.
Re-introduce constants for most often used arguments
Convert “burnin” to definition-based options
Add tools directory to constants
Use script to generate bash completion
Completion for tools/burnin is not yet implemented. It needs to beconverted to definition-based options handling first.
Add more auto-completion metadata
Make all options use cli_option
Change scripts to use new argument definitions
This can be used to generate the bash completion script automatically.In the future it may allow for better command line validation as well.
cli: Add new classes for argument definitions
Add gnt-instance move
This uses the new LUMoveInstance. It supports only single-instance moves.
Add OPMoveInstance and LUMoveInstance
This patch adds a basic version of LUMoveInstance. It doesn't yetsupport iallocator-mode and it's implemented in old-style (non-TL) mode.
Add arbitrary node support to create/remove disks
Currently the cmdlib _CreateDisks and _RemoveDisks always work on theinstance's (current/primary) nodes. This patch extends them to take anadditional target_node parameter denoting that the creation/removal...
Add disk copy support at backend and the rpc level
This uses a simple 'dd if=… | ssh $target dd of=…' method, like theExportSnapshot (which uses the OS export; here we want full disk-levelcopy and not any FS-level changes).
Signed-off-by: Iustin Pop <iustin@google.com>...
Remove extra argument from HooksMaster class
The mcpu.py:HooksMaster class needs to have a proc attribute/argument toinit in ordet to call its LogWarning method. However, this is availablefrom the 'lu' attribute, so we can remove this dependency.
cmdlib: Fix broken QueryInstanceData for plain instances
Fixes this bug:Failure: command execution error:Can't compute disk status for instX.domain.tld: No error information
Reinsert simple timers in Mainloop
This time we use the standard python sched module, rather than doing itall by ourselves. The scheduler in mainloop can be manipulated directlyby callers, to enter new events.
Convert ganeti-confd to Mainloop
Now that mainloop is asyncore-enabled we can easily do that.
Convert the http server/mainloop to asyncore
We can avoid most of the Mainloop.Run() code if we use asyncorefor delivering I/O events, and just concentrate on what's missing inasyncore: singnal handling and timers. This way confd can be ported touse Mainloop as well....
Pass the correct signal to handlers
Mainloop currently calls all handlers with the signal number harcoded tosigchild. Fixing this.
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Olivier Tharan <olive@google.com>
design-2.1: specify hmac key permissions
design-2.1: clarify confd usage of serial numbers
Convert daemon.Mainloop to @SignalHandled
This makes the function a lot simpler, since it used to install twodifferent signal handlers, which are now transparently handled by thedecorator. The code is unindented, but remains unchanged apart from thepart that checks the signal handlers (which is now collapsed toghether)....
Convert ganeti-masterd to @utils.SignalHandled
Add a new SignalHandled decorator
This decorator can be used to call a function holding with protectionfrom a given signal. The function should accept a dict ofutils.SignalHandler, indexed by signal number, and make use of it.