Change in vdsm[master]: adding API methods for blkio limits MOM integration
gchaplik at redhat.com
gchaplik at redhat.com
Tue Jun 10 09:20:43 UTC 2014
Gilad Chaplik has uploaded a new change for review.
Change subject: adding API methods for blkio limits MOM integration
......................................................................
adding API methods for blkio limits MOM integration
Adding API methods to vm.py to integrate with MOM's collectors and controllers:
setBlkioTuneMap(device, blkioTuneMap).
This method sets blkio keys & values to the VM's device using the libvirt api.
Acceptable keys: 'total_bytes_sec', 'read_bytes_sec', 'write_bytes_sec', 'total_iops_sec', 'read_iops_sec', 'write_iops_sec'.
Acceptable value type for all keys: integer.
Change-Id: I43b25627e5365fdd1145a75e91fb5b7714e46aaf
Signed-off-by: Gilad Chaplik <gchaplik at redhat.com>
---
M vdsm/API.py
M vdsm/virt/vm.py
M vdsm_api/vdsmapi-schema.json
3 files changed, 60 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/28547/1
diff --git a/vdsm/API.py b/vdsm/API.py
index 14bb5b6..f11f151 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -719,6 +719,17 @@
return errCode['noVM']
return v.setCpuTunePeriod(period)
+ def setDeviceBlkioTuneMap(self, dev, blkIoTuneMap):
+ """
+ Sets a Blkio Tune parameter map per device.
+ Acceptable keys: 'total_bytes_sec', 'read_bytes_sec', 'write_bytes_sec', 'total_iops_sec', 'read_iops_sec', 'write_iops_sec'.
+ Acceptable value type for all keys: integer.
+ """
+ v = self._cif.vmContainer.get(self._UUID)
+ if not v:
+ return errCode['noVM']
+ return v.setDeviceBlkioTuneMap(dev, blkIoTuneMap)
+
def getDiskAlignment(self, drive):
if self._UUID != VM.BLANK_UUID:
return errCode['noimpl']
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 5bd2d01..79cbe5f 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -4605,6 +4605,40 @@
return self._reportError(msg=e.message, entity='vcpu period')
return {'status': doneCode}
+ def setBlkioTuneMap(self, dev, blkIoTuneMap):
+ self._validateIoTuneParams(self, blkIoTuneMap)
+
+ try:
+ self._dom.setBlockIoTune(dev, blkIoTuneMap, libvirt.VIR_DOMAIN_AFFECT_CURRENT)
+ except ValueError:
+ return self._reportError(msg='a map is required for blkio tune')
+ except libvirt.libvirtError as e:
+ return self._reportError(msg=e.message)
+ return {'status': doneCode}
+
+ def _checkIoTuneInvalidParams(self, blkIoTuneMap):
+ validKeys = set(('total_bytes_sec', 'read_bytes_sec',
+ 'write_bytes_sec', 'total_iops_sec',
+ 'write_iops_sec', 'read_iops_sec'))
+ paramKeys = set(blkIoTuneMap)
+
+ invalidParams = paramKeys - validKeys
+ if invalidParams:
+ invalidParamNames = ', '.join(invalidParams)
+ raise ValueError('Parameter %s name(s) are invalid' %
+ invalidParamNames)
+
+ def _validateIoTuneParams(self, blkIoTuneMap):
+ self._checkIoTuneInvalidParams(blkIoTuneMap)
+ self._checkIoTuneCategories(blkIoTuneMap)
+
+ try:
+ for key, value in blkIoTuneMap.iteritems():
+ blkIoTuneMap[key] = int(value)
+ except ValueError as e:
+ e.message = 'Integer is required for parameter %s' % key
+ raise
+
def _reportError(self, key='Err', msg=None):
"""
Print an error and return an error status.
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json
index 1fc1de8..77741d1 100644
--- a/vdsm_api/vdsmapi-schema.json
+++ b/vdsm_api/vdsmapi-schema.json
@@ -7344,6 +7344,21 @@
'returns': 'TasksStatus'}
##
+# @VM.setBlkioTuneMap:
+#
+# Sets the blkio tune parameters map of a device
+#
+# @period: a number representing the period to be set
+# Returns:
+# Status code
+#
+# Since: 4.15.0
+##
+{'command': {'class': 'VM', 'name': 'setBlkioTuneMap'},
+ 'data': {'device', 'total_bytes_sec': 'int', 'read_bytes_sec': 'int', 'write_bytes_sec': 'int', 'total_iops_sec': 'int', 'read_iops_sec': 'int', 'write_iops_sec': 'int'},
+ 'returns': 'TasksStatus'}
+
+##
# @VM.updateVmPolicy:
#
# Set VM SLA parameters
--
To view, visit http://gerrit.ovirt.org/28547
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I43b25627e5365fdd1145a75e91fb5b7714e46aaf
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Gilad Chaplik <gchaplik at redhat.com>
More information about the vdsm-patches
mailing list