Commit a6c7e2a2 authored by Iustin Pop's avatar Iustin Pop
Browse files

Move parameter title definitions to constants



This fixes an old TODO for moving these; now they can be reused in the
Haskell Query2 implementation.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
parent 9d4cc8ed
......@@ -849,6 +849,20 @@ HVS_PARAMETER_TYPES = {
HVS_PARAMETERS = frozenset(HVS_PARAMETER_TYPES.keys())
HVS_PARAMETER_TITLES = {
HV_ACPI: "ACPI",
HV_BOOT_ORDER: "Boot_order",
HV_CDROM_IMAGE_PATH: "CDROM_image_path",
HV_DISK_TYPE: "Disk_type",
HV_INITRD_PATH: "Initrd_path",
HV_KERNEL_PATH: "Kernel_path",
HV_NIC_TYPE: "NIC_type",
HV_PAE: "PAE",
HV_VNC_BIND_ADDRESS: "VNC_bind_address",
HV_PASSTHROUGH: "pci_pass",
HV_CPU_TYPE: "cpu_type",
}
# Migration statuses
HV_MIGRATION_COMPLETED = "completed"
HV_MIGRATION_ACTIVE = "active"
......@@ -936,6 +950,13 @@ BES_PARAMETER_TYPES = {
BE_SPINDLE_USE: VTYPE_INT,
}
BES_PARAMETER_TITLES = {
BE_AUTO_BALANCE: "Auto_balance",
BE_MAXMEM: "ConfigMaxMem",
BE_MINMEM: "ConfigMinMem",
BE_VCPUS: "ConfigVCPUs",
}
BES_PARAMETER_COMPAT = {
BE_MEMORY: VTYPE_SIZE,
}
......@@ -995,6 +1016,11 @@ NDS_PARAMETER_TYPES = {
NDS_PARAMETERS = frozenset(NDS_PARAMETER_TYPES.keys())
NDS_PARAMETER_TITLES = {
ND_OOB_PROGRAM: "OutOfBandProgram",
ND_SPINDLE_COUNT: "SpindleCount",
}
# Logical Disks parameters
LDP_RESYNC_RATE = "resync-rate"
LDP_STRIPES = "stripes"
......
......@@ -145,12 +145,6 @@ _VTToQFT = {
_SERIAL_NO_DOC = "%s object serial number, incremented on each modification"
# TODO: Consider moving titles closer to constants
NDP_TITLE = {
constants.ND_OOB_PROGRAM: "OutOfBandProgram",
constants.ND_SPINDLE_COUNT: "SpindleCount",
}
def _GetUnknownField(ctx, item): # pylint: disable=W0613
"""Gets the contents of an unknown field.
......@@ -987,7 +981,9 @@ def _BuildNDFields(is_group):
field_kind = GQ_CONFIG
else:
field_kind = NQ_GROUP
return [(_MakeField("ndp/%s" % name, NDP_TITLE.get(name, "ndp/%s" % name),
return [(_MakeField("ndp/%s" % name,
constants.NDS_PARAMETER_TITLES.get(name,
"ndp/%s" % name),
_VTToQFT[kind], "The \"%s\" node parameter" % name),
field_kind, 0, _GetNDParam(name))
for name, kind in constants.NDS_PARAMETER_TYPES.items()]
......@@ -1755,28 +1751,6 @@ def _GetInstanceParameterFields():
@return: List of field definitions used as input for L{_PrepareFieldList}
"""
# TODO: Consider moving titles closer to constants
be_title = {
constants.BE_AUTO_BALANCE: "Auto_balance",
constants.BE_MAXMEM: "ConfigMaxMem",
constants.BE_MINMEM: "ConfigMinMem",
constants.BE_VCPUS: "ConfigVCPUs",
}
hv_title = {
constants.HV_ACPI: "ACPI",
constants.HV_BOOT_ORDER: "Boot_order",
constants.HV_CDROM_IMAGE_PATH: "CDROM_image_path",
constants.HV_DISK_TYPE: "Disk_type",
constants.HV_INITRD_PATH: "Initrd_path",
constants.HV_KERNEL_PATH: "Kernel_path",
constants.HV_NIC_TYPE: "NIC_type",
constants.HV_PAE: "PAE",
constants.HV_VNC_BIND_ADDRESS: "VNC_bind_address",
constants.HV_PASSTHROUGH: "pci_pass",
constants.HV_CPU_TYPE: "cpu_type",
}
fields = [
# Filled parameters
(_MakeField("hvparams", "HypervisorParameters", QFT_OTHER,
......@@ -1809,7 +1783,8 @@ def _GetInstanceParameterFields():
return lambda ctx, _: ctx.inst_hvparams.get(name, _FS_UNAVAIL)
fields.extend([
(_MakeField("hv/%s" % name, hv_title.get(name, "hv/%s" % name),
(_MakeField("hv/%s" % name,
constants.HVS_PARAMETER_TITLES.get(name, "hv/%s" % name),
_VTToQFT[kind], "The \"%s\" hypervisor parameter" % name),
IQ_CONFIG, 0, _GetInstHvParam(name))
for name, kind in constants.HVS_PARAMETER_TYPES.items()
......@@ -1821,7 +1796,8 @@ def _GetInstanceParameterFields():
return lambda ctx, _: ctx.inst_beparams.get(name, None)
fields.extend([
(_MakeField("be/%s" % name, be_title.get(name, "be/%s" % name),
(_MakeField("be/%s" % name,
constants.BES_PARAMETER_TITLES.get(name, "be/%s" % name),
_VTToQFT[kind], "The \"%s\" backend parameter" % name),
IQ_CONFIG, 0, _GetInstBeParam(name))
for name, kind in constants.BES_PARAMETER_TYPES.items()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment