Martin Sivák has uploaded a new change for review. Change subject: Add getIoTune API ......................................................................
Add getIoTune API Change-Id: Ib7983d91fe4b90c5b85c986c2b5a9a1931cfdc42 Signed-off-by: Martin Sivak <[email protected]> --- M tests/vmTests.py M vdsm/API.py M vdsm/rpc/vdsmapi-schema.json M vdsm/virt/vm.py 4 files changed, 67 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/96/28896/1 diff --git a/tests/vmTests.py b/tests/vmTests.py index d6ab61f..cf3cd3c 100644 --- a/tests/vmTests.py +++ b/tests/vmTests.py @@ -1124,6 +1124,40 @@ self.maxDiff = None self.assertEqual(expected_xml, self._xml_sanitizer(dom._metadata)) + def testGetIoTune(self): + with FakeVM() as machine: + dom = FakeDomain() + dom._metadata = """ + <qos> + <vcpuLimit>999</vcpuLimit> + <ioTune> + <device name='test-device-by-name'> + <maximum> + <totalBytes>9999</totalBytes> + </maximum> + </device> + <device name='other-device'> + <guaranteed> + <totalBytes>9999</totalBytes> + </guaranteed> + </device> + </ioTune> + </qos> + """ + machine._dom = dom + + tunables = machine.getIoTune() + expected = [ + {'name': u'test-device-by-name', + 'maximum': { + u'totalBytes': 9999 + }}, + {'name': u'other-device', + 'guaranteed': { + u'totalBytes': 9999 + }} + ] + self.assertEqual(tunables, expected) class FakeGuestAgent(object): diff --git a/vdsm/API.py b/vdsm/API.py index 321e105..1714722 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -714,6 +714,12 @@ return errCode['noVM'] return v.setIoTune(tunables) + def getIoTune(self): + v = self._cif.vmContainer.get(self._UUID) + if not v: + return errCode['noVM'] + return v.getIoTune() + def setCpuTunePeriod(self, period): v = self._cif.vmContainer.get(self._UUID) if not v: @@ -1194,7 +1200,7 @@ return {'status': {'code': 0, 'message': message}, 'power': power} threading.Thread(target=fence, args=(script, inp)).start() - return {'status': doneCode, 'power': 'unknown'} + return {'status': doneCode} def ping(self): "Ping the server. Useful for tests" diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json index 9bd0d21..9319f61 100644 --- a/vdsm/rpc/vdsmapi-schema.json +++ b/vdsm/rpc/vdsmapi-schema.json @@ -7506,6 +7506,20 @@ 'returns': 'TasksStatus'} ## +# @VM.getIoTune: +# +# Gets the ioTune parameters for block devices +# +# Returns: +# list of VmDiskDeviceTuneParams objects describing +# the current settings +# +# Since: 4.15.0 +## +{'command': {'class': 'VM', 'name': 'getIoTune'}, + 'returns': ['VmDiskDeviceTuneParams']} + +## # @VM.setCpuTuneQuota: # # Set the vCpu quota tune parameter to the VM diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py index 0280cb6..82b5321 100644 --- a/vdsm/virt/vm.py +++ b/vdsm/virt/vm.py @@ -3910,6 +3910,18 @@ qos = metadata.getElementsByTagName("qos")[0] return qos + def getIoTune(self): + tunables = [] + qos = self._getVmPolicy() + ioTuneList = qos.getElementsByTagName("ioTune") + if not ioTuneList or not ioTuneList[0].hasChildNodes(): + return [] + + for device in ioTuneList[0].getElementsByTagName("device"): + tunables.append(self._ioTuneDomToValues(device)) + + return tunables + def setIoTune(self, tunables): for io_tune_change in tunables: device_name = io_tune_change.get('name', None) -- To view, visit http://gerrit.ovirt.org/28896 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib7983d91fe4b90c5b85c986c2b5a9a1931cfdc42 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
