ganeti-local
11 years agoFix bug in network module
Dimitris Aragiorgis [Fri, 23 Nov 2012 08:32:47 +0000 (10:32 +0200)]
Fix bug in network module

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Iustin Pop <iustin@google.com>
[iustin@google.com: slightly improved code flow]
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd design for simplified node-add process
Michael Hanselmann [Mon, 19 Nov 2012 15:59:01 +0000 (16:59 +0100)]
Add design for simplified node-add process

Instead of initiating many SSH connections to copy files using “scp”, a
JSON structure is passed to a program running on the node to be added.
The design is similar to the one used for SSH setup.

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

11 years agoImplement the correct handling of numbers without commas
Michele Tartara [Wed, 21 Nov 2012 17:25:53 +0000 (17:25 +0000)]
Implement the correct handling of numbers without commas

commaInt now recognizes only the first 3 digits for numbers without commas.

It was erroneously recognizing numbers of any size before the first comma.

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

11 years agoMake ipolicy violations a warning
Helga Velroyen [Wed, 21 Nov 2012 17:55:50 +0000 (18:55 +0100)]
Make ipolicy violations a warning

So far, when running 'gnt-cluster verify' on a cluster which
has instances that violate the instance policy, those
violations were shown as an error. This patch makes them a
warning.

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

