Jenny Tokar has uploaded a new change for review.

Change subject: Add new api to get the IO tune policies for all vms
......................................................................

Add new api to get the IO tune policies for all vms

This patch adds a new api to vdsm that allows retrieval
of the io tune policy and its' values for all the vms via
a single api thus removing the need to query vdsm for that
info for every present vm.

Change-Id: I16ead268367901ae85e47fb71104e23705f0e0e1
Bug-Url: https://bugzilla.redhat.com/1374988
Signed-off-by: Jenny Tokar <jto...@redhat.com>
---
M lib/api/vdsm-api.yml
M lib/vdsm/jsonrpcvdscli.py
M lib/vdsm/rpc/Bridge.py
M lib/vdsm/rpc/bindingxmlrpc.py
M vdsm/API.py
M vdsm/clientIF.py
M vdsm/virt/vm.py
7 files changed, 65 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/48/63748/7

diff --git a/lib/api/vdsm-api.yml b/lib/api/vdsm-api.yml
index c7ab7f5..c27079e 100644
--- a/lib/api/vdsm-api.yml
+++ b/lib/api/vdsm-api.yml
@@ -6027,6 +6027,28 @@
             type: *VmDiskDeviceIoTuneParams
         type: object
 
+    BulkIoTunePolicy: &BulkIoTunePolicy
+        added: '4.0'
+        description: Io tune policy info and current values for a vm
+        name: BulkIoTunePolicy
+        properties:
+        -   description: Io tune policy info
+            name: policy
+            type: *VmDiskDeviceTuneLimits
+
+        -   description: Io tune policy current values
+            name: current_values
+            type: *VmDiskDeviceTuneParams
+        type: object
+
+    BulkIoTunePolicyMap: &BulkIoTunePolicyMap
+         added: '4.0'
+         name: BulkIoTunePolicyMap
+         description: A map of io tune policies for all VMs
+         key-type: *UUID
+         value-type: *BulkIoTunePolicy
+         type: map
+
     UpdateVmPolicyParams: &UpdateVmPolicyParams
         added: '3.4'
         description: QoS policy update data
@@ -7617,6 +7639,13 @@
         type:
         - *VmStats
 
+Host.getAllVmIoTunePolicies:
+    added: '4.0'
+    description: Get io tune policies for all virtual machines.
+    return:
+        description: A map of io tune policies for all VMs
+        type: *BulkIoTunePolicyMap
+
 Host.hostdevListByCaps:
     added: '3.6'
     description: Refresh and get information about devices available on the
diff --git a/lib/vdsm/jsonrpcvdscli.py b/lib/vdsm/jsonrpcvdscli.py
index e276f86..837311c 100644
--- a/lib/vdsm/jsonrpcvdscli.py
+++ b/lib/vdsm/jsonrpcvdscli.py
@@ -59,6 +59,7 @@
     'getAllTasksInfo': 'Host.getAllTasksInfo',
     'getAllTasksStatuses': 'Host.getAllTasksStatuses',
     'getAllVmStats': 'Host.getAllVmStats',
+    'getAllVmIoTunePolicies': 'Host.getAllVmIoTunePolicies',
     'getConnectedStoragePoolsList': 'Host.getConnectedStoragePools',
     'getDeviceList': 'Host.getDeviceList',
     'getImagesList': 'StorageDomain.getImages',
diff --git a/lib/vdsm/rpc/Bridge.py b/lib/vdsm/rpc/Bridge.py
index 5dedcc0..7456ab3 100644
--- a/lib/vdsm/rpc/Bridge.py
+++ b/lib/vdsm/rpc/Bridge.py
@@ -354,6 +354,7 @@
     'Host_getVMList': {'call': Host_getVMList_Call, 'ret': 'vmList'},
     'Host_getVMFullList': {'call': Host_getVMFullList_Call, 'ret': 'vmList'},
     'Host_getAllVmStats': {'ret': 'statsList'},
+    'Host_getAllVmIoTunePolicies': {'ret': 'io_tune_policies_dict'},
     'Host_setupNetworks': {'ret': 'status'},
     'Host_setKsmTune': {'ret': 'status'},
     'Image_cloneStructure': {'ret': 'uuid'},
diff --git a/lib/vdsm/rpc/bindingxmlrpc.py b/lib/vdsm/rpc/bindingxmlrpc.py
index b8bb3f6..1a6ab84 100644
--- a/lib/vdsm/rpc/bindingxmlrpc.py
+++ b/lib/vdsm/rpc/bindingxmlrpc.py
@@ -561,6 +561,10 @@
         api = API.Global()
         return api.getAllVmStats()
 
+    def getAllVmIoTunePolicies(self):
+        api = API.Global()
+        return api.getAllVmIoTunePolicies()
+
     def hostdevListByCaps(self, caps=None):
         api = API.Global()
         return api.hostdevListByCaps(caps)
