Commit 024e157f authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a new instance query flag ‘disk_usage’

This patch adds a new instance query flag called disk_usage that
retrieves the overall space used by an instance on each of its nodes.
This can be used when balancing the cluster or checking N+1 status.

The flag is also exported in RAPI. Note the flag is currently broken for
file-based instances, as it represents the amount of space in the
cluster volume group.

Reviewed-by: ultrotter
parent 821d1bd1
......@@ -3087,7 +3087,7 @@ class LUQueryInstances(NoHooksLU):
"sda_size", "sdb_size", "vcpus", "tags",
"network_port", "beparams",
"(disk).(sizes)", "disk_usage",
......@@ -3244,6 +3244,9 @@ class LUQueryInstances(NoHooksLU):
val = instance.FindDisk(idx).size
except errors.OpPrereqError:
val = None
elif field == "disk_usage": # total disk usage per node
disk_sizes = [{'size': disk.size} for disk in instance.disks]
val = _ComputeDiskSize(instance.disk_template, disk_sizes)
elif field == "tags":
val = list(instance.GetTags())
elif field == "serial_no":
......@@ -34,7 +34,7 @@ I_FIELDS = ["name", "admin_state", "os",
"pnode", "snodes",
"nic.ips", "nic.macs", "nic.bridges",
"disk.sizes", "disk_usage",
"beparams", "hvparams",
"oper_state", "oper_ram", "status",
......@@ -226,6 +226,7 @@ def ListInstances(opts, args):
"ip": "IP_address", "mac": "MAC_address",
"bridge": "Bridge",
"sda_size": "Disk/0", "sdb_size": "Disk/1",
"disk_usage": "DiskUsage",
"status": "Status", "tags": "Tags",
"network_port": "Network_port",
"hv/kernel_path": "Kernel_path",
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