ganeti-local
11 years agoMake Paramiko an optional dependency for listrunner
Michael Hanselmann [Wed, 24 Oct 2012 00:01:42 +0000 (02:01 +0200)]
Make Paramiko an optional dependency for listrunner

With the move away from “setup-ssh”, Paramiko is no longer necessary to
configure SSH on nodes.

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

11 years agoRemove setup-ssh
Michael Hanselmann [Tue, 23 Oct 2012 23:58:37 +0000 (01:58 +0200)]
Remove setup-ssh

It has been superseeded by “prepare-node-join”.

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

11 years agognt-node add: Use prepare-node-join
Michael Hanselmann [Tue, 23 Oct 2012 18:16:25 +0000 (20:16 +0200)]
gnt-node add: Use prepare-node-join

This patch changes “gnt-node add” to use the newly added
“prepare-node-join” tool. Hereby Paramiko is no longer a hard dependency
for setting up SSH on nodes.

In “gnt_cluster.py”, a positional parameter is no longer passed as a
keyword parameter.

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

11 years agoprepare-node-join: Use ssh.GetAllUserFiles
Michael Hanselmann [Tue, 23 Oct 2012 23:16:50 +0000 (01:16 +0200)]
prepare-node-join: Use ssh.GetAllUserFiles

Instead of building the dictionary locally, the global version in
“ssh.py” can be used.

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

11 years agossh: Add function to get all of user's SSH files
Michael Hanselmann [Tue, 23 Oct 2012 23:10:36 +0000 (01:10 +0200)]
ssh: Add function to get all of user's SSH files

This new function returns the file paths for all of a user's SSH-related
files (RSA, DSA and authorized_keys).

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

11 years agoRunCmd: Support standard input file descriptor
Michael Hanselmann [Tue, 23 Oct 2012 19:25:30 +0000 (21:25 +0200)]
RunCmd: Support standard input file descriptor

This patch changes “utils.RunCmd” to accept a file-like object or a
numeric file descriptor which will be used as the command's standard
input. One use-case will be to pass all necessary data to
“prepare-node-join”.

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

11 years agoFactorize job selection in “gnt-job cancel”
Michael Hanselmann [Thu, 25 Oct 2012 15:29:51 +0000 (17:29 +0200)]
Factorize job selection in “gnt-job cancel”

This will also be used for changing jobs' priorities. All parameters to
the common function are non-optional.

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

11 years agoutils.x509: Factorize code to extract X509 certificate
Michael Hanselmann [Tue, 23 Oct 2012 23:55:53 +0000 (01:55 +0200)]
utils.x509: Factorize code to extract X509 certificate

This will be useful in “gnt-node add”.

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

11 years agoprepare_node_join: Move daemon SSH files to constants
Michael Hanselmann [Tue, 23 Oct 2012 23:11:45 +0000 (01:11 +0200)]
prepare_node_join: Move daemon SSH files to constants

This dictionary will also be useful in “gnt-node add”.

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

11 years agoprepare-node-join: Swap private and public keys
Michael Hanselmann [Tue, 23 Oct 2012 23:24:19 +0000 (01:24 +0200)]
prepare-node-join: Swap private and public keys

Other places, such as “ssh.GetUserFiles”, use a structure where the
private key comes before the private key. Until now prepare-node-join
did the opposite, that is the public key came first. To avoid confusion
and potential bugs, this is changed.

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

11 years agoprepare-node-join: Use public key directly for auth…_keys
Michael Hanselmann [Tue, 23 Oct 2012 22:26:16 +0000 (00:26 +0200)]
prepare-node-join: Use public key directly for auth…_keys

A public key already includes the necessary prefix (“ssh-rsa” or
“ssh-dss”), so there is no need to add it again.

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

11 years agossh.GetUserFiles: Parameter to disable directory check
Michael Hanselmann [Tue, 23 Oct 2012 22:55:39 +0000 (00:55 +0200)]
ssh.GetUserFiles: Parameter to disable directory check

Without this parameter, either an error would be raised or “.ssh” would
have to be created. Now it is possible to retrieve the paths without
requiring the “.ssh” directory to exist.

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

11 years agoMove htools backends to a separate directory
Iustin Pop [Fri, 26 Oct 2012 07:32:35 +0000 (09:32 +0200)]
Move htools backends to a separate directory

Five modules under the HTools/ directories are backend
implementations, so let's move them to a separate directory, to more
clearly show the hierarchy. I wanted to do this for a while, but
merging between branches is always an issue, so let's do it know since
we have an opportunity.

This patch contains the actual renames, the required changed module
names, imports, etc., but no other changes.

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

