ganeti-local
12 years agohtools: Refactor some of IAlloc.readRequest to Hail
René Nussbaumer [Fri, 2 Mar 2012 10:49:34 +0000 (11:49 +0100)]
htools: Refactor some of IAlloc.readRequest to Hail

This makes it possible to reuse that function when we want to use IAlloc
as a data source backend

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agohinfo: Adjust the verbosity
René Nussbaumer [Thu, 1 Mar 2012 09:54:54 +0000 (10:54 +0100)]
hinfo: Adjust the verbosity

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agohinfo: Gather and print group statistics
René Nussbaumer [Wed, 29 Feb 2012 15:29:44 +0000 (16:29 +0100)]
hinfo: Gather and print group statistics

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoExplicitly remove the .x.in man pages on failure
Iustin Pop [Wed, 29 Feb 2012 14:55:58 +0000 (15:55 +0100)]
Explicitly remove the .x.in man pages on failure

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoMore -- fixes
Iustin Pop [Wed, 29 Feb 2012 14:55:18 +0000 (15:55 +0100)]
More -- fixes

Because .DELETE_ON_ERROR doesn't work consistently (works when the
target we're talking about is a final target, but not for
intermediates), I missed a lot of man checks.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agohtools: Adding printTable helper
René Nussbaumer [Wed, 29 Feb 2012 13:33:49 +0000 (14:33 +0100)]
htools: Adding printTable helper

This helper abstract away all the unlines and unwords call you've to do
after you got a formatTable back.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoFixup a Node unittest
Iustin Pop [Tue, 21 Feb 2012 09:42:32 +0000 (10:42 +0100)]
Fixup a Node unittest

This fixes the prop_Node_rMem test, which cares about memory only;
otherwise we could fail due to other problems (e.g. not enough disk).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAllow overriding the target test count
Iustin Pop [Mon, 20 Feb 2012 12:45:24 +0000 (13:45 +0100)]
Allow overriding the target test count

This is not perfect, as the override applies identical target test
values to both the 'fast' and 'slow' tests (making the slow tests take
a long time), but it allows a quick override for manual runs.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAdd two more unittests for Node add/remove
Iustin Pop [Mon, 20 Feb 2012 12:30:04 +0000 (13:30 +0100)]
Add two more unittests for Node add/remove

These just test that add/remove are idempotent. This is not perfect,
as we use unsorted lists for some values (instead of sets), so when
using non-empty nodes this would break (but for empty nodes, a
1-element list is sorted, so it's fine).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoUse the spindles metric in cluster scores
Iustin Pop [Mon, 20 Feb 2012 12:14:27 +0000 (13:14 +0100)]
Use the spindles metric in cluster scores

This makes balancing use the new metric.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoTrack instance-used spindles in node set/add/remove
Iustin Pop [Mon, 20 Feb 2012 11:18:15 +0000 (12:18 +0100)]
Track instance-used spindles in node set/add/remove

This simply tracks the instance-used spindles (using hard-coded '1'
per instance), and additionally prevents additions in soft-mode when
we go over the limit.

Note: there's an assymetry between addSec and removeSec (basically
secondaries should only exist with DTDrbd8, so the check for uses_disk
is superflous), will be cleaned up later.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoShorten some function names
Iustin Pop [Mon, 20 Feb 2012 10:43:50 +0000 (11:43 +0100)]
Shorten some function names

Since we use the functions always module-qualified, let's drop the
`instance` prefix and use a shorter one.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoSimplify logic in Node operations
Iustin Pop [Sun, 19 Feb 2012 20:43:40 +0000 (21:43 +0100)]
Simplify logic in Node operations

This patch adds two helper functions and uses them for a somewhat
simplified logic in the add/remove pri/sec node functions.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohtools: support spindles in simu backend
Iustin Pop [Thu, 16 Feb 2012 12:43:01 +0000 (13:43 +0100)]
htools: support spindles in simu backend

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohtools: support spindles in text load/save
Iustin Pop [Thu, 16 Feb 2012 12:34:02 +0000 (13:34 +0100)]
htools: support spindles in text load/save

If missing, we'll default to 1 spindle.

This also updates the text file format with the ipolicy, which was
forgotten.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohtools: add support for listing spindles for nodes
Iustin Pop [Thu, 16 Feb 2012 11:57:51 +0000 (12:57 +0100)]
htools: add support for listing spindles for nodes

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohtools: add spindle-related attribute to nodes
Iustin Pop [Thu, 16 Feb 2012 11:52:54 +0000 (12:52 +0100)]
htools: add spindle-related attribute to nodes

This adds the spindleCount, hiSpindles and instSpindles attributes.

The spindleCount is equivalent to spindle_count on the ganeti side (a
node parameter). hiSpindles is the maximum instance-used spindles, and
instSpindles will be used to track spindles as used by instances (in
later patches).

The patch also reads spindleCount from the live backends. The text and
simu backends currently set it to 1, hard-coded.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAdd spindle ratio to htool's IPolicy
Iustin Pop [Fri, 27 Jan 2012 16:21:24 +0000 (17:21 +0100)]
Add spindle ratio to htool's IPolicy

Just the usual data/type declarations, read/save in the text backend,
etc. Also does a bit of unit-test cleanup (the way we build
ipolicies).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohinfo: Adding man page
René Nussbaumer [Wed, 29 Feb 2012 09:59:22 +0000 (10:59 +0100)]
hinfo: Adding man page

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agohinfo: Reorganize the code to separate functions
René Nussbaumer [Tue, 28 Feb 2012 14:39:24 +0000 (15:39 +0100)]
hinfo: Reorganize the code to separate functions

Also rename some functions as they don't reflect their actions anymore

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoTwo tiny fixed related to runtime functionality
Iustin Pop [Tue, 28 Feb 2012 12:50:14 +0000 (13:50 +0100)]
Two tiny fixed related to runtime functionality

Adds an assert and fixes a typo.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agohinfo: Adding basic skeleton based on hbal
René Nussbaumer [Mon, 27 Feb 2012 09:33:08 +0000 (10:33 +0100)]
hinfo: Adding basic skeleton based on hbal

It prints the information which hbal prints in a nice formatted manner and of
course without doing any actions. An example output looks like this:

$ hinfo -m xen.example.com
Loaded 4 nodes, 2 instances
Cluster has 1 node group(s)
Cluster coefficients:
   Field                Value Weight
   free_mem_cv     0.00195342  x1.00
   free_disk_cv    0.00000000  x1.00
   n1_cnt          0.00000000  x1.00
   reserved_mem_cv 0.00195342  x1.00
   offline_all_cnt 0.00000000  x4.00
   offline_pri_cnt 0.00000000 x16.00
   vcpu_ratio_cv   0.12500000  x1.00
   cpu_load_cv     0.50000000  x1.00
   mem_load_cv     0.50000000  x1.00
   disk_load_cv    0.00000000  x1.00
   net_load_cv     0.50000000  x1.00
   pri_tags_score  0.00000000  x2.00
Cluster score: 1.62890685

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoAdd automated checking for non-escaped --
Iustin Pop [Mon, 27 Feb 2012 14:51:15 +0000 (15:51 +0100)]
Add automated checking for non-escaped --

This checks to see if any man output has [em] in it, as that will not
be correctly show in ASCII. Unfortunately the check will depend on
whether the other man check is done, but I didn't want to introduce
yet another short script for this (can be done, no issue).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoFix man pages to not use unescaped --
Iustin Pop [Mon, 27 Feb 2012 14:48:05 +0000 (15:48 +0100)]
Fix man pages to not use unescaped --

