# W0614: Unused import %s from wildcard import (since we need cli)
# C0103: Invalid name gnt-cluster
+from cStringIO import StringIO
import os.path
import time
import OpenSSL
ispecs_disk_count=opts.ispecs_disk_count,
ispecs_disk_size=opts.ispecs_disk_size,
ispecs_nic_count=opts.ispecs_nic_count,
+ minmax_ispecs=opts.ipolicy_bounds_specs,
+ std_ispecs=opts.ipolicy_std_specs,
ipolicy_disk_templates=opts.ipolicy_disk_templates,
ipolicy_vcpu_ratio=opts.ipolicy_vcpu_ratio,
ipolicy_spindle_ratio=opts.ipolicy_spindle_ratio,
else:
reserved_lvs = "(none)"
+ enabled_hv = result["enabled_hypervisors"]
+ hvparams = dict((k, v) for k, v in result["hvparams"].iteritems()
+ if k in enabled_hv)
+
info = [
("Cluster name", result["name"]),
("Cluster UUID", result["uuid"]),
("Tags", tags),
("Default hypervisor", result["default_hypervisor"]),
- ("Enabled hypervisors",
- utils.CommaJoin(result["enabled_hypervisors"])),
+ ("Enabled hypervisors", utils.CommaJoin(enabled_hv)),
- ("Hypervisor parameters", _FormatGroupedParams(result["hvparams"])),
+ ("Hypervisor parameters", _FormatGroupedParams(hvparams)),
("OS-specific hypervisor parameters",
_FormatGroupedParams(result["os_hvp"])),
("OS search path", utils.CommaJoin(pathutils.OS_SEARCH_PATH)),
("ExtStorage Providers search path",
utils.CommaJoin(pathutils.ES_SEARCH_PATH)),
- ("enabled storage types",
- utils.CommaJoin(result["enabled_storage_types"])),
("enabled disk templates",
utils.CommaJoin(result["enabled_disk_templates"])),
]),
opts.use_external_mip_script is not None or
opts.prealloc_wipe_disks is not None or
opts.hv_state or
- # FIXME: Remove 'enabled_storage_types' once 'enabled_disk_templates'
- # are fully implemented.
- opts.enabled_storage_types or
opts.enabled_disk_templates or
opts.disk_state or
- opts.ispecs_mem_size or
- opts.ispecs_cpu_count or
- opts.ispecs_disk_count or
- opts.ispecs_disk_size or
- opts.ispecs_nic_count or
+ opts.ipolicy_bounds_specs is not None or
+ opts.ipolicy_std_specs is not None or
opts.ipolicy_disk_templates is not None or
opts.ipolicy_vcpu_ratio is not None or
opts.ipolicy_spindle_ratio is not None):
if hvlist is not None:
hvlist = hvlist.split(",")
- # FIXME: Remove once 'enabled_disk_templates' are fully implemented.
- enabled_storage_types = opts.enabled_storage_types
- if enabled_storage_types is not None:
- enabled_storage_types = enabled_storage_types.split(",")
-
enabled_disk_templates = opts.enabled_disk_templates
if enabled_disk_templates:
enabled_disk_templates = enabled_disk_templates.split(",")
utils.ForceDictType(ndparams, constants.NDS_PARAMETER_TYPES)
ipolicy = CreateIPolicyFromOpts(
- ispecs_mem_size=opts.ispecs_mem_size,
- ispecs_cpu_count=opts.ispecs_cpu_count,
- ispecs_disk_count=opts.ispecs_disk_count,
- ispecs_disk_size=opts.ispecs_disk_size,
- ispecs_nic_count=opts.ispecs_nic_count,
+ minmax_ispecs=opts.ipolicy_bounds_specs,
+ std_ispecs=opts.ipolicy_std_specs,
ipolicy_disk_templates=opts.ipolicy_disk_templates,
ipolicy_vcpu_ratio=opts.ipolicy_vcpu_ratio,
ipolicy_spindle_ratio=opts.ipolicy_spindle_ratio,
use_external_mip_script=ext_ip_script,
hv_state=hv_state,
disk_state=disk_state,
- # FIXME: remove once 'enabled_disk_templates' are fully implemented.
- enabled_storage_types=enabled_storage_types,
enabled_disk_templates=enabled_disk_templates,
+ force=opts.force,
)
SubmitOrSend(op, opts)
return 0
return _off_fn(opts, node_list, inst_map)
+def _GetCreateCommand(info):
+ buf = StringIO()
+ buf.write("gnt-cluster init")
+ PrintIPolicyCommand(buf, info["ipolicy"], False)
+ buf.write(" ")
+ buf.write(info["name"])
+ return buf.getvalue()
+
+
+def ShowCreateCommand(opts, args):
+ """Shows the command that can be used to re-create the cluster.
+
+ Currently it works only for ipolicy specs.
+
+ """
+ cl = GetClient(query=True)
+ result = cl.QueryClusterInfo()
+ ToStdout(_GetCreateCommand(result))
+
+
commands = {
"init": (
InitCluster, [ArgHost(min=1, max=1)],
MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, DRBD_HELPER_OPT, NODRBD_STORAGE_OPT,
DEFAULT_IALLOCATOR_OPT, 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]
- + INSTANCE_POLICY_OPTS,
+ DISK_PARAMS_OPT, HV_STATE_OPT, DISK_STATE_OPT, ENABLED_DISK_TEMPLATES_OPT,
+ IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS + SPLIT_ISPECS_OPTS,
"[opts...] <cluster_name>", "Initialises a new cluster configuration"),
"destroy": (
DestroyCluster, ARGS_NONE, [YES_DOIT_OPT],
"{pause <timespec>|continue|info}", "Change watcher properties"),
"modify": (
SetClusterParams, ARGS_NONE,
- [BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, MASTER_NETDEV_OPT,
+ [FORCE_OPT,
+ BACKEND_OPT, CP_SIZE_OPT, ENABLED_HV_OPT, HVLIST_OPT, MASTER_NETDEV_OPT,
MASTER_NETMASK_OPT, NIC_PARAMS_OPT, NOLVM_STORAGE_OPT, VG_NAME_OPT,
MAINTAIN_NODE_HEALTH_OPT, UIDPOOL_OPT, ADD_UIDS_OPT, REMOVE_UIDS_OPT,
DRBD_HELPER_OPT, NODRBD_STORAGE_OPT, DEFAULT_IALLOCATOR_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_OPT, ENABLED_STORAGE_TYPES_OPT,
- ENABLED_DISK_TEMPLATES_OPT] +
- INSTANCE_POLICY_OPTS,
+ DISK_STATE_OPT, SUBMIT_OPT, ENABLED_DISK_TEMPLATES_OPT,
+ IPOLICY_STD_SPECS_OPT] + INSTANCE_POLICY_OPTS,
"[opts...]",
"Alters the parameters of the cluster"),
"renew-crypto": (
"deactivate-master-ip": (
DeactivateMasterIp, ARGS_NONE, [CONFIRM_OPT], "",
"Deactivates the master IP"),
+ "show-ispecs-cmd": (
+ ShowCreateCommand, ARGS_NONE, [], "",
+ "Show the command line to re-create the cluster"),
}