diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py index 5637774f3531e8770e67e602937c8a6a205571e0..f3ada54864d92e09f677a079b6d73047279dd91e 100644 --- a/lib/client/gnt_cluster.py +++ b/lib/client/gnt_cluster.py @@ -223,6 +223,32 @@ def RenameCluster(opts, args): return 0 +def ActivateMasterIp(opts, args): + """Activates the master IP. + + """ + op = opcodes.OpClusterActivateMasterIp() + SubmitOpCode(op) + return 0 + + +def DeactivateMasterIp(opts, args): + """Deactivates the master IP. + + """ + if not opts.confirm: + usertext = ("This will disable the master IP. All the open connections to" + " the master IP will be closed. To reach the master you will" + " need to use its node IP." + " Continue?") + if not AskUser(usertext): + return 1 + + op = opcodes.OpClusterDeactivateMasterIp() + SubmitOpCode(op) + return 0 + + def RedistributeConfig(opts, args): """Forces push of the cluster configuration. @@ -1411,6 +1437,11 @@ commands = { SHUTDOWN_TIMEOUT_OPT, POWER_DELAY_OPT], "[opts...] [args]", "Performs an emergency power-off on given args"), + "activate-master-ip": ( + ActivateMasterIp, ARGS_NONE, [], "", "Activates the master IP"), + "deactivate-master-ip": ( + DeactivateMasterIp, ARGS_NONE, [CONFIRM_OPT], "", + "Deactivates the master IP"), } diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 9a3231b8685c03391b1bf0b1bc343709a7baf4f9..2b2409b362bc234916d2991a7476a27b6ccd69b9 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -3797,6 +3797,30 @@ class LUClusterRedistConf(NoHooksLU): _RedistributeAncillaryFiles(self) +class LUClusterActivateMasterIp(NoHooksLU): + """Activate the master IP on the master node. + + """ + def Exec(self, feedback_fn): + """Activate the master IP. + + """ + master = self.cfg.GetMasterNode() + self.rpc.call_node_activate_master_ip(master) + + +class LUClusterDeactivateMasterIp(NoHooksLU): + """Deactivate the master IP on the master node. + + """ + def Exec(self, feedback_fn): + """Deactivate the master IP. + + """ + master = self.cfg.GetMasterNode() + self.rpc.call_node_deactivate_master_ip(master) + + def _WaitForSync(lu, instance, disks=None, oneshot=False): """Sleep and poll for an instance's disk to sync. diff --git a/lib/opcodes.py b/lib/opcodes.py index 6b2f1870bb31e9d2ac0501688ef718adc9c4e3ef..6b90ce6dde2a75293513367496da28c42f1bcee8 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -796,6 +796,18 @@ class OpClusterRedistConf(OpCode): """ +class OpClusterActivateMasterIp(OpCode): + """Activate the master IP on the master node. + + """ + + +class OpClusterDeactivateMasterIp(OpCode): + """Deactivate the master IP on the master node. + + """ + + class OpQuery(OpCode): """Query for resources/items. diff --git a/man/gnt-cluster.rst b/man/gnt-cluster.rst index 88511197a84365a178af0087aaaea1ee66df23c3..b9b26c91db6c8258f73ee82b4084b492e6666a23 100644 --- a/man/gnt-cluster.rst +++ b/man/gnt-cluster.rst @@ -20,6 +20,13 @@ Ganeti system. COMMANDS -------- +ACTIVATE-MASTER-IP +~~~~~~~~~~~~~~~~~~ + +**activate-master-ip** + +Activates the master IP on the master node. + ADD-TAGS ~~~~~~~~ @@ -89,6 +96,18 @@ primary/secondary IPs are different). Example:: This will copy the file /tmp/test from the current node to the two named nodes. +DEACTIVATE-MASTER-IP +~~~~~~~~~~~~~~~~~~~~ + +**deactivate-master-ip** [--yes] + +Deactivates the master IP on the master node. + +This should be run only locally or on a connection to the node ip +directly, as a connection to the master ip will be broken by this +operation. Because of this risk it will require user confirmation +unless the ``--yes`` option is passed. + DESTROY ~~~~~~~ diff --git a/test/docs_unittest.py b/test/docs_unittest.py index 0db111f2fc119b1d0b10ecd3ff340581cec393ee..c43792060980e387494a4eb09ace5060242e5940 100755 --- a/test/docs_unittest.py +++ b/test/docs_unittest.py @@ -56,6 +56,8 @@ RAPI_OPCODE_EXCLUDE = frozenset([ opcodes.OpNodeQueryvols, opcodes.OpOobCommand, opcodes.OpTagsSearch, + opcodes.OpClusterActivateMasterIp, + opcodes.OpClusterDeactivateMasterIp, # Difficult if not impossible opcodes.OpClusterDestroy,