ganeti-local
11 years agoChange -G option description
Guido Trotter [Mon, 19 Nov 2012 09:06:06 +0000 (10:06 +0100)]
Change -G option description

The new one is more consistent with the rest of the nodegroup
terminology and more generic for use in different htools.

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

11 years agoFix Haskell profiling targets
Iustin Pop [Fri, 30 Nov 2012 00:03:57 +0000 (01:03 +0100)]
Fix Haskell profiling targets

It turns out that in newer GHC versions, the suffix shouldn't be
prefixed with a dot; otherwise name mangling is broken.

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

11 years agoOptimise recursive Query filters
Iustin Pop [Thu, 29 Nov 2012 23:53:04 +0000 (00:53 +0100)]
Optimise recursive Query filters

Currently, the And and Or filters use very nice code, e.g. in case of
OrFilter:

   any id <$> mapM evaluateFilter flts

However, looking at the memory profiles shows that application of
any/id to monadic values via '<$>' does not work nicely, losing the
'early' success property. This results in too much memory being used
for thunks in monadic sequencing.

Rather than trying to add more strictness (not sure exactly how, TBH),
switching these to explicit recursion solves the problem, since we
take the 'early' exit problem in our hands and we are explicit about
it.

Memory usage in case of big (e.g. 1000 'Or' elements) is reduced
significantly, and thus also the runtime.

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

11 years agoMake Query operators enforce strictness
Iustin Pop [Thu, 29 Nov 2012 23:32:52 +0000 (00:32 +0100)]
Make Query operators enforce strictness

Currently, the query operators (binop, etc.) create thunks, instead of
forcing the evaluation of the simple boolean results. This results in
higher than needed memory use.

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

11 years agoFix htools/rpc-test after recent changes
Iustin Pop [Thu, 29 Nov 2012 19:23:58 +0000 (20:23 +0100)]
Fix htools/rpc-test after recent changes

Since this program is not built normally, a few recent commits broke
it:

- 707cd3d (“Use exitErr instead of explicit error message and
  exitWith”) introduced wrong syntax (missing '$')
- 29a3053 (“Remove unsafePerformIO usage”) changed the signature of
  G.Path.clusterConfFile
- 5183e8b (“Convert query path from string errors to GanetiException”)
  changed the signature of 'getNode'

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

11 years agoAdd explicit test for wrong OpCode arbitrary instances
Iustin Pop [Mon, 26 Nov 2012 12:34:31 +0000 (13:34 +0100)]
Add explicit test for wrong OpCode arbitrary instances

I've been bitten a couple of times with arbitrary opcodes working on
UTF-8 locale, but failing on buildbot (ASCII). So let's add an
explicit test that checks always (even with UTF-8) for correct
arbitrary values, showing explicitly which opcodes fail.

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

11 years agoRemove read instances from our Haskell code
Iustin Pop [Mon, 26 Nov 2012 11:50:08 +0000 (12:50 +0100)]
Remove read instances from our Haskell code

It turns out that optimising 'read' derived instances (via -O) for
complex data types (like OpCode, or the various objects) can be slow
to very slow. Disabling such instances results in (time make
$all_our_haskell_binaries) large compile-time savings and also smaller
(unstripped) binaries (by a significant amount):

ghc 6.12:        time  htools sz  hconfd sz
  with read:    4m50s 12,244,694 14,927,928
  no read:      3m30s 10,234,305 12,536,745
ghc 7.6:
  with read:   14m45s 13,694,761 15,741,755
  no read:      3m40s 11,631,373 13,245,134

So let's remove these instances, since we never use read in production
for our custom types, and even when debugging in GHCI, we can simply
use the 'show' representation to create the types, without needing to
actually parse from strings.

Note: for the very slow ghc 7.6 compilation time, I filled a ticket
(ghc #7450), since it is surprising(ly slow).

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

11 years agoReplace hand-coded 'live' field of OpInstanceMigrate
Iustin Pop [Sun, 25 Nov 2012 22:58:31 +0000 (23:58 +0100)]
Replace hand-coded 'live' field of OpInstanceMigrate

This is the last inline-written field; I've done it separately from
the last patch due to changes being needed in HTools (field changed
type).

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

11 years agoRemove remaining in-line parameters
Iustin Pop [Sun, 25 Nov 2012 22:28:31 +0000 (23:28 +0100)]
Remove remaining in-line parameters

… except one, and replace them with separately-defined ones in
OpParams.

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

11 years agoAbstract query common opcode definitions
Iustin Pop [Sun, 25 Nov 2012 21:44:25 +0000 (22:44 +0100)]
Abstract query common opcode definitions

It would be even better if the opcodes would actually have all the
same definitions, until then we have two sets of definitions.

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

11 years agoMake QuickCheck generator names more uniform
Iustin Pop [Sun, 25 Nov 2012 15:24:59 +0000 (16:24 +0100)]
Make QuickCheck generator names more uniform

Due to lack of attention, we have two styles for generators of
arbitrary values: get* and gen* (e.g. getFQDN and genDiskIndices). In
order to make this more obvious that we deal with a function in the
Gen monad, let's rename all get* functions to gen*.

A few other simplifications were done on existing tests, switching to
helpers that were introduced later.

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

11 years agoEnable equivalence checks of opcode list
Iustin Pop [Sun, 25 Nov 2012 15:11:26 +0000 (16:11 +0100)]
Enable equivalence checks of opcode list

This patch enhances the opcode list checks - instead of spawning a
Python interpreter to display the opcode list, we export it statically
in Constants.hs via a slight convert-constants change.

Furthermore, since we now have opcode parity, we enable full opcode
list checks.

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

11 years agoAdd two last missing opcodes
Iustin Pop [Sun, 25 Nov 2012 15:10:12 +0000 (16:10 +0100)]
Add two last missing opcodes

OpInstanceQuery was missing accidentally, whereas OpRestrictedCommand
was just recently added without Haskell definitions.

The patch also slightly improves the OpNodeQuery arbitrary generation.

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

11 years agoAdd types, parameters and the opcodes for networks
Iustin Pop [Sun, 25 Nov 2012 13:29:11 +0000 (14:29 +0100)]
Add types, parameters and the opcodes for networks

This completes the last missing opcode group. The only difficulty was
with the ip addresses, where we used simple strings to represent them
and (for IPv4) a few helpers to generate arbitrary instances;
otherwise, the patch is trivial.

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

11 years agoMove NICMode from Objects.hs to Types.hs
Iustin Pop [Sun, 25 Nov 2012 13:28:25 +0000 (14:28 +0100)]
Move NICMode from Objects.hs to Types.hs

Also add some unittests for this type.

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

11 years agoComplete the Test opcodes
Iustin Pop [Sat, 24 Nov 2012 21:35:07 +0000 (22:35 +0100)]
Complete the Test opcodes

This adds the OpTestAllocator, OpTestJqueue and OpTestDummy
opcodes. The OpTestAllocator seems to need some cleanup (on the Python
side), for now we implement it as is. As for the other two, while not
used in production, we should have full coverage for them as well.

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

11 years agoRename OpTestAllocator.allocator to iallocator
Iustin Pop [Sat, 24 Nov 2012 00:55:12 +0000 (01:55 +0100)]
Rename OpTestAllocator.allocator to iallocator

This makes the OpCode more consistent with the other opcodes. The
downside is incompatibility when upgrading from 2.6, but since this is
a test opcode it shouldn't be problematic.

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

11 years agoAdd a helper for the "iallocator" opcode field
Iustin Pop [Sat, 24 Nov 2012 00:39:45 +0000 (01:39 +0100)]
Add a helper for the "iallocator" opcode field

This field is used with just changed description in about 10 opcodes,
so unifying it makes things simpler for future potential changes to
the field type.

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

11 years agoComplete the Tag opcodes and fix OpTestDelay missing param
Iustin Pop [Fri, 23 Nov 2012 16:44:30 +0000 (17:44 +0100)]
Complete the Tag opcodes and fix OpTestDelay missing param

The regexp in OpTagsSearch is loaded as is, without testing for
validity; the rest of the patch is trivial.

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

11 years agoAdd Group, OS and Backup opcodes
Iustin Pop [Fri, 23 Nov 2012 16:16:14 +0000 (17:16 +0100)]
Add Group, OS and Backup opcodes

This also corrects a docstring in OpBackupExport on the Python side.

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

11 years agoComplete the instance OpCodes and parameters
Iustin Pop [Fri, 23 Nov 2012 14:21:01 +0000 (15:21 +0100)]
Complete the instance OpCodes and parameters

Only the original instance opcodes (used in htools) are left
non-converted to only parameter style; they'll be cleaned up later,
once the htools codebase itself migrates to safer types.

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

11 years agoAdd test for mutable default values in opcode parameters
Iustin Pop [Thu, 22 Nov 2012 13:31:47 +0000 (14:31 +0100)]
Add test for mutable default values in opcode parameters

This is not comprehensive, since in Python one can't determine what is
and what is not mutable; but I've added a few base cases (list, dict,
set).

