Commit bf689b7a authored by Andrea Spadaccini's avatar Andrea Spadaccini

Add --use-external-mip-script flag

- add a command line flag to gnt-cluster init and modify to change the
  value of the cluster parameter use_external_mip_script;
- add two constants representing the paths of the default script and of
  the external script;
- add documentation for the new option in the gnt-cluster man page;
- add use_external_mip_script to gnt-cluster info output.
Signed-off-by: default avatarAndrea Spadaccini <spadaccio@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 33be7576
......@@ -289,7 +289,8 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913
hvparams=None, enabled_hypervisors=None, modify_etc_hosts=True,
modify_ssh_setup=True, maintain_node_health=False,
drbd_helper=None, uid_pool=None, default_iallocator=None,
primary_ip_version=None, prealloc_wipe_disks=False):
primary_ip_version=None, prealloc_wipe_disks=False,
use_external_mip_script=False):
"""Initialise the cluster.
@type candidate_pool_size: int
......@@ -482,6 +483,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913
default_iallocator=default_iallocator,
primary_ip_family=ipcls.family,
prealloc_wipe_disks=prealloc_wipe_disks,
use_external_mip_script=use_external_mip_script,
)
master_node_config = objects.Node(name=hostname.name,
primary_ip=hostname.ip,
......
......@@ -177,6 +177,7 @@ __all__ = [
"TO_GROUP_OPT",
"UIDPOOL_OPT",
"USEUNITS_OPT",
"USE_EXTERNAL_MIP_SCRIPT",
"USE_REPL_NET_OPT",
"VERBOSE_OPT",
"VG_NAME_OPT",
......@@ -1016,6 +1017,13 @@ MASTER_NETMASK_OPT = cli_option("--master-netmask", dest="master_netmask",
metavar="NETMASK",
default=None)
USE_EXTERNAL_MIP_SCRIPT = cli_option("--use-external-mip-script",
dest="use_external_mip_script",
help="Specify whether to run a user-provided"
" script for the master IP address turnup and"
" turndown operations",
type="bool", metavar=_YORNO, default=None)
GLOBAL_FILEDIR_OPT = cli_option("--file-storage-dir", dest="file_storage_dir",
help="Specify the default directory (cluster-"
"wide) for storing the file-based disks [%s]" %
......
......@@ -133,6 +133,10 @@ def InitCluster(opts, args):
if opts.prealloc_wipe_disks is None:
opts.prealloc_wipe_disks = False
external_ip_setup_script = opts.use_external_mip_script
if external_ip_setup_script is None:
external_ip_setup_script = False
try:
primary_ip_version = int(opts.primary_ip_version)
except (ValueError, TypeError), err:
......@@ -169,6 +173,7 @@ def InitCluster(opts, args):
default_iallocator=opts.default_iallocator,
primary_ip_version=primary_ip_version,
prealloc_wipe_disks=opts.prealloc_wipe_disks,
use_external_mip_script=external_ip_setup_script,
)
op = opcodes.OpClusterPostInit()
SubmitOpCode(op, opts=opts)
......@@ -381,6 +386,8 @@ def ShowClusterConfig(opts, args):
convert=opts.roman_integers))
ToStdout(" - master netdev: %s", result["master_netdev"])
ToStdout(" - master netmask: %s", result["master_netmask"])
ToStdout(" - use external master IP address setup script: %s",
result["use_external_mip_script"])
ToStdout(" - lvm volume group: %s", result["volume_group_name"])
if result["reserved_lvs"]:
reserved_lvs = utils.CommaJoin(result["reserved_lvs"])
......@@ -879,6 +886,7 @@ def SetClusterParams(opts, args):
opts.reserved_lvs is not None or
opts.master_netdev is not None or
opts.master_netmask is not None or
opts.use_external_mip_script is not None or
opts.prealloc_wipe_disks is not None):
ToStderr("Please give at least one of the parameters.")
return 1
......@@ -945,6 +953,8 @@ def SetClusterParams(opts, args):
ToStderr("The --master-netmask option expects an int parameter.")
return 1
ext_ip_script = opts.use_external_mip_script
op = opcodes.OpClusterSetParams(vg_name=vg_name,
drbd_helper=drbd_helper,
enabled_hypervisors=hvlist,
......@@ -962,7 +972,9 @@ def SetClusterParams(opts, args):
prealloc_wipe_disks=opts.prealloc_wipe_disks,
master_netdev=opts.master_netdev,
master_netmask=opts.master_netmask,
reserved_lvs=opts.reserved_lvs)
reserved_lvs=opts.reserved_lvs,
use_external_mip_script=ext_ip_script,
)
SubmitOpCode(op, opts=opts)
return 0
......@@ -1364,7 +1376,7 @@ commands = {
NOMODIFY_SSH_SETUP_OPT, SECONDARY_IP_OPT, VG_NAME_OPT,
MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
DEFAULT_IALLOCATOR_OPT, PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT,
NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT],
NODE_PARAMS_OPT, GLOBAL_SHARED_FILEDIR_OPT, USE_EXTERNAL_MIP_SCRIPT],
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
"destroy": (
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
......@@ -1441,7 +1453,7 @@ commands = {
MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT,
DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_OPT,
RESERVED_LVS_OPT, DRY_RUN_OPT, PRIORITY_OPT, PREALLOC_WIPE_DISKS_OPT,
NODE_PARAMS_OPT],
NODE_PARAMS_OPT, USE_EXTERNAL_MIP_SCRIPT],
"[opts...]",
"Alters the parameters of the cluster"),
"renew-crypto": (
......
......@@ -3683,6 +3683,9 @@ class LUClusterSetParams(LogicalUnit):
if self.op.reserved_lvs is not None:
self.cluster.reserved_lvs = self.op.reserved_lvs
if self.op.use_external_mip_script is not None:
self.cluster.use_external_mip_script = self.op.use_external_mip_script
def helper_os(aname, mods, desc):
desc += " OS list"
lst = getattr(self.cluster, aname)
......
......@@ -180,6 +180,7 @@ ENABLE_SHARED_FILE_STORAGE = _autoconf.ENABLE_SHARED_FILE_STORAGE
SYSCONFDIR = _autoconf.SYSCONFDIR
TOOLSDIR = _autoconf.TOOLSDIR
CONF_DIR = SYSCONFDIR + "/ganeti"
USER_SCRIPTS_DIR = CONF_DIR + "/scripts"
#: Lock file for watcher, locked in shared mode by watcher; lock in exclusive
# mode to block watcher (see L{cli._RunWhileClusterStoppedHelper.Call}
......@@ -195,6 +196,10 @@ WATCHER_GROUP_INSTANCE_STATUS_FILE = DATA_DIR + "/watcher.%s.instance-status"
#: File containing Unix timestamp until which watcher should be paused
WATCHER_PAUSEFILE = DATA_DIR + "/watcher.pause"
# Master IP address setup scripts paths (default and user-provided)
DEFAULT_MASTER_SETUP_SCRIPT = TOOLSDIR + "/master-ip-setup"
EXTERNAL_MASTER_SETUP_SCRIPT = USER_SCRIPTS_DIR + "/master-ip-setup"
ALL_CERT_FILES = frozenset([
NODED_CERT_FILE,
RAPI_CERT_FILE,
......
......@@ -796,6 +796,8 @@ class OpClusterSetParams(OpCode):
"Modify list of blacklisted operating systems. Each modification must have"
" two items, the operation and the OS name. The operation can be"
" ``%s`` or ``%s``." % (constants.DDM_ADD, constants.DDM_REMOVE)),
("use_external_mip_script", None, ht.TMaybeBool,
"Whether to use an external master IP address setup script"),
]
......
......@@ -167,6 +167,7 @@ INIT
| [--vg-name *vg-name*]
| [--master-netdev *interface-name*]
| [--master-netmask *netmask*]
| [--use-external-mip-script {yes \| no}]
| [{-m|--mac-prefix} *mac-prefix*]
| [--no-lvm-storage]
| [--no-etc-hosts]
......@@ -228,6 +229,12 @@ master IP. The netmask must be specified as an integer, and will be
interpreted as a CIDR netmask. The default value is 32 for an IPv4
address and 128 for an IPv6 address.
The ``--use-external-mip-script`` options allows to specify
whether to use an user-supplied master IP address setup script, whose
location is ``/etc/ganeti/scripts/master-ip-setup``. If the option value
is set to False, the default script, whose location is
``/usr/local/lib/ganeti/tools/master-ip-setup``, will be executed.
The ``-m (--mac-prefix)`` option will let you specify a three byte
prefix under which the virtual MAC addresses of your instances will be
generated. The prefix must be specified in the format ``XX:XX:XX`` and
......@@ -438,6 +445,7 @@ MODIFY
| [--node-parameters *ndparams*]
| [--master-netdev *interface-name*]
| [--master-netmask *netmask*]
| [--use-external-mip-script {yes \| no}]
Modify the options for the cluster.
......@@ -445,8 +453,9 @@ The ``--vg-name``, ``--no-lvm-storarge``, ``--enabled-hypervisors``,
``-H (--hypervisor-parameters)``, ``-B (--backend-parameters)``,
``--nic-parameters``, ``-C (--candidate-pool-size)``,
``--maintain-node-health``, ``--prealloc-wipe-disks``, ``--uid-pool``,
``--node-parameters``, ``--master-netdev`` and ``--master-netmask``
options are described in the **init** command.
``--node-parameters``, ``--master-netdev``, ``--master-netmask`` and
``--use-external-mip-script`` options are described in the
**init** command.
The ``--add-uids`` and ``--remove-uids`` options can be used to
modify the user-id pool by adding/removing a list of user-ids or
......
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