commit 015f151753d2ca97f76c12e02910183309f4da44
Author: Jose A. Lopes <jabolopes@google.com>
Date:   Wed Jan 29 16:19:25 2014 +0100

    Add CLI and OpCode instance communication option
    
    * Add command-line interface flag to enable instance communication
    * Add instance communication parameter to the opcode that creates an instance
    
    Signed-off-by: Jose A. Lopes <jabolopes@google.com>
    Reviewed-by: Michele Tartara <mtartara@google.com>

diff --git a/lib/cli.py b/lib/cli.py
index ad6c5bc..cb28c09 100644
--- a/lib/cli.py
+++ b/lib/cli.py
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -115,6 +115,7 @@ __all__ = [
   "IGNORE_SIZE_OPT",
   "INCLUDEDEFAULTS_OPT",
   "INTERVAL_OPT",
+  "INSTANCE_COMMUNICATION_OPT",
   "MAC_PREFIX_OPT",
   "MAINTAIN_NODE_HEALTH_OPT",
   "MASTER_NETDEV_OPT",
@@ -1686,6 +1687,13 @@ HOTPLUG_IF_POSSIBLE_OPT = cli_option("--hotplug-if-possible",
                                      help="Hotplug devices in case"
                                           " hotplug is supported")
 
+INSTANCE_COMMUNICATION_OPT = \
+    cli_option("-c", "--communication",
+               default=False,
+               dest="instance_communication",
+               help=constants.INSTANCE_COMMUNICATION_DOC,
+               type="bool")
+
 #: Options provided by all commands
 COMMON_OPTS = [DEBUG_OPT, REASON_OPT]
 
@@ -2727,6 +2735,7 @@ def GenericInstanceCreate(mode, opts, args):
     no_install = opts.no_install
     identify_defaults = False
     compress = constants.IEC_NONE
+    instance_communication = opts.instance_communication
   elif mode == constants.INSTANCE_IMPORT:
     start = False
     os_type = None
@@ -2736,6 +2745,7 @@ def GenericInstanceCreate(mode, opts, args):
     no_install = None
     identify_defaults = opts.identify_defaults
     compress = opts.compress
+    instance_communication = False
   else:
     raise errors.ProgrammerError("Invalid creation mode %s" % mode)
 
@@ -2765,7 +2775,8 @@ def GenericInstanceCreate(mode, opts, args):
                                 tags=tags,
                                 no_install=no_install,
                                 identify_defaults=identify_defaults,
-                                ignore_ipolicy=opts.ignore_ipolicy)
+                                ignore_ipolicy=opts.ignore_ipolicy,
+                                instance_communication=instance_communication)
 
   SubmitOrSend(op, opts)
   return 0
diff --git a/lib/client/gnt_instance.py b/lib/client/gnt_instance.py
index e761a9a..f6d270b 100644
--- a/lib/client/gnt_instance.py
+++ b/lib/client/gnt_instance.py
@@ -1,7 +1,7 @@
 #
 #
 
-# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2014 Google Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -1479,6 +1479,7 @@ add_opts = [
   FORCE_VARIANT_OPT,
   NO_INSTALL_OPT,
   IGNORE_IPOLICY_OPT,
+  INSTANCE_COMMUNICATION_OPT,
   ]
 
 commands = {
diff --git a/src/Ganeti/Constants.hs b/src/Ganeti/Constants.hs
index 533ec6a..9e008fe 100644
--- a/src/Ganeti/Constants.hs
+++ b/src/Ganeti/Constants.hs
@@ -16,7 +16,7 @@ imported.
 
 {-
 
-Copyright (C) 2013 Google Inc.
+Copyright (C) 2013, 2014 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -4764,6 +4764,10 @@ glusterPortDefault = 24007
 
 -- * Instance communication
 
+instanceCommunicationDoc :: String
+instanceCommunicationDoc =
+  "Enable or disable the communication mechanism for an instance"
+
 instanceCommunicationNetwork :: String
 instanceCommunicationNetwork = "ganeti:network:communication"
 
diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs
index 9c9d736..bee6449 100644
--- a/src/Ganeti/OpCodes.hs
+++ b/src/Ganeti/OpCodes.hs
@@ -7,7 +7,7 @@
 
 {-
 
-Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
+Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -452,6 +452,7 @@ $(genOpCode "OpCode"
      , pBackupCompress
      , pStartInstance
      , pInstTags
+     , pInstanceCommunication
      ],
      "instance_name")
   , ("OpInstanceMultiAlloc",
diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs
index 5453b89..c5588de 100644
--- a/src/Ganeti/OpParams.hs
+++ b/src/Ganeti/OpParams.hs
@@ -12,7 +12,7 @@ module.
 
 {-
 
-Copyright (C) 2012 Google Inc.
+Copyright (C) 2012, 2014 Google Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -44,6 +44,7 @@ module Ganeti.OpParams
   , SetParamsMods(..)
   , ExportTarget(..)
   , pInstanceName
+  , pInstanceCommunication
   , pInstanceUuid
   , pInstances
   , pName
@@ -985,6 +986,11 @@ pInstanceName =
   withDoc "A required instance name (for single-instance LUs)" $
   simpleField "instance_name" [t| String |]
 
+pInstanceCommunication :: Field
+pInstanceCommunication =
+  withDoc C.instanceCommunicationDoc $
+  defaultFalse "instance_communication"
+
 pForceVariant :: Field
 pForceVariant =
   withDoc "Whether to force an unknown OS variant" $
diff --git a/test/hs/Test/Ganeti/OpCodes.hs b/test/hs/Test/Ganeti/OpCodes.hs
index 2f5a233..fc169aa 100644
--- a/test/hs/Test/Ganeti/OpCodes.hs
+++ b/test/hs/Test/Ganeti/OpCodes.hs
@@ -241,7 +241,8 @@ instance Arbitrary OpCodes.OpCode where
           genMaybe genNodeNameNE <*> return Nothing <*> genMaybe (pure []) <*>
           genMaybe genNodeNameNE <*> arbitrary <*> genMaybe genNodeNameNE <*>
           return Nothing <*> genMaybe genNodeNameNE <*> genMaybe genNameNE <*>
-          arbitrary <*> arbitrary <*> (genTags >>= mapM mkNonEmpty)
+          arbitrary <*> arbitrary <*> (genTags >>= mapM mkNonEmpty) <*>
+          arbitrary
       "OP_INSTANCE_MULTI_ALLOC" ->
         OpCodes.OpInstanceMultiAlloc <$> arbitrary <*> genMaybe genNameNE <*>
         pure []