The patch also improves (makes more uniform) the error messages in the
parameter definitions.

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

11 years agoFix empty list as default value in OpInstanceMultiAlloc
Iustin Pop [Thu, 22 Nov 2012 13:25:18 +0000 (14:25 +0100)]
Fix empty list as default value in OpInstanceMultiAlloc

Commit 12e62af5 (“Adding the new opcode for multi-allocation”)
introduced a "bad" default value; while porting this to Haskell, I
realised this is wrong.

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

11 years agoAdd types and parameters for OpInstanceCreate
Iustin Pop [Thu, 22 Nov 2012 13:20:18 +0000 (14:20 +0100)]
Add types and parameters for OpInstanceCreate

This is a "big" opcode, so sending it separately.

A few types needed changing, and a few parameters were renamed to make
it more clear which are cluster-level and which are instance-level
parameters.

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

11 years agoMove FileDriver from Objects to Types
Iustin Pop [Thu, 22 Nov 2012 10:41:22 +0000 (11:41 +0100)]
Move FileDriver from Objects to Types

Another base type that we need in opcodes as well.

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

11 years agoFix breakage introduced in commit a8b3b09
Michael Hanselmann [Fri, 30 Nov 2012 09:04:42 +0000 (10:04 +0100)]
Fix breakage introduced in commit a8b3b09

The order of the calls to “ctx.use_privatekey” and “ctx.use_certificate”
was wrong, leading to an exception being thrown.

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

11 years agoFactorize SSL context setup for certificate check
Michael Hanselmann [Wed, 28 Nov 2012 10:09:08 +0000 (11:09 +0100)]
Factorize SSL context setup for certificate check

This code will also be used by the node daemon setup utility.

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

11 years agoIntroduce ht.TMaybeValueNone and ht.TValueNone
Dimitris Aragiorgis [Thu, 29 Nov 2012 11:49:38 +0000 (13:49 +0200)]
Introduce ht.TMaybeValueNone and ht.TValueNone

TValueNone checks if a value is "none" and TMaybeValueNone is a wrapper
of TOr(TValueNone, x). This is used by OpNetworkSetParam in order to
reset a network value (e.g. mac_prefix, gateway, etc.)

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

11 years agoopcodes: Replace manual loop with map
Michael Hanselmann [Thu, 29 Nov 2012 11:33:46 +0000 (12:33 +0100)]
opcodes: Replace manual loop with map

Also remove a superfluous empty line in test file.

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

11 years agoFix type descriptions in RAPI documentation
Michael Hanselmann [Thu, 29 Nov 2012 11:23:50 +0000 (12:23 +0100)]
Fix type descriptions in RAPI documentation

This patch adds descriptors to the “_CheckCIDR*” functions in opcodes
and improves the descriptions generated by “ht.TInstanceOf”, thereby
indirectly fixing bad type descriptions in the RAPI documentation.

Before this patch:
- (String and (<function _CheckCIDRAddrNotation at 0x2f…>))
- (Instance of (<class 'ganeti.opcodes.OpInstanceCreate'>))

After this patch:
- (String and (IPv4 address))
- (Instance of (ganeti.opcodes.OpInstanceCreate))

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