11 years agoFix lint issue in Test/…/THH.hs
Iustin Pop [Fri, 26 Oct 2012 11:48:45 +0000 (13:48 +0200)]
Fix lint issue in Test/…/THH.hs

Sorry!

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

11 years agoFix X509CertError definition in Haskell codebase
Iustin Pop [Fri, 26 Oct 2012 08:22:21 +0000 (10:22 +0200)]
Fix X509CertError definition in Haskell codebase

Thanks Dato for catching this.

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

11 years agoFix a few issues found by newer hlint
Iustin Pop [Fri, 26 Oct 2012 06:49:48 +0000 (08:49 +0200)]
Fix a few issues found by newer hlint

Testing with a newer hlint found a few minor issues; but all are real,
valid recommendations:

- don't use "if cond then f x else f y", but "f (if cond then x else y)"
- "if a then b else True" is equivalent to the simpler "not a || b"
- and as usual, one more ignore to our "testing basic properties"
  module

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

11 years agoAdd a simple unittest for THH code
Iustin Pop [Thu, 25 Oct 2012 14:04:56 +0000 (16:04 +0200)]
Add a simple unittest for THH code

This is very THH specific, and applies to all serialisations generated
by THH, so I'm adding it in its own module.

Probably we should add some more generic tests, but in general THH
code is tested by the various definitions; this new field type however
is not (yet), so this is why I want this specific unittest.

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

11 years agoAdd support for optional fields with null serialised
Iustin Pop [Thu, 25 Oct 2012 13:48:05 +0000 (15:48 +0200)]
Add support for optional fields with null serialised

This follows a conversation we had for how to deal with
optional-but-required fields in JSON serialisations: fields which are
optional (can be either a given type or 'null'), but where the 'null'
value is required. There are just a few of these in the Python code,
but we should support them nevertheless.

The patch changes the 'isOptional' attribute from boolean to a custom
ADT, three-typed. This allows us to keep the same path on load (which
deals with both cases), but use a custom save path where we explicitly
save the 'null' value.

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

11 years agoErrors.hs: improve field names for ConfigVersionMismatch
Dato Simó [Thu, 25 Oct 2012 16:11:12 +0000 (17:11 +0100)]
Errors.hs: improve field names for ConfigVersionMismatch

Change {exp,act}Code to {exp,act}Ver, which gives a better idea that
the integer fields represent version numbers.

Also:

  - errors.py: update OpPrereqError's docstring to note that an error
    code is always expected as the second argument (it was previously
    optional).

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoRemove unused cache implementation
Iustin Pop [Thu, 25 Oct 2012 14:21:25 +0000 (16:21 +0200)]
Remove unused cache implementation

Note that this commit has no Makefile.am changes, as the files were
not actually used. So it's better to actually remove them.

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

11 years agoTHH.hs: delete isOptional, no longer used
Dato Simó [Wed, 24 Oct 2012 14:28:57 +0000 (15:28 +0100)]
THH.hs: delete isOptional, no longer used

The isOptional function is no longer used after a150585 (“Convert
opcode TH code to the use of Field type”).

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix two typos in Ganeti administrator's guide
Michele Tartara [Tue, 23 Oct 2012 15:55:14 +0000 (17:55 +0200)]
Fix two typos in Ganeti administrator's guide

Fix a verb tense and add a missing verb.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Adeodato Simo <dato@google.com>

11 years agobdev: Remove unused import of itertools
Michael Hanselmann [Thu, 25 Oct 2012 12:54:53 +0000 (14:54 +0200)]
bdev: Remove unused import of itertools

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Michele Tartara <mtartara@google.com>

11 years agobdev: Add verification for file storage paths
Michael Hanselmann [Wed, 17 Oct 2012 14:10:07 +0000 (16:10 +0200)]
bdev: Add verification for file storage paths

An earlier version of this patch series verified all paths in cmdlib in
the master daemon. With this change all that verification code is moved
to bdev to run inside the node daemon. The checks are much stricter
now--it is no longer possible to use forbidden paths (e.g. /bin) to
manipulate file storage devices (once these checks are being used).

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

11 years agojqueue: Factorize code to modify job
Michael Hanselmann [Wed, 24 Oct 2012 01:19:20 +0000 (03:19 +0200)]
jqueue: Factorize code to modify job

A new function will be added to change a job's priority.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

11 years agocli: Use callback for --priority
Michael Hanselmann [Wed, 24 Oct 2012 02:08:42 +0000 (04:08 +0200)]
cli: Use callback for --priority

If the option is used elsewhere, the numeric value is directly
available.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

11 years agojqueue: Add docstring for _DetermineJobDirectories
Michael Hanselmann [Wed, 24 Oct 2012 00:37:34 +0000 (02:37 +0200)]
jqueue: Add docstring for _DetermineJobDirectories

