ganeti-noded: Close listening socket in child
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
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.
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.
Signed-off-by: Iustin Pop <iustin@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
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....
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.
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
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.
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.
cli: Use ToStdout/ToStderr instead of print
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.
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
Merge commit 'origin/next' into branch-2.1
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.
Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Michael Hanselmann <hansmi@google.com>
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.
Signed-off-by: Luca Bigliardi <shammash@google.com>...
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: s/Reload/_Load/
Since we use it also to load the config file initially we rename theReload function to _Load. Then we re-export it as Reload to clients(since for them it's a reload).
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.
Post cluster initialization LU
Add an 'empty' logical unit to run hooks after cluster initialization.
Upgrade be/hv params with default values
From time to time we're adding new be or hv parameters. With this patchmissing parameters get set to the default value when loading the clusterobject. This patch version also considers the case when hv/be params...
Implement the KERNEL_PATH parameter for xen-hvm
For the xen-hvm hypervisor, the KERNEL_PATH parameter is needed buttoday is hardcoded to a constants in the xen hypervisor library (argh!).
This patch moves this to a hypervisor constant with the default value...
Move HVM's device_model to a hypervisor parameter
This moves yet another hardcoded value to a hypervisor parameter. Iremoved the 64/32 difference as it doesn't seem valid to me - it's moreof a local site config rather than arch config.
objects: add configuration upgrade system
Add a very basic configuration update mechanism to objects.An object can define the UpgradeConfig method, which will be called atinit time, and use it to fill in missing defaults in the configuration.In the future we may want to make it more complex, for example adding...
Add cluster-init --no-etc-hosts parameter
If --no-etc-hosts is passed in at cluster init time we set a newparameter in the cluster's object to false, and avoid adding nodes tothe hosts file. The UpgradeConfig function is used to set the value toTrue, when upgrading from an old configuration version....
serializer.DumpSignedJson
Don't indent the final message.
SimpleConfigReader: add serial numbers reading
GetConfigSerialNo and GetClusterSerialNo return respectively the serialnumber for the config and for the cluster object.
constants: confd node roles
confd will return the node role as an integer, which represents one ofthe mutually exclusive roles a node can be in.
Merge branch 'master' into next
constants: confd query types
Initially confd will support only two queries:
CONFD_REQ_NODE_ROLE_BYNAMEGiven a node name, return its role.
CONFD_REQ_NODE_PIP_BY_INSTANCE_IPGiven an instance ip, return its node primary ip.This rather weird query is the basis for ganeti nbma lookup....
SimpleConfigReader.Reload()
Rather than initializing the config statically at class creation time,we load it every time Reload() is called.
Confd{Request,Reply} objects
These objects are used to store confd queries and replies.
Serializer, remove salt_verifier functionality
The salt needs to be returned anyway, so we don't have to add anotherkey for the sender to recognize which request an answer is answering, soall that infrastructure is useless. :(
asycnotifier.AsyncNotifier
AsyncNotifier is a special asyncore class that delivers inotify eventsasynchronously.
SimpleConfigReader: Handle errors when loading
Handling both IOErrors and ValueErrors (thrown by the simplejson loader)
ssconf.CheckMasterCandidate
This function checks that the current node is a master candidate, andterminates otherwise. It will be used upon ganeti-confd startup.
Convert ldisk_degraded to tri-state value
This allows us to report “uncertain” states (LDS_UNKNOWN) for caseswhere the code can't easily detect or report what's wrong with ablock device.
Add constants for local disk status
Signed-off-by: Michael Hanselmann <hansmi@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Iustin Pop <iustin@google.com>
Handle None result from BlockdevFind
objects.BlockDevStatus: Remove ToLegacyStatus
Add master candidates IPs informations to ssconf
This will be used when querying confd, in order not to rely on DNS beingavailable.
Signed-off-by: Luca Bigliardi <shammash@google.com>Signed-off-by: Guido Trotter <ultrotter@google.com>Reviewed-by: Guido Trotter <ultrotter@google.com>
ConfigObject.ToDict() only export non-None values
The method is changed to a normal loop, to avoid calling getattr()twice. Also getstate is changed to just use ToDict() by default.
This should also make getstate work for objects which have tooverride the ToDict function because they contain other objects....