11 years agoFixing crash when removing disks
Helga Velroyen [Thu, 29 Nov 2012 10:06:42 +0000 (11:06 +0100)]
Fixing crash when removing disks

This bug was introduced by my commit "Check ispecs against ipolicy on
instance modify", because I did not filter for the 'add' action. Thus it
would try to read the size parameter also when removing disks.

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

11 years agolocking: Change locking order, move NAL after instances
Michael Hanselmann [Thu, 29 Nov 2012 09:19:17 +0000 (10:19 +0100)]
locking: Change locking order, move NAL after instances

Some opcodes, for example LUInstanceFailover and LUInstanceMigrate,
can't know whether they need to acquire all nodes until they have a lock
on the instance. In turn they would have to acquire the node allocation
lock “just in case” and could only release it once the instance had been
acquired.

Since there is no good reason for the node allocation lock to be before
instances in the locking order, this patch changes the order so that
instances are locked first.

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

11 years agoFix Attoparsec test coverage check compatibility
Michele Tartara [Thu, 29 Nov 2012 09:36:40 +0000 (10:36 +0100)]
Fix Attoparsec test coverage check compatibility

The hpc tool, on squeeze, does not handle utf8 encoded files correctly.
The Attoparsec test is just needed to verify whether the parser handles
uft8 correctly, so the solution is to exclude it from coverage checks.

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

11 years agoAdd constant for node certificate mode
Michael Hanselmann [Thu, 29 Nov 2012 07:40:04 +0000 (08:40 +0100)]
Add constant for node certificate mode

A new utility for configuring the node daemon will have to write the
node certificate as well. To not split information about the certificate
file even more, the constant is added to “pathutils”.

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

11 years agoMove cluster verification out of prepare-node-join
Michael Hanselmann [Wed, 28 Nov 2012 09:03:40 +0000 (10:03 +0100)]
Move cluster verification out of prepare-node-join

A new tool for configuring the node daemon will also have to verify the
cluster name, so it's better to have this function in a central place.
In the process of moving it to ssconf it is also changed to use
“SimpleStore” instead of reading the ssconf directly. Tests are updated.

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

11 years agossconf: Verify file size when reading, add some tests
Michael Hanselmann [Wed, 28 Nov 2012 08:23:28 +0000 (09:23 +0100)]
ssconf: Verify file size when reading, add some tests

Until now ssconf would limit the amount read from files to 128 KiB and
silently ignored files larger than that. With this patch a check is
added by using fstat(2) on the file descriptor while it's being read.

There were no tests file ssconf at all, so some are added.

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

11 years agoFix pylint error introduced in commit 9675661
Michael Hanselmann [Wed, 28 Nov 2012 06:40:19 +0000 (07:40 +0100)]
Fix pylint error introduced in commit 9675661

Missing spaces around operator.

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

11 years agossconf: Move class-level constants to module
Michael Hanselmann [Tue, 27 Nov 2012 11:44:03 +0000 (12:44 +0100)]
ssconf: Move class-level constants to module

There is no good reason why these two constants should be inside the
class. This patch moves them to the module so they can be used without
“self”.

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

11 years agoRemove ssconf.SimpleConfigReader
Michael Hanselmann [Tue, 27 Nov 2012 11:45:46 +0000 (12:45 +0100)]
Remove ssconf.SimpleConfigReader

Commit b0dcdc1 removed the last user of this class.

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

11 years agossconf: Small error message fixes
Michael Hanselmann [Tue, 27 Nov 2012 11:27:38 +0000 (12:27 +0100)]
ssconf: Small error message fixes

- Include filename in error message
- s/ip/IP/
- Stop using superfluous variable

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

11 years agoFix network query for extra stats fields
Helga Velroyen [Tue, 27 Nov 2012 17:33:40 +0000 (18:33 +0100)]
Fix network query for extra stats fields

Extend _GetNetworkStatsField() to accept 4 arguments.
This fixes Issue 323.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Helga Velroyen <helgav@google.com>

11 years agoExport UUID and serial no in network queries
Dimitris Aragiorgis [Tue, 27 Nov 2012 12:54:42 +0000 (14:54 +0200)]
Export UUID and serial no in network queries