Somehow this was missed in commit 0422250e.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agojqueue: Fix comments in _SubmitJobUnlocked
Michael Hanselmann [Wed, 24 Oct 2012 00:38:27 +0000 (02:38 +0200)]
jqueue: Fix comments in _SubmitJobUnlocked

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoDrop SSHS_FORCE constant
Michael Hanselmann [Tue, 23 Oct 2012 21:52:44 +0000 (23:52 +0200)]
Drop SSHS_FORCE constant

It is not actually used.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoAdd a default `.ghci' file
Iustin Pop [Thu, 25 Oct 2012 10:33:10 +0000 (12:33 +0200)]
Add a default `.ghci' file

This options file for ghci preseeds the correct include paths, so that
interactive sessions don't need to always pass these args.

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

11 years agoConvert query path from string errors to GanetiException
Iustin Pop [Fri, 12 Oct 2012 12:37:20 +0000 (14:37 +0200)]
Convert query path from string errors to GanetiException

This patch converts all the call paths from 'Result' (which contains
just string errors) to 'ErrorResult', which holds
GanetiException-encoded errors. We can now return proper
OpPrereq/OpExec errors to the clients of the luxi/query socket.

The patch touches many files as we had to convert the entire call
chains in a single round. But it should be pretty straightforward
otherwise:

- change 'Result' into 'ErrorResult'
- add error annotations: change "Bad msg" into "Bad (XXXEror msg)"
- add a helper function for confd, where we don't send to client
  formatted exceptions, to convert back from ErrorResult into Result
- change tests similarly, where needed

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

11 years agoAdd exception utility functions
Iustin Pop [Fri, 12 Oct 2012 10:37:27 +0000 (12:37 +0200)]
Add exception utility functions

In Python, formatError also returns the exit code, but I find that
splitting them leads to clearer code.

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

11 years agoAdd an Errors module mirroring the Python one
Iustin Pop [Sun, 7 Oct 2012 22:02:20 +0000 (00:02 +0200)]
Add an Errors module mirroring the Python one

As described in the module doc string, while writing this it dawned
upon me that we're mixing all errors together into a single hierarchy
(well, type on the Haskell side), which is not good. Some errors are
used purely within noded, some in the CLI frontends, etc. so these
should not be the same type; frontend functions should only be able to
raise frontend errors, not backend ones.

As to this patch itself, I've used again Template Haskell to generate
both the data type and the serialisation functions, as the initial
version, hand-written, seemed too prone to errors due to string
matching.

A small unittest for checking serialisation consistency is also added.

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

11 years agoAbstract Luxi template functionality
Iustin Pop [Fri, 12 Oct 2012 09:09:05 +0000 (11:09 +0200)]
Abstract Luxi template functionality

These are almost generic, so let's change the signatures a bit a make
them fully so.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Adeodato Simo <dato@google.com>

11 years agoAbstract a few types in THH.hs
Iustin Pop [Fri, 12 Oct 2012 08:51:26 +0000 (10:51 +0200)]
Abstract a few types in THH.hs

This 'simple' way of defining objects will be used also for errors, so
let's make it less Luxi-specific.

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

11 years agoAdd missing empty line
Guido Trotter [Wed, 24 Oct 2012 12:11:51 +0000 (14:11 +0200)]
Add missing empty line

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

11 years agoRemove dumb-allocator code from devel/upload
Iustin Pop [Wed, 24 Oct 2012 10:25:30 +0000 (12:25 +0200)]
Remove dumb-allocator code from devel/upload

The 'dumb-allocator' has been removed almost two years ago (commit
6f547f96, “Remove dumb-allocator”), let's remove this special casing
for it from devel/upload.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoFix devel/upload restart of daemons
Iustin Pop [Wed, 24 Oct 2012 10:23:25 +0000 (12:23 +0200)]
Fix devel/upload restart of daemons

While running with a wrong --prefix/--sysconfdir, I saw that
devel/upload actually uses a hardcoded path for the init script, even
though it installs it in the correct place.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoAdd small design for Linux HA integration
Guido Trotter [Wed, 24 Oct 2012 10:08:48 +0000 (12:08 +0200)]
Add small design for Linux HA integration

This documents the status (or wanted status) of some example ocf modules
I've written for Ganeti. They are far from perfect, but they should be
shipped as a starting point for other people who want to run this to
improve on.

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

11 years agoReplace @LIBDIR@ in .in files
Guido Trotter [Fri, 4 Nov 2011 09:57:27 +0000 (09:57 +0000)]
Replace @LIBDIR@ in .in files

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

