Send application name to ceph-mon
Send application name to ceph-mon as ceph-mon cannot derive it from CMR relations. Change-Id: Idffa90cb6e46cf016eac5ecff0094e4d145d67ac
This commit is contained in:
parent
fcbc6e76aa
commit
a55a6e22c2
|
@ -41,6 +41,7 @@ from subprocess import (
|
|||
)
|
||||
from charmhelpers import deprecate
|
||||
from charmhelpers.core.hookenv import (
|
||||
application_name,
|
||||
config,
|
||||
service_name,
|
||||
local_unit,
|
||||
|
@ -162,6 +163,17 @@ def get_osd_settings(relation_name):
|
|||
return _order_dict_by_key(osd_settings)
|
||||
|
||||
|
||||
def send_application_name(relid=None):
|
||||
"""Send the application name down the relation.
|
||||
|
||||
:param relid: Relation id to set application name in.
|
||||
:type relid: str
|
||||
"""
|
||||
relation_set(
|
||||
relation_id=relid,
|
||||
relation_settings={'application-name': application_name()})
|
||||
|
||||
|
||||
def send_osd_settings():
|
||||
"""Pass on requested OSD settings to osd units."""
|
||||
try:
|
||||
|
@ -1074,7 +1086,10 @@ def create_erasure_profile(service, profile_name,
|
|||
erasure_plugin_technique=None):
|
||||
"""Create a new erasure code profile if one does not already exist for it.
|
||||
|
||||
Updates the profile if it exists. Please refer to [0] for more details.
|
||||
Profiles are considered immutable so will not be updated if the named
|
||||
profile already exists.
|
||||
|
||||
Please refer to [0] for more details.
|
||||
|
||||
0: http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/
|
||||
|
||||
|
@ -1110,6 +1125,11 @@ def create_erasure_profile(service, profile_name,
|
|||
:type erasure_plugin_technique: str
|
||||
:return: None. Can raise CalledProcessError, ValueError or AssertionError
|
||||
"""
|
||||
if erasure_profile_exists(service, profile_name):
|
||||
log('EC profile {} exists, skipping update'.format(profile_name),
|
||||
level=WARNING)
|
||||
return
|
||||
|
||||
plugin_techniques = {
|
||||
'jerasure': [
|
||||
'reed_sol_van',
|
||||
|
@ -1209,9 +1229,6 @@ def create_erasure_profile(service, profile_name,
|
|||
if scalar_mds:
|
||||
cmd.append('scalar-mds={}'.format(scalar_mds))
|
||||
|
||||
if erasure_profile_exists(service, profile_name):
|
||||
cmd.append('--force')
|
||||
|
||||
check_call(cmd)
|
||||
|
||||
|
||||
|
@ -2198,6 +2215,7 @@ def send_request_if_needed(request, relation='ceph'):
|
|||
for rid in relation_ids(relation):
|
||||
log('Sending request {}'.format(request.request_id), level=DEBUG)
|
||||
relation_set(relation_id=rid, broker_req=request.request)
|
||||
relation_set(relation_id=rid, relation_settings={'unit-name': local_unit()})
|
||||
|
||||
|
||||
def has_broker_rsp(rid=None, unit=None):
|
||||
|
|
|
@ -25,7 +25,8 @@ UBUNTU_RELEASES = (
|
|||
'cosmic',
|
||||
'disco',
|
||||
'eoan',
|
||||
'focal'
|
||||
'focal',
|
||||
'groovy'
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ from charmhelpers.contrib.storage.linux.ceph import (
|
|||
delete_keyring,
|
||||
ensure_ceph_keyring,
|
||||
is_request_complete,
|
||||
send_application_name,
|
||||
send_request_if_needed,
|
||||
)
|
||||
from charmhelpers.core.hookenv import (
|
||||
|
@ -105,6 +106,7 @@ def install():
|
|||
def ceph_joined():
|
||||
if not os.path.isdir('/etc/ceph'):
|
||||
os.mkdir('/etc/ceph')
|
||||
send_application_name()
|
||||
|
||||
|
||||
def get_ceph_request():
|
||||
|
|
|
@ -58,6 +58,7 @@ TO_PATCH = [
|
|||
'remove_alternative',
|
||||
'status_set',
|
||||
'os_application_version_set',
|
||||
'send_application_name',
|
||||
]
|
||||
|
||||
|
||||
|
@ -81,6 +82,7 @@ class TestCinderHooks(CharmTestCase):
|
|||
isdir.return_value = False
|
||||
hooks.hooks.execute(['hooks/ceph-relation-joined'])
|
||||
mkdir.assert_called_with('/etc/ceph')
|
||||
self.send_application_name.assert_called_with()
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
def test_ceph_changed_no_key(self, mock_config):
|
||||
|
|
Loading…
Reference in New Issue