Merge "Adds volume-usage-audit-period config directive >= kilo."
This commit is contained in:
commit
0743f0f843
@ -6,7 +6,7 @@ options:
|
||||
verbose:
|
||||
default: False
|
||||
type: boolean
|
||||
description: Enable verbose logging.
|
||||
description: Enable verbose logging.
|
||||
use-syslog:
|
||||
type: boolean
|
||||
default: False
|
||||
@ -368,4 +368,9 @@ options:
|
||||
description: |
|
||||
Apply system hardening. Supports a space-delimited list of modules
|
||||
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.
|
||||
|
@ -182,3 +182,22 @@ class RegionContext(OSContextGenerator):
|
||||
return {'region': region}
|
||||
else:
|
||||
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")
|
||||
}
|
||||
|
@ -229,7 +229,8 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
context.BindHostContext(),
|
||||
context.WorkerConfigContext(),
|
||||
cinder_contexts.RegionContext(),
|
||||
context.InternalEndpointContext()],
|
||||
context.InternalEndpointContext(),
|
||||
cinder_contexts.VolumeUsageAuditContext()],
|
||||
'services': ['cinder-api', 'cinder-volume', 'cinder-scheduler',
|
||||
'haproxy']
|
||||
}),
|
||||
|
@ -62,6 +62,8 @@ os_region_name = {{ region }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
volume_usage_audit_period = {{ volume_usage_audit_period }}
|
||||
|
||||
{% include "parts/backends" %}
|
||||
|
||||
{% include "section-keystone-authtoken-legacy" %}
|
||||
|
@ -62,6 +62,8 @@ os_region_name = {{ region }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
volume_usage_audit_period = {{ volume_usage_audit_period }}
|
||||
|
||||
{% include "parts/backends" %}
|
||||
|
||||
{% include "section-keystone-authtoken" %}
|
||||
|
@ -62,6 +62,8 @@ os_region_name = {{ region }}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
volume_usage_audit_period = {{ volume_usage_audit_period }}
|
||||
|
||||
{% include "parts/backends" %}
|
||||
|
||||
{% include "section-keystone-authtoken-mitaka" %}
|
||||
@ -77,3 +79,8 @@ lock_path = /var/lock/cinder
|
||||
# XXX: hack to work around http://pad.lv/1516085
|
||||
# will be superceeded by SRU to cinder package
|
||||
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'
|
||||
ctxt = contexts.RegionContext()()
|
||||
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…
x
Reference in New Issue
Block a user