Commit 75f2ff7d authored by Michele Tartara's avatar Michele Tartara
Browse files

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: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent c89db623
...@@ -974,7 +974,8 @@ def SetClusterParams(opts, args): ...@@ -974,7 +974,8 @@ def SetClusterParams(opts, args):
opts.ipolicy_std_specs is not None or opts.ipolicy_std_specs is not None or
opts.ipolicy_disk_templates is not None or opts.ipolicy_disk_templates is not None or
opts.ipolicy_vcpu_ratio 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.") ToStderr("Please give at least one of the parameters.")
return 1 return 1
...@@ -1079,6 +1080,7 @@ def SetClusterParams(opts, args): ...@@ -1079,6 +1080,7 @@ def SetClusterParams(opts, args):
ipolicy=ipolicy, ipolicy=ipolicy,
candidate_pool_size=opts.candidate_pool_size, candidate_pool_size=opts.candidate_pool_size,
maintain_node_health=mnh, maintain_node_health=mnh,
modify_etc_hosts=opts.modify_etc_hosts,
uid_pool=uid_pool, uid_pool=uid_pool,
add_uids=add_uids, add_uids=add_uids,
remove_uids=remove_uids, remove_uids=remove_uids,
...@@ -1597,7 +1599,7 @@ commands = { ...@@ -1597,7 +1599,7 @@ commands = {
RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT, 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, NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT, HV_STATE_OPT,
DISK_STATE_OPT, SUBMIT_OPT, ENABLED_DISK_TEMPLATES_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...]", "[opts...]",
"Alters the parameters of the cluster"), "Alters the parameters of the cluster"),
"renew-crypto": ( "renew-crypto": (
......
...@@ -971,6 +971,9 @@ class LUClusterSetParams(LogicalUnit): ...@@ -971,6 +971,9 @@ class LUClusterSetParams(LogicalUnit):
" maintenance is not useful (still enabling it)") " maintenance is not useful (still enabling it)")
self.cluster.maintain_node_health = self.op.maintain_node_health 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: if self.op.prealloc_wipe_disks is not None:
self.cluster.prealloc_wipe_disks = self.op.prealloc_wipe_disks self.cluster.prealloc_wipe_disks = self.op.prealloc_wipe_disks
......
...@@ -979,6 +979,8 @@ class OpClusterSetParams(OpCode): ...@@ -979,6 +979,8 @@ class OpClusterSetParams(OpCode):
ht.TMaybe(ht.TAnd(ht.TListOf(ht.TElemOf(constants.DISK_TEMPLATES)), ht.TMaybe(ht.TAnd(ht.TListOf(ht.TElemOf(constants.DISK_TEMPLATES)),
ht.TTrue)), ht.TTrue)),
"List of enabled disk templates"), "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 OP_RESULT = ht.TNone
......
...@@ -177,6 +177,7 @@ $(genOpCode "OpCode" ...@@ -177,6 +177,7 @@ $(genOpCode "OpCode"
, pBlacklistedOs , pBlacklistedOs
, pUseExternalMipScript , pUseExternalMipScript
, pEnabledDiskTemplates , pEnabledDiskTemplates
, pModifyEtcHosts
]) ])
, ("OpClusterRedistConf", []) , ("OpClusterRedistConf", [])
, ("OpClusterActivateMasterIp", []) , ("OpClusterActivateMasterIp", [])
......
...@@ -116,6 +116,7 @@ module Ganeti.OpParams ...@@ -116,6 +116,7 @@ module Ganeti.OpParams
, pAddUids , pAddUids
, pRemoveUids , pRemoveUids
, pMaintainNodeHealth , pMaintainNodeHealth
, pModifyEtcHosts
, pPreallocWipeDisks , pPreallocWipeDisks
, pNicParams , pNicParams
, pInstNics , pInstNics
...@@ -865,6 +866,10 @@ pRemoveUids = optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |] ...@@ -865,6 +866,10 @@ pRemoveUids = optionalField $ simpleField "remove_uids" [t| [[(Int, Int)]] |]
pMaintainNodeHealth :: Field pMaintainNodeHealth :: Field
pMaintainNodeHealth = optionalField $ booleanField "maintain_node_health" 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. -- | Whether to wipe disks before allocating them to instances.
pPreallocWipeDisks :: Field pPreallocWipeDisks :: Field
pPreallocWipeDisks = optionalField $ booleanField "prealloc_wipe_disks" pPreallocWipeDisks = optionalField $ booleanField "prealloc_wipe_disks"
......
...@@ -161,7 +161,7 @@ instance Arbitrary OpCodes.OpCode where ...@@ -161,7 +161,7 @@ instance Arbitrary OpCodes.OpCode where
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*>
emptyMUD <*> emptyMUD <*> arbitrary <*> emptyMUD <*> emptyMUD <*> arbitrary <*>
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*>
arbitrary <*> arbitrary <*> arbitrary <*> arbitrary arbitrary <*> arbitrary <*> arbitrary <*> arbitrary <*> arbitrary
"OP_CLUSTER_REDIST_CONF" -> pure OpCodes.OpClusterRedistConf "OP_CLUSTER_REDIST_CONF" -> pure OpCodes.OpClusterRedistConf
"OP_CLUSTER_ACTIVATE_MASTER_IP" -> "OP_CLUSTER_ACTIVATE_MASTER_IP" ->
pure OpCodes.OpClusterActivateMasterIp pure OpCodes.OpClusterActivateMasterIp
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment