Commit 0e514de1 authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

Export instance disk spindles



Instance disk spindles can be queried via LUXI and RAPI, and are exported
through the allocator interface. This is a prerequisite for htools to
handle spindles.

The length of a RAPI query including all the instance fields now has become
~4400 characters. For this reason the server buffer has been increased.
Signed-off-by: default avatarBernardo Dal Seno <bdalseno@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent c324da14
......@@ -593,6 +593,11 @@ class LUInstanceRecreateDisks(LogicalUnit):
# reasons, then recreating the disks on the same nodes should be fine.
disk_template = self.instance.disk_template
spindle_use = be_full[constants.BE_SPINDLE_USE]
disks = [{
constants.IDISK_SIZE: d.size,
constants.IDISK_MODE: d.mode,
constants.IDISK_SPINDLES: d.spindles,
} for d in self.instance.disks]
req = iallocator.IAReqInstanceAlloc(name=self.op.instance_name,
disk_template=disk_template,
tags=list(self.instance.GetTags()),
......@@ -601,9 +606,7 @@ class LUInstanceRecreateDisks(LogicalUnit):
vcpus=be_full[constants.BE_VCPUS],
memory=be_full[constants.BE_MAXMEM],
spindle_use=spindle_use,
disks=[{constants.IDISK_SIZE: d.size,
constants.IDISK_MODE: d.mode}
for d in self.instance.disks],
disks=disks,
hypervisor=self.instance.hypervisor,
node_whitelist=None)
ial = iallocator.IAllocator(self.cfg, self.rpc, req)
......
......@@ -159,7 +159,7 @@ class _HttpClientToServerMessageReader(http.HttpMessageReader):
"""
# Length limits
START_LINE_LENGTH_MAX = 4096
START_LINE_LENGTH_MAX = 8192
HEADER_LENGTH_MAX = 4096
def ParseStartLine(self, start_line):
......
......@@ -603,7 +603,8 @@ class IAllocator(object):
"nodes": [iinfo.primary_node] + list(iinfo.secondary_nodes),
"nics": nic_data,
"disks": [{constants.IDISK_SIZE: dsk.size,
constants.IDISK_MODE: dsk.mode}
constants.IDISK_MODE: dsk.mode,
constants.IDISK_SPINDLES: dsk.spindles}
for dsk in iinfo.disks],
"disk_template": iinfo.disk_template,
"disks_active": iinfo.disks_active,
......
......@@ -1582,6 +1582,19 @@ def _GetInstDiskSize(ctx, _, disk): # pylint: disable=W0613
return disk.size
def _GetInstDiskSpindles(ctx, _, disk): # pylint: disable=W0613
"""Get a Disk's spindles.
@type disk: L{objects.Disk}
@param disk: The Disk object
"""
if disk.spindles is None:
return _FS_UNAVAIL
else:
return disk.spindles
def _GetInstDeviceName(ctx, _, device): # pylint: disable=W0613
"""Get a Device's Name.
......@@ -1905,6 +1918,9 @@ def _GetInstanceDiskFields():
IQ_CONFIG, 0, lambda ctx, inst: len(inst.disks)),
(_MakeField("disk.sizes", "Disk_sizes", QFT_OTHER, "List of disk sizes"),
IQ_CONFIG, 0, lambda ctx, inst: [disk.size for disk in inst.disks]),
(_MakeField("disk.spindles", "Disk_spindles", QFT_OTHER,
"List of disk spindles"),
IQ_CONFIG, 0, lambda ctx, inst: [disk.spindles for disk in inst.disks]),
(_MakeField("disk.names", "Disk_names", QFT_OTHER, "List of disk names"),
IQ_CONFIG, 0, lambda ctx, inst: [disk.name for disk in inst.disks]),
(_MakeField("disk.uuids", "Disk_UUIDs", QFT_OTHER, "List of disk UUIDs"),
......@@ -1918,6 +1934,9 @@ def _GetInstanceDiskFields():
(_MakeField("disk.size/%s" % i, "Disk/%s" % i, QFT_UNIT,
"Disk size of %s disk" % numtext),
IQ_CONFIG, 0, _GetInstDisk(i, _GetInstDiskSize)),
(_MakeField("disk.spindles/%s" % i, "DiskSpindles/%s" % i, QFT_NUMBER,
"Spindles of %s disk" % numtext),
IQ_CONFIG, 0, _GetInstDisk(i, _GetInstDiskSpindles)),
(_MakeField("disk.name/%s" % i, "DiskName/%s" % i, QFT_TEXT,
"Name of %s disk" % numtext),
IQ_CONFIG, 0, _GetInstDisk(i, _GetInstDeviceName)),
......
......@@ -74,7 +74,7 @@ I_FIELDS = ["name", "admin_state", "os",
"nic.ips", "nic.macs", "nic.modes",
"nic.links", "nic.networks", "nic.bridges",
"network_port",
"disk.sizes", "disk_usage",
"disk.sizes", "disk.spindles", "disk_usage",
"beparams", "hvparams",
"oper_state", "oper_ram", "oper_vcpus", "status",
"custom_hvparams", "custom_beparams", "custom_nicparams",
......
......@@ -105,7 +105,7 @@ def Setup(username, password):
INSTANCE_FIELDS = ("name", "os", "pnode", "snodes",
"admin_state",
"disk_template", "disk.sizes",
"disk_template", "disk.sizes", "disk.spindles",
"nic.ips", "nic.macs", "nic.modes", "nic.links",
"beparams", "hvparams",
"oper_state", "oper_ram", "oper_vcpus", "status", "tags")
......
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