236 |
236 |
"FormatQueryResult",
|
237 |
237 |
"FormatParameterDict",
|
238 |
238 |
"FormatParamsDictInfo",
|
|
239 |
"FormatPolicyInfo",
|
239 |
240 |
"PrintGenericInfo",
|
240 |
241 |
"GenerateTable",
|
241 |
242 |
"AskUser",
|
... | ... | |
3639 |
3640 |
return ret
|
3640 |
3641 |
|
3641 |
3642 |
|
|
3643 |
def _FormatListInfoDefault(data, def_data):
|
|
3644 |
if data is not None:
|
|
3645 |
ret = utils.CommaJoin(data)
|
|
3646 |
else:
|
|
3647 |
ret = "default (%s)" % utils.CommaJoin(def_data)
|
|
3648 |
return ret
|
|
3649 |
|
|
3650 |
|
|
3651 |
def FormatPolicyInfo(custom_ipolicy, eff_ipolicy, iscluster):
|
|
3652 |
"""Formats an instance policy.
|
|
3653 |
|
|
3654 |
@type custom_ipolicy: dict
|
|
3655 |
@param custom_ipolicy: own policy
|
|
3656 |
@type eff_ipolicy: dict
|
|
3657 |
@param eff_ipolicy: effective policy (including defaults); ignored for
|
|
3658 |
cluster
|
|
3659 |
@type iscluster: bool
|
|
3660 |
@param iscluster: the policy is at cluster level
|
|
3661 |
@rtype: list of pairs
|
|
3662 |
@return: formatted data, suitable for L{PrintGenericInfo}
|
|
3663 |
|
|
3664 |
"""
|
|
3665 |
if iscluster:
|
|
3666 |
eff_ipolicy = custom_ipolicy
|
|
3667 |
|
|
3668 |
custom_minmax = custom_ipolicy.get(constants.ISPECS_MINMAX)
|
|
3669 |
ret = [
|
|
3670 |
(key,
|
|
3671 |
FormatParamsDictInfo(custom_minmax.get(key, {}),
|
|
3672 |
eff_ipolicy[constants.ISPECS_MINMAX][key]))
|
|
3673 |
for key in constants.ISPECS_MINMAX_KEYS
|
|
3674 |
]
|
|
3675 |
if iscluster:
|
|
3676 |
stdspecs = custom_ipolicy[constants.ISPECS_STD]
|
|
3677 |
ret.append(
|
|
3678 |
(constants.ISPECS_STD,
|
|
3679 |
FormatParamsDictInfo(stdspecs, stdspecs))
|
|
3680 |
)
|
|
3681 |
|
|
3682 |
ret.append(
|
|
3683 |
("enabled disk templates",
|
|
3684 |
_FormatListInfoDefault(custom_ipolicy.get(constants.IPOLICY_DTS),
|
|
3685 |
eff_ipolicy[constants.IPOLICY_DTS]))
|
|
3686 |
)
|
|
3687 |
ret.extend([
|
|
3688 |
(key, str(custom_ipolicy.get(key, "default (%s)" % eff_ipolicy[key])))
|
|
3689 |
for key in constants.IPOLICY_PARAMETERS
|
|
3690 |
])
|
|
3691 |
return ret
|
|
3692 |
|
|
3693 |
|
3642 |
3694 |
def ConfirmOperation(names, list_type, text, extra=""):
|
3643 |
3695 |
"""Ask the user to confirm an operation on a list of list_type.
|
3644 |
3696 |
|