Allow modify_etc_hosts to be changed
authorMichele Tartara <mtartara@google.com>
Fri, 12 Jul 2013 12:15:34 +0000 (12:15 +0000)
committerMichele Tartara <mtartara@google.com>
Mon, 15 Jul 2013 09:10:30 +0000 (09:10 +0000)
The modify_etc_hosts options, enabling the cluster to modify the /etc/hosts
files of nodes, and to keep them in sync, could only be set at cluster init
time.

With this commit it can now be changed through modify_etc_hosts as well.

Fixes Issue 206.

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

lib/client/gnt_cluster.py
lib/cmdlib/cluster.py
lib/opcodes.py
src/Ganeti/OpCodes.hs
src/Ganeti/OpParams.hs
test/hs/Test/Ganeti/OpCodes.hs

index 287ae31..a6d3d01 100644 (file)
@@ -974,7 +974,8 @@ def SetClusterParams(opts, args):
           opts.ipolicy_std_specs is not None or
           opts.ipolicy_disk_templates is not None or
           opts.ipolicy_vcpu_ratio is not None or
-          opts.ipolicy_spindle_ratio is not None):
+          opts.ipolicy_spindle_ratio is not None or
+          opts.modify_etc_hosts is not None):
     ToStderr("Please give at least one of the parameters.")
     return 1
 
@@ -1079,6 +1080,7 @@ def SetClusterParams(opts, args):
     ipolicy=ipolicy,
     candidate_pool_size=opts.candidate_pool_size,
     maintain_node_health=mnh,
+    modify_etc_hosts=opts.modify_etc_hosts,
     uid_pool=uid_pool,
     add_uids=add_uids,
     remove_uids=remove_uids,
@@ -1597,7 +1599,7 @@ commands = {
      RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT,
      NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT,
      DISK_STATE_OPT, SUBMIT_OPT, ENABLED_DISK_TEMPLATES_OPT,
-     IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS,
+     IPOLICY_STD_SPECS_OPT, MODIFY_ETCHOSTS_OPT] + INSTANCE_POLICY_OPTS,
     "[opts...]",
     "Alters the parameters of the cluster"),
   "renew-crypto": (
index d3e26bd..c520530 100644 (file)
@@ -971,6 +971,9 @@ class LUClusterSetParams(LogicalUnit):
                     " maintenance is not useful (still enabling it)")
       self.cluster.maintain_node_health = self.op.maintain_node_health
 
+    if self.op.modify_etc_hosts is not None:
+      self.cluster.modify_etc_hosts = self.op.modify_etc_hosts
+
     if self.op.prealloc_wipe_disks is not None:
       self.cluster.prealloc_wipe_disks = self.op.prealloc_wipe_disks
 
index 9cc8028..113f9b0 100644 (file)
@@ -979,6 +979,8 @@ class OpClusterSetParams(OpCode):
      ht.TMaybe(ht.TAnd(ht.TListOf(ht.TElemOf(constants.DISK_TEMPLATES)),
                        ht.TTrue)),
      "List of enabled disk templates"),
+    ("modify_etc_hosts", None, ht.TMaybeBool,
+     "Whether the cluster can modify and keep in sync the /etc/hosts files"),
     ]
   OP_RESULT = ht.TNone
 
index 92f5644..c31465b 100644 (file)
@@ -177,6 +177,7 @@ $(genOpCode "OpCode"
      , pBlacklistedOs
      , pUseExternalMipScript
      , pEnabledDiskTemplates
+     , pModifyEtcHosts
      ])
   , ("OpClusterRedistConf", [])
   , ("OpClusterActivateMasterIp", [])
index e445aa9..a1e445c 100644 (file)
@@ -116,6 +116,7 @@ module Ganeti.OpParams
   , pAddUids
   , pRemoveUids
   , pMaintainNodeHealth
+  , pModifyEtcHosts
   , pPreallocWipeDisks
   , pNicParams
   , pInstNics
@@ -865,6 +866,10 @@ pRemoveUids = optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |]
 pMaintainNodeHealth :: Field
 pMaintainNodeHealth = optionalField $ booleanField "maintain_node_health"
 
+-- | Whether to modify and keep in sync the @/etc/hosts@ files of nodes.
+pModifyEtcHosts :: Field
+pModifyEtcHosts = optionalField $ booleanField "modify_etc_hosts"
+
 -- | Whether to wipe disks before allocating them to instances.
 pPreallocWipeDisks :: Field
 pPreallocWipeDisks = optionalField $ booleanField "prealloc_wipe_disks"
index eb539a6..2968173 100644 (file)
@@ -161,7 +161,7 @@ instance Arbitrary OpCodes.OpCode where
           arbitrary <*> arbitrary <*> arbitrary <*>
           emptyMUD <*> emptyMUD <*> arbitrary <*>
           arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*>
-          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
+          arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
       "OP_CLUSTER_REDIST_CONF" -> pure OpCodes.OpClusterRedistConf
       "OP_CLUSTER_ACTIVATE_MASTER_IP" ->
         pure OpCodes.OpClusterActivateMasterIp