Adds volume-usage-audit-period config directive >= kilo.
This change adds the config directive called volume-usage-audit-period for versions >= kilo. Also, According to the doc change I90dff1b5c2a7dd2943cfa7ff25bb63c08eb7986d, messagingv2 should be the default for anything > Icehouse. So, this change also sets the following configuration section for versions >= mitaka. [oslo_messaging_notifications] driver = messagingv2 This change adds a specific configuration context that installs a crontab entry for running the cinder-volume-usage-audit recurrently. Change-Id: I0056edaac55210a1a1f509ec908ae61c0ea887df Closes-Bug: #1623144 Signed-off-by: Jorge Niedbalski <jorge.niedbalski@canonical.com>
This commit is contained in:
parent
e3362bcc6c
commit
07ae3acbb4
|
@ -6,7 +6,7 @@ options:
|
||||||
verbose:
|
verbose:
|
||||||
default: False
|
default: False
|
||||||
type: boolean
|
type: boolean
|
||||||
description: Enable verbose logging.
|
description: Enable verbose logging.
|
||||||
use-syslog:
|
use-syslog:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: False
|
default: False
|
||||||
|
@ -368,4 +368,9 @@ options:
|
||||||
description: |
|
description: |
|
||||||
Apply system hardening. Supports a space-delimited list of modules
|
Apply system hardening. Supports a space-delimited list of modules
|
||||||
to run. Supported modules currently include os, ssh, apache and mysql.
|
to run. Supported modules currently include os, ssh, apache and mysql.
|
||||||
|
volume-usage-audit-period:
|
||||||
|
default: "month"
|
||||||
|
type: string
|
||||||
|
description: |
|
||||||
|
Time period for which to generate volume usages. The options are hour,
|
||||||
|
day, month, or year.
|
||||||
|
|
|
@ -183,3 +183,22 @@ class RegionContext(OSContextGenerator):
|
||||||
return {'region': region}
|
return {'region': region}
|
||||||
else:
|
else:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
class VolumeUsageAuditContext(OSContextGenerator):
|
||||||
|
"""This context provides the configuration directive
|
||||||
|
volume_usage_audit_period and also creates a crontab entry
|
||||||
|
for running the cinder-volume-usage-audit script recurrently.
|
||||||
|
"""
|
||||||
|
DEFAULT_CRONTAB_PATH = '/etc/cron.d/cinder-volume-usage-audit'
|
||||||
|
|
||||||
|
def __call__(self):
|
||||||
|
log("Installing crontab: %s" % self.DEFAULT_CRONTAB_PATH)
|
||||||
|
with open(self.DEFAULT_CRONTAB_PATH, "w+") as crontab:
|
||||||
|
# The cinder-volume-usage-audit executable will only gather
|
||||||
|
# data that fits on the configured volume-usage-audit-period.
|
||||||
|
crontab.write('0 * * * * root '
|
||||||
|
'/usr/bin/cinder-volume-usage-audit\n')
|
||||||
|
return {
|
||||||
|
'volume_usage_audit_period': config("volume-usage-audit-period")
|
||||||
|
}
|
||||||
|
|
|
@ -226,7 +226,8 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||||
context.BindHostContext(),
|
context.BindHostContext(),
|
||||||
context.WorkerConfigContext(),
|
context.WorkerConfigContext(),
|
||||||
cinder_contexts.RegionContext(),
|
cinder_contexts.RegionContext(),
|
||||||
context.InternalEndpointContext()],
|
context.InternalEndpointContext(),
|
||||||
|
cinder_contexts.VolumeUsageAuditContext()],
|
||||||
'services': ['cinder-api', 'cinder-volume', 'cinder-scheduler',
|
'services': ['cinder-api', 'cinder-volume', 'cinder-scheduler',
|
||||||
'haproxy']
|
'haproxy']
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -62,6 +62,8 @@ os_region_name = {{ region }}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
volume_usage_audit_period = {{ volume_usage_audit_period }}
|
||||||
|
|
||||||
{% include "parts/backends" %}
|
{% include "parts/backends" %}
|
||||||
|
|
||||||
{% include "section-keystone-authtoken-legacy" %}
|
{% include "section-keystone-authtoken-legacy" %}
|
||||||
|
|
|
@ -62,6 +62,8 @@ os_region_name = {{ region }}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
volume_usage_audit_period = {{ volume_usage_audit_period }}
|
||||||
|
|
||||||
{% include "parts/backends" %}
|
{% include "parts/backends" %}
|
||||||
|
|
||||||
{% include "section-keystone-authtoken" %}
|
{% include "section-keystone-authtoken" %}
|
||||||
|
|
|
@ -62,6 +62,8 @@ os_region_name = {{ region }}
|
||||||
{% endfor -%}
|
{% endfor -%}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
volume_usage_audit_period = {{ volume_usage_audit_period }}
|
||||||
|
|
||||||
{% include "parts/backends" %}
|
{% include "parts/backends" %}
|
||||||
|
|
||||||
{% include "section-keystone-authtoken-mitaka" %}
|
{% include "section-keystone-authtoken-mitaka" %}
|
||||||
|
@ -77,3 +79,8 @@ lock_path = /var/lock/cinder
|
||||||
# XXX: hack to work around http://pad.lv/1516085
|
# XXX: hack to work around http://pad.lv/1516085
|
||||||
# will be superceeded by SRU to cinder package
|
# will be superceeded by SRU to cinder package
|
||||||
encryption_auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v3
|
encryption_auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v3
|
||||||
|
|
||||||
|
[oslo_messaging_notifications]
|
||||||
|
# .openstack.common.* is pre-icehouse option.
|
||||||
|
# Check change-id: I90dff1b5c2a7dd2943cfa7ff25bb63c08eb7986d
|
||||||
|
driver = messagingv2
|
||||||
|
|
|
@ -358,3 +358,12 @@ class TestCinderContext(CharmTestCase):
|
||||||
self.config.return_value = 'two'
|
self.config.return_value = 'two'
|
||||||
ctxt = contexts.RegionContext()()
|
ctxt = contexts.RegionContext()()
|
||||||
self.assertEqual('two', ctxt['region'])
|
self.assertEqual('two', ctxt['region'])
|
||||||
|
|
||||||
|
@patch('__builtin__.open')
|
||||||
|
def test_volume_usage_audit_context(self, _open):
|
||||||
|
self.config.return_value = 'month'
|
||||||
|
ctxt = contexts.VolumeUsageAuditContext()()
|
||||||
|
_open.assert_called_with(
|
||||||
|
contexts.VolumeUsageAuditContext.DEFAULT_CRONTAB_PATH, "w+")
|
||||||
|
self.assertEqual(self.config.return_value,
|
||||||
|
ctxt["volume_usage_audit_period"])
|
||||||
|
|
Loading…
Reference in New Issue