I've seen that man pages, as generated by the version of pandoc we
use, show single dashes in option names instead of double ones (-
versus --). After bringing it up with upstream
(http://groups.google.com/group/pandoc-discuss/browse_thread/thread/9c4589a4001d42f9/95ee8dae8932dc93),
it seems that this is a known behaviour of pandoc that has been
improved in newer versions.

Until then, let's use correctly double dashes; from the two options in
the above thread, I chose to use \-- as that doesn't change the actual
output; whereas ``--nodes`` make this a code block, which will look
differently from a short option and could change how the output looks
(e.g. when in a bold span).

Additionally, I've removed two cases where unescape em was explicitly
intended, as that makes automated checking harder and we can use other
formatting.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoAdd job result descriptions to RAPI documentation
Michael Hanselmann [Fri, 24 Feb 2012 11:22:02 +0000 (12:22 +0100)]
Add job result descriptions to RAPI documentation

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoRemove a superfluous warning in LUNodeRemove
Iustin Pop [Mon, 27 Feb 2012 13:40:44 +0000 (14:40 +0100)]
Remove a superfluous warning in LUNodeRemove

Since we run the post-hooks explicitly in the Exec() function (via
_RunPostHook) after we removed the target node from the config, we
will get a:

  WARNING Node 'node2', which is about to be removed, was not found in
  the list of all nodes

in the logs every time we remove a node. The patch just removes the
warning, as actually invalid configurations (for the pre hook) will be
checked correctly elsewhere.

Additionally, the docstrings for BuildHooksEnv and BuildHooksNodes are
corrected/switched.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoopcodes: Remove dependency on query module
Michael Hanselmann [Thu, 23 Feb 2012 15:43:35 +0000 (16:43 +0100)]
opcodes: Remove dependency on query module

There's no need to verify the field definitions on every query. They are
static for all intents and purposes anyway and verified at module load
time.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohttp.server: Factorize request handling even more
Michael Hanselmann [Tue, 21 Feb 2012 19:14:46 +0000 (20:14 +0100)]
http.server: Factorize request handling even more

This splits even more parts of the request handling code into a separate
class. Doing so allows us to reuse this part of the code for tests (e.g.
mocks). Unlike before now the error handling can also be reused.

The patch became a bit more convoluted than intended, but the end result
is easier to read than the original code.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohttp.server: Move error message formatting to handler class
Michael Hanselmann [Tue, 21 Feb 2012 17:23:37 +0000 (18:23 +0100)]
http.server: Move error message formatting to handler class

Like before this patch moves more functionality from the actual server
class into a separate handler class. At the same time the function is
changed to return both content-type and body instead of relying on a
class attribute.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

12 years agonoded: Shorter docstring for mlockall(2) executor
Michael Hanselmann [Tue, 21 Feb 2012 16:40:20 +0000 (17:40 +0100)]
noded: Shorter docstring for mlockall(2) executor

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoSplit handling HTTP requests into separate class
Michael Hanselmann [Tue, 21 Feb 2012 16:39:46 +0000 (17:39 +0100)]
Split handling HTTP requests into separate class

Until now HTTP requests were handled in the same class as incoming
connections (http.server.HttpServer). With this change the request
handling is delegated to a separate class which can be re-used in tests
without creating a socket, etc.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohttp.server: Factorize request handling
Michael Hanselmann [Tue, 21 Feb 2012 16:13:50 +0000 (17:13 +0100)]
http.server: Factorize request handling

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoRemove deprecated “QueryLocks” LUXI request
Michael Hanselmann [Wed, 22 Feb 2012 11:58:05 +0000 (12:58 +0100)]
Remove deprecated “QueryLocks” LUXI request

This has been deprecated since Ganeti 2.4 and hasn't been used by
Ganeti's code since. I'm not aware of any external users.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoAdd result checks for OpTags*
Michael Hanselmann [Tue, 21 Feb 2012 15:19:48 +0000 (16:19 +0100)]
Add result checks for OpTags*

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoopcodes: Annotate the OP_RESULT of query operations
René Nussbaumer [Tue, 21 Feb 2012 09:05:29 +0000 (10:05 +0100)]
opcodes: Annotate the OP_RESULT of query operations

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoReplace single- with double-quotes
Michael Hanselmann [Tue, 21 Feb 2012 13:37:58 +0000 (14:37 +0100)]
Replace single- with double-quotes

In at least two cases "%s" is replaced with str(), too.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoFix asyncnotifier unit tests
Iustin Pop [Tue, 21 Feb 2012 08:36:04 +0000 (09:36 +0100)]
Fix asyncnotifier unit tests

On my workstation, if I run the following two tests in this exact
order:

- TestSingleFileEventHandler.testError
- TestSingleFileEventHandler.testReplace

the second test will fail, because there is no "unregister" of
previous tests (and the poll() done by asyncore will fire on the
previous files which are now removed, etc. etc.).

While investigating this, I realised that we don't do any cleanup of
the various handlers/notifiers we setup for this test, so if we simply
add a proper cleanup, the tests will work nicely (in any order :).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoSmall fixup to rapi docstrings
Iustin Pop [Tue, 21 Feb 2012 07:42:09 +0000 (08:42 +0100)]
Small fixup to rapi docstrings

The fast that most classes don't override the @cvars means that direct
references to FillOpcode can fail (they do on my workstation, but not
on buildbot?). Anyway, for safety, it's best to qualify the name.

Additionally a small typo is fixed.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoSmall update to LogicalUnit.ExpandNames docstring
Iustin Pop [Mon, 20 Feb 2012 14:40:46 +0000 (15:40 +0100)]
Small update to LogicalUnit.ExpandNames docstring

… to make even more obvious what's the difference between a declared
lock level with an empty list of locks and no lock level.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoExport ndparams in RAPI node query
Iustin Pop [Thu, 16 Feb 2012 09:56:40 +0000 (10:56 +0100)]
Export ndparams in RAPI node query

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoAdd ndp/* fields to group/node query
Iustin Pop [Fri, 3 Feb 2012 15:55:01 +0000 (16:55 +0100)]
Add ndp/* fields to group/node query

Also change the meaning of group ndparams to mean the actual (not
custom) nd params, and add custom_ndparams for the current meaning of
ndparams.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoExport ndparams in iallocator
Iustin Pop [Fri, 27 Jan 2012 13:45:10 +0000 (14:45 +0100)]
Export ndparams in iallocator

Strangely, these were not exported at all before.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoAdd ipolicy parameter spindle_ratio
Iustin Pop [Fri, 27 Jan 2012 13:38:31 +0000 (14:38 +0100)]
Add ipolicy parameter spindle_ratio

This will represent the instance (count) per spindle_count of their
node(s). Debatable whether we need to add a per-instance
spindle_weight.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoAdd new spindle_count node parameter
Iustin Pop [Fri, 27 Jan 2012 13:29:31 +0000 (14:29 +0100)]
Add new spindle_count node parameter

Currently this is not handled by Ganeti, just recorded.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoFix upgrading of ndparams
Iustin Pop [Fri, 27 Jan 2012 13:26:35 +0000 (14:26 +0100)]
Fix upgrading of ndparams

Currently, we only upgrade the ndparams if they are missing
completely, which creates problems if we add any new parameters on an
already-upgraded cluster.

Fix this by adding an UpgradeNDParams function.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoSmall fixes to objects.UpgradeDiskParams
Iustin Pop [Fri, 27 Jan 2012 13:25:03 +0000 (14:25 +0100)]
Small fixes to objects.UpgradeDiskParams

Fix a typo, and cleanup the code a bit.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoopcodes: Add result checks for OpBackup*
Michael Hanselmann [Mon, 20 Feb 2012 16:21:51 +0000 (17:21 +0100)]
opcodes: Add result checks for OpBackup*

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoImprove opcode result check test to have a whitelist
Michael Hanselmann [Mon, 20 Feb 2012 12:29:38 +0000 (13:29 +0100)]
Improve opcode result check test to have a whitelist

Only whitelisted opcodes may not have a result check.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoconfig: Add check for disk's “iv_name”
Michael Hanselmann [Fri, 17 Feb 2012 16:49:35 +0000 (17:49 +0100)]
config: Add check for disk's “iv_name”

This check verifies “iv_name” of all instance disks. If one is wrong
(which shouldn't happen in the first place), cluster verification will
warn:

“ERROR: cluster: Instance 'inst.example.com' has wrongly named disks:
name of disk 1 should be 'disk/1', but is 'disk/4'”

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoopcodes: Fix OP_RESULT for OobCommand
René Nussbaumer [Mon, 20 Feb 2012 10:35:11 +0000 (11:35 +0100)]
opcodes: Fix OP_RESULT for OobCommand

The result is a list of a list with elements with size of 2.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agocli: Handle negative numbers when parsing key-value assignments
Michael Hanselmann [Fri, 17 Feb 2012 10:49:00 +0000 (11:49 +0100)]
cli: Handle negative numbers when parsing key-value assignments

To remove the last disk, or to add a NIC to the end, one can use the
index -1. This wouldn't work as intended as “-” is a special prefix.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoutils.text: Add function to truncate string
Michael Hanselmann [Fri, 17 Feb 2012 12:42:04 +0000 (13:42 +0100)]
utils.text: Add function to truncate string

The function adds an ellipse if the string was actually truncated. Also
start using it in mcpu for result checks (where the message is also
slightly changed to use a colon).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoFix breakage introduced by fa6dd6bb56
Michael Hanselmann [Fri, 17 Feb 2012 12:46:55 +0000 (13:46 +0100)]
Fix breakage introduced by fa6dd6bb56

Forgot “enumerate”.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoLUInstanceSetParams: Update disk's “iv_name”
Michael Hanselmann [Wed, 15 Feb 2012 16:52:47 +0000 (17:52 +0100)]
LUInstanceSetParams: Update disk's “iv_name”

When modifications are made, disks may not have the same index anymore.
Updating all disks fixes this.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoApplyContainerMods: Fix issues with indices
Michael Hanselmann [Wed, 15 Feb 2012 17:50:08 +0000 (18:50 +0100)]
ApplyContainerMods: Fix issues with indices

When adding an item the index given to the callback function would be
incorrect under certain conditions. This patch also adds assertions and
more tests.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agocmdlib: Remove some users of “iv_name”
Michael Hanselmann [Wed, 15 Feb 2012 16:36:36 +0000 (17:36 +0100)]
cmdlib: Remove some users of “iv_name”

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoConfigWriter: Stop using “iv_name”
Michael Hanselmann [Wed, 15 Feb 2012 16:09:20 +0000 (17:09 +0100)]
ConfigWriter: Stop using “iv_name”

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoConfigWriter.RenameInstance: Stop using iv_name, safer operation
Michael Hanselmann [Wed, 15 Feb 2012 16:06:29 +0000 (17:06 +0100)]
ConfigWriter.RenameInstance: Stop using iv_name, safer operation

Stop using the disk index encoded in “iv_name” when renaming an instance.

This patch also changes the code to operate on a copy of the instance
until the major changes have been applied. In the case of a failure we
won't loose the instance object anymore.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agognt-instance modify: Support new-style NIC/disk modifications
Michael Hanselmann [Tue, 14 Feb 2012 12:41:57 +0000 (13:41 +0100)]
gnt-instance modify: Support new-style NIC/disk modifications

This patch adds support for adding/removing NICs/disks at arbitrary
indices on the command line. To add a disk at a specified index, use
“--disk 3:size=16G”. To remove the second disk, use “--disk 2:remove”.
Unittests are included.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoopcodes: Adding missing OP_RESULTs
René Nussbaumer [Fri, 10 Feb 2012 14:51:53 +0000 (15:51 +0100)]
opcodes: Adding missing OP_RESULTs

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agomcpu: Make the op result exception more verbose
René Nussbaumer [Mon, 13 Feb 2012 09:14:49 +0000 (10:14 +0100)]
mcpu: Make the op result exception more verbose

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agocmdlib: De-duplicate code in _GenerateDiskTemplate
Michael Hanselmann [Wed, 15 Feb 2012 13:23:49 +0000 (14:23 +0100)]
cmdlib: De-duplicate code in _GenerateDiskTemplate

There has been a lot of duplicated code in _GenerateDiskTemplate,
and some cases of very similar, but not quite same duplicates. This
patch merges them.

Generating a disk's “logical_id” attribute is done via a
lambda/function. Maybe the ID's could be pre-computed and stored in a
list.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAdd unittest for cmdlib._GenerateDiskTemplate
Michael Hanselmann [Tue, 14 Feb 2012 13:53:28 +0000 (14:53 +0100)]
Add unittest for cmdlib._GenerateDiskTemplate

This is in preparation to de-duplicating significant chunks of code in
cmdlib._GenerateDiskTemplate.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agorapi.testutils: Add exported functions to verify opcode input/result
Michael Hanselmann [Tue, 14 Feb 2012 16:11:41 +0000 (17:11 +0100)]
rapi.testutils: Add exported functions to verify opcode input/result

These can be used by third-party code to verify mock code. Further work
on mocks is forthcoming, so this is only a start.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agocmdlib: Fix “unpack non-sequence” error
Michael Hanselmann [Tue, 14 Feb 2012 11:47:47 +0000 (12:47 +0100)]
cmdlib: Fix “unpack non-sequence” error

The callback is expected to return a two-valued tuple.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoFix doc bug introduced in 12637df
Iustin Pop [Fri, 3 Feb 2012 16:22:05 +0000 (17:22 +0100)]
Fix doc bug introduced in 12637df

Commit 12637df changed/generalised how we build fields in the sphinx
extension, however it resulted in this uncaught-so-far result:

$ echo @QUERY_FIELDS_GROUP@ | ./autotools/docpp
<generator object BuildValuesDoc at 0x28fd370>

There's no point in yield-ing a single value (as opposed to a stream
of values), so let's just "return" it.

By the way, there's no test for this kind of error, but I don't think
it would happen too often, so I didn't add one (e.g. grep "<.* at
0x[0-9a-f]+>" man/*.[178]).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agohtools: allow rbd disk template
Guido Trotter [Mon, 13 Feb 2012 16:56:39 +0000 (16:56 +0000)]
htools: allow rbd disk template

Notes:
  - it'd be nice if there was a way to automatically generate the
    DiskTemplate list instead of manually specifying it. After all we
    have C.diskTemplates
  - Of course this actually does nothing, as for other
    "half-implemented" templates :(

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

12 years agoApplyContainerMods: Return changes from callbacks
Michael Hanselmann [Mon, 13 Feb 2012 16:47:08 +0000 (17:47 +0100)]
ApplyContainerMods: Return changes from callbacks

… instead of passing the list of changes as a parameter.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoUse the ipolicy constants for key names
Iustin Pop [Fri, 27 Jan 2012 15:59:04 +0000 (16:59 +0100)]
Use the ipolicy constants for key names

Sorry, I missed this when I wrote the code originally.

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

12 years agoLUInstanceSetParams: Convert to generic algorithm for NIC/disk changes
Michael Hanselmann [Fri, 10 Feb 2012 16:59:55 +0000 (17:59 +0100)]
LUInstanceSetParams: Convert to generic algorithm for NIC/disk changes

Unfortunately this got a bit messier than I intended, but then again it
cleans up a lot of messy code with heaps of local variables
(“this_nic_override”) and LU attributes (“nic_pnew”, “nic_pinst”). Most
of these variables were index by a number, or one of the
constants.DDM_* constants.

This patch moves the code for adding/modifying/removing a NIC/disk to
dedicated, small functions. The previously added generic algorithm for
applying changes to containers is then used to actually change the
instance's network interfaces or disks based on the requested
modifications. The LU now supports adding/removing disks/NICs in
arbitrary positions.

The compuation of all network interface changes has been moved to
CheckPrereq, so that its result can be used for hooks. For this to work
without side-effects, the NIC objects need to be copied (only done if
there are actual changes).

The command line utility still needs to be updated.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agocmdlib: Add generic algorithm for modifying NICs/disks
Michael Hanselmann [Fri, 10 Feb 2012 16:57:23 +0000 (17:57 +0100)]
cmdlib: Add generic algorithm for modifying NICs/disks

While preparing this patch series I identified at least three different
implementations of the algorithm for adding/removing/changing
NICs/disks. These two functions and corresponding unittests provide a
generic implementation with added support for adding/removing arbitrary
disks or NICs.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoFix unittest breakage after commit a2aadb34b
Michael Hanselmann [Mon, 13 Feb 2012 13:57:39 +0000 (14:57 +0100)]
Fix unittest breakage after commit a2aadb34b

Thou shalt run “make check” before sending patches.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoLUInstanceSetParams: Assertion on disk template/disk changes
Michael Hanselmann [Fri, 10 Feb 2012 16:59:40 +0000 (17:59 +0100)]
LUInstanceSetParams: Assertion on disk template/disk changes

Disk changes aren't allowed at the same time as a disk template change.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoOpInstanceSetParams: Make two type checks public
Michael Hanselmann [Fri, 10 Feb 2012 17:04:38 +0000 (18:04 +0100)]
OpInstanceSetParams: Make two type checks public

They'll be used for tests in cmdlib.py.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoOpInstanceSetParams: Accept more flexible NIC/disk modifications
Michael Hanselmann [Fri, 10 Feb 2012 16:55:39 +0000 (17:55 +0100)]
OpInstanceSetParams: Accept more flexible NIC/disk modifications

Start accepting a new form of NIC/disk modifications for adding/removing
arbitrary NICs/disks. Unlike before the index must always be given. An
index of “-1” stands for the last item.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoconstants: Add constant for modifying existing NIC/disk
Michael Hanselmann [Fri, 10 Feb 2012 16:56:26 +0000 (17:56 +0100)]
constants: Add constant for modifying existing NIC/disk

Until now it would not be possible to add/remove a NIC/disk in an
arbitrary position. This constant will be used in the data structures
necessary to add/remove arbitrary NICs/disks.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoopcodes: Add comments to two parameter tests
Michael Hanselmann [Fri, 10 Feb 2012 16:54:51 +0000 (17:54 +0100)]
opcodes: Add comments to two parameter tests

These comments appear in the RAPI documentation.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agorbd disk template documentation and manpages
Stratos Psomadakis [Fri, 10 Feb 2012 10:29:13 +0000 (12:29 +0200)]
rbd disk template documentation and manpages

Add documentation and modify manpages for the RBD disk template.

Signed-off-by: Constantinos Venetsanopoulos <cven@grnet.gr>
Signed-off-by: Stratos Psomadakis <psomas@grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoRe-added constant mistakenly removed in 58f0ce16873
Michael Hanselmann [Wed, 1 Feb 2012 07:41:22 +0000 (08:41 +0100)]
Re-added constant mistakenly removed in 58f0ce16873

“INSTANCE_DOWN” is still being used.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agorapi.client: Removing constants not needed anymore
René Nussbaumer [Tue, 31 Jan 2012 12:14:13 +0000 (13:14 +0100)]
rapi.client: Removing constants not needed anymore

They were not referenced through the whole code and were marked internal
only.

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoAdd stricter checks for OpInstanceSetParams.{nics,disks}
Michael Hanselmann [Tue, 31 Jan 2012 11:53:53 +0000 (12:53 +0100)]
Add stricter checks for OpInstanceSetParams.{nics,disks}

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAdd ht.TMaybeListOf type check
Michael Hanselmann [Tue, 31 Jan 2012 11:53:32 +0000 (12:53 +0100)]
Add ht.TMaybeListOf type check

Replaces some uses of TOr(TNone, TListOf(…)).

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoStricter check for OS modifications passed to OpClusterSetParams
Michael Hanselmann [Tue, 31 Jan 2012 07:56:35 +0000 (08:56 +0100)]
Stricter check for OS modifications passed to OpClusterSetParams

Don't just check the first element of each item, but also make sure the
OS name is a string and not empty.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoLUInstanceSetParams: Allow no-op change of instance offline status
Michael Hanselmann [Tue, 31 Jan 2012 06:39:02 +0000 (07:39 +0100)]
LUInstanceSetParams: Allow no-op change of instance offline status

With this patch marking an instance already marked offline (or online)
as offline/online again becomes a no-op. Also removed the unused
INSTANCE_UP variable.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

12 years agoOpInstanceSetParams: Merge {off,on}line_inst parameters
Michael Hanselmann [Mon, 30 Jan 2012 13:43:00 +0000 (14:43 +0100)]
OpInstanceSetParams: Merge {off,on}line_inst parameters

Instead of having two separate parameters, a single boolean parameter is
used. Unfortunately we need a third state to say “no change”, so the
value can be None, True or False (similar to other parameters). There
are no user interface changes.

New QA tests are added, too.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

12 years agoipolicy: Make the keys of the dict consistent
René Nussbaumer [Fri, 27 Jan 2012 15:24:33 +0000 (16:24 +0100)]
ipolicy: Make the keys of the dict consistent

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

12 years agowalkthrough.rst: updates for maxmem/minmem
Guido Trotter [Fri, 27 Jan 2012 13:35:47 +0000 (13:35 +0000)]
walkthrough.rst: updates for maxmem/minmem

- Fix two example outputs
- Improve N+1 resolution section specifying how different memories
  affect N+1 calculation depending on the node

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

12 years agoadmin.rst: add information about maxmem/minmem
Guido Trotter [Fri, 27 Jan 2012 13:33:31 +0000 (13:33 +0000)]
admin.rst: add information about maxmem/minmem

- Specify how maxmem and minmem are used at startup, failover and
  migrate
- Add a paragraph about how to manually change the runtime memory, and
  what Ganeti will and won't do automatically as of version 2.6

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoN+1: verify using minimum memory
Guido Trotter [Fri, 27 Jan 2012 13:33:06 +0000 (13:33 +0000)]
N+1: verify using minimum memory

Since instances can be started, failed over and migrated with less than
their maximum memory N+1 will use the minimum memory for verification.

Note that this accounts only for the instances being moved being
resized, and not for the ones already on the node, as ganeti will not
automatically resize other instances on the target node now when trying
to start/failover/migrate an instance.

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

12 years agoFix integer overflow in Node unittest
Iustin Pop [Thu, 26 Jan 2012 18:41:13 +0000 (19:41 +0100)]
Fix integer overflow in Node unittest

When using a really random "extra cpus" variable, this can overflow
(especially on 32 bit) and thus the final value can be < 0, thus the
test will fail to fail.

It doesn't make sense to test with huge values, so let's just generate
a reasonable value.

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

12 years agoUse allow_runtime_chgs in cmdlib
Guido Trotter [Wed, 25 Jan 2012 15:37:07 +0000 (15:37 +0000)]
Use allow_runtime_chgs in cmdlib

- Report the attribute value in the hooks runtime variable.
- Use it to abort migration if not enough memory is available on the
  target node.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agocli/opcodes: add a --no-runtime-changes migrate opt
Guido Trotter [Wed, 25 Jan 2012 15:26:22 +0000 (15:26 +0000)]
cli/opcodes: add a --no-runtime-changes migrate opt

This will be used for now to avoid ballooning memory at live migration time.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoMigrate/Failover: allow less-than-max-mem op
Guido Trotter [Fri, 20 Jan 2012 14:33:29 +0000 (14:33 +0000)]
Migrate/Failover: allow less-than-max-mem op

Failover works magically after we relax the check: the start operation
will just use less memory, if less memory is available.

For migrate we need to balloon down the source memory before the
migration, if the target node doesn't have enough capacity.

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

12 years agoFailover and Migrate: acquire node resource locks
Guido Trotter [Fri, 20 Jan 2012 14:28:13 +0000 (14:28 +0000)]
Failover and Migrate: acquire node resource locks

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agocmdlib._CheckNodeFreeMemory: return free memory
Guido Trotter [Mon, 12 Dec 2011 12:27:39 +0000 (12:27 +0000)]
cmdlib._CheckNodeFreeMemory: return free memory

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agodoc/rapi.rst: Document ipolicy parameter
René Nussbaumer [Thu, 26 Jan 2012 14:02:59 +0000 (15:02 +0100)]
doc/rapi.rst: Document ipolicy parameter

Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

12 years agoExpand the tiered alloc unittest to check allocation stats
Iustin Pop [Wed, 25 Jan 2012 14:00:48 +0000 (15:00 +0100)]
Expand the tiered alloc unittest to check allocation stats

This was missing before, so with the new metric (NCpus), it's a good
time to test this.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoSwitch over some hspace stats from RSpec to AllocInfo
Iustin Pop [Wed, 25 Jan 2012 10:33:59 +0000 (11:33 +0100)]
Switch over some hspace stats from RSpec to AllocInfo

This patch changes the allocation delta stats from RSpec to
AllocInfo. There's nothing interesting about it, but it should allow
more correct computations of Npus in hspace.

I also moved the AllocStats type alias from Cluster.hs to Types.hs
(just makes more sense).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoAdd a new type for holding allocation statistics
Iustin Pop [Wed, 25 Jan 2012 10:21:36 +0000 (11:21 +0100)]
Add a new type for holding allocation statistics

The current RSpec type doesn't cut it anymore (and it's used in other
places), so let's introduce a separate type for holding these
statistics.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>

12 years agoTrack 'normalised' used CPUs in Cluster.CStats
Iustin Pop [Tue, 24 Jan 2012 18:35:18 +0000 (19:35 +0100)]
Track 'normalised' used CPUs in Cluster.CStats

This will be used in hspace for proper tracking of used/pool/unavail
npus.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: René Nussbaumer <rn@google.com>