11 years agoSmall style fixes (' vs ") in network code
Iustin Pop [Wed, 21 Nov 2012 15:27:51 +0000 (16:27 +0100)]
Small style fixes (' vs ") in network code

This is just trivial fixes; I think I caught all of them.

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

11 years agoA few more hlint fixes
Iustin Pop [Wed, 21 Nov 2012 12:14:05 +0000 (13:14 +0100)]
A few more hlint fixes

I'm ignoring the use of Control.Arrow.*** since it's a non-obvious
function, and we're not widely using Arrows in the code base, so I
think switching to it would make the code less readable to most
people.

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

11 years agoFix OpCode arbitrary generation w.r.t. non-ASCII chars
Iustin Pop [Wed, 21 Nov 2012 11:55:46 +0000 (12:55 +0100)]
Fix OpCode arbitrary generation w.r.t. non-ASCII chars

Since we generate arbitrary strings and then we send them over a pipe
to Python, we can (and will) generate non-ascii chars, which means
when run in a non-UTF8 locale, this will break with ghc 6.12 and
later. It didn't break on my workstation, since I have a "nice"
locale.

So to fix this, we replace all name generations with explicit
genName/genNameNE and similar, to ensure we only send "nice" strings.

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

11 years agoBulk add of remaining cluster/node opcodes
Iustin Pop [Mon, 19 Nov 2012 15:55:30 +0000 (16:55 +0100)]
Bulk add of remaining cluster/node opcodes

These are tested for equivalence with the Python code using existing
tests. These tests are not perfect - for many "TDict" we simply send
empty dicts, as we don't have a way to generate proper data, but the
tests did catch many trivial errors during writing of this patch
series.

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

11 years agoConvert a few existing opcode parameters to safer types
Iustin Pop [Mon, 19 Nov 2012 15:39:52 +0000 (16:39 +0100)]
Convert a few existing opcode parameters to safer types

This does a partial conversion of existing opcodes to the new
non-empty string type, which is needed so that we don't add even more
opcodes without this safety net (and to have consistent "target_node",
etc. in opcodes).

By partial I mean that only the opcode are changed, and not the entire
htools types/workflow, so we use error to abort if, when submitting
the opcodes, we detect an empty node name. FIXME added.

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

11 years agoAdd many more opcode parameters
Iustin Pop [Mon, 19 Nov 2012 15:35:45 +0000 (16:35 +0100)]
Add many more opcode parameters

This is a bulk add of all node parameters needed for node and cluster
opcodes. The parameters are defined with a few helper functions in
this module, and, opposite from opcodes.py, there won't be any (new)
opcode attributes declared in-line (without a separate field
definition).

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

11 years agoAdd two more basic types
Iustin Pop [Mon, 19 Nov 2012 15:21:44 +0000 (16:21 +0100)]
Add two more basic types

These are needed for completing the node opcode parameters.

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

11 years agoAdd an arbitrary set generator helper
Iustin Pop [Mon, 19 Nov 2012 15:20:00 +0000 (16:20 +0100)]
Add an arbitrary set generator helper

This makes it easy to generate sets of "things" that don't even need
to have arbitrary instances, but which have bounded/enum instances.

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

11 years agoMove StorageType from RPC.hs to Types.hs
Iustin Pop [Mon, 19 Nov 2012 15:19:18 +0000 (16:19 +0100)]
Move StorageType from RPC.hs to Types.hs

This fixes a FIXME actually recommending this move :)

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

11 years agoSplit 'Query.Language.ItemType' in two sub-types
Iustin Pop [Mon, 19 Nov 2012 12:15:23 +0000 (13:15 +0100)]
Split 'Query.Language.ItemType' in two sub-types

The QR_VIA_OP/QR_VIA_LUXI types in Python are using yet another
validation mode: QR_VIA_OP is the base type, and QR_VIA_LUXI extends
it (when doing luxi queries). But on the wire they have the same
representation.

To accommodate this properly, we split the ItemType in two: a
QueryTypeOp and a QueryTypeLuxi, joining them back together in
ItemType itself. This requires custom serialisation/deserialisation,
but allows us to express correctly that at opcode level, we only
accept a QueryTypeOp, but at Luxi query level, we accept either of
them.

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

11 years agoMove the 'Hypervisor' type from Objects to Types
Iustin Pop [Mon, 19 Nov 2012 09:46:50 +0000 (10:46 +0100)]
Move the 'Hypervisor' type from Objects to Types

This is a very basic type and 'Objects' is a heavy-weight module. By
moving it to 'types' we simplify (in the future) the import chains.

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

11 years agoGeneralise the JSON "Container" type
Iustin Pop [Fri, 16 Nov 2012 13:32:53 +0000 (14:32 +0100)]
Generalise the JSON "Container" type

Currently, we have some types that we kept as dictionaries in the
objects representation (due to inconsistent behaviour, or other
technical reasons). This should be improved in the future, but in the
meantime we can improve the Container type by allowing its keys to be
non-strings; this is needed, for example, for better safe in
DiskParams type, where we don't want arbitrary strings as keys, but
only the actually defined types.

To implement this change, we generalise the type (Container →
GenericContainer), and in the process we introduce a type class for
"things that can be represented as strings". This is very similar to a
combination of Read and Show, but with custom string
representation. The new type class is needed because in JSON
representation, object keys must be strings, so we need to be able to
serialised/deserialise the generic keys to/from plain strings.

We also add the instance for DiskTemplate at the same time.

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

11 years agoAdd more basic Ganeti types
Iustin Pop [Fri, 16 Nov 2012 13:31:09 +0000 (14:31 +0100)]
Add more basic Ganeti types

These are needed both in opcodes and (potentially) outside, so we add
them in the main Types module.

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

11 years agoRename leftovers from remote to restricted commands
Michael Hanselmann [Tue, 20 Nov 2012 05:04:26 +0000 (06:04 +0100)]
Rename leftovers from remote to restricted commands

As per Iustin Pop's suggestion in <20121115131730.GX824@google.com> on
<ganeti-devel@googlegroups.com>.

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

11 years agobackend: Rename RunRemoteCommand to RunRestrictedCmd
Michael Hanselmann [Tue, 20 Nov 2012 04:53:12 +0000 (05:53 +0100)]
backend: Rename RunRemoteCommand to RunRestrictedCmd

As per Iustin Pop's suggestion in <20121115131730.GX824@google.com> on
<ganeti-devel@googlegroups.com>.

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

11 years agoRename constants and directory for restricted commands
Michael Hanselmann [Tue, 20 Nov 2012 04:47:39 +0000 (05:47 +0100)]
Rename constants and directory for restricted commands

As per Iustin Pop's suggestion in <20121115131730.GX824@google.com> on
<ganeti-devel@googlegroups.com>.

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

11 years agoRename configure option for restricted commands
Michael Hanselmann [Fri, 16 Nov 2012 17:11:57 +0000 (18:11 +0100)]
Rename configure option for restricted commands

It is no longer “--enable-remote-commands”, but rather
“--enable-restricted-commands”.

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

11 years agoAdd command line interface for running commands remotely
Michael Hanselmann [Thu, 15 Nov 2012 10:16:32 +0000 (11:16 +0100)]
Add command line interface for running commands remotely

This patch adds a new command, “gnt-node restricted-command”. Since the
semantics are different from “gnt-cluster command”, the same subcommand
shouldn't be re-used.

The included man page update also includes a small description of how to
configure and use remote commands.

Restricted commands can be run on a whole node group or on any number of
manually chosen nodes.

The output is similar to “gnt-cluster command”.

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

11 years agoRemove delayed iallocator call in TLReplaceDisks
Michael Hanselmann [Wed, 21 Nov 2012 07:44:27 +0000 (08:44 +0100)]
Remove delayed iallocator call in TLReplaceDisks

By setting the “delay_iallocator” parameter one could delay the call to
the instance allocator. This was not used for some time now, but the
code was still there.

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

11 years agocmdlib: Merge duplicated code for TLMigrateInstance
Michael Hanselmann [Wed, 21 Nov 2012 07:36:37 +0000 (08:36 +0100)]
cmdlib: Merge duplicated code for TLMigrateInstance

LUInstanceFailover and LUInstanceMigrate use TLMigrateInstance and had
the essentially same code for expanding names and declaring locks. In
LUInstanceMigrate.ExpandNames there was a mistake which led to node
resource locks not being declared properly. The two DeclareLocks methods
were exactly the same, down to the byte.

TLMigrateInstance had a lot of keyword parameters. Since it is only used
on two places, all parameters were made positional, making it easier to
determine the value of a parameter.

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

11 years agoFix lint error about too many variables
Helga Velroyen [Wed, 21 Nov 2012 10:35:18 +0000 (11:35 +0100)]
Fix lint error about too many variables

Lint complains about too many variables in the CheckPrereq
method. While I think that this method/class would need
some refactoring in general, at least this patch makes lint
shut up for now.

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

11 years agoCheck ispecs against ipolicy on instance modify
Helga Velroyen [Tue, 20 Nov 2012 17:16:29 +0000 (18:16 +0100)]
Check ispecs against ipolicy on instance modify

When modifying an instance, so far the specs were not checked against
the ipolicy. This patch fixes this issue.

Note that for backend parameters which have a minimum and a maximum
value (currently only memory), it checks both limits against the
ipolicy. Because locking of the instance's node group was necessary, a
TODO of commit b8925b86 was fixed as well.

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

11 years agolocking.LockSet: Replace boolean parameter with constants
Michael Hanselmann [Mon, 19 Nov 2012 21:34:12 +0000 (22:34 +0100)]
locking.LockSet: Replace boolean parameter with constants

Upcoming changes will add opportunistic locking to “locking.LockSet”.
Doing so will require additional code in “LockSet.__acquire_inner”, at
which point the existing “want_all” parameter does not always apply.
This patch replaces it with a “mode” parameter. For opportunistic
locking a new mode will be added.

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

11 years agoRAPI: Clarify non-exhaustive nature of examples
Michael Hanselmann [Wed, 21 Nov 2012 05:14:32 +0000 (06:14 +0100)]
RAPI: Clarify non-exhaustive nature of examples

The examples given in the RAPI documentation are not exhaustive. This
patch tries to clarify this by adding ellipses where appropriate. One
example's indentation is also fixed.

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

11 years agoAdd tests for __repr__ in locking classes
Michael Hanselmann [Wed, 21 Nov 2012 05:07:01 +0000 (06:07 +0100)]
Add tests for __repr__ in locking classes

“locking.PipeCondition” and “locking.SharedLock” define “__repr__”,
which until now was not tested at all.

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

11 years agotest/*.py: s/'/"/
Michael Hanselmann [Wed, 21 Nov 2012 04:57:22 +0000 (05:57 +0100)]
test/*.py: s/'/"/

Now that 2.6 is essentially finished and 2.7 going to be branched
soon-ish, I thought it would be a good moment to replace some single
quotes in test/*.py. Merge pains should be limited.

In one place in test/ganeti.locking_unittest.py, spaces are added for
assignments.

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

11 years agonetwork: Style updates
Michael Hanselmann [Wed, 21 Nov 2012 01:42:17 +0000 (02:42 +0100)]
network: Style updates

- Quote characters
- Docstrings

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

11 years agoDocument requirement for ipaddr and bitarray modules
Michael Hanselmann [Wed, 21 Nov 2012 01:42:00 +0000 (02:42 +0100)]
Document requirement for ipaddr and bitarray modules

Also update configure.ac.

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

11 years agoht: Complain if TNone isn't listed first for TOr/TAnd
Michael Hanselmann [Wed, 21 Nov 2012 04:08:09 +0000 (05:08 +0100)]
ht: Complain if TNone isn't listed first for TOr/TAnd

Some type descriptions are rather long. If "None" is listed at the end
or somewhere in between it is easily missed. Therefore it should be at
the beginning, e.g. "None or (long description)".

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

11 years agoAdd unit test for default parameter default values
Michael Hanselmann [Wed, 21 Nov 2012 03:52:06 +0000 (04:52 +0100)]
Add unit test for default parameter default values

Fails if the default value of an opcode parameter doesn't verify.

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

11 years agoopcodes: Network parameter improvements and fixes
Michael Hanselmann [Wed, 21 Nov 2012 04:06:08 +0000 (05:06 +0100)]
opcodes: Network parameter improvements and fixes

- Use variables for checks for IP addresses (makes them more consistent,
  too)
- Fix checks to accept default values
- Small description improvements (e.g. s/IP/IP address/)

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

11 years agoMerge branch 'devel-2.6'
Michael Hanselmann [Wed, 21 Nov 2012 05:51:40 +0000 (06:51 +0100)]
Merge branch 'devel-2.6'

* devel-2.6:
  Fix opcode validation for OpOobCommand.command
  Fix typo in manpage for gnt-os
  gnt-instance.8: Add index to disk and nic removal

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

11 years agoMerge branch 'stable-2.6' into devel-2.6
Michael Hanselmann [Wed, 21 Nov 2012 03:52:29 +0000 (04:52 +0100)]
Merge branch 'stable-2.6' into devel-2.6

* stable-2.6:
  Fix opcode validation for OpOobCommand.command
  Fix typo in manpage for gnt-os
  gnt-instance.8: Add index to disk and nic removal

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

11 years agolocking: Use frozenset instead of utils.UniqueSequence
Michael Hanselmann [Mon, 19 Nov 2012 21:09:47 +0000 (22:09 +0100)]
locking: Use frozenset instead of utils.UniqueSequence

In this case “frozenset” is good enough as the result's order doesn't
matter--it is the input to “sorted” (“utils.UniqueSequence” preserves
the order). “frozenset” is ca. 25% faster for this use-case.

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

11 years agolocking: Add test for downgrade without names
Michael Hanselmann [Tue, 20 Nov 2012 03:19:12 +0000 (04:19 +0100)]
locking: Add test for downgrade without names

Until now there was no test for calling “LockSet.downgrade” without
specifying any names.

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

11 years agoFix some more hlint warnings
Iustin Pop [Tue, 20 Nov 2012 18:00:13 +0000 (19:00 +0100)]
Fix some more hlint warnings

Sorry…

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

11 years agoFix tools/move-instance after networks addition
Iustin Pop [Tue, 20 Nov 2012 16:44:26 +0000 (17:44 +0100)]
Fix tools/move-instance after networks addition

Commits d4117a72 (“Modify LUInstanceCreate to support networks”) and
09a3d21f (“Pass detailed network info in hooks“) expanded the nic
information as computed by _NICToTuple, which means that the format of
the result value from LUInstanceQueryData has changed, and
move-instance has not been changed to deal with this.

A proper fix needs to support correctly importing from old clusters,
right now this is a temporary fix to ensure QA still passes.

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

11 years agoMove _BuildNetworkEnv() at top-level
Dimitris Aragiorgis [Tue, 30 Oct 2012 15:51:42 +0000 (17:51 +0200)]
Move _BuildNetworkEnv() at top-level

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoUse bitarray 0.8 interface
Dimitris Aragiorgis [Tue, 30 Oct 2012 11:00:57 +0000 (13:00 +0200)]
Use bitarray 0.8 interface

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoMinor fix in query.py
Dimitris Aragiorgis [Tue, 30 Oct 2012 01:31:02 +0000 (03:31 +0200)]
Minor fix in query.py

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoMinor fix in ovf
Dimitris Aragiorgis [Tue, 30 Oct 2012 01:10:31 +0000 (03:10 +0200)]
Minor fix in ovf

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix a few docstrings
Dimitris Aragiorgis [Mon, 29 Oct 2012 19:11:59 +0000 (21:11 +0200)]
Fix a few docstrings

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoSimplify GenerateFree in network module
Dimitris Aragiorgis [Mon, 29 Oct 2012 19:00:06 +0000 (21:00 +0200)]
Simplify GenerateFree in network module

GenerateFree now returns the first available IP in the network
or raises AddressPoolError if it is full.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoReplace string values with proper constants
Dimitris Aragiorgis [Mon, 29 Oct 2012 18:39:58 +0000 (20:39 +0200)]
Replace string values with proper constants

_UnlockedCommitIp is used either for releasing or reserving an
IP inside a network. New constants RELEASE_ACTION/RESERVE_ACTION
are used to decide which is the case.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd docstring to the GetECReserved config method
Dimitris Aragiorgis [Mon, 29 Oct 2012 18:31:54 +0000 (20:31 +0200)]
Add docstring to the GetECReserved config method

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoSimplify mac generation funtions
Dimitris Aragiorgis [Mon, 29 Oct 2012 18:10:04 +0000 (20:10 +0200)]
Simplify mac generation funtions

Introduce new config method _UnlockedGetNetworkMACPrefix and refactor
original _GenerateOneMAC so that it takes prefix as an optional
argument and returns a function that actually generates a MAC. If
prefix is not given or None it uses the cluster level default.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFix _ComputeNics to include network slot
Dimitris Aragiorgis [Tue, 16 Oct 2012 05:46:51 +0000 (08:46 +0300)]
Fix _ComputeNics to include network slot

This bug was introduced after rebasing master branch.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFixes to pass py-apidoc (make commit-check)
Dimitris Aragiorgis [Fri, 12 Oct 2012 18:37:41 +0000 (21:37 +0300)]
Fixes to pass py-apidoc (make commit-check)

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFixes to pass pep8 (make lint)
Dimitris Aragiorgis [Fri, 12 Oct 2012 14:49:06 +0000 (17:49 +0300)]
Fixes to pass pep8 (make lint)

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFixes to pass pylint (make lint)
Dimitris Aragiorgis [Fri, 12 Oct 2012 11:18:28 +0000 (14:18 +0300)]
Fixes to pass pylint (make lint)

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoFixes to pass unittests (make check)
Dimitris Aragiorgis [Thu, 11 Oct 2012 13:30:04 +0000 (15:30 +0200)]
Fixes to pass unittests (make check)

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoCheck for existing networks/groups in Network LUs
Dimitris Aragiorgis [Wed, 3 Oct 2012 15:35:42 +0000 (18:35 +0300)]
Check for existing networks/groups in Network LUs

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd tags in network objects
Dimitris Aragiorgis [Fri, 27 Jul 2012 07:50:04 +0000 (10:50 +0300)]
Add tags in network objects

Support:
 - gnt-network add --tags.
 - gnt-network list-tags/add-tags/remove-tags/.
 - gnt-network list -o +tags

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoChange default fields for network listing
Dimitris Aragiorgis [Mon, 18 Jun 2012 16:05:28 +0000 (19:05 +0300)]
Change default fields for network listing

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoPass detailed network info in hooks
Dimitris Aragiorgis [Thu, 7 Jun 2012 15:51:34 +0000 (18:51 +0300)]
Pass detailed network info in hooks

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoPass netinfo in rpcs
Dimitris Aragiorgis [Wed, 6 Jun 2012 12:57:37 +0000 (15:57 +0300)]
Pass netinfo in rpcs

If a nic has a network field then encapsulate a network object in
netinfo slot for every rpc. This is needed to pass network info to
scripts managing nics (kvm-vif-bridge).

Introduce _BuildNetworkEnv().

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agocfgupgrade for networks
Dimitris Aragiorgis [Tue, 5 Jun 2012 23:08:11 +0000 (02:08 +0300)]
cfgupgrade for networks

Add networks slot in config data.
Add networks slot in nodegroups.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoUse network's mac prefix
Dimitris Aragiorgis [Tue, 5 Jun 2012 23:03:08 +0000 (02:03 +0300)]
Use network's mac prefix

Modify existing GenerateMAC so that it takes network as an argument.

Substitute _GenerateOneMAC with a decorator _GenerateMACPrefix that
chooses the prefix (network's or cluster's) and wraps
_GenerateMACSuffix that generates the three remaining bytes.

Check mac prefix validity when adding/modifing a network.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoInclude networks in Makefile and bash completion
Apollon Oikonomopoulos [Mon, 4 Jun 2012 20:52:31 +0000 (23:52 +0300)]
Include networks in Makefile and bash completion

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd gnt-network man page
Apollon Oikonomopoulos [Mon, 4 Jun 2012 20:51:44 +0000 (23:51 +0300)]
Add gnt-network man page

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoRapi support for networks
Dimitris Aragiorgis [Mon, 4 Jun 2012 20:20:09 +0000 (23:20 +0300)]
Rapi support for networks

Support:
 - GetNetwork(s)
 - CreateNetwork
 - ConnectNetwork
 - DisconnectNetwork
 - RemoveNetwork

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoss_conf support for networks
Apollon Oikonomopoulos [Mon, 4 Jun 2012 20:15:42 +0000 (23:15 +0300)]
ss_conf support for networks

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoIntroduce client support for networks
Dimitris Aragiorgis [Mon, 4 Jun 2012 20:09:27 +0000 (23:09 +0300)]
Introduce client support for networks

gnt-network is used to manipulate and handle networks that currently
provides the following operations:

 * Add a new network:
   gnt-network add --network=1.2.3.0/28 --gateway=1.2.3.1
                   --add-reserved-ips=1.2.3.4,1.2.3.5 testnet

 * Remove an existing network:
   gnt-network remove testnet

 * Modify an existing network:
   gnt-network modify --gateway=1.2.3.6
                      --network-type=private
                      --network6=2001:648::/64
                      --gateway6=none testnet
                      --add-reserved-ips=1.2.3.10,1.2.3.10,
                      --remove-reserved-ips=1.2.3.20
                      testnet

 * Connect an existing network to a nodegroup:
   gnt-network connect testnet default bridged br100
   gnt-network connect testnet <nodegroup> <mode> <link>
   (pass all for <nodegroup> to connect to all nodegroups)

 * Disconnect an existing network from a nodegroup:
   gnt-network disconnect testnet <nodegroup>
   (pass all for <nodegroup> to disconnect from all nodegroups)

 * List available networks:
   gnt-network list

 * Show network info:
   gnt-network info [testnet]

Introduce new option NOCONFLICTSCHECK_OPT for not checking for
conflicting IPs. Using this might cause data inconsistency.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoModify instance client to support networks
Apollon Oikonomopoulos [Mon, 4 Jun 2012 20:03:44 +0000 (23:03 +0300)]
Modify instance client to support networks

Add --no-conflicts-check option.
Modify instance query methods to return nic's network info.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoPeripheral changes for networks
Apollon Oikonomopoulos [Mon, 4 Jun 2012 19:58:12 +0000 (22:58 +0300)]
Peripheral changes for networks

Specifically:
 * export a new environment variable for the gnt-os-interface
 * export a new environment variable for KVM specific scripts
 * ovf support for networks

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoModify LUInstanceSetParams() to support networks
Dimitris Aragiorgis [Mon, 4 Jun 2012 19:39:53 +0000 (22:39 +0300)]
Modify LUInstanceSetParams() to support networks

Keep backwards compatibility just like LUInstanceCreate() and support
network parameter for NIC object.

Add ec_id argument in Update() to be able to commit temporary IPs that
were previously reserved.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoModify RemoveInstance() to support networks
Dimitris Aragiorgis [Mon, 4 Jun 2012 19:37:12 +0000 (22:37 +0300)]
Modify RemoveInstance() to support networks

Release any IPs held the instance before actually removing.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoModify LUInstanceCreate to support networks
Dimitris Aragiorgis [Mon, 4 Jun 2012 19:31:30 +0000 (22:31 +0300)]
Modify LUInstanceCreate to support networks

Implement backend support, to export the IP pool management
functionality to the clients. When the new NIC parameter 'network' is
given, the ippool management system is triggered.  If a NIC belongs to
a network, it inherits the netparams (mode, link) as its nicparams. If
a network is requested, then no 'mode' or 'link' should be
specified. Backwards compatibility is preserved, if 'network'
parameter is omitted.

Examples for IP pool management system:

--net 0:network=net1
  for an IPless NIC in a network

--net 0:ip=pool,network=net1
  for automatically generated IP inside the network

--net 0:ip=1.2.3.4,network=net1
  for specific IP inside the network

--net 0:network=none
  for IPless NIC with default nicparams

Examples for traditional assignment:

--net 0:ip=1.2.3.4,link=br100,mode=bridged
--net 0:ip=none,link=rt2,mode=routed
--net 0

Check for conflicting IPs to ensure IP uniqueness inside nodegroups.

IAllocator should be extended to become network aware. If an instance
has a NIC inside a network, then IAllocator must pick a node that its
nodegroup is already connected with that network.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoConfig methods for reserving/releasing IPs
Dimitris Aragiorgis [Mon, 4 Jun 2012 19:24:47 +0000 (22:24 +0300)]
Config methods for reserving/releasing IPs

Use TemporaryReservationManager for IP handling to ensure config data
consistency.

Implement:
 - methods for reserving/releasing IPs
 - _UnlockedCommitTemporaryIps()
 - CheckIPInNodeGroup() used for conflicting IPs
 - GetGroupNetParams() used for inheriting netparams.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoImplement network/nodegroup mappings
Dimitris Aragiorgis [Mon, 4 Jun 2012 18:08:36 +0000 (21:08 +0300)]
Implement network/nodegroup mappings

LUNetworkConnect() connects a network to a nodegroup and defines
its netparams (mode and link). Specifically:
 * Check if network already exists
 * Check if netparams are valid
 * Check if already connected to the same nodegroup
 * Produce errors if any conflicting IPs found
 * Update the 'networks' slot in NodeGroup config object
   with the network UUID and netparams requested. E.g.
   nodegroup_uuid {
     networks {
       network_uuid: {mode: 'bridged', link: 'br100'}
     }
   }

LUNetworkDisconnect() unmaps a network from a nodegroup:
 * Produce errors if an instance has a NIC with IP inside the network
 * Remove corresponding entry in 'networks' slot of NodeGroup object

Check for conflicting ips can be avoided with corresponding option.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoImplement LUNetworkSetParams
Dimitris Aragiorgis [Mon, 4 Jun 2012 18:05:03 +0000 (21:05 +0300)]
Implement LUNetworkSetParams

Support modifying all network parameters except for network (ip
range). Cannot modify gateway and reserved ips at the same time.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoImplement LUNetworkQuery
Apollon Oikonomopoulos [Mon, 4 Jun 2012 18:02:55 +0000 (21:02 +0300)]
Implement LUNetworkQuery

Summarily list all existing networks
Supply detailed info for every existing network
 - List used/free IPs
 - List instances with NICs assigned to the corresponding network
 - List NIC index and IP for the above instances

Implement complementary config methods for retrieving networks.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoBasic IP pool management logic
Dimitris Aragiorgis [Mon, 4 Jun 2012 15:54:02 +0000 (18:54 +0300)]
Basic IP pool management logic

Implement LUs for corresponding opcodes:
 * LUNetworkAdd:
   - Check for IP validity
   - Reserves all necessary IPs
   - Create new Network config object
 * LUNetworkRemove:
   - Checks if connected to any nodegroup
   - Remove a Network config object

Implement basic config methods:
 * LookupNetwork()
   - Given the network name return the network UUID
 * AddNetwork()
   - Add a new network to the config
 * RemoveNetwork()
   - Remove a network from the config

Add new locking level: LEVEL_NETWORK

Add various useful config methods for retrieving network info.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoIntroduce new module for IP pool management
Apollon Oikonomopoulos [Mon, 4 Jun 2012 14:33:22 +0000 (17:33 +0300)]
Introduce new module for IP pool management

Add new library module lib/network.py.
Introduce new class: AddressPool.

AddressPool implements all operations needed for managing IPs inside
the IP pool.

Given a Network config object (nobj), the class:

 * initializes the corresponding IP pool object via
   network.AddressPool.InitializeNetwork(nobj)
 * obtains the corresponding IP pool object via
   network.AddressPool(nobj)
 * manipulates IPs inside the pool

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoIP pool related objects, opcodes and constants
Dimitris Aragiorgis [Mon, 4 Jun 2012 13:50:42 +0000 (16:50 +0300)]
IP pool related objects, opcodes and constants

Config objects:
 * Introduce L{Network} with
  - IPv4 network field (mandatory)
  - IPv4 gateway, IPv6 (network/gateway), mac prefix, type (optional)
 * Modify existing config objects to support networks:
  - Add new slot 'network' to L{NIC} config object
  - Add new slot 'networks' to L{NodeGroup} config object

Opcodes:
 * Introduce new opcodes for networks
  - add/remove/modify/query/connect/disconnect.
 * In InstanceCreate/InstanceSetParams add conflicts_check option

Constants:
 * INIC_PARAM 'INIC_NETWORK'
 * NIC_IP_POOL for automaticaly obtain an IP from a pool
 * NETWORK_TYPE_PUBLIC/PRIVATE for network types

Checking of network_type handled by the opcode parameter validation.
Introduce _CheckCIDR*Notation() functions for network parameters
validation.

Signed-off-by: Apollon Oikonomopoulos <apollon@noc.grnet.gr>
Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoAdd more basic validation types
Iustin Pop [Thu, 15 Nov 2012 12:24:14 +0000 (13:24 +0100)]
Add more basic validation types

This mirrors the ht.py types PositiveInt, NonNegative, etc., except
that they work at a more generic level (any numeric type, respectively
any non-empty list).

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

11 years agoFix a hlint warning
Iustin Pop [Tue, 20 Nov 2012 09:59:45 +0000 (10:59 +0100)]
Fix a hlint warning

This is yet-another version-specific warning (fixed in later hlint
versions), but it's better to keep it clean.

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

11 years agoAdd DRBD parser unit tests
Michele Tartara [Mon, 19 Nov 2012 14:20:36 +0000 (15:20 +0100)]
Add DRBD parser unit tests

This adds tests that existing test files can be parsed by the Haskell
parser as well, plus one new test file.

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

11 years agoAdd parser for DRBD /proc file
Michele Tartara [Mon, 19 Nov 2012 14:19:51 +0000 (15:19 +0100)]
Add parser for DRBD /proc file

A new directory for haskell modules about block devices has been created
The parser is divided in two modules:
* one exports the data types describing the DRBD status
* one exports the parser itself

Signed-off-by: Michele Tartara <mtartara@google.com>
[iustin@google.com: indentation/alignment fixes]
Reviewed-by: Iustin Pop <iustin@google.com>

11 years agoProperly log errors when setting up daemon FDs
Iustin Pop [Tue, 6 Nov 2012 14:23:34 +0000 (15:23 +0100)]
Properly log errors when setting up daemon FDs

While writing the pipe-based reporting and trying various ways to
break the startup, I fought for a while trying to understand why error
reporting was _different_ when running the daemon as a user (with no
rights). It turns out that setupDaemonFDs wants to open the log file
in append mode way before, so we are not protected by the 'prepare'
phase.

This patch explicitly runs the 'setupDaemonFDs' function under the
same handler as the prepare phase, with the only change that here we
instruct handlePrepErr to not log the message via log*, since logging
is not yet set up.

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

11 years agoSwitch opcode data type from normal to record constructors
Iustin Pop [Mon, 19 Nov 2012 09:21:28 +0000 (10:21 +0100)]
Switch opcode data type from normal to record constructors

Currently, the OpCode definitions are using normal constructors:

  data OpCode = OpTestDelay Double Bool [String]
              | OpInstanceFailover String Bool (Maybe String)
              …

While this works for a few opcodes, it becomes unwieldy when dealing
with a bigger number of opcode definitions and/or with opcodes having
many fields.

This patch changes the opcodes to record-based constructors, so that
we get for free accessor functions:

  data OpCode
    = OpTestDelay {
        opDuration :: Double,
        opOnMaster :: Bool,
        opOnNodes :: [String]
      }
      | OpInstanceFailover {
         opInstanceName :: String,
         opIgnoreConsistency :: Bool,
         opTargetNode :: Maybe String
      }
      …

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

11 years agoFix docstrings for the Filter type
Iustin Pop [Mon, 19 Nov 2012 16:07:01 +0000 (17:07 +0100)]
Fix docstrings for the Filter type

While looking at the opcode docs and clicking accidentally on the
filter type, I saw that the haddock formatting is broken due to
non-escaped use of special chars. Let's convert the ascii-like
formatting to haddock, and have nicer apidoc.

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

11 years agoSimplify a few test helpers
Iustin Pop [Mon, 19 Nov 2012 15:57:24 +0000 (16:57 +0100)]
Simplify a few test helpers

Use more monadic combinators instead of explicit code.

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

11 years agoAdd custom code for CV_E* constants to convert-constants
Iustin Pop [Fri, 16 Nov 2012 13:24:20 +0000 (14:24 +0100)]
Add custom code for CV_E* constants to convert-constants

Currently, the cluster verify errors are defined as follows:

CV_ECLUSTER_FOO = (TCLUSTER, "ECLUSTER_FOO", "description")

This means there's no standalone name for the string "ECLUSTER_FOO",
which makes it hard to derive automatically a type for this union in
Haskell.

There are three possible fixes:

- manually separate the CV_ECLUSTER_FOO_STR = "ECLUSTER_FOO" in
  constants.py
- manually extract the strings in Haskell code
- change convert-constants to automatically export virtual constants
  for those

After discussion on IRC, I've taken the latter approach; even though a
bit hack-ish, it avoids manual work and potential errors.

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

11 years agoImprove error message for wrong opcode parameter values
Iustin Pop [Mon, 19 Nov 2012 09:10:09 +0000 (10:10 +0100)]
Improve error message for wrong opcode parameter values

When given an empty string as value to a parameter that doesn't accept
empty strings, the error message was confusing, since it was showing
just as a double space.

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

11 years agoCleanup ht's use of positive/strictpositive
Iustin Pop [Thu, 15 Nov 2012 09:28:17 +0000 (10:28 +0100)]
Cleanup ht's use of positive/strictpositive

Currently, ht.py uses a bad terminology for positive/non-negative
numbers. Per http://en.wikipedia.org/wiki/Positive_number, this is the
correct terminology:

- A number is positive if it is greater than zero.
- A number is negative if it is less than zero.
- A number is non-negative if it is greater than or equal to zero.
- A number is non-positive if it is less than or equal to zero.

So this patch renames things as follows:

- TPositiveInt            ⇒ TNonNegativeInt
- TStrictPositiveInt      ⇒ TPositiveInt
- TMaybePositiveInt       ⇒ dropped, not used anywhere
- TMaybeStrictPositiveInt ⇒ TMaybePositiveInt
- TPositiveFloat          ⇒ TNonNegativeFloat
- TStrictNegativeInt      ⇒ TNegativeInt

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

11 years agoSplit OpCode.hs and add module for opcode parameters
Iustin Pop [Tue, 13 Nov 2012 15:37:31 +0000 (16:37 +0100)]
Split OpCode.hs and add module for opcode parameters

Due to TemplateHaskell stage restrictions, we can't define parameters
in the same module as we're using them for TH, so we have to define
all module parameters in a separate module.

This patch therefore splits OpCodes.hs in two, adding that module and
moves most code there (types, parameters, etc.). The remaining parts
in OpCodes.hs, the actual opcode definitions, now use more parameters
instead of direct field definitions (more will come later)

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

11 years agoCreate a new Ganeti/Types.hs module
Iustin Pop [Thu, 15 Nov 2012 09:05:45 +0000 (10:05 +0100)]
Create a new Ganeti/Types.hs module

There are already three cases where we copied type definitions between
the htools-specific types into the main ganeti code. Let's stop doing
this ☺ and create a common types module that holds these.

Note that there already exists BasicTypes.hs, but that refers to very
low-level types, and can't use TH derivation itself.

A side effect of this unification is that there is a small conflict
between AdminStatus/AdminOffline and InstanceStatus/AdminOffline. As
such, I renamed AdminOffline and AdminDown to StatusOffline/StatusDown
in the InstanceStatus type.

The patch also moves the tests related to these types to a new test
module.

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

11 years agolocking: Simplify condition
Michael Hanselmann [Mon, 19 Nov 2012 16:14:44 +0000 (17:14 +0100)]
locking: Simplify condition

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

11 years agoconfigure: Shell cleanup
Michael Hanselmann [Wed, 14 Nov 2012 10:59:04 +0000 (11:59 +0100)]
configure: Shell cleanup

- Remote unnecessary quote characters
- Change some uses of “test "$foo"” to “test -n "$foo"”
- Merge “if/else/if” into “if/elif”
- Wrap lines longer than 80 characters and add a test to “make check”

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

11 years agoFix opcode validation for OpOobCommand.command
Iustin Pop [Mon, 19 Nov 2012 12:34:42 +0000 (13:34 +0100)]
Fix opcode validation for OpOobCommand.command

The 'command' attribute of the OpOobCommand command is defined with a
default value of None, but its validation requires a member of
constants.OOB_COMMANDS, which doesn't accept None. This result in the
following error when submitting an opcode without the command:

  error type: wrong_input, error details:
  Parameter 'OP_OOB_COMMAND.command' fails validation

I suspect this was simply a mistake, since the commit that introduced
it (65e183af, “opcodes: Add opcode parameter definitions”) did lots of
bulk updates.

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

11 years agoAdd opcode for running commands remotely
Michael Hanselmann [Thu, 15 Nov 2012 10:16:09 +0000 (11:16 +0100)]
Add opcode for running commands remotely

The opcode doesn't pay attention to the build-time flag to enable or
disable restricted commands. In a cluster different nodes could have
different settings.

Node locks are acquired in shared mode by default, but the use of an
exclusive lock can be forced using the “use_locking” parameter.

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

11 years agoAdd RPC for restricted commands
Michael Hanselmann [Tue, 13 Nov 2012 20:11:34 +0000 (21:11 +0100)]
Add RPC for restricted commands

Expose the functionality to run restricted commands remotely via RPC.

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

11 years agolocking: Don't schedule pending acq. for short timeout
Michael Hanselmann [Fri, 16 Nov 2012 16:43:50 +0000 (17:43 +0100)]
locking: Don't schedule pending acq. for short timeout

Scheduling a pending acquisition is relatively expensive and lot of code
is involved. Unless there is already one, a new pipe needs to be opened.
Data structures need to be updated as well, only to be undone shortly
after. This patch adds a small condition to return straight away if the
timeout is shorter than 1ms and the lock couldn't be acquired right
away. Blocking acquisitions are not affected, as are acquisitions with
longer timeouts.

While I tried hard, I could not find a way of writing a test
specifically for this case which wouldn't have involved making
significant other modifications. Other tests already exercise the new
code, though.

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

11 years agoPrevent hlint crash on unicode chars
Michele Tartara [Mon, 19 Nov 2012 09:30:20 +0000 (10:30 +0100)]
Prevent hlint crash on unicode chars

Some versions of hlint crash on the Attoparsec test file because they
are not able to correctly handle unicode characters if the proper encoding
(--utf8) is not specified.

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

11 years agoRename design document for SSH setup
Michael Hanselmann [Fri, 16 Nov 2012 15:38:17 +0000 (16:38 +0100)]
Rename design document for SSH setup

More design details will be added regarding setting up the node daemon,
so this is more about adding a node than just setting up SSH.

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