@@ -1073,6 +1077,7 @@
                 (self.getStats, 'getVdsStats'),
                 (self.vmGetStats, 'getVmStats'),
                 (self.getAllVmStats, 'getAllVmStats'),
+                (self.getAllVmIoTunePolicies, 'getAllVmIoTunePolicies'),
                 (self.hostdevListByCaps, 'hostdevListByCaps'),
                 (self.hostdevChangeNumvfs, 'hostdevChangeNumvfs'),
                 (self.hostdevReattach, 'hostdevReattach'),
diff --git a/vdsm/API.py b/vdsm/API.py
index f000297..0ad84bf 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -780,7 +780,7 @@
         v = self._cif.vmContainer.get(self._UUID)
         if not v:
             return errCode['noVM']
-        return v.getIoTune()
+        return v.getIoTuneResponse()
 
     def setIoTune(self, tunables):
         v = self._cif.vmContainer.get(self._UUID)
@@ -792,7 +792,7 @@
         v = self._cif.vmContainer.get(self._UUID)
         if not v:
             return errCode['noVM']
-        return v.getIoTunePolicy()
+        return v.getIoTunePolicyResponse()
 
     def setCpuTunePeriod(self, period):
         v = self._cif.vmContainer.get(self._UUID)
@@ -1395,6 +1395,13 @@
                           AllVmStatsValue(statsList))
         return {'status': doneCode, 'statsList': Suppressed(statsList)}
 
+    def getAllVmIoTunePolicies(self):
+        """
+        Get IO tuning policies of all running VMs.
+        """
+        io_tune_policies_dict = self._cif.getAllVmIoTunePolicies()
+        return {'status': doneCode, 'io_tune_policies_dict': 
io_tune_policies_dict}
+
     def hostdevListByCaps(self, caps=None):
         devices = hostdev.list_by_caps(caps)
         return {'status': doneCode, 'deviceList': devices}
diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index fefc915..c3bc10f 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -441,6 +441,12 @@
     def getAllVmStats(self):
         return [v.getStats() for v in self.vmContainer.values()]
 
+    def getAllVmIoTunePolicies(self):
+        vm_io_tune_policies = {}
+        for v in self.vmContainer.values():
+                vm_io_tune_policies[v.id] = {'policy':v.getIoTunePolicy(), 
'current_values': v.getIoTune()}
+        return vm_io_tune_policies
+
     def createStompClient(self, client_socket):
         if 'jsonrpc' in self.bindings:
             json_binding = self.bindings['jsonrpc']
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 967dbab..0af45b7 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -2576,19 +2576,29 @@
         else:
             return None
 
+    def getIoTunePolicyResponse(self):
+        tunables = self.getIoTunePolicy()
+        return response.success(ioTunePolicyList=tunables)
+
     def getIoTunePolicy(self):
         tunables = []
         qos = self._getVmPolicy()
         ioTuneList = qos.getElementsByTagName("ioTune")
         if not ioTuneList or not ioTuneList[0].hasChildNodes():
-            return response.success(ioTunePolicyList=[])
+            return []
 
         for device in ioTuneList[0].getElementsByTagName("device"):
             tunables.append(io_tune_dom_to_values(device))
 
-        return response.success(ioTunePolicyList=tunables)
+        return tunables
 
     def getIoTune(self):
+        result = self.getIoTuneResponse()
+        if response.is_error(result):
+            return []
+        return result.get('ioTuneList', [])
+
+    def getIoTuneResponse(self):
         resultList = []
 
         for device in self.getDiskDevices():
@@ -2615,8 +2625,10 @@
             except libvirt.libvirtError as e:
                 self.log.exception("getVmIoTune failed")
                 if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
+                    self.logger.error('noVM')
                     return response.error('noVM')
                 else:
+                    self.logger.error('updateIoTuneErr', e.message)
                     return response.error('updateIoTuneErr', e.message)
 
         return response.success(ioTuneList=resultList)


-- 
To view, visit https://gerrit.ovirt.org/63748
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I16ead268367901ae85e47fb71104e23705f0e0e1
Gerrit-PatchSet: 7
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Jenny Tokar <jto...@redhat.com>
Gerrit-Reviewer: Andrej Krejcir <akrej...@redhat.com>
Gerrit-Reviewer: Francesco Romani <from...@redhat.com>
Gerrit-Reviewer: Jenny Tokar <jto...@redhat.com>
Gerrit-Reviewer: Martin Sivák <msi...@redhat.com>
Gerrit-Reviewer: Phillip Bailey <phbai...@redhat.com>
Gerrit-Reviewer: Piotr Kliczewski <piotr.kliczew...@gmail.com>
Gerrit-Reviewer: Roman Mohr <rm...@redhat.com>
Gerrit-Reviewer: Roy Golan <rgo...@redhat.com>
Gerrit-Reviewer: Yanir Quinn <yqu...@redhat.com>
Gerrit-Reviewer: gerrit-hooks <automat...@ovirt.org>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to