Vinzenz Feenstra has uploaded a new change for review.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
[WIP] VDSM <=> Engine data optimization
Change-Id: Ifa0a7a86a351a8c2d891f22802a95d1fe1bc1df4 Signed-off-by: Vinzenz Feenstra vfeenstr@redhat.com --- M vdsm/API.py M vdsm/BindingXMLRPC.py M vdsm/vm.py M vdsm_api/vdsmapi-schema.json 4 files changed, 499 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/41/14541/1
diff --git a/vdsm/API.py b/vdsm/API.py index ee72116..ebf331d 100644 --- a/vdsm/API.py +++ b/vdsm/API.py @@ -334,6 +334,66 @@ return errCode['noVM'] return v.migrateStatus()
+ def getRuntimeStats(self): + """ + Retrieve runtime statistics for the specific VM + """ + v = self._cif.vmContainer.get(self._UUID) + if not v: + return errCode['noVM'] + return { + 'status': doneCode, + 'runtimeStats': { + self._UUID: v.getRuntimeStats().copy()}} + + def getStatus(self): + """ + Retrieve VM status information for the specific VM + """ + v = self._cif.vmContainer.get(self._UUID) + if not v: + return errCode['noVM'] + return { + 'status': doneCode, + 'vmStatus': { + self._UUID: v.getStatus().copy()}} + + def getDeviceStats(self): + """ + Retrieve device statistics for the specific VM + """ + v = self._cif.vmcontainer.get(self._uuid) + if not v: + return errCode['noVM'] + return { + 'status': doneCode, + 'deviceStats': { + self._UUID: v.getDeviceStats().copy()}} + + def getConfInfo(self): + """ + Retrieve configuration information for the specific VM + """ + v = self._cif.vmcontainer.get(self._uuid) + if not v: + return errCode['noVM'] + return { + 'status': doneCode, + 'info': { + self._UUID: v.getInfo().copy()}} + + def getGuestDetails(self): + """ + Retrieve guest information for the specific VM + """ + v = self._cif.vmcontainer.get(self._uuid) + if not v: + return errCode['noVM'] + return { + 'status': doneCode, + 'guestDetails': { + self._UUID: v.getGuestDetails().copy()}} + def getStats(self): """ Obtain statistics of the specified VM diff --git a/vdsm/BindingXMLRPC.py b/vdsm/BindingXMLRPC.py index 9a4db12..912018c 100644 --- a/vdsm/BindingXMLRPC.py +++ b/vdsm/BindingXMLRPC.py @@ -314,6 +314,52 @@ vm = API.VM(vmId) return vm.getStats()
+ def vmGetRuntimeStats(self, vmIds): + result = {} + for vmId in vmIds: + vm = API.VM(vmId) + result.update(vm.getRuntimeStats()['runtimeStats']) + return { + 'status': doneCode, + 'runtimeStats': result} + + def vmGetStatus(self, vmIds): + result = {} + for vmId in vmIds: + vm = API.VM(vmId) + result.update(vm.getStatus()['vmStatus']) + return { + 'status': doneCode, + 'vmStatus': result} + + def vmGetAllDeviceStats(self): + vms = self.getVMList() + result = {} + for vm in vms['vmList']: + v = API.VM(vm['vmId']) + result.update(v.getDeviceStats()['deviceStats']) + return { + 'status': doneCode, + 'deviceStats': result} + + def vmGetConfInfo(self, vmIds): + result = {} + for vmId in vmIds: + vm = API.VM(vmId) + result.update(vm.getConfInfo()['vmConfInfo']) + return { + 'status': doneCode, + 'vmConfInfo': result} + + def vmGetGuestDetails(self, vmIds): + result = {} + for vmId in vmIds: + vm = API.VM(vmId) + result.update(vm.getGuestDetails()['guestDetails']) + return { + 'status': doneCode, + 'guestDetails': result} + def getAllVmStats(self): """ Get statistics of all running VMs. diff --git a/vdsm/vm.py b/vdsm/vm.py index ddb09c8..6d57649 100644 --- a/vdsm/vm.py +++ b/vdsm/vm.py @@ -26,6 +26,7 @@ import tempfile import pickle from copy import deepcopy +import json
from vdsm import utils from vdsm.define import NORMAL, ERROR, doneCode, errCode @@ -1115,6 +1116,65 @@ self.conf['status'] = self.lastStatus return self.conf
+ def _hashObject(self, o): + return str(hash(json.dumps(o))) + + def _getHashes(self, stats): + return { + 'info': self._hashObject(self._getInfo(stats)), + 'status': self._hashObject(self._getStatus(stats)), + 'guestDetals': self._hashObject(self._getGuestDetails(stats))} + + def _extractKeys(self, dictObject, keys): + extracted = {} + for k in keys: + v = dictObject.get(k) + if v: + extracted[k] = v + return extracted + + def getRuntimeStats(self): + allStats = self.getStats() + USED_KEYS = ('cpuSys', 'cpuUser', 'memUsage', 'elapsedTime', 'status', + 'statsAge') + stats = self._extractKeys(allStats, USED_KEYS) + stats['hashes'] = self._getHashes(allStats) + if 'hash' in allStats: + stats['hashes']['config'] = allStats['hash'] + return stats + + def _getStatus(self, stats): + USED_KEYS = ('timeOffset', 'monitorResponse', 'clientIp', 'lastLogin', + 'username', 'session', 'guestIPs') + return self._extractKeys(stats, USED_KEYS) + + def getStatus(self): + return self._getStatus(self.getStats()) + + def _getDeviceStats(self, stats): + USED_KEYS = ('network', 'disks', 'disksUsage', 'balloonInfo', + 'memoryStats') + return self._extractKeys(stats, USED_KEYS) + + def getDeviceStats(self): + return self._getDeviceStats(self.getStats()) + + def _getInfo(self, stats): + USED_KEYS = ('acpiEnable', 'vmType', 'guestName', 'guestOS', + 'kvmEnable', 'pauseCode', 'displayIp', 'displayPort', + 'displaySecurePort', 'pid') + return self._extractKeys(stats, USED_KEYS) + + def getInfo(self): + return self._getInfo(self.getStats()) + + def _getGuestDetails(self, stats): + USED_KEYS = ('appList', 'netIfaces') + return self._extractKeys(stats, USED_KEYS) + + def getGuestDetails(self): + return self._getGuestDetails(self.getStats()) + def getStats(self): # used by API.Vm.getStats
diff --git a/vdsm_api/vdsmapi-schema.json b/vdsm_api/vdsmapi-schema.json index 4ff8c7a..33be905 100644 --- a/vdsm_api/vdsmapi-schema.json +++ b/vdsm_api/vdsmapi-schema.json @@ -4850,6 +4850,339 @@ 'data': {'vmID': 'UUID'}, 'returns': 'VmDefinition'}
+## +# @VmRuntimeStatsHashes: +# +# Hashes of several statistics and information around VMs +# +# @info: Hash for VmConfInfo data +# +# @config: Hash of the VM configuration XML +# +# @status: Hash of the VmStatusInfo data +# +# @guestDetails: Hash of the VmGuestDetails data +# +# Since: 4.10.3 +## +{ 'type': 'VmRuntimeStatsHashes', + 'data': { 'info': 'str', 'config': 'str', 'status': 'str', + 'guestDetails': 'str'}} + +## +# @VmRuntimeStats: +# +# Frequently changed and required data around VMs +# +# @cpuSys: Ratio of CPU time spent by qemu on other than guest time +# +# @cpuUser: Ratio of CPU time spent by the guest VM +# +# @memUsage: The percent of memory in use by the guest +# +# @elapsedTime: The number of seconds that the VM has been running +# +# @status: The current status of the given VM +# +# @statsAge: The age of these statistics in seconds +# +# @hashes: Hashes of several statistics and information around VMs +# +# Since: 4.10.3 +## +{ 'type': 'VmRuntimeStats', + 'data': { 'cpuSys': 'float', 'cpuUser': 'float', 'memUsage': 'uint', + 'elapsedTime': 'uint', 'status': 'VmStatus', 'statsAge': 'float', + 'hashes': 'VmRuntimeStatsHashes'}} + +## +# @VmRuntimeStatsResult: +# +# Union result of VmRuntimeStats or ExitedVmStats +# +# @exited: Indicates if the result is VmRuntimeStats or ExitedVmStats +# +# Since: 4.10.3 +## +{'type': 'VmRuntimeStatsResult', + 'data': { 'exited': 'bool' }, + 'union': ['VmRuntimeStats', 'ExitedVmStats']} + +## +# @VmRuntimeStatsMap: +# +# A mapping of VM runtime statistics indexed by vm id (UUID). +# +# Since: 4.10.3 +## +{'map': 'VmRuntimeStatsMap', + 'key': 'UUID', 'value': 'VmRuntimeStatsResult' }} + + +## +# @VM.getRuntimeStats: +# +# Get runtime information about a list of VMs +# +# @vmIDs: a list of UUIDs for VMs to query +# +# Returns: +# VmRuntimeStatsMap +# +# Since: 4.10.3 +## +{'command': {'class': 'VM', 'name': 'getRuntimeStats'}, + 'data': {'vmIDs': ['UUID']}, + 'returns': 'VmRuntimeStatsMap'} + +## +# @VmStatusInfo: +# +# Information to the status of a VM and less frequently changed information +# +# @timeOffset: The time difference from host to the VM in seconds +# +# @monitorResponse: Indicates if the qemu monitor is responsive +# +# @clientIp: The IP address of the client connected to the display +# +# @username: the username associated with the current session +# +# @session: The current state of user interaction with the VM +# +# @guestIPs: A space separated string of assigned IPv4 addresses +# +# @pauseCode: Indicates the reason a VM has been paused +# +# Since: 4.10.3 +## +{ 'type': 'VmStatusInfo', + 'data': { 'timeOffset': 'uint', 'monitorResponse': 'int', 'clientIp': 'str', + 'username': 'str', 'session': 'GuestSessionState', + 'guestIPs': 'str', 'pauseCode': 'str'}} + +## +# @VmStatusInfoResult: +# +# Union result of VmStatusInfo or ExitedVmStats +# +# @exited: Indicates if the result is VmStatusInfo or ExitedVmStats +# +# Since: 4.10.3 +## +{'type': 'VmStatusInfoResult', + 'data': { 'exited': 'bool' }, + 'union': ['VmStatusInfo', 'ExitedVmStats']} + +## +# @VmStatusInfoMap: +# +# A mapping of VM status information indexed by vm id (UUID). +# +# Since: 4.10.3 +## +{'map': 'VmStatusInfoMap', + 'key': 'UUID', 'value': 'VmStatusInfoResult'} + +## +# @VM.getStatus: +# +# Get status information about a list of VMs +# +# @vmIDs: a list of UUIDs for VMs to query +# +# Returns: +# VmStatusMap +# +# Since: 4.10.3 +## +{'command': {'class': 'VM', 'name': 'getStatus'}, + 'data': {'vmIDs': ['UUID']}, + 'returns': 'VmStatusInfoMap'} + +## +# @VmConfInfo: +# +# VM configuration information +# +# @acpiEnable: Indicates if ACPI is enabled inside the VM +# +# @displayPort: The port in use for unencrypted display data +# +# @displaySecurePort: The port in use for encrypted display data +# +# @displayType: The type of display in use +# +# @displayIp: The IP address to use for accessing the VM display +# +# @pid: The process ID of the underlying qemu process +# +# @vmType: The type of VM +# +# @kvmEnable: Indicates if KVM hardware acceleration is enabled +# +# @cdrom: #optional The path to an ISO image used in the VM's CD-ROM device +# +# @boot: #optional An alias for the type of device used to boot the VM +# +# Since: 4.10.3 +## +{ 'type': 'VmConfInfo', + 'data': { 'acpiEnable': 'bool', 'vmType': 'VmType', + 'kvmEnable': 'bool', 'displayIp': 'str', 'displayPort': 'uint', + 'displaySecurePort': 'uint', 'displayType': 'VmDisplayType', + 'pid': 'uint', '*boot': 'VmBootMode', '*cdrom': 'str'}} + +## +# @VmConfInfoResult: +# +# Union result of VmConfInfo or ExitedVmStats +# +# @exited: Indicates if the result is VmConfInfo or ExitedVmStats +# +# Since: 4.10.3 +## +{'type': 'VmConfInfoResult', + 'data': { 'exited': 'bool' }, + 'union': ['VmConfInfo', 'ExitedVmStats']} + +## +# @VmConfInfoMap: +# +# A mapping of VM config information indexed by vm id (UUID). +# +# Since: 4.10.3 +## +{'map': 'VmConfInfoMap', + 'key': 'UUID', 'value': 'VmConfInfoResult' }} + +## +# @VM.getConfInfo: +# +# Get configuration information about a list of VMs +# +# @vmIDs: a list of UUIDs for VMs to query +# +# Returns: +# VmConfInfoMap +# +# Since: 4.10.3 +## +{'command': {'class': 'VM', 'name': 'getConfInfo'}, + 'data': {'vmIDs': ['UUID']}, + 'returns': 'VmConfInfoMap'} + +## +# @VmDeviceStats: +# +# VM device statistics containing information for getting statistics and SLA +# information. +# +# @memoryStats: Memory statistics as reported by the guest agent +# +# @balloonInfo: Guest memory balloon information +# +# @disksUsage: Info about mounted filesystems as reported by the agent +# +# @network: Network bandwidth/utilization statistics +# +# @disks: Disk bandwidth/utilization statistics +# +# Since: 4.10.3 +## +{ 'type': 'VmDeviceStats', + 'data': { 'network': 'NetworkInterfaceStatsMap', 'disks': 'VmDiskStatsMap', + 'disksUsage': ['GuestMountInfo'], 'balloonInfo': 'BalloonInfo', + 'memoryStats': 'GuestMemoryStats' }} + +## +# @VmDeviceStatsResult: +# +# Union result of VmDeviceStats or ExitedVmStats +# +# @exited: Indicates if the result is VmDeviceStats or ExitedVmStats +# +# Since: 4.10.3 +## +{'type': 'VmDeviceStatsResult', + 'data': { 'exited': 'bool' }, + 'union': ['VmDeviceStats', 'ExitedVmStats']} + +## +# @VmDeviceStatsMap: +# +# A mapping of VM device statistics indexed by vm id (UUID). +# +# Since: 4.10.3 +## +{'map': 'VmDeviceStatsMap', + 'key': 'UUID', 'value': 'VmDeviceStatsResult' }} + +## +# @VM.getAllDeviceStats: +# +# Get device statistics from all VMs +# +# Returns: +# VmDeviceStatsMap +# +# Since: 4.10.3 +## +{'command': {'class': 'VM', 'name': 'getAllDeviceStats'}, + 'returns': 'VmDeviceStatsMap'} + +## +# @VmGuestDetails: +# +# Non-frequent changed details from guest OSes +# +# @appsList: A list of installed applications with their versions +# +# @netIfaces: Network device address info as reported by the agent +# +# Since: 4.10.3 +## +{ 'type': 'VmGuestDetails', + 'data': { 'appsList': ['str'], 'netIfaces': ['GuestNetworkDeviceInfo'] }} + +## +# @VmGuestDetailsResult: +# +# Union result of VmDeviceStats or ExitedVmStats +# +# @exited: Indicates if the result is VmGuestDetails or ExitedVmStats +# +# Since: 4.10.3 +## +{'type': 'VmGuestDetailsResult', + 'data': { 'exited': 'bool' }, + 'union': ['VmGuestDetails', 'ExitedVmStats']} + +## +# @VmGuestDetailsMap: +# +# A mapping of detailed information of guests indexed by vm id (UUID). +# +# Since: 4.10.3 +## +{'map': 'VmGuestDetailsMap', + 'key': 'UUID', 'value': 'VmGuestDetailsResult' }} + +## +# @VM.getGuestDetails: +# +# Get details from the guest OS from a list of VMs +# +# @vmIDs: a list of UUIDs for VMs to query +# +# Returns: +# VmGuestDetailsMap +# +# Since: 4.10.3 +## +{'command': {'class': 'VM', 'name': 'getGuestDetails'}, + 'data': {'vmIDs': ['UUID']}, + 'returns': 'VmGuestDetailsMap'}
## # @VM.getMigrationStatus:
-- To view, visit http://gerrit.ovirt.org/14541 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa0a7a86a351a8c2d891f22802a95d1fe1bc1df4 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra vfeenstr@redhat.com
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/2179/ (1/2)
-- To view, visit http://gerrit.ovirt.org/14541 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ifa0a7a86a351a8c2d891f22802a95d1fe1bc1df4 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra vfeenstr@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
Patch Set 1:
Build Started http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/2240/ (2/2)
-- To view, visit http://gerrit.ovirt.org/14541 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ifa0a7a86a351a8c2d891f22802a95d1fe1bc1df4 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra vfeenstr@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
Patch Set 1:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/2240/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/2179/ : SUCCESS
-- To view, visit http://gerrit.ovirt.org/14541 To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment Gerrit-Change-Id: Ifa0a7a86a351a8c2d891f22802a95d1fe1bc1df4 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Vinzenz Feenstra vfeenstr@redhat.com Gerrit-Reviewer: Roy Golan rgolan@redhat.com Gerrit-Reviewer: oVirt Jenkins CI Server
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
Patch Set 2: Fails; I would prefer that you didn't submit this
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3176/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3097/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2286/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
Patch Set 3: Fails; I would prefer that you didn't submit this
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3234/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3155/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2344/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] VDSM <=> Engine data optimization ......................................................................
Patch Set 4:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3245/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3166/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2356/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] vdsm: API extension to improve the communication with the Engine ......................................................................
Patch Set 5: Fails; I would prefer that you didn't submit this
Build Failed
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2647/ : FAILURE
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3454/ : UNSTABLE
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3538/ : FAILURE
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] vdsm: API extension to improve the communication with the Engine ......................................................................
Patch Set 6:
Build Successful
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/2667/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_pep8_gerrit/3474/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/3558/ : SUCCESS
oVirt Jenkins CI Server has posted comments on this change.
Change subject: [WIP] vdsm: API extension to improve the communication with the Engine ......................................................................
Patch Set 7:
Build Successful
http://jenkins.ovirt.org/job/vdsm_master_pep8_gerrit/7322/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit_el/6538/ : SUCCESS
http://jenkins.ovirt.org/job/vdsm_unit_tests_gerrit/7440/ : SUCCESS
Itamar Heim has posted comments on this change.
Change subject: [WIP] vdsm: API extension to improve the communication with the Engine ......................................................................
Patch Set 7:
ping
Vinzenz Feenstra has abandoned this change.
Change subject: [WIP] vdsm: API extension to improve the communication with the Engine ......................................................................
Abandoned
Outdated
vdsm-patches@lists.fedorahosted.org