diff --git a/ceilometer/compute/virt/inspector.py b/ceilometer/compute/virt/inspector.py index dbbc7281eb..921bc94472 100644 --- a/ceilometer/compute/virt/inspector.py +++ b/ceilometer/compute/virt/inspector.py @@ -27,8 +27,7 @@ OPTS = [ cfg.StrOpt('hypervisor_inspector', default='libvirt', help='Inspector to use for inspecting the hypervisor layer. ' - 'Known inspectors are libvirt, hyperv, vsphere ' - 'and xenapi. Note that xenapi has been deprecated.'), + 'Known inspectors are libvirt, hyperv, and vsphere.'), ] @@ -270,9 +269,6 @@ class Inspector(object): def get_hypervisor_inspector(conf): - if conf.hypervisor_inspector == 'xenapi': - LOG.warning('Support for XenServer/Xen Cloud Platform has been ' - 'deprecated and will be removed in a future release') try: namespace = 'ceilometer.compute.virt' mgr = driver.DriverManager(namespace, diff --git a/ceilometer/compute/virt/libvirt/utils.py b/ceilometer/compute/virt/libvirt/utils.py index 79684ea3e8..e3aa4b6a97 100644 --- a/ceilometer/compute/virt/libvirt/utils.py +++ b/ceilometer/compute/virt/libvirt/utils.py @@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__) OPTS = [ cfg.StrOpt('libvirt_type', default='kvm', - choices=['kvm', 'lxc', 'qemu', 'uml', 'xen'], + choices=['kvm', 'lxc', 'qemu', 'uml'], help='Libvirt domain type.'), cfg.StrOpt('libvirt_uri', default='', @@ -38,7 +38,7 @@ OPTS = [ '(which is dependent on libvirt_type).'), ] -LIBVIRT_PER_TYPE_URIS = dict(uml='uml:///system', xen='xen:///', lxc='lxc:///') +LIBVIRT_PER_TYPE_URIS = dict(uml='uml:///system', lxc='lxc:///') # We don't use the libvirt constants in case of libvirt is not available diff --git a/ceilometer/compute/virt/xenapi/__init__.py b/ceilometer/compute/virt/xenapi/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ceilometer/compute/virt/xenapi/inspector.py b/ceilometer/compute/virt/xenapi/inspector.py deleted file mode 100644 index bcb8bdb81e..0000000000 --- a/ceilometer/compute/virt/xenapi/inspector.py +++ /dev/null @@ -1,192 +0,0 @@ -# Copyright 2014 Intel -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -"""Implementation of Inspector abstraction for XenAPI.""" - -from os_xenapi.client import session as xenapi_session -from os_xenapi.client import XenAPI -from oslo_config import cfg -from oslo_log import log as logging -from oslo_utils import units - -from ceilometer.compute.pollsters import util -from ceilometer.compute.virt import inspector as virt_inspector -from ceilometer.i18n import _ - -LOG = logging.getLogger(__name__) - -opt_group = cfg.OptGroup(name='xenapi', - title='Options for XenAPI') - -OPTS = [ - cfg.StrOpt('connection_url', - deprecated_for_removal=True, - deprecated_reason='Support for XenServer/Xen Cloud Platform ' - 'has been deprecated', - help='URL for connection to XenServer/Xen Cloud Platform.'), - cfg.StrOpt('connection_username', - default='root', - deprecated_for_removal=True, - deprecated_reason='Support for XenServer/Xen Cloud Platform ' - 'has been deprecated', - help='Username for connection to XenServer/Xen Cloud ' - 'Platform.'), - cfg.StrOpt('connection_password', - deprecated_for_removal=True, - deprecated_reason='Support for XenServer/Xen Cloud Platform ' - 'has been deprecated', - help='Password for connection to XenServer/Xen Cloud Platform.', - secret=True), -] - - -class XenapiException(virt_inspector.InspectorException): - pass - - -def get_api_session(conf): - url = conf.xenapi.connection_url - username = conf.xenapi.connection_username - password = conf.xenapi.connection_password - if not url or password is None: - raise XenapiException(_('Must specify connection_url, and ' - 'connection_password to use')) - - try: - session = xenapi_session.XenAPISession(url, username, password, - originator="ceilometer") - LOG.debug("XenAPI session is created successfully, %s", session) - except XenAPI.Failure as e: - msg = _("Could not connect to XenAPI: %s") % e.details[0] - raise XenapiException(msg) - return session - - -class XenapiInspector(virt_inspector.Inspector): - - def __init__(self, conf): - super(XenapiInspector, self).__init__(conf) - self.session = get_api_session(self.conf) - - def _lookup_by_name(self, instance_name): - vm_refs = self.session.VM.get_by_name_label(instance_name) - n = len(vm_refs) - if n == 0: - raise virt_inspector.InstanceNotFoundException( - _('VM %s not found in XenServer') % instance_name) - elif n > 1: - raise XenapiException( - _('Multiple VM %s found in XenServer') % instance_name) - else: - return vm_refs[0] - - def inspect_instance(self, instance, duration): - instance_name = util.instance_name(instance) - vm_ref = self._lookup_by_name(instance_name) - cpu_util = self._get_cpu_usage(vm_ref, instance_name) - memory_usage = self._get_memory_usage(vm_ref) - LOG.debug("inspect_instance, cpu_util: %(cpu)s, memory_usage: %(mem)s", - {'cpu': cpu_util, 'mem': memory_usage}, instance=instance) - return virt_inspector.InstanceStats(cpu_util=cpu_util, - memory_usage=memory_usage) - - def _get_cpu_usage(self, vm_ref, instance_name): - vcpus_number = int(self.session.VM.get_VCPUs_max(vm_ref)) - if vcpus_number <= 0: - msg = _("Could not get VM %s CPU number") % instance_name - raise XenapiException(msg) - cpu_util = 0.0 - for index in range(vcpus_number): - cpu_util += float(self.session.VM.query_data_source( - vm_ref, "cpu%d" % index)) - return cpu_util / int(vcpus_number) * 100 - - def _get_memory_usage(self, vm_ref): - total_mem = float(self.session.VM.query_data_source(vm_ref, "memory")) - try: - free_mem = float(self.session.VM.query_data_source( - vm_ref, "memory_internal_free")) - except XenAPI.Failure: - # If PV tools is not installed in the guest instance, it's - # impossible to get free memory. So give it a default value - # as 0. - free_mem = 0 - # memory provided from XenServer is in Bytes; - # memory_internal_free provided from XenServer is in KB, - # converting it to MB. - return (total_mem - free_mem * units.Ki) / units.Mi - - def inspect_vnics(self, instance, duration): - instance_name = util.instance_name(instance) - vm_ref = self._lookup_by_name(instance_name) - dom_id = self.session.VM.get_domid(vm_ref) - vif_refs = self.session.VM.get_VIFs(vm_ref) - bw_all = self.session.call_plugin_serialized('bandwidth', - 'fetch_all_bandwidth') - LOG.debug("inspect_vnics, all bandwidth: %s", bw_all, - instance=instance) - - for vif_ref in vif_refs: - vif_rec = self.session.VIF.get_record(vif_ref) - - bw_vif = bw_all[dom_id][vif_rec['device']] - - # TODO(jianghuaw): Currently the plugin can only support - # rx_bytes and tx_bytes, so temporarily set others as -1. - yield virt_inspector.InterfaceStats( - name=vif_rec['uuid'], - mac=vif_rec['MAC'], - fref=None, - parameters=None, - rx_bytes=bw_vif['bw_in'], rx_packets=-1, rx_drop=-1, - rx_errors=-1, tx_bytes=bw_vif['bw_out'], tx_packets=-1, - tx_drop=-1, tx_errors=-1, rx_bytes_delta=-1, - tx_bytes_delta=-1) - - def inspect_vnic_rates(self, instance, duration): - instance_name = util.instance_name(instance) - vm_ref = self._lookup_by_name(instance_name) - vif_refs = self.session.VM.get_VIFs(vm_ref) - for vif_ref in vif_refs: - vif_rec = self.session.VIF.get_record(vif_ref) - - rx_rate = float(self.session.VM.query_data_source( - vm_ref, "vif_%s_rx" % vif_rec['device'])) - tx_rate = float(self.session.VM.query_data_source( - vm_ref, "vif_%s_tx" % vif_rec['device'])) - - yield virt_inspector.InterfaceRateStats( - name=vif_rec['uuid'], - mac=vif_rec['MAC'], - fref=None, - parameters=None, - rx_bytes_rate=rx_rate, - tx_bytes_rate=tx_rate) - - def inspect_disk_rates(self, instance, duration): - instance_name = util.instance_name(instance) - vm_ref = self._lookup_by_name(instance_name) - vbd_refs = self.session.VM.get_VBDs(vm_ref) - for vbd_ref in vbd_refs: - vbd_rec = self.session.VBD.get_record(vbd_ref) - - read_rate = float(self.session.VM.query_data_source( - vm_ref, "vbd_%s_read" % vbd_rec['device'])) - write_rate = float(self.session.VM.query_data_source( - vm_ref, "vbd_%s_write" % vbd_rec['device'])) - yield virt_inspector.DiskRateStats( - device=vbd_rec['device'], - read_bytes_rate=read_rate, - read_requests_rate=0, - write_bytes_rate=write_rate, - write_requests_rate=0) diff --git a/ceilometer/opts.py b/ceilometer/opts.py index 27a7be4412..88d5bbfda3 100644 --- a/ceilometer/opts.py +++ b/ceilometer/opts.py @@ -21,7 +21,6 @@ import ceilometer.compute.discovery import ceilometer.compute.virt.inspector import ceilometer.compute.virt.libvirt.utils import ceilometer.compute.virt.vmware.inspector -import ceilometer.compute.virt.xenapi.inspector import ceilometer.event.converter import ceilometer.hardware.discovery import ceilometer.hardware.pollsters.generic @@ -118,7 +117,6 @@ def list_opts(): ceilometer.objectstore.swift.SERVICE_OPTS, ceilometer.volume.discovery.SERVICE_OPTS,)), ('vmware', ceilometer.compute.virt.vmware.inspector.OPTS), - ('xenapi', ceilometer.compute.virt.xenapi.inspector.OPTS), ] diff --git a/ceilometer/tests/unit/compute/virt/xenapi/__init__.py b/ceilometer/tests/unit/compute/virt/xenapi/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/ceilometer/tests/unit/compute/virt/xenapi/test_inspector.py b/ceilometer/tests/unit/compute/virt/xenapi/test_inspector.py deleted file mode 100644 index 94d6548328..0000000000 --- a/ceilometer/tests/unit/compute/virt/xenapi/test_inspector.py +++ /dev/null @@ -1,162 +0,0 @@ -# Copyright 2014 Intel -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -"""Tests for xenapi inspector.""" - -from unittest import mock - -from oslotest import base - -from ceilometer.compute.virt.xenapi import inspector as xenapi_inspector -from ceilometer import service - - -class TestXenapiInspection(base.BaseTestCase): - - def setUp(self): - super(TestXenapiInspection, self).setUp() - conf = service.prepare_service([], []) - api_session = mock.Mock() - xenapi_inspector.get_api_session = mock.Mock(return_value=api_session) - self.inspector = xenapi_inspector.XenapiInspector(conf) - - def test_inspect_instance(self): - fake_instance = {'OS-EXT-SRV-ATTR:instance_name': 'fake_instance_name', - 'id': 'fake_instance_id'} - fake_total_mem = 134217728.0 - fake_free_mem = 65536.0 - - session = self.inspector.session - with mock.patch.object(session.VM, 'get_by_name_label') as mock_name, \ - mock.patch.object(session.VM, 'get_VCPUs_max') as mock_vcpu, \ - mock.patch.object(session.VM, 'query_data_source') \ - as mock_query: - mock_name.return_value = ['vm_ref'] - mock_vcpu.return_value = '1' - mock_query.side_effect = [0.4, fake_total_mem, fake_free_mem] - stats = self.inspector.inspect_instance(fake_instance, None) - self.assertEqual(40, stats.cpu_util) - self.assertEqual(64, stats.memory_usage) - - def test_inspect_memory_usage_without_freeMem(self): - fake_instance = {'OS-EXT-SRV-ATTR:instance_name': 'fake_instance_name', - 'id': 'fake_instance_id'} - fake_total_mem = 134217728.0 - fake_free_mem = 0 - - session = self.inspector.session - with mock.patch.object(session.VM, 'get_by_name_label') as mock_name, \ - mock.patch.object(session.VM, 'get_VCPUs_max') as mock_vcpu, \ - mock.patch.object(session.VM, 'query_data_source') \ - as mock_query: - mock_name.return_value = ['vm_ref'] - mock_vcpu.return_value = '1' - mock_query.side_effect = [0.4, fake_total_mem, fake_free_mem] - stats = self.inspector.inspect_instance(fake_instance, None) - self.assertEqual(128, stats.memory_usage) - - def test_inspect_vnics(self): - fake_instance = { - 'OS-EXT-SRV-ATTR:instance_name': 'fake_instance_name', - 'id': 'fake_instance_id'} - vif_rec = { - 'uuid': 'vif_uuid', - 'MAC': 'vif_mac', - 'device': '0', - } - bandwidth_returns = [{ - '10': { - '0': { - 'bw_in': 1024, 'bw_out': 2048 - } - } - }] - session = self.inspector.session - with mock.patch.object(session.VM, 'get_by_name_label') as mock_name, \ - mock.patch.object(session.VM, 'get_domid') as mock_domid, \ - mock.patch.object(session.VM, 'get_VIFs') as mock_vif, \ - mock.patch.object(session.VIF, 'get_record') as mock_record, \ - mock.patch.object(session, 'call_plugin_serialized') \ - as mock_plugin: - mock_name.return_value = ['vm_ref'] - mock_domid.return_value = '10' - mock_vif.return_value = ['vif_ref'] - mock_record.return_value = vif_rec - mock_plugin.side_effect = bandwidth_returns - interfaces = list(self.inspector.inspect_vnics( - fake_instance, None)) - - self.assertEqual(1, len(interfaces)) - vnic0 = interfaces[0] - self.assertEqual('vif_uuid', vnic0.name) - self.assertEqual('vif_mac', vnic0.mac) - self.assertEqual(1024, vnic0.rx_bytes) - self.assertEqual(2048, vnic0.tx_bytes) - - def test_inspect_vnic_rates(self): - fake_instance = {'OS-EXT-SRV-ATTR:instance_name': 'fake_instance_name', - 'id': 'fake_instance_id'} - - vif_rec = { - 'metrics': 'vif_metrics_ref', - 'uuid': 'vif_uuid', - 'MAC': 'vif_mac', - 'device': '0', - } - - session = self.inspector.session - with mock.patch.object(session.VM, 'get_by_name_label') as mock_name, \ - mock.patch.object(session.VM, 'get_VIFs') as mock_vif, \ - mock.patch.object(session.VIF, 'get_record') as mock_record, \ - mock.patch.object(session.VM, 'query_data_source') \ - as mock_query: - mock_name.return_value = ['vm_ref'] - mock_vif.return_value = ['vif_ref'] - mock_record.return_value = vif_rec - mock_query.side_effect = [1024.0, 2048.0] - interfaces = list(self.inspector.inspect_vnic_rates( - fake_instance, None)) - - self.assertEqual(1, len(interfaces)) - vnic0 = interfaces[0] - self.assertEqual('vif_uuid', vnic0.name) - self.assertEqual('vif_mac', vnic0.mac) - self.assertEqual(1024.0, vnic0.rx_bytes_rate) - self.assertEqual(2048.0, vnic0.tx_bytes_rate) - - def test_inspect_disk_rates(self): - fake_instance = {'OS-EXT-SRV-ATTR:instance_name': 'fake_instance_name', - 'id': 'fake_instance_id'} - - vbd_rec = { - 'device': 'xvdd' - } - - session = self.inspector.session - with mock.patch.object(session.VM, 'get_by_name_label') as mock_name, \ - mock.patch.object(session.VM, 'get_VBDs') as mock_vbds, \ - mock.patch.object(session.VBD, 'get_record') as mock_records, \ - mock.patch.object(session.VM, 'query_data_source') \ - as mock_query: - mock_name.return_value = ['vm_ref'] - mock_vbds.return_value = ['vbd_ref'] - mock_records.return_value = vbd_rec - mock_query.side_effect = [1024.0, 2048.0] - disks = list(self.inspector.inspect_disk_rates( - fake_instance, None)) - - self.assertEqual(1, len(disks)) - disk0 = disks[0] - self.assertEqual('xvdd', disk0.device) - self.assertEqual(1024.0, disk0.read_bytes_rate) - self.assertEqual(2048.0, disk0.write_bytes_rate) diff --git a/lower-constraints.txt b/lower-constraints.txt index df38213356..559a3134c4 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -11,7 +11,6 @@ lxml==4.5.1 monotonic==0.6 msgpack==0.5.2 os-win==3.0.0 -os-xenapi==0.3.3 oslo.cache==1.26.0 oslo.concurrency==3.26.0 oslo.config==6.0.0 diff --git a/releasenotes/notes/remove-xen-support-7cb932b7bc621269.yaml b/releasenotes/notes/remove-xen-support-7cb932b7bc621269.yaml new file mode 100644 index 0000000000..7a10c39652 --- /dev/null +++ b/releasenotes/notes/remove-xen-support-7cb932b7bc621269.yaml @@ -0,0 +1,4 @@ +--- +upgrade: + - | + Support for XenServer/Xen Cloud Platform has been removed. diff --git a/requirements.txt b/requirements.txt index 3713e08ba0..ea199fca18 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,7 +33,6 @@ requests!=2.9.0,>=2.8.1 # Apache-2.0 stevedore>=1.20.0 # Apache-2.0 tenacity>=4.12.0 # Apache-2.0 tooz[zake]>=1.47.0 # Apache-2.0 -os-xenapi>=0.3.3 # Apache-2.0 oslo.cache>=1.26.0 # Apache-2.0 gnocchiclient>=7.0.0 # Apache-2.0 python-monascaclient>=1.12.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index d71985223d..02f7f42d3f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -195,7 +195,6 @@ ceilometer.compute.virt = libvirt = ceilometer.compute.virt.libvirt.inspector:LibvirtInspector hyperv = ceilometer.compute.virt.hyperv.inspector:HyperVInspector vsphere = ceilometer.compute.virt.vmware.inspector:VsphereInspector - xenapi = ceilometer.compute.virt.xenapi.inspector:XenapiInspector ceilometer.hardware.inspectors = snmp = ceilometer.hardware.inspector.snmp:SNMPInspector