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

Export more information via LUQueryInstances/RAPI



Currently, the custom instance parameters (hv, be, nicp) are only
queryable via LUQueryInstanceData. LUQueryInstance returns only the
filled parameters, thus its users (especially RAPI) have no way to know
if a parameter is custom or the default value.

This patch adds three new parameters: custom_hvparams, custom_beparams,
custom_nicparams, that are also exported in RAPI.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent bd631b02
...@@ -5151,7 +5151,8 @@ class LUQueryInstances(NoHooksLU): ...@@ -5151,7 +5151,8 @@ class LUQueryInstances(NoHooksLU):
r"(nic)\.(bridge)/([0-9]+)", r"(nic)\.(bridge)/([0-9]+)",
r"(nic)\.(macs|ips|modes|links|bridges)", r"(nic)\.(macs|ips|modes|links|bridges)",
r"(disk|nic)\.(count)", r"(disk|nic)\.(count)",
"hvparams", "hvparams", "custom_hvparams",
"custom_beparams", "custom_nicparams",
] + _SIMPLE_FIELDS + ] + _SIMPLE_FIELDS +
["hv/%s" % name ["hv/%s" % name
for name in constants.HVS_PARAMETERS for name in constants.HVS_PARAMETERS
...@@ -5329,6 +5330,8 @@ class LUQueryInstances(NoHooksLU): ...@@ -5329,6 +5330,8 @@ class LUQueryInstances(NoHooksLU):
val = instance.nics[0].mac val = instance.nics[0].mac
else: else:
val = None val = None
elif field == "custom_nicparams":
val = [nic.nicparams for nic in instance.nics]
elif field == "sda_size" or field == "sdb_size": elif field == "sda_size" or field == "sdb_size":
idx = ord(field[2]) - ord('a') idx = ord(field[2]) - ord('a')
try: try:
...@@ -5340,12 +5343,16 @@ class LUQueryInstances(NoHooksLU): ...@@ -5340,12 +5343,16 @@ class LUQueryInstances(NoHooksLU):
val = _ComputeDiskSize(instance.disk_template, disk_sizes) val = _ComputeDiskSize(instance.disk_template, disk_sizes)
elif field == "tags": elif field == "tags":
val = list(instance.GetTags()) val = list(instance.GetTags())
elif field == "custom_hvparams":
val = instance.hvparams # not filled!
elif field == "hvparams": elif field == "hvparams":
val = i_hv val = i_hv
elif (field.startswith(HVPREFIX) and elif (field.startswith(HVPREFIX) and
field[len(HVPREFIX):] in constants.HVS_PARAMETERS and field[len(HVPREFIX):] in constants.HVS_PARAMETERS and
field[len(HVPREFIX):] not in constants.HVC_GLOBALS): field[len(HVPREFIX):] not in constants.HVC_GLOBALS):
val = i_hv.get(field[len(HVPREFIX):], None) val = i_hv.get(field[len(HVPREFIX):], None)
elif field == "custom_beparams":
val = instance.beparams
elif field == "beparams": elif field == "beparams":
val = i_be val = i_be
elif (field.startswith(BEPREFIX) and elif (field.startswith(BEPREFIX) and
......
...@@ -59,6 +59,7 @@ I_FIELDS = ["name", "admin_state", "os", ...@@ -59,6 +59,7 @@ I_FIELDS = ["name", "admin_state", "os",
"disk.sizes", "disk_usage", "disk.sizes", "disk_usage",
"beparams", "hvparams", "beparams", "hvparams",
"oper_state", "oper_ram", "oper_vcpus", "status", "oper_state", "oper_ram", "oper_vcpus", "status",
"custom_hvparams", "custom_beparams", "custom_nicparams",
] + _COMMON_FIELDS ] + _COMMON_FIELDS
N_FIELDS = ["name", "offline", "master_candidate", "drained", N_FIELDS = ["name", "offline", "master_candidate", "drained",
......
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