"AUTO_PROMOTE_OPT",
"AUTO_REPLACE_OPT",
"BACKEND_OPT",
+ "BLK_OS_OPT",
"CLEANUP_OPT",
"CLUSTER_DOMAIN_SECRET_OPT",
"CONFIRM_OPT",
"FORCE_OPT",
"FORCE_VARIANT_OPT",
"GLOBAL_FILEDIR_OPT",
+ "HID_OS_OPT",
"HVLIST_OPT",
"HVOPTS_OPT",
"HYPERVISOR_OPT",
action="store_false", default=True,
help="Disable support for DRBD")
+HID_OS_OPT = cli_option("--hidden", dest="hidden",
+ type="bool", default=None, metavar=_YORNO,
+ help="Sets the hidden flag on the OS")
+
+BLK_OS_OPT = cli_option("--blacklisted", dest="blacklisted",
+ type="bool", default=None, metavar=_YORNO,
+ help="Sets the blacklisted flag on the OS")
+
+
#: Options provided by all commands
COMMON_OPTS = [DEBUG_OPT]
("drbd_helper", None, _TOr(_TString, _TNone)),
("default_iallocator", None, _TMaybeString),
("reserved_lvs", None, _TOr(_TListOf(_TNonEmptyString), _TNone)),
+ ("hidden_oss", None, _TOr(_TListOf(\
+ _TAnd(_TList,
+ _TIsLength(2),
+ _TMap(lambda v: v[0], _TElemOf(constants.DDMS_VALUES)))),
+ _TNone)),
+ ("blacklisted_oss", None, _TOr(_TListOf(\
+ _TAnd(_TList,
+ _TIsLength(2),
+ _TMap(lambda v: v[0], _TElemOf(constants.DDMS_VALUES)))),
+ _TNone)),
]
REQ_BGL = False
if self.op.reserved_lvs is not None:
self.cluster.reserved_lvs = self.op.reserved_lvs
+ def helper_oss(aname, mods, desc):
+ lst = getattr(self.cluster, aname)
+ for key, val in mods:
+ if key == constants.DDM_ADD:
+ if val in lst:
+ feedback_fn("OS %s already in %s, ignoring", val, desc)
+ else:
+ lst.append(val)
+ elif key == constants.DDM_REMOVE:
+ if val in lst:
+ lst.remove(val)
+ else:
+ feedback_fn("OS %s not found in %s, ignoring", val, desc)
+ else:
+ raise errors.ProgrammerError("Invalid modification '%s'" % key)
+
+ if self.op.hidden_oss:
+ helper_oss("hidden_oss", self.op.hidden_oss,
+ "hidden OS list")
+
+ if self.op.blacklisted_oss:
+ helper_oss("blacklisted_oss", self.op.blacklisted_oss,
+ "blacklisted OS list")
+
self.cfg.Update(self.cluster, feedback_fn)
INISECT_OSP = "os"
# dynamic device modification
-DDM_ADD = 'add'
-DDM_REMOVE = 'remove'
+DDM_ADD = "add"
+DDM_REMOVE = "remove"
+DDMS_VALUES = frozenset([DDM_ADD, DDM_REMOVE])
# common exit codes
EXIT_SUCCESS = 0
"remove_uids",
"default_iallocator",
"reserved_lvs",
+ "hidden_oss",
+ "blacklisted_oss",
]
</cmdsynopsis>
<para>
- This command will allow you to modify OS parameters. At the moment
- we just support per-os-hypervisor settings. You can run modify
+ This command will allow you to modify OS parameters.
+
+ </para>
+
+ <para>
+ To modify the per-OS hypervisor parameters (which override the
+ global hypervisor parameters), you can run modify
<option>-H</option> with the same syntax as in
<command>gnt-cluster init</command> to override default hypervisor
parameters of the cluster for specified
</para>
<para>
+ To modify the hidden and blacklisted states of an OS, pass the
+ options <option>--hidden <replaceable>yes|no</replaceable></option>,
+ or respectively <option>--blacklisted ...</option>. The 'hidden'
+ state means that an OS won't be listed by default in the OS
+ list, but is available for installation. The 'blacklisted' state
+ means that the OS is not listed and is also not allowed for new
+ instance creations (but can be used for reinstalling old
+ instances).
+ </para>
+
+ <para>
Note: The <replaceable>OS</replaceable> doesn't have to exists.
This allows preseeding the settings for
<replaceable>OS</replaceable>es not yet known to
else:
osp = None
- if not (os_hvp or osp):
+ if opts.hidden is not None:
+ if opts.hidden:
+ ohid = [(constants.DDM_ADD, os)]
+ else:
+ ohid = [(constants.DDM_REMOVE, os)]
+ else:
+ ohid = None
+
+ if opts.blacklisted is not None:
+ if opts.blacklisted:
+ oblk = [(constants.DDM_ADD, os)]
+ else:
+ oblk = [(constants.DDM_REMOVE, os)]
+ else:
+ oblk = None
+
+ if not (os_hvp or osp or ohid or oblk):
ToStderr("At least one of OS parameters or hypervisor parameters"
" must be passed")
return 1
- op = opcodes.OpSetClusterParams(vg_name=None,
- enabled_hypervisors=None,
- hvparams=None,
- beparams=None,
- nicparams=None,
- candidate_pool_size=None,
- os_hvp=os_hvp,
- osparams=osp)
+ op = opcodes.OpSetClusterParams(os_hvp=os_hvp,
+ osparams=osp,
+ hidden_oss=ohid,
+ blacklisted_oss=oblk)
SubmitOpCode(op, opts=opts)
return 0
ShowOSInfo, [ArgOs()], [], "", "Show detailed information about "
"operating systems"),
'modify': (
- ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT], "",
+ ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT, DRY_RUN_OPT,
+ HID_OS_OPT, BLK_OS_OPT], "",
"Modify the OS parameters"),
}