LGTM, thanks
On Tue, May 13, 2014 at 10:43 AM, 'Jose A. Lopes' via ganeti-devel < [email protected]> wrote: > * 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: Jose A. Lopes <[email protected]> > --- > lib/bootstrap.py | 3 ++- > lib/cli.py | 9 +++++++++ > lib/client/gnt_cluster.py | 28 ++++++++++++++++++---------- > lib/cmdlib/cluster.py | 8 ++++++++ > src/Ganeti/OpCodes.hs | 1 + > src/Ganeti/OpParams.hs | 8 +++++++- > 6 files changed, 45 insertions(+), 12 deletions(-) > > diff --git a/lib/bootstrap.py b/lib/bootstrap.py > index 05b5a7b..958b97d 100644 > --- a/lib/bootstrap.py > +++ b/lib/bootstrap.py > @@ -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): > + install_image=None, zeroing_image=None): > """Initialise the cluster. > > @type candidate_pool_size: int > @@ -822,6 +822,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 > ) > master_node_config = objects.Node(name=hostname.name, > diff --git a/lib/cli.py b/lib/cli.py > index aed12f1..8582f30 100644 > --- a/lib/cli.py > +++ b/lib/cli.py > @@ -116,6 +116,7 @@ __all__ = [ > "IGNORE_SIZE_OPT", > "INCLUDEDEFAULTS_OPT", > "INTERVAL_OPT", > + "INSTALL_IMAGE_OPT", > "INSTANCE_COMMUNICATION_OPT", > "INSTANCE_COMMUNICATION_NETWORK_OPT", > "MAC_PREFIX_OPT", > @@ -1728,6 +1729,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", > diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py > index ceb56cf..998c50a 100644 > --- a/lib/client/gnt_cluster.py > +++ b/lib/client/gnt_cluster.py > @@ -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: > @@ -301,6 +306,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 > ) > op = opcodes.OpClusterPostInit() > @@ -1132,6 +1138,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): > @@ -1246,6 +1253,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, > @@ -2113,8 +2121,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] > - + INSTANCE_POLICY_OPTS + SPLIT_ISPECS_OPTS, > + IPOLICY_STD_SPECS_OPT, GLOBAL_GLUSTER_FILEDIR_OPT, INSTALL_IMAGE_OPT, > + ZEROING_IMAGE_OPT] + INSTANCE_POLICY_OPTS + SPLIT_ISPECS_OPTS, > "[opts...] <cluster_name>", "Initialises a new cluster > configuration"), > "destroy": ( > DestroyCluster, ARGS_NONE, [YES_DOIT_OPT], > @@ -2188,14 +2196,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], > diff --git a/lib/cmdlib/cluster.py b/lib/cmdlib/cluster.py > index 646a1cd..5418c09 100644 > --- a/lib/cmdlib/cluster.py > +++ b/lib/cmdlib/cluster.py > @@ -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, > } > > @@ -805,6 +806,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. > @@ -1628,6 +1633,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") > diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs > index 0cb840c..bf59f61 100644 > --- a/src/Ganeti/OpCodes.hs > +++ b/src/Ganeti/OpCodes.hs > @@ -239,6 +239,7 @@ $(genOpCode "OpCode" > , pClusterFileStorageDir > , pClusterSharedFileStorageDir > , pClusterGlusterStorageDir > + , pInstallImage > , pInstanceCommunicationNetwork > , pZeroingImage > ], > diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs > index 40527c7..e22fff9 100644 > --- a/src/Ganeti/OpParams.hs > +++ b/src/Ganeti/OpParams.hs > @@ -44,6 +44,7 @@ module Ganeti.OpParams > , SetParamsMods(..) > , ExportTarget(..) > , pInstanceName > + , pInstallImage > , pInstanceCommunication > , pOptInstanceCommunication > , pInstanceUuid > @@ -595,11 +596,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" > -- > 1.9.1.423.g4596e3a > >