Add uuid and serial_no to _NETWORK_SIMPLE_FIELDS in order to export
them in network queries. Modify gnt-network to list them too.

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

11 years agossconf: Remove unused regular expression
Michael Hanselmann [Tue, 27 Nov 2012 11:40:36 +0000 (12:40 +0100)]
ssconf: Remove unused regular expression

RE_VALID_SSCONF_NAME is not used anywhere.

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

11 years agoFix build after commit 9b7e05a
Michael Hanselmann [Tue, 27 Nov 2012 09:30:04 +0000 (10:30 +0100)]
Fix build after commit 9b7e05a

Commit 9b7e05a didn't quite work as expected: glm.is_owned expects a
locking level, not a lock name.

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

11 years agoFactorize code to load and verify JSON
Michael Hanselmann [Tue, 27 Nov 2012 10:43:07 +0000 (11:43 +0100)]
Factorize code to load and verify JSON

A new tool to configure the node daemon will also have to load and
verify JSON data.

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

11 years agoFactorize logging setup in tools
Michael Hanselmann [Tue, 27 Nov 2012 09:27:00 +0000 (10:27 +0100)]
Factorize logging setup in tools

Most tools had their own “SetupLogging” function, but they were all
essentially the same. This patch adds a generic version to “utils.log”
and provides unit tests.

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

11 years agoSmall improvements to the DRBD parser and tests
Michele Tartara [Fri, 23 Nov 2012 13:26:46 +0000 (14:26 +0100)]
Small improvements to the DRBD parser and tests

* Now the parser completely consumes the input, up to the end of the text.
* Name of the test suite module changed to adhere to naming conventions.
* Some reformatting of the source code.

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

11 years agoLUNodeQueryStorage: Use node allocation lock
Michael Hanselmann [Fri, 23 Nov 2012 03:42:09 +0000 (04:42 +0100)]
LUNodeQueryStorage: Use node allocation lock

Block instance allocations when all node locks will be acquired.

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

11 years agocmdlib: Don't pass processor to _ComputeNics
Michael Hanselmann [Tue, 27 Nov 2012 07:01:37 +0000 (08:01 +0100)]
cmdlib: Don't pass processor to _ComputeNics

The execution context ID can be passed right away.

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

11 years agocmdlib.LUInstanceRename: Another assertion for BGL
Michael Hanselmann [Tue, 27 Nov 2012 06:57:28 +0000 (07:57 +0100)]
cmdlib.LUInstanceRename: Another assertion for BGL

Check whether the BGL is actually held instead of just testing
“REQ_BGL”.

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

11 years agocmdlib: Stop using proc.Log*
Michael Hanselmann [Tue, 27 Nov 2012 06:55:56 +0000 (07:55 +0100)]
cmdlib: Stop using proc.Log*

The Log* functions are re-exported through the LU. Inline use of string
formatting (“%”) was converted to additional arguments to Log* (unlike
“feedback_fn”, these functions support it). Some punctuation has been
removed from messages, as well as some small re-wordings.

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

11 years agocmdlib: Use CommaJoin where appropriate
Michael Hanselmann [Tue, 27 Nov 2012 07:49:07 +0000 (08:49 +0100)]
cmdlib: Use CommaJoin where appropriate

Don't use inline versions of CommaJoin.

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

11 years agoLUNetwork*: Build dictionaries right away
Michael Hanselmann [Tue, 27 Nov 2012 07:52:52 +0000 (08:52 +0100)]
LUNetwork*: Build dictionaries right away

… instead of constructing an object, only to fill it separately.

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

11 years agolocking: Method to check if LockSet is fully acquired
Michael Hanselmann [Mon, 26 Nov 2012 05:34:52 +0000 (06:34 +0100)]
locking: Method to check if LockSet is fully acquired

A new method is added to check whether the LockSet-internal lock is
held. This is the case after LockSet.acquire was called with
locking.ALL_SET.

Unit tests are updated, including one where the list of names must be
empty.

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

11 years agomcpu: Start locking at correct level
Michael Hanselmann [Mon, 26 Nov 2012 06:02:39 +0000 (07:02 +0100)]
mcpu: Start locking at correct level