11 years agoImprove devel/upload command line handling
Iustin Pop [Tue, 23 Oct 2012 16:19:01 +0000 (18:19 +0200)]
Improve devel/upload command line handling

To people not used to it, it was completely non-obvious why
"./devel/upload" didn't do anything.

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

11 years agoImprove logging of AssertionErrors
Iustin Pop [Tue, 23 Oct 2012 14:01:18 +0000 (16:01 +0200)]
Improve logging of AssertionErrors

Currently, when we have an assertion error raised from cmdlib, it looks like this:

  [cluster] root@node4:~# gnt-instance grow-disk instance1 0 1G
  Failure: command execution error:

This is very very confusing. This patch adds a bit of traceback
formatting to improve this as follows:

  [cluster] root@node4:~# gnt-instance grow-disk instance1 0 1G
  Failure: command execution error:
  Internal assertion error: please report this as a bug.
  Error message: ''; location:
    File "/usr/lib/python2.6/dist-packages/ganeti/cmdlib.py", line 11954, in CheckPrereq
      assert False

This is not perfect, but at least it shows better what the problem is.

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

11 years agotools.prepare_node_join: Fix pep8 errors
Michael Hanselmann [Tue, 23 Oct 2012 16:01:12 +0000 (18:01 +0200)]
tools.prepare_node_join: Fix pep8 errors

Pep8 didn't agree with the indentation.

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

11 years agoAdd initial implementation of prepare-node-join
Michael Hanselmann [Tue, 16 Oct 2012 14:04:15 +0000 (16:04 +0200)]
Add initial implementation of prepare-node-join

This is a new tool as per the design document “design-ssh-setup”. It
receives a JSON data structure on its standard input and configures the
SSH daemon and root's SSH keys accordingly. Unit tests are included.

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

11 years agossh.GetUserFiles: RSA support, unit tests
Michael Hanselmann [Thu, 18 Oct 2012 15:34:02 +0000 (17:34 +0200)]
ssh.GetUserFiles: RSA support, unit tests

This patch changes “ssh.GetUserFiles” to support two different kinds of
SSH keys, RSA and DSA. Before it would always use DSA. Newly written
unit tests are included.

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

11 years agoFix typo in walkthrough document
Michele Tartara [Tue, 23 Oct 2012 07:41:14 +0000 (09:41 +0200)]
Fix typo in walkthrough document

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFind coverage during configure, issue with Debian package
Michael Hanselmann [Mon, 22 Oct 2012 15:05:16 +0000 (17:05 +0200)]
Find coverage during configure, issue with Debian package

- Debian Squeeze and up have a package named “python-coverage”, but it
  doesn't use the same binary name as upstream (“coverage”).
- Said package includes a patch to use symlinks instead of file copies
  for jQuery. If files from previous runs are around, an exception is
  raised. This is fixed by removing all regular files and symlinks
  before generating a report.

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

11 years agoRemove multiple uses of '.&&.' with conjoin
Iustin Pop [Mon, 22 Oct 2012 12:19:42 +0000 (14:19 +0200)]
Remove multiple uses of '.&&.' with conjoin

This is just a bit of cleanup. The (.&&.) operator is internally just:

  a .&& b = conjoin [a, b]

so let's replace 'a .&&. b .&&. c .&&. d' directly with 'conjoin [a,
b, c, d]'.

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

11 years agoImprove message for (==?) operator
Iustin Pop [Mon, 22 Oct 2012 12:07:06 +0000 (14:07 +0200)]
Improve message for (==?) operator

After seeing how nice HUnit formats the error message on failed
'assertEqual', I think we can do better with ==?. Currently it says
(on one line): "Expected equality, but 1 /= 2".

This patch changes the code to format it similar to HUnit:

  Expected equality, but got mismatch
  expected: 1
   but got: 2

(on three lines). This makes it more clear what is the expected and
what is the wrong value.

A few tests have been modified to ensure that the expected value is
the second argument to ==?. This is different than HUnit, but makes
more sense in the operator version (I think).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoAdd a new 'really-all' make target
Iustin Pop [Mon, 22 Oct 2012 11:46:03 +0000 (13:46 +0200)]
Add a new 'really-all' make target

This is used when one wants to build all binaries, including those
that are used only for testing. A handy shortcut to make sure all
binaries can be built.

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

11 years agoAnnotated inequality operator for unit test properties
Helga Velroyen [Mon, 22 Oct 2012 11:08:46 +0000 (13:08 +0200)]
Annotated inequality operator for unit test properties

This includes:
 * The operator (/=?), which checks for inequality and prints
   an error message if it encounters equality. (Basically the
   negation of the (==?) operator).
 * Application of this operator in the test property
   prop_addPri_NoN1Fail.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix setting of 'failN1' flag for corner case
