Commit 1fbe43de authored by Jose A. Lopes's avatar Jose A. Lopes

Add 'install_image' to bootstrap, CLI, opcodes, and queries

* Add 'install_image' to 'bootstrap.InitCluster' and cluster client
* Add '--install-image' flag to 'gnt-cluster init'
* Add '--install-image' flag to 'gnt-cluster modify'
* Add param 'install_image' to 'OpClusterSetParams'
* Add 'install_image' field to cluster info
Signed-off-by: default avatarJose A. Lopes <jabolopes@google.com>
Reviewed-by: default avatarHrvoje Ribicic <riba@google.com>
parent e78b63ed
......@@ -553,7 +553,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
primary_ip_version=None, ipolicy=None,
prealloc_wipe_disks=False, use_external_mip_script=False,
hv_state=None, disk_state=None, enabled_disk_templates=None,
zeroing_image=None, compression_tools=None):
install_image=None, zeroing_image=None, compression_tools=None):
"""Initialise the cluster.
@type candidate_pool_size: int
......@@ -825,6 +825,7 @@ def InitCluster(cluster_name, mac_prefix, # pylint: disable=R0913, R0914
candidate_certs=candidate_certs,
osparams={},
osparams_private_cluster={},
install_image=install_image,
zeroing_image=zeroing_image,
compression_tools=compression_tools
)
......
......@@ -117,6 +117,7 @@ __all__ = [
"IGNORE_SIZE_OPT",
"INCLUDEDEFAULTS_OPT",
"INTERVAL_OPT",
"INSTALL_IMAGE_OPT",
"INSTANCE_COMMUNICATION_OPT",
"INSTANCE_COMMUNICATION_NETWORK_OPT",
"MAC_PREFIX_OPT",
......@@ -1734,6 +1735,14 @@ HOTPLUG_IF_POSSIBLE_OPT = cli_option("--hotplug-if-possible",
help="Hotplug devices in case"
" hotplug is supported")
INSTALL_IMAGE_OPT = \
cli_option("--install-image",
dest="install_image",
action="store",
type="string",
default=None,
help="The OS image to use for running the OS scripts safely")
INSTANCE_COMMUNICATION_OPT = \
cli_option("-c", "--communication",
dest="instance_communication",
......
......@@ -265,6 +265,11 @@ def InitCluster(opts, args):
hv_state = dict(opts.hv_state)
if opts.install_image:
install_image = opts.install_image
else:
install_image = ""
if opts.zeroing_image:
zeroing_image = opts.zeroing_image
else:
......@@ -303,6 +308,7 @@ def InitCluster(opts, args):
hv_state=hv_state,
disk_state=disk_state,
enabled_disk_templates=enabled_disk_templates,
install_image=install_image,
zeroing_image=zeroing_image,
compression_tools=compression_tools
)
......@@ -1148,6 +1154,7 @@ def SetClusterParams(opts, args):
opts.ipolicy_spindle_ratio is not None or
opts.modify_etc_hosts is not None or
opts.file_storage_dir is not None or
opts.install_image is not None or
opts.instance_communication_network is not None or
opts.zeroing_image is not None or
opts.shared_file_storage_dir is not None or
......@@ -1265,6 +1272,7 @@ def SetClusterParams(opts, args):
enabled_disk_templates=enabled_disk_templates,
force=opts.force,
file_storage_dir=opts.file_storage_dir,
install_image=opts.install_image,
instance_communication_network=opts.instance_communication_network,
zeroing_image=opts.zeroing_image,
shared_file_storage_dir=opts.shared_file_storage_dir,
......@@ -2133,8 +2141,8 @@ commands = {
PRIMARY_IP_VERSION_OPT, PREALLOC_WIPE_DISKS_OPT, NODE_PARAMS_OPT,
GLOBAL_SHARED_FILEDIR_OPT, USE_EXTERNAL_MIP_SCRIPT, DISK_PARAMS_OPT,
HV_STATE_OPT, DISK_STATE_OPT, ENABLED_DISK_TEMPLATES_OPT,
IPOLICY_STD_SPECS_OPT, GLOBAL_GLUSTER_FILEDIR_OPT, ZEROING_IMAGE_OPT,
COMPRESSION_TOOLS_OPT]
IPOLICY_STD_SPECS_OPT, GLOBAL_GLUSTER_FILEDIR_OPT, INSTALL_IMAGE_OPT,
ZEROING_IMAGE_OPT, COMPRESSION_TOOLS_OPT]
+ INSTANCE_POLICY_OPTS + SPLIT_ISPECS_OPTS,
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
"destroy": (
......@@ -2209,14 +2217,14 @@ commands = {
"modify": (
SetClusterParams, ARGS_NONE,
[FORCE_OPT,
BACKEND_OPT, CP_SIZE_OPT, RQL_OPT, INSTANCE_COMMUNICATION_NETWORK_OPT,
ENABLED_HV_OPT, HVLIST_OPT, MAC_PREFIX_OPT, MASTER_NETDEV_OPT,
MASTER_NETMASK_OPT, NIC_PARAMS_OPT, VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT,
UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT, DRBD_HELPER_OPT,
DEFAULT_IALLOCATOR_OPT, DEFAULT_IALLOCATOR_PARAMS_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, DISK_STATE_OPT] +
SUBMIT_OPTS +
BACKEND_OPT, CP_SIZE_OPT, RQL_OPT, INSTALL_IMAGE_OPT,
INSTANCE_COMMUNICATION_NETWORK_OPT, ENABLED_HV_OPT, HVLIST_OPT,
MAC_PREFIX_OPT, MASTER_NETDEV_OPT, MASTER_NETMASK_OPT, NIC_PARAMS_OPT,
VG_NAME_OPT, MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, ADD_UIDS_OPT,
REMOVE_UIDS_OPT, DRBD_HELPER_OPT, DEFAULT_IALLOCATOR_OPT,
DEFAULT_IALLOCATOR_PARAMS_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, DISK_STATE_OPT] + SUBMIT_OPTS +
[ENABLED_DISK_TEMPLATES_OPT, IPOLICY_STD_SPECS_OPT, MODIFY_ETCHOSTS_OPT] +
INSTANCE_POLICY_OPTS +
[GLOBAL_FILEDIR_OPT, GLOBAL_SHARED_FILEDIR_OPT, ZEROING_IMAGE_OPT,
......
......@@ -415,6 +415,7 @@ class LUClusterQuery(NoHooksLU):
"hidden_os": cluster.hidden_os,
"blacklisted_os": cluster.blacklisted_os,
"enabled_disk_templates": cluster.enabled_disk_templates,
"install_image": cluster.install_image,
"instance_communication_network": cluster.instance_communication_network,
"compression_tools": cluster.compression_tools,
}
......@@ -833,6 +834,10 @@ class LUClusterSetParams(LogicalUnit):
raise errors.OpPrereqError("While verify diskparams options: %s" % err,
errors.ECODE_INVAL)
if self.op.install_image is not None:
CheckImageValidity(self.op.install_image,
"Install image must be an absolute path or a URL")
def ExpandNames(self):
# FIXME: in the future maybe other cluster params won't require checking on
# all nodes to be modified.
......@@ -1659,6 +1664,9 @@ class LUClusterSetParams(LogicalUnit):
result.Warn("Could not change the master IP netmask", feedback_fn)
self.cluster.master_netmask = self.op.master_netmask
if self.op.install_image:
self.cluster.install_image = self.op.install_image
if self.op.zeroing_image is not None:
CheckImageValidity(self.op.zeroing_image,
"Zeroing image must be an absolute path or a URL")
......
......@@ -239,6 +239,7 @@ $(genOpCode "OpCode"
, pClusterFileStorageDir
, pClusterSharedFileStorageDir
, pClusterGlusterStorageDir
, pInstallImage
, pInstanceCommunicationNetwork
, pZeroingImage
, pCompressionTools
......
......@@ -44,6 +44,7 @@ module Ganeti.OpParams
, SetParamsMods(..)
, ExportTarget(..)
, pInstanceName
, pInstallImage
, pInstanceCommunication
, pOptInstanceCommunication
, pInstanceUuid
......@@ -596,11 +597,16 @@ pClusterGlusterStorageDir =
renameField "ClusterGlusterStorageDir" $
optionalStringField "gluster_storage_dir"
pInstallImage :: Field
pInstallImage =
withDoc "OS image for running OS scripts in a safe environment" $
optionalStringField "install_image"
pInstanceCommunicationNetwork :: Field
pInstanceCommunicationNetwork =
optionalStringField "instance_communication_network"
-- | The OS to use when zeroing instance disks
-- | The OS to use when zeroing instance disks.
pZeroingImage :: Field
pZeroingImage =
optionalStringField "zeroing_image"
......
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