Add object-store relation

Implements the swift-proxy interface. This is needed in order for
the glance (or any other) charm to be able to consume RadosGW the
same way they would consume Swift.

Change-Id: Ia59e1286ca25a71bcdf74be38c9dffb07c5be64f
This commit is contained in:
Gabriel Adrian Samfira 2020-09-07 13:43:52 +00:00
parent d048882532
commit bb7dfbcf92
4 changed files with 28 additions and 0 deletions

View File

@ -181,6 +181,15 @@ def install():
leader_set(namespace_tenants=config('namespace-tenants'))
@hooks.hook('object-store-relation-joined')
def object_store_joined(relation_id=None):
relation_data = {
'swift-url':
"{}:{}".format(canonical_url(CONFIGS, INTERNAL), listen_port())
}
relation_set(relation_id=relation_id, relation_settings=relation_data)
@hooks.hook('upgrade-charm.real')
def upgrade_charm():
if is_leader() and not leader_get('namespace_tenants') == 'True':
@ -225,6 +234,10 @@ def config_changed():
for r_id in relation_ids('certificates'):
certs_joined(r_id)
# Refire object-store relations for VIP/port changes
for r_id in relation_ids('object-store'):
object_store_joined(r_id)
process_multisite_relations()
CONFIGS.write_all()

View File

@ -0,0 +1 @@
hooks.py

View File

@ -43,6 +43,8 @@ provides:
interface: http
master:
interface: radosgw-multisite
object-store:
interface: swift-proxy
peers:
cluster:
interface: swift-ha

View File

@ -250,6 +250,18 @@ class CephRadosGWTests(CharmTestCase):
ceph_hooks.gateway_relation()
self.relation_set.assert_called_with(hostname='10.0.0.1', port=80)
@patch.object(ceph_hooks, "canonical_url")
def test_object_store_relation(self, _canonical_url):
relation_data = {
"swift-url": "http://radosgw:80"
}
self.listen_port.return_value = 80
_canonical_url.return_value = "http://radosgw"
ceph_hooks.object_store_joined()
self.relation_set.assert_called_with(
relation_id=None,
relation_settings=relation_data)
@patch.object(ceph_hooks, 'leader_get')
@patch('charmhelpers.contrib.openstack.ip.service_name',
lambda *args: 'ceph-radosgw')