Helga Velroyen [Mon, 22 Oct 2012 09:19:48 +0000 (11:19 +0200)]
Fix setting of 'failN1' flag for corner case

This patch includes:

* The 'failN1' flag is now only set if there is strictly less
  memory available than required for failover.
* Unit tests for that.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoA few unittests improvements
Helga Velroyen [Mon, 22 Oct 2012 09:28:22 +0000 (11:28 +0200)]
A few unittests improvements

Small simplifications of other unit tests using the (==?)
operator when possible, and typo fixes.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoCorrected some commandlines in walkthrough
Helga Velroyen [Fri, 19 Oct 2012 14:56:48 +0000 (16:56 +0200)]
Corrected some commandlines in walkthrough

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoBasicTypes.hs: fix docstring for eitherToResult
Dato Simó [Fri, 19 Oct 2012 14:54:54 +0000 (15:54 +0100)]
BasicTypes.hs: fix docstring for eitherToResult

eitherToResult now converts from `Either a b` to `GenericResult`, not
necessarily from `Either String` only. Also, fix a typo.

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd note about running individual test cases
Iustin Pop [Fri, 19 Oct 2012 14:25:23 +0000 (16:25 +0200)]
Add note about running individual test cases

This was asked a few times offline, so let's document it.

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

11 years agoAdd a small QA check in instance renames for tags update
Iustin Pop [Fri, 19 Oct 2012 11:42:35 +0000 (13:42 +0200)]
Add a small QA check in instance renames for tags update

We also need to change the signature for _GetInstanceInfo, since we
don't have access to the instance dictionary in the rename instance
test.

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

11 years agoUpdate blockdev's "info" at instance rename
Iustin Pop [Thu, 18 Oct 2012 15:59:56 +0000 (17:59 +0200)]
Update blockdev's "info" at instance rename

Currently, we set "info" metadata on block devices at device creation
time, but we never update it, leading to stale data in case of
instance renames. This would not be a big problem in case of regular
renames (assuming this is a rare operation), but importing instances
into the cluster via the import/export feature usually is done with a
rename; this means that all imported instances have wrong information
in their block devices.

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

11 years agoLVM: remove old tags when adding new ones
Iustin Pop [Thu, 18 Oct 2012 15:58:45 +0000 (17:58 +0200)]
LVM: remove old tags when adding new ones

This patch adds a small helper function to clear an LV's tags, and
calls it at SetInfo time. We need this to be able to correctly track
instance renames, once we will call SetInfo at such times.

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

11 years agoAdd a small bdev helper function
Iustin Pop [Thu, 18 Oct 2012 15:56:48 +0000 (17:56 +0200)]
Add a small bdev helper function

I wanted to write that snippet the third time, which is too much :)

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

11 years agoAdd a small note about tab completion and generated files
Iustin Pop [Thu, 18 Oct 2012 14:11:13 +0000 (16:11 +0200)]
Add a small note about tab completion and generated files

This can indeed be annoying, so let's document it.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Adeodato Simo <dato@google.com>

11 years agoUpdate for SSH design: Cluster name, ignore node daemon
Michael Hanselmann [Thu, 18 Oct 2012 11:38:40 +0000 (13:38 +0200)]
Update for SSH design: Cluster name, ignore node daemon

While writing the initial version of this design I misunderstood what
“setup-ssh” does. It doesn't actually start the node daemon and just
configures SSH, nothing else.

This patch adds the cluster name as a field to the JSON structure and
clarifies the purpose of the node daemon certificate given.

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

11 years agoCompare significant fields only for simple SSH keys
Michael Hanselmann [Thu, 18 Oct 2012 17:59:22 +0000 (19:59 +0200)]
Compare significant fields only for simple SSH keys

For simple SSH keys, that is those without options such as
“command="…"”, only the first two parts need to be compared. The third
field is a free-form comment.

This patch changes the comparison used in
AddAuthorizedKey/RemoveAuthorizedKey to take this into account. Lines
with options are still compared in full.

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

11 years agoAdd instance uptime to monitoring info
Guido Trotter [Thu, 18 Oct 2012 15:15:19 +0000 (17:15 +0200)]
Add instance uptime to monitoring info

This can be used to detect a reboot between two checks.

Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

