This deprecates the option '--no-drbd-storage' from 'gnt-cluster modify'. The consistency check with '--drbd-usermode-helper' is replaced by one against '--enabled-disk-templates' instead.
Signed-off-by: Helga Velroyen <[email protected]> --- lib/client/gnt_cluster.py | 54 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/lib/client/gnt_cluster.py b/lib/client/gnt_cluster.py index 8c2fb6e..85bd858 100644 --- a/lib/client/gnt_cluster.py +++ b/lib/client/gnt_cluster.py @@ -73,6 +73,16 @@ def _CheckNoLvmStorageOptDeprecated(opts): return 1 +def _CheckNoDrbdStorageOptDeprecated(opts): + """Checks if the legacy option '--no-drbd-storage' is used.""" + if not opts.drbd_storage: + ToStderr("The option --no-drbd-storage is no longer supported. If you want" + " to disable drbd storage cluster-wide, use the option" + " --enabled-disk-templates to disable the '%s' disk template." + % constants.DT_DRBD8) + return 1 + + @UsesRPC def InitCluster(opts, args): """Initialize the cluster. @@ -103,12 +113,16 @@ def InitCluster(opts, args): if utils.IsLvmEnabled(enabled_disk_templates) and not opts.vg_name: vg_name = constants.DEFAULT_VG - if not opts.drbd_storage and opts.drbd_helper: - ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.") + if _CheckNoDrbdStorageOptDeprecated(opts): + return 1 + drbd_enabled = constants.DT_DRBD8 in opts.enabled_disk_templates + if not drbd_enabled and opts.drbd_helper: + ToStderr("Use option --drbd-usermode-helper only if you are enabling the" + " '%s' disk template." % constants.DT_DRBD8) return 1 drbd_helper = opts.drbd_helper - if opts.drbd_storage and not opts.drbd_helper: + if drbd_enabled and not opts.drbd_helper: drbd_helper = constants.DEFAULT_DRBD_HELPER master_netdev = opts.master_netdev @@ -976,8 +990,7 @@ def SetClusterParams(opts, args): @return: the desired exit code """ - if not (opts.vg_name or - not opts.drbd_storage or opts.drbd_helper or + if not (opts.vg_name or opts.drbd_helper or opts.enabled_hypervisors or opts.hvparams or opts.beparams or opts.nicparams or opts.ndparams or opts.diskparams or @@ -1006,16 +1019,19 @@ def SetClusterParams(opts, args): ToStderr("Please give at least one of the parameters.") return 1 - if _CheckNoLvmStorageOptDeprecated(opts): + if _CheckNoLvmStorageOptDeprecated(opts) \ + or _CheckNoDrbdStorageOptDeprecated(opts): return 1 + + # Note that we only check consistency between --vg-name, + # --drbd-usermode-helper, and --enabled-disk-templates if the option + # --enabled-disk-templates is explicitely used in this operation. + # We cannot make a statement about the consistency with the already + # configured enabled disk templates at this point. enabled_disk_templates = opts.enabled_disk_templates + + # consistency between vg name and enabled disk templates vg_name = opts.vg_name - # Note that this only checks consistency between the vg_name and the - # enabled lvm-based disk templates if both parameters --vg-name and - # --enabled-disk-templates are used in this operation. If the option - # --enabled-disk-templates is not explicitly used, we cannot make a statement - # about the consistency with the already configured enabled disk templates - # at this point. if enabled_disk_templates: enabled_disk_templates = enabled_disk_templates.split(",") if not utils.IsLvmEnabled(enabled_disk_templates) and opts.vg_name: @@ -1027,13 +1043,17 @@ def SetClusterParams(opts, args): if not utils.IsLvmEnabled(enabled_disk_templates): vg_name = "" + # consistency between drbd usermode helper and enabled disk templates drbd_helper = opts.drbd_helper - if not opts.drbd_storage and opts.drbd_helper: - ToStderr("Options --no-drbd-storage and --drbd-usermode-helper conflict.") - return 1 + if enabled_disk_templates: + drbd_enabled = constants.DT_DRBD8 in enabled_disk_templates + if not drbd_enabled and opts.drbd_helper: + ToStderr("Use option --drbd-usermode-helper only if you enable the '%s'" + " disk template." % constants.DT_DRBD8) + return 1 - if not opts.drbd_storage: - drbd_helper = "" + if not drbd_enabled: + drbd_helper = "" hvlist = opts.enabled_hypervisors if hvlist is not None: -- 1.8.1.3
