Config adapters for trilio s3 cert
Change-Id: I2351baa89b3f9d33eb2f9ad6bf4f82d044b2d330
This commit is contained in:
parent
7b28c45320
commit
6c8eb01162
|
@ -31,6 +31,9 @@ import charms.reactive as reactive
|
|||
|
||||
TV_MOUNTS = "/var/triliovault-mounts"
|
||||
|
||||
# Location of the certificate file to use when talking to S3 endpoint.
|
||||
S3_SSL_CERT_FILE = '/usr/share/ca-certificates/charm-s3.cert'
|
||||
|
||||
# Used to store the discovered release version for caching between invocations
|
||||
TRILIO_RELEASE_KEY = 'charmers.trilio-release-version'
|
||||
|
||||
|
@ -64,6 +67,22 @@ def trilio_properties(cls):
|
|||
'transport_type': 'legacy'}
|
||||
|
||||
|
||||
@charms_openstack.adapters.config_property
|
||||
def trilio_s3_cert_config(cls):
|
||||
"""Trilio S3 certificate config
|
||||
|
||||
:param cls: Configuration Adapter class
|
||||
:type cls: charms_openstack.adapters.DefaultConfigurationAdapter
|
||||
"""
|
||||
s3_cert_config = {}
|
||||
config = ch_core.hookenv.config('tv-s3-ssl-cert')
|
||||
if config:
|
||||
s3_cert_config = {
|
||||
'cert_file': S3_SSL_CERT_FILE,
|
||||
'cert_data': base64.b64decode(config).decode('utf-8')}
|
||||
return s3_cert_config
|
||||
|
||||
|
||||
class AptPkgVersion():
|
||||
"""Allow package version to be compared."""
|
||||
|
||||
|
|
|
@ -181,6 +181,19 @@ class TestTrilioCommonBehaviours(BaseOpenStackCharmTest):
|
|||
trilio.trilio_properties(cls_mock),
|
||||
{'db_type': 'legacy', 'transport_type': 'legacy'})
|
||||
|
||||
def test_trilio_s3_cert_config(self):
|
||||
cls_mock = mock.MagicMock()
|
||||
self.config.return_value = 'QSBjZXJ0Cg=='
|
||||
self.assertEqual(
|
||||
trilio.trilio_s3_cert_config(cls_mock),
|
||||
{
|
||||
'cert_file': '/usr/share/ca-certificates/charm-s3.cert',
|
||||
'cert_data': 'A cert\n'})
|
||||
self.config.return_value = None
|
||||
self.assertEqual(
|
||||
trilio.trilio_s3_cert_config(cls_mock),
|
||||
{})
|
||||
|
||||
def test_get_trilio_codename_install_source(self):
|
||||
self.assertEqual(
|
||||
trilio.get_trilio_codename_install_source(
|
||||
|
|
Loading…
Reference in New Issue