11 years agotest/*.py: Replace '' with ""
Michael Hanselmann [Thu, 18 Oct 2012 15:39:42 +0000 (17:39 +0200)]
test/*.py: Replace '' with ""

There might be more, but at least replace all these low-hanging fruits.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoAdd cluster monitoring agent design document
Guido Trotter [Wed, 10 Oct 2012 10:07:15 +0000 (12:07 +0200)]
Add cluster monitoring agent design document

This design addresses the lack of a uniform way to query ganeti nodes
for real time information that can be used by monitoring.

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

11 years agoRemove custom OpResult type/monad
Iustin Pop [Sun, 7 Oct 2012 20:12:56 +0000 (22:12 +0200)]
Remove custom OpResult type/monad

Since we now have the GeneralResult as a multi-purpose monad, we can
remove the custom OpResult monad, and just use 'GeneralResult
FailMode' as our type. This allows removal of a few bits of
specialised infrastructure, relying instead on the generic one.

The restriction on using OpResult as a general monad remains as
before.

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

11 years agoMerge branch 'devel-2.6'
Michael Hanselmann [Thu, 18 Oct 2012 10:44:37 +0000 (12:44 +0200)]
Merge branch 'devel-2.6'

* devel-2.6:
  ensure-dirs: Don't accept arguments
  ensure-dirs: Fix program name on usage screen
  cli: Fix small typo

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

11 years agoensure-dirs: Don't accept arguments
Michael Hanselmann [Wed, 17 Oct 2012 15:40:11 +0000 (17:40 +0200)]
ensure-dirs: Don't accept arguments

Before they would just be silently ignored.

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

11 years agoensure-dirs: Fix program name on usage screen
Michael Hanselmann [Wed, 17 Oct 2012 15:32:15 +0000 (17:32 +0200)]
ensure-dirs: Fix program name on usage screen

No string replacements are used, so doubling of the percent sign is not
necessary.

Before: Usage: %ensure-dirs [--full-run]
After: Usage: ensure-dirs [--full-run]

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

11 years agoConvert man page highlighting to standard RST
Iustin Pop [Wed, 17 Oct 2012 23:11:24 +0000 (01:11 +0200)]
Convert man page highlighting to standard RST

Instead of using the sphinx-specific highlight extension, which is not
parsed by Pandoc, let's switch to the standard RST directive, which
will be picked up and will result in slightly nicer man pages when
converted to HTML (in man output it remains the same).

Note that I've converted only some of the examples (the one that
actually had shell scripts); the ones that show command lines
(e.g. starting with '#') I didn't convert, as they don't look nice
(and Pandoc/Kate highlighting doesn't have the equivalent of our
shell-example lexer we use in sphinx).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoConvert two more 'sh' highlight styles to 'shell-example'
Iustin Pop [Wed, 17 Oct 2012 22:19:57 +0000 (00:19 +0200)]
Convert two more 'sh' highlight styles to 'shell-example'

This is straightforward; only one shell example remained, but as we
process the man pages via pandoc and not sphinx, it's not actually
used, we leave it as such for now.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoSmall improvements to the move-instance doc
Iustin Pop [Wed, 17 Oct 2012 22:09:32 +0000 (00:09 +0200)]
Small improvements to the move-instance doc

While reading the docs, I saw that this is not converted to the shell
lexer, and that a few other small improvements can be done.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoUse exitErr instead of explicit error message and exitWith
Helga Velroyen [Thu, 18 Oct 2012 08:56:30 +0000 (10:56 +0200)]
Use exitErr instead of explicit error message and exitWith

Furthermore, a few messages have their capitalisation changed (fixed).

Signed-off-by: Helga Velroyen <helgav@google.com>
Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix running of Haskell tests
Iustin Pop [Wed, 17 Oct 2012 16:50:58 +0000 (18:50 +0200)]
Fix running of Haskell tests

Commit 21a5e56c forgot to rename a variable used in a conditional (of
course shell didn't complain about unused vars), so the AM_CONDITIONAL
was always false.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Adeodato Simo <dato@google.com>

11 years agoGeneralise the Result type
Iustin Pop [Sun, 7 Oct 2012 19:52:11 +0000 (21:52 +0200)]
Generalise the Result type

Currently, our error monad—Result—has a plain string error type. This
is not good, as we don't have structured errors, we can't pass back
proper error information to Python code, etc.

To solve this, we generalise this type as 'GenericResult a', and make
Result an alias to 'GenericResult String' for compatibility with the
old code. New error hierarchies will be introduced as different
types. Furthermore, we generalise our helper functions too, so that
they can work on any 'GeneralInstance a' type, not only Result.

There are two small drawbacks to this generalisation. First, a Monad
instance requires (at least for the way we use it) a 'fail :: String
-> m a' instance, so we need to be able to build an 'a' value from a
string; therefore, we can implement the Monad instance only for a
newly-introduced typeclass, 'FromString', which requires the needed
conversion function. Second, due to the fact that 'String' is a type
alias (for [Char]) instead of an actual type, we need to enable the
FlexibleInstances language pragma; as far as I know, this has no
significant drawbacks.

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

11 years agoMerge branch 'devel-2.6' into master
Dato Simó [Wed, 17 Oct 2012 15:40:05 +0000 (16:40 +0100)]
Merge branch 'devel-2.6' into master

* devel-2.6:
  htools-excl.test: add test case for exclusion tags in hbal
  Instance.hs: rename 'tags' to 'exclTags', provide 'allTags'
  Group.hs: add 'allTags'; adjust loaders and test data for it
  Add hbal-excl-tags.data to Makefile.am, missed in 0397694

Conflicts:
Makefile.am: hbal-excl-tags.data moved under htest/
htools/Ganeti/HTools/Luxi.hs: types from Qlang are now used
htools/Ganeti/HTools/QC.hs: defGroup definition now in TestHTools.hs
lib/cmdlib.py: IAllocator class now in iallocator.py
test/htools-excl.test: moved under htest/

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agocli: Fix small typo
Michael Hanselmann [Wed, 17 Oct 2012 15:29:12 +0000 (17:29 +0200)]
cli: Fix small typo

s/it/if/

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Dato Simó <dato@google.com>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoAdd hbal-excl-tags.data to Makefile.am, missed in 0397694
Dato Simó [Wed, 17 Oct 2012 15:24:51 +0000 (16:24 +0100)]
Add hbal-excl-tags.data to Makefile.am, missed in 0397694

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

11 years agoGroup.hs: add 'allTags'; adjust loaders and test data for it
Dato Simó [Wed, 10 Oct 2012 21:51:30 +0000 (22:51 +0100)]
Group.hs: add 'allTags'; adjust loaders and test data for it

This commit adds a Group.allTags field to store the tags of node groups,
and teaches each loader backend in HTools to populate it (additionally, the
IAllocator class in lib/cmdlib.py now includes tags for groups too). Test
data is updated to include an empty set of tags for node groups in all
affected test cases.

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoInstance.hs: rename 'tags' to 'exclTags', provide 'allTags'
Dato Simó [Wed, 10 Oct 2012 16:58:37 +0000 (17:58 +0100)]
Instance.hs: rename 'tags' to 'exclTags', provide 'allTags'

The mergeData function in Loader.hs included a step to filter an instance's
tags to include only the exclusion tags (as specified via the commandline,
or cluster-level tags). Later on, code in Node.hs assumed Instance.tags to
contain only tags to be used for exclusion.

Because in the future we will need to access the full list of an instance's
tags (and not only exclusion tags), this commits deprecates the 'tags'
field, and introduces Instance.exclTags and Instance.allTags.

Instance.allTags is now populated from the different backends (Text, Luxi,
Rapi, etc.), and Instance.exclTags is only populated from Loader.mergeData,
as was done previously. This means that loading tags from e.g. Text or Simu
and assuming that they'll be used as exclusion tags without going through
Loader.hs will no longer work; but this was already the case with other
fields, and 'mergeData' or 'loadExternalData' continue to be the only entry
points to get a consistent view of the cluster. (Additionally, there were
no tests that made this assumption that I could find.)

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agohtools-excl.test: add test case for exclusion tags in hbal
Dato Simó [Fri, 12 Oct 2012 15:03:15 +0000 (16:03 +0100)]
htools-excl.test: add test case for exclusion tags in hbal

In preparation for future modifications in the exclusion tags field, add a
test that verifies that exclusion tags are being honored: in a test cluster
with two instances of the same exclusion group in each node, hbal should
shuffle instances around to improve the score.

Signed-off-by: Dato Simó <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix small typo in NEWS file
Iustin Pop [Wed, 17 Oct 2012 11:55:53 +0000 (13:55 +0200)]
Fix small typo in NEWS file

Sorry, I didn't see this before pushing 5a7cb9d3

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Adeodato Simo <dato@google.com>

11 years agoRemove support for PUT in noded
Iustin Pop [Wed, 17 Oct 2012 05:47:51 +0000 (07:47 +0200)]
Remove support for PUT in noded

This takes care of a FIXME; 2.6 already uses the new method, so we're
good during upgrades.

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

11 years agoIgnore empty/comment lines in OS variants file
Iustin Pop [Wed, 17 Oct 2012 07:50:00 +0000 (09:50 +0200)]
Ignore empty/comment lines in OS variants file

Per a conversation on ganeti@googlegroups.com:

  - gnt-os diagnose ; gnt-os list take in consideration blank lines in
   /etc/ganeti/instance-image/variants.list that could be confusing.

Let's fix this and also let's ignore comment lines.

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

11 years agognt-job cancel: Confirmation and selection of jobs
Michael Hanselmann [Fri, 12 Oct 2012 09:10:13 +0000 (11:10 +0200)]
gnt-job cancel: Confirmation and selection of jobs

New parameters, “--pending”, “--queued” and “--waiting”, are added to
select all jobs in the respective state. If one of those options is used
and “--force” is not given, the user is asked to confirm the operation.
Unit tests are included.

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

11 years agoUpdate NEWS for file storage paths
Michael Hanselmann [Fri, 5 Oct 2012 01:39:42 +0000 (03:39 +0200)]
Update NEWS for file storage paths

Mention that the file is something new and should be written by
cfgupgrade.

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

11 years agoReplace custom algorithm in constants unittest
Michael Hanselmann [Fri, 12 Oct 2012 09:26:23 +0000 (11:26 +0200)]
Replace custom algorithm in constants unittest

There is no need for the “_IsUniqueSequence” function anymore, it can
easily be replaced by utils.FindDuplicates. Also, pass the message as a
keyword parameter and use the more commonly used assert* functions.

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

11 years agoDesign for remote command execution via RPC
Michael Hanselmann [Fri, 12 Oct 2012 13:53:35 +0000 (15:53 +0200)]
Design for remote command execution via RPC

This is a first design for executing commands via RPC.

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

11 years agoMakefile: Verify version of security.rst document
Michael Hanselmann [Fri, 12 Oct 2012 13:05:41 +0000 (15:05 +0200)]
Makefile: Verify version of security.rst document

This document should be kept up-to-date.

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

11 years agoAdd new constant for pending job status
Michael Hanselmann [Fri, 12 Oct 2012 09:35:54 +0000 (11:35 +0200)]
Add new constant for pending job status

This constant contains the job status' “queued”, “waiting” and
“cancelled”.

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

11 years agoMerge branch 'devel-2.6'
Michael Hanselmann [Tue, 16 Oct 2012 14:40:26 +0000 (16:40 +0200)]
Merge branch 'devel-2.6'

* devel-2.6:
  ensure-dirs: Fix permissions on master socket
  Update security document for version 2.6
  Update NEWS and bump version to 2.6.1
  Text.hs: update field lists in parseData comments

Conflicts:
NEWS: Trivial
lib/tools/ensure_dirs.py: constant moved to pathutils

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

11 years agoensure-dirs: Fix permissions on master socket
Michael Hanselmann [Fri, 12 Oct 2012 13:07:47 +0000 (15:07 +0200)]
ensure-dirs: Fix permissions on master socket

A socket shouldn't have its executable bit set.

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

11 years agoUpdate security document for version 2.6
Michael Hanselmann [Fri, 12 Oct 2012 13:06:40 +0000 (15:06 +0200)]
Update security document for version 2.6

Quite some things were out of date. Some formatting was also updated.

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

11 years agoAdd a very simple test rpc program
Iustin Pop [Tue, 16 Oct 2012 10:56:40 +0000 (12:56 +0200)]
Add a very simple test rpc program

This only supports test delay for now, is not built by default (only
on demand), and is also not installed anywhere.

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

11 years agoconfd: add the test_delay RPC call
Iustin Pop [Tue, 16 Oct 2012 10:55:42 +0000 (12:55 +0200)]
confd: add the test_delay RPC call

Also add some more haddock structure to the module. The RPC call
itself is rather trivial.

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

11 years agoAdd htools program code to hlint call
Iustin Pop [Tue, 16 Oct 2012 10:55:06 +0000 (12:55 +0200)]
Add htools program code to hlint call

Currently only the libraries are added, but not the actual main binary
(usually short) code.

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

11 years agoAdd design for changing node SSH setup
Michael Hanselmann [Mon, 15 Oct 2012 17:03:39 +0000 (19:03 +0200)]
Add design for changing node SSH setup

The goal is to remove the dependency on Paramiko.

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

11 years agoconfd: fix RpcVersion call
Iustin Pop [Mon, 15 Oct 2012 19:50:50 +0000 (21:50 +0200)]
confd: fix RpcVersion call

By accident, we sent the node object as call data in this rpc call,
instead the version request (i.e. nothing). This is due to the fact
that the 'call' data comes second, not first in the function argument.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>

11 years agoCleanup HTools.Types/BasicTypes imports
Iustin Pop [Sun, 7 Oct 2012 18:46:28 +0000 (20:46 +0200)]
Cleanup HTools.Types/BasicTypes imports

Before we reorganised the source tree, the 'Result' type was exported
from HTools/Types.hs. This changed during the reorg, but at that time
we didn't change the exports; instead, we kept re-exporting it from
the old module for compatibility.

In light of future changes to the Result type, let's stop this
re-export and cleanup the imports of the other modules.

One test is slightly rewritten with explicit types declaration (part
of the values already needed one, let's make it explicit).

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