Adam Litke has uploaded a new change for review. Change subject: Revert "Adding support in CPU monitoring" ......................................................................
Revert "Adding support in CPU monitoring" This reverts commit a7fa2ec418c65c881362950a4e680fa56afe63cc. Build Failure: http://jenkins.ovirt.org/job/mom_create-rpms/45/label=centos64/console Change-Id: If26228ca6219927534abde90ac600f1eafc7f729 Signed-off-by: Adam Litke <[email protected]> --- M mom/Collectors/Collector.py D mom/Collectors/GuestCpuTune.py D mom/Collectors/HostCpu.py D mom/Controllers/CpuTune.py M mom/HypervisorInterfaces/libvirtInterface.py M mom/HypervisorInterfaces/vdsmInterface.py 6 files changed, 0 insertions(+), 225 deletions(-) git pull ssh://gerrit.ovirt.org:29418/mom refs/changes/40/27940/1 diff --git a/mom/Collectors/Collector.py b/mom/Collectors/Collector.py index 3a135b2..46b3a5e 100644 --- a/mom/Collectors/Collector.py +++ b/mom/Collectors/Collector.py @@ -138,14 +138,3 @@ return int(m.group(1)) else: return None - -def count_occurrences(regex, src): - """ - Parse a body of text according to the provided regular expression and return - the count of matches as an integer. - """ - m = re.findall(regex, src, re.M) - if m: - return len(m) - else: - return None diff --git a/mom/Collectors/GuestCpuTune.py b/mom/Collectors/GuestCpuTune.py deleted file mode 100644 index 4c704b9..0000000 --- a/mom/Collectors/GuestCpuTune.py +++ /dev/null @@ -1,45 +0,0 @@ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -from mom.Collectors.Collector import * -class GuestCpuTune(Collector): - """ - This Collector uses hypervisor interface to collect guest cpu info - """ - def getFields(self=None): - return set(['vcpu_quota', 'vcpu_period', 'vcpu_user_limit', 'vcpu_count']) - - def __init__(self, properties): - self.hypervisor_iface = properties['hypervisor_iface'] - self.uuid = properties['uuid'] - self.logger = logging.getLogger('mom.Collectors.CpuTuneInfo') - self.cpu_tune_info_available = True - - def stats_error(self, msg): - """ - Only print stats interface errors one time when we first discover a - problem. Otherwise the log will be overrun with noise. - """ - if self.cpu_tune_info_available: - self.logger.debug(msg) - self.cpu_tune_info_available = False - - def collect(self): - stat = self.hypervisor_iface.getVmCpuTuneInfo(self.uuid) - - if stat == None: - self.stats_error('getVmCpuTuneInfo() is not ready') - else: - self.cpu_tune_info_available = True - - return stat diff --git a/mom/Collectors/HostCpu.py b/mom/Collectors/HostCpu.py deleted file mode 100644 index 3107f34..0000000 --- a/mom/Collectors/HostCpu.py +++ /dev/null @@ -1,39 +0,0 @@ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -from mom.Collectors.Collector import * - -class HostCpu(Collector): - """ - This Collector uses the /proc/cpuinfo file to retrieve CPU info for the host. - Currently it only retrieve the number of CPUs in the host into 'cpu_count' - """ - - def __init__(self, properties): - self.cpuinfo = open_datafile("/proc/cpuinfo") - - def __del__(self): - if self.cpuinfo is not None: - self.cpuinfo.close() - - def collect(self): - self.cpuinfo.seek(0) - - contents = self.cpuinfo.read() - cpu_count = count_occurrences("^processor.*:.*", contents) - - data = { 'cpu_count': cpu_count } - return data - - def getFields(self=None): - return set(['cpu_count']) diff --git a/mom/Controllers/CpuTune.py b/mom/Controllers/CpuTune.py deleted file mode 100644 index 687f7bc..0000000 --- a/mom/Controllers/CpuTune.py +++ /dev/null @@ -1,45 +0,0 @@ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2 as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -import logging - -class CpuTune: - """ - Controller that uses the hypervisor interface to manipulate - the cpu tuning parameters. - The current parameters that can be set are: - vcpu_quota: The optional quota element specifies the maximum allowed bandwidth(unit: microseconds). - vcpu_period: The optional period element specifies the enforcement interval(unit: microseconds). - For more: http://libvirt.org/formatdomain.html#elementsCPUTuning - """ - def __init__(self, properties): - self.hypervisor_iface = properties['hypervisor_iface'] - self.logger = logging.getLogger('mom.Controllers.Cputune') - - def process_guest(self, guest): - quota = guest.GetControl('vcpu_quota') - period = guest.GetControl('vcpu_period') - if quota is not None and period is not None: - quota = int(quota) - period = int(period) - uuid = guest.Prop('uuid') - name = guest.Prop('name') - prev_quota = guest.vcpu_quota - prev_period = guest.vcpu_period - self.logger.info("CpuTune guest:%s from quota:%s period:%s to quota:%s period:%s", \ - name, prev_quota, prev_period, quota, period) - self.hypervisor_iface.setVmCpuTune(uuid, quota, period) - - def process(self, host, guests): - for guest in guests: - self.process_guest(guest) diff --git a/mom/HypervisorInterfaces/libvirtInterface.py b/mom/HypervisorInterfaces/libvirtInterface.py index e29333d..916ca12 100644 --- a/mom/HypervisorInterfaces/libvirtInterface.py +++ b/mom/HypervisorInterfaces/libvirtInterface.py @@ -244,51 +244,12 @@ 'balloon_min': self._getGuaranteedMemory(domain) } return ret - def getVmCpuTuneInfo(self, uuid): - ret = {} - domain = self._getDomainFromUUID(uuid) - - # Get the user selection for vcpuLimit from the metadata - metadataCpuLimit = domain.getMetadata(2,'http://ovirt.org/param/vcpu_limit',0) - - if metadataCpuLimit: - ret['vcpu_user_limit'] = metadataCpuLimit - else: - ret['vcpu_user_limit'] = 100 - - # Retrieve the current cpu tuning params - ret.update(domain.getSchedulerParameters({ 'vcpu_quota', 'vcpu_period'})) - - if ret['vcpu_quota'] == None: - ret['vcpu_quota'] = -1 - - if ret['vcpu_period'] == None: - ret['vcpu_period'] = 1000 - - # Get the number of vcpus - vcpuCount = domain.getVcpusFlags(libvirt.VIR_DOMAIN_MEM_CURRENT) - if vcpuCount != -1: - ret['vcpu_count'] = vcpuCount - else: - self.logger.error('Failed to get VM cpu count') - return None - - return ret - def setVmBalloonTarget(self, uuid, target): dom = self._getDomainFromUUID(uuid) if dom is not None: if self._domainSetBalloonTarget(dom, target): name = self._domainGetName(dom) self.logger.warn("Error while ballooning guest:%i", name) - - def setVmCpuTune(self, uuid, quota, period): - dom = self._getDomainFromUUID(uuid) - try: - dom.setSchedulerParameters({ 'vcpu_quota': quota, 'vcpu_period': period}) - except libvirt.libvirtError, e: - self.logger.error("libvirtInterface: Exception while " \ - "setSchedulerParameters: %s", e.message); def ksmTune(self, tuningParams): def write_value(fname, value): diff --git a/mom/HypervisorInterfaces/vdsmInterface.py b/mom/HypervisorInterfaces/vdsmInterface.py index 6e43283..ddf8981 100644 --- a/mom/HypervisorInterfaces/vdsmInterface.py +++ b/mom/HypervisorInterfaces/vdsmInterface.py @@ -163,52 +163,6 @@ except vdsmException, e: e.handle_exception() - def getVmCpuTuneInfo(self, uuid): - try: - ret = {} - vm = API.VM(uuid) - response = vm.getStats() - self._check_status(response) - - # Get user selection for vCPU limit - user_cpu_tune_info = response['statsList'][0]['userCpuTuneInfo'] - ret.update(user_cpu_tune_info) - - # Get current vcpu tuning info - cpu_tune_info = response['statsList'][0]['cpuTuneInfo'] - ret.update(cpu_tune_info) - - #Get num of vCPUs - vcpuCount = response['statsList'][0]['cpu_count'] - if vcpuCount == None: - return None - else: - ret['vcpu_count'] = vcpuCount - - # Make sure the values are numbers, VDSM is using str - # to avoid xml-rpc issues - # We are modifying the dict keys inside the loop so - # iterate over copy of the list with keys, also use - # list() to make this compatible with Python 3 - for key in list(ret.keys()): - ret[key] = int(ret[key]) - return ret - except vdsmException, e: - e.handle_exception() - - def setVmCpuTune(self, uuid, quota, period): - vm = API.VM(uuid) - try: - response = vm.setCpuTuneQuota(quota) - self._check_status(response) - except vdsmException, e: - e.handle_exception() - try: - response = vm.setCpuTunePeriod(period) - self._check_status(response) - except vdsmException, e: - e.handle_exception() - def ksmTune(self, tuningParams): # When MOM is lauched by vdsm, it's running without root privileges. # So we need resort to supervdsm to set the KSM parameters. -- To view, visit http://gerrit.ovirt.org/27940 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If26228ca6219927534abde90ac600f1eafc7f729 Gerrit-PatchSet: 1 Gerrit-Project: mom Gerrit-Branch: master Gerrit-Owner: Adam Litke <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
