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.
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
Return cluster tags from LUQueryClusterInfo
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Olivier Tharan <olive@google.com>
Merge branch 'next' into branch-2.1
Bash completion: Implement dynamic option value completion
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.
constants: add confd reload and rate limit times
Add errors.InotifyError
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
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Add file to pause watcher for a certain duration
This can be used during maintenance work.
cli._Argument: Remove unused, optional “suggest” parameter
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
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.
Signed-off-by: Luca Bigliardi <shammash@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
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>
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>
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.
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
Add tools directory to constants
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 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.
Signed-off-by: Guido Trotter <ultrotter@google.com>...
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>
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)....
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.
SignalHandler, only accept list of signals
utils.SignalHandler can accept either a list of signals or a singlesignal, but it's always called with a list. Removing the single signaloption.
Simplify IO waiting in Mainloop
IO is never unregistered in our current usage, so dropping thatfunctionality for now. Also putting the poller outside of the Run()function allows us to avoid the double step of adding tuples to an_io_wait_add queue and adding them later in the main loop....
Remove timers from Mainloop
Timers are currently unused, slightly buggy (for example timeout doesn'tget updated correctly), and unneeded in the current form. Confd willhave timeouts in more simple fashion, and is not a mainloop useranyway.
rapi: Add /2/instances/[instance_name]/info resource
cli: Merge ikv_option and keyval_option into cli_option
Merging them gets rid of two public functions in cli.py and optparse explicitlysupports more than one option type per class.
cli: Use ToStdout/ToStderr instead of print
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Iustin Pop <iustin@google.com>(cherry picked from commit 03298ebe95f393fc77f8acce62e5aa0b95a2bdd0)
Add support for querying the ctime/mtime
This patch adds querying of ctime/mtime for the cluster/nodes/instances.
Add ctime/mtime support to the main ConfigObjects
This patch adds ctime/mtime support to the “main” config objects - theconfig data itself, and the cluster/nodes/instances objects.
These are not added on auto-upgrade, but rather should be migrated if it...
Add utils.FormatTime and a simple unittest
We don't format with subsecond-precision.
rapi: Add /2/nodes/[node_name]/storage/repair resource
Add opcode to repair storage volumes
Add RPC call for storage operations
storage: Add operation for “vgreduce --removemissing”
storage: Add new function to execute operations
cmdlib: Add function to list all instances on node
cmdlib: Use common function to list instances on node
This will be used by another new function, too.
cmdlib: Make TLReplaceDisks._FindFaultyDisks global
It'll be used for repairing storage units.
Remove obsolete ConfigObject.__setitem__
setitem is used to emulate container objects. We don't use this, andthe method is not used in a couple of normal operations (add/removeinstance, add/remove disk).
Implement instance recreate-disks
This can be used for a 'plain' type instance when the underlying storagewent away, to recreate the storage (and reinstall) instead of removingthe instance and readding it.
Simplify handling of boolean args in rapi
This patch replaces hardcoded boolean-type args withbool(_checkIntVariable). There should be no other cases of this left, Ithink.
Fix checks in LUSetNodeParms for the master node
There was a check already in the LU for the master node, however iswasn't correct. This patch disallows any role changes on the master nodevia LUSetNodeParms (and as this LU can't change anything else, it...
TLReplaceDisks: Refuse changing secondary for specific disks
We move all disks anyway.
rapi: Add /2/instances/[instance_name]/replace-disks resource
rlib2: Remove leftover DOC_URI constant
cmdlib: Add new automatic disk replacement mode
TLReplaceDisks: Simplify argument checking logic
Fix a typo in InitCluster
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Iustin Pop <iustin@google.com>(cherry picked from commit 022c3a0b36cb60644b6861ff27ad59202883963c)
Ignore results from drained nodes in iallocator
Since drained nodes could be (partially or fully) broken in iallocator,we ignore results from these nodes when building the cluster map inpreparation for sending it to the script.
This is a cheap change for the stable branch; ideally we should not...
InstanceIpToNodePrimaryIpQuery
This implements CONFD_REQ_NODE_PIP_BY_INSTANCE_IP, and maps instance ipsto primary node ips.
querylib: abstract a couple of common errors
Rather than composing them every time, we'll keep "ready-made" tuplesfor unknown entries and internal errors (which is, yet, unused)
SimpleConfigReader: add IP address lookup helpers
Add the following functions to SimpleConfigReader:GetInstanceByIp, nic ip -> instance nameGetNodePrimaryIp, node name -> node primary ipGetInstancePrimaryNode, instance name -> primary node
For the first one we precalculate the _ip_to_instance, so we don't have...
Add NodeRoleQuery
This implements CONFD_REQ_NODE_ROLE_BYNAME.
Remove unused imports from confd files
confd.server and daemons/ganeti-confd import a few modules they don'tactually use. Clean them up.
ConfdProcessor fix init docstring
The message is an error deriving from some code moving/refactoringhappening before the initial submission
Add constants for a ping confd request
Implement confd queries
We'll start with a simple ping query, which returns ok if it gets noquery argument, and an error if it gets any. Also non-implemented queryare handled by the base ConfdQuery class, so we don't have tospecial-case them in ConfdProcessor anymore....
ConfdProcessor: move verification to init
During a query execution we currently verify whether we have that querysupported in our dispatch table. Since it's an error not to have itanyway, we move this verification to the class creation, erroring out...
Add a missing node role
Apart from being a master, a candidate, offline or drained, a node canhave one more state: none of those. Adding back the normal, nice,healthy "just" a node! :)
Add a common error code for confd
If we standardize common error codes, clients can make use of them toreact, rather than trying to parse error strings.
SimpleConfigReader.GetNodeStatusFlags
Adding a way to retrieve the three node status flags, all in one go,from SimpleConfigReader. Non-existing nodes are handled by returning"None".
rapi: Add /2/nodes/[node_name]/storage/modify resource
rlib2: Import rapi
This fixes ganeti-rapi which was broken in commit 7a95a954.
rapi: Add /2/nodes/[node_name]/storage resource
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
Constants: config directories cleanup
Use variables already defined.Introduce ganeti CONF_DIR.
Ssconf IP lists: change separator
Use " " instead of ",".
Signed-off-by: Luca Bigliardi <shammash@google.com>
Map Node/IP in ssconf IP lists
Map the node hostname with its primary/secondary ganeti IP in ssconf.In this way a node can discover which are its IPs simply grepping ssconf files,thus avoiding checks depending on network configuration.
confd.server.ConfdProcessor
A ConfdProcessor is the job processor for a confd query.It's responsible for all the processing, from unpacking it, verifyingit, to calculating the result.
Add empty ganeti.confd module
It will be used for the confd server code, and for a basic clientlibrary.
SimpleConfigReader.Reload, avoid double reloads
If for some reason we try to call Reload twice but the config filehasn't changed, we don't want to load it again. Use stat() on the fileto cheaply avoid that situation.
We also return a boolean value, according to whether we have reloaded...
Basic exceptions used by confd
Reply status constants for confd
These are valid values for the "status" field in objects.ConfdReply
constants for the confd daemon
Adding the various basic daemon constants for confd.