Commit 8716b1d added a new lock level, LEVEL_NODE_ALLOC. It is ahead of
LEVEL_INSTANCE. The latter was hardcoded in mcpu to be locked right
after the BGL, effectively ignoring LEVEL_NODE_ALLOC.

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

11 years agoFix wrong edge case in a QuickChek Drbd property
Michele Tartara [Fri, 23 Nov 2012 16:36:37 +0000 (16:36 +0000)]
Fix wrong edge case in a QuickChek Drbd property

The bug was in the test itself, not in the tested code.

Also, fixed a line longer than 80 characters in the same file.

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

11 years agoAdd new lock level for node allocations
Michael Hanselmann [Thu, 22 Nov 2012 21:41:44 +0000 (22:41 +0100)]
Add new lock level for node allocations

The new lock is similar to the BGL in the sense that it has its own
level and there is only one. It is called “node allocation lock”.
Logical units will use it to synchronize with instance creations, which
in turn will start using opportunistic locks on nodes.

Additionally, an assertion in GanetiLockManager gained a message.

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

11 years agoQuickCheck Tests for the commaIntParser, part of DRBD Parser
Michele Tartara [Wed, 21 Nov 2012 11:53:00 +0000 (11:53 +0000)]
QuickCheck Tests for the commaIntParser, part of DRBD Parser

These new tests substitute the HTests, as by the suggestion
received after submitting the previous patch.

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

11 years agoAdd gnt-network to .gitignore
Michael Hanselmann [Fri, 23 Nov 2012 01:47:39 +0000 (02:47 +0100)]
Add gnt-network to .gitignore

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

11 years agoCorrected network design doc regarding user interface
Helga Velroyen [Fri, 23 Nov 2012 13:46:45 +0000 (14:46 +0100)]
Corrected network design doc regarding user interface

This patch fixes some inconsistencies betwen the network
design doc and the actual user interface. Adding reserved
ips works with option --add-reserved-ips and removing them
with --remove-reserved-ips. There is no toggling of the
reservation status of ips.

Signed-off-by: Helga Velroyen <helgav@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

11 years agoFix network opcode parameters
Iustin Pop [Wed, 21 Nov 2012 17:03:13 +0000 (18:03 +0100)]
Fix network opcode parameters

Commit 32e3d8b1 (“opcodes: Network parameter improvements and fixes”)
changed a few parameters in the network add, connect and set params
opcodes, but some of the changes are buggy. The patch changed the type
to TMaybe(), whereas the default should have been changed from None to
NoDefault - the network, mode and link are required. It also wrongly
unified all types as _CheckCIDRNetNotation, whereas some are
AddrNotation.

The patch fixes these (correctly, I hope) and also add some new
aliases for readability.

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

11 years agoIntroduce a TMaybe combinator
Iustin Pop [Wed, 21 Nov 2012 17:28:36 +0000 (18:28 +0100)]
Introduce a TMaybe combinator

We have many cases in the code where we write TOr(TNone, a), so let's
introduce a combinator that simplifies this case.

Beside replacing the above with TMaybe(a), I did a few other parameter
fixes:

- noop change TOr(TNone, TDict) to TMaybeDict
- noop change TOr(TNone, TNonEmptyString) to TMaybeString
- OpClusterSetParams, change master netmask from any integer to a
  non-negative integer

(I can move the last one to a separate patch if desired)

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

11 years agoReplace dict() with {}
Iustin Pop [Wed, 21 Nov 2012 16:14:36 +0000 (17:14 +0100)]
Replace dict() with {}

The network patches and an existing test added function-call based
dict construction as opposed to literal sintax.

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

11 years agoExport network in FinalizeExport()
Dimitris Aragiorgis [Fri, 23 Nov 2012 08:32:49 +0000 (10:32 +0200)]
Export network in FinalizeExport()

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

11 years agoFix bug in OpNetworkQuery result check
Dimitris Aragiorgis [Fri, 23 Nov 2012 08:32:48 +0000 (10:32 +0200)]
Fix bug in OpNetworkQuery result check

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

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>