From 75f2ff7ddcbaf1b1dc2a7b6cc303d0f880d5d12a Mon Sep 17 00:00:00 2001 From: Michele Tartara Date: Fri, 12 Jul 2013 12:15:34 +0000 Subject: [PATCH] Allow modify_etc_hosts to be changed 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 Reviewed-by: Helga Velroyen --- lib/client/gnt_cluster.py | 6 ++++-- lib/cmdlib/cluster.py | 3 +++ lib/opcodes.py | 2 ++ src/Ganeti/OpCodes.hs | 1 + src/Ganeti/OpParams.hs | 5 +++++ test/hs/Test/Ganeti/OpCodes.hs | 2 +- 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py index 287ae31..a6d3d01 100644 --- a/lib/client/gnt_cluster.py +++ b/lib/client/gnt_cluster.py @@ -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": ( diff --git a/lib/cmdlib/cluster.py b/lib/cmdlib/cluster.py index d3e26bd..c520530 100644 --- a/lib/cmdlib/cluster.py +++ b/lib/cmdlib/cluster.py @@ -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 diff --git a/lib/opcodes.py b/lib/opcodes.py index 9cc8028..113f9b0 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -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 diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs index 92f5644..c31465b 100644 --- a/src/Ganeti/OpCodes.hs +++ b/src/Ganeti/OpCodes.hs @@ -177,6 +177,7 @@ $(genOpCode "OpCode" , pBlacklistedOs , pUseExternalMipScript , pEnabledDiskTemplates + , pModifyEtcHosts ]) , ("OpClusterRedistConf", []) , ("OpClusterActivateMasterIp", []) diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs index e445aa9..a1e445c 100644 --- a/src/Ganeti/OpParams.hs +++ b/src/Ganeti/OpParams.hs @@ -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" diff --git a/test/hs/Test/Ganeti/OpCodes.hs b/test/hs/Test/Ganeti/OpCodes.hs index eb539a6..2968173 100644 --- a/test/hs/Test/Ganeti/OpCodes.hs +++ b/test/hs/Test/Ganeti/OpCodes.hs @@ -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 -- 1.7.10.4