Merge "Add send_cluster_metrics configuration parameter"
This commit is contained in:
commit
e644a20e81
@ -226,6 +226,7 @@ function create_magnum_conf {
|
||||
# default in magnum.conf
|
||||
default_volume_type=$(iniget /etc/cinder/cinder.conf DEFAULT default_volume_type)
|
||||
iniset $MAGNUM_CONF cinder default_docker_volume_type $default_volume_type
|
||||
iniset $MAGNUM_CONF drivers send_cluster_metrics False
|
||||
}
|
||||
|
||||
function create_api_paste_conf {
|
||||
|
@ -29,7 +29,11 @@ drivers_opts = [
|
||||
cfg.StrOpt('openstack_ca_file',
|
||||
default="",
|
||||
help='Path to the OpenStack CA-bundle file to pass and '
|
||||
'install in all cluster nodes.')
|
||||
'install in all cluster nodes.'),
|
||||
cfg.BoolOpt('send_cluster_metrics',
|
||||
default=True,
|
||||
help='Allow periodic tasks to pull COE data and send to '
|
||||
'ceilometer.')
|
||||
]
|
||||
|
||||
|
||||
|
@ -141,6 +141,10 @@ class MagnumPeriodicTasks(periodic_task.PeriodicTasks):
|
||||
@periodic_task.periodic_task(run_immediately=True)
|
||||
@set_context
|
||||
def _send_cluster_metrics(self, ctx):
|
||||
if not CONF.drivers.send_cluster_metrics:
|
||||
LOG.debug('Skip sending cluster metrics')
|
||||
return
|
||||
|
||||
LOG.debug('Starting to send cluster metrics')
|
||||
for cluster in objects.Cluster.list(ctx):
|
||||
if cluster.status not in (
|
||||
|
@ -332,3 +332,30 @@ class PeriodicTestCase(base.TestCase):
|
||||
|
||||
self.assertEqual(1, mock_create_monitor.call_count)
|
||||
self.assertEqual(0, notifier.info.call_count)
|
||||
|
||||
@mock.patch('magnum.conductor.monitors.create_monitor')
|
||||
@mock.patch('magnum.objects.Cluster.list')
|
||||
@mock.patch('magnum.common.rpc.get_notifier')
|
||||
@mock.patch('magnum.common.context.make_admin_context')
|
||||
def test_send_cluster_metrics_disable_pull_data(
|
||||
self, mock_make_admin_context, mock_get_notifier,
|
||||
mock_cluster_list, mock_create_monitor):
|
||||
mock_make_admin_context.return_value = self.context
|
||||
notifier = mock.MagicMock()
|
||||
mock_get_notifier.return_value = notifier
|
||||
mock_cluster_list.return_value = [self.cluster1, self.cluster2,
|
||||
self.cluster3, self.cluster4]
|
||||
self.cluster4.status = cluster_status.CREATE_COMPLETE
|
||||
monitor = mock.MagicMock()
|
||||
monitor.get_metric_names.return_value = ['metric1', 'metric2']
|
||||
monitor.compute_metric_value.return_value = 30
|
||||
monitor.get_metric_unit.return_value = '%'
|
||||
mock_create_monitor.return_value = monitor
|
||||
|
||||
CONF.set_override('send_cluster_metrics',
|
||||
False, group='drivers')
|
||||
|
||||
periodic.MagnumPeriodicTasks(CONF)._send_cluster_metrics(self.context)
|
||||
|
||||
self.assertEqual(0, mock_create_monitor.call_count)
|
||||
self.assertEqual(0, notifier.info.call_count)
|
||||
|
Loading…
x
Reference in New Issue
Block a user