mode: Optional[int] = None,
uid: Optional[int] = None,
gid: Optional[int] = None,
+ include_ceph_conf: bool = True,
) -> None:
self.entity = entity
self.placement = placement
self.mode = mode or 0o600
self.uid = uid or 0
self.gid = gid or 0
+ self.include_ceph_conf = include_ceph_conf
def validate(self) -> None:
pass
'mode': self.mode,
'uid': self.uid,
'gid': self.gid,
+ 'include_ceph_conf': self.include_ceph_conf,
}
@property
output = to_format(self.keys.keys.values(), format, many=True, cls=ClientKeyringSpec)
else:
table = PrettyTable(
- ['ENTITY', 'PLACEMENT', 'MODE', 'OWNER', 'PATH'],
+ ['ENTITY', 'PLACEMENT', 'MODE', 'OWNER', 'PATH', 'INCLUDE_CEPH_CONF'],
border=False)
table.align = 'l'
table.left_padding_width = 0
utils.file_mode_to_str(ks.mode),
f'{ks.uid}:{ks.gid}',
ks.path,
+ ks.include_ceph_conf
))
output = table.get_string()
return HandleCommandResult(stdout=output)
placement: str,
owner: Optional[str] = None,
mode: Optional[str] = None,
+ no_ceph_conf: bool = False,
) -> HandleCommandResult:
"""
Add or update client keyring under cephadm management
else:
imode = 0o600
pspec = PlacementSpec.from_string(placement)
- ks = ClientKeyringSpec(entity, pspec, mode=imode, uid=uid, gid=gid)
+ ks = ClientKeyringSpec(
+ entity,
+ pspec,
+ mode=imode,
+ uid=uid,
+ gid=gid,
+ include_ceph_conf=(not no_ceph_conf)
+ )
self.keys.update(ks)
self._kick_serve_loop()
return HandleCommandResult()
if host not in client_files:
client_files[host] = {}
ceph_conf = (0o644, 0, 0, bytes(config), str(config_digest))
- client_files[host]['/etc/ceph/ceph.conf'] = ceph_conf
- client_files[host][f'{cluster_cfg_dir}/ceph.conf'] = ceph_conf
+ if ks.include_ceph_conf:
+ client_files[host]['/etc/ceph/ceph.conf'] = ceph_conf
+ client_files[host][f'{cluster_cfg_dir}/ceph.conf'] = ceph_conf
client_key = (ks.mode, ks.uid, ks.gid, keyring.encode('utf-8'), digest)
client_files[host][ks.path] = client_key
client_files[host][f'{cluster_cfg_dir}/{os.path.basename(ks.path)}'] = client_key
CephadmServe(cephadm_module)._write_client_files({}, 'host2')
CephadmServe(cephadm_module)._write_client_files({}, 'host3')
+ @mock.patch('cephadm.CephadmOrchestrator.mon_command')
+ @mock.patch("cephadm.inventory.HostCache.get_host_client_files")
+ def test_dont_write_etc_ceph_client_files_when_turned_off(self, _get_client_files, _mon_command, cephadm_module):
+ cephadm_module.keys.update(ClientKeyringSpec('keyring1', PlacementSpec(label='keyring1'), include_ceph_conf=False))
+ cephadm_module.inventory.add_host(HostSpec('host1', '1.2.3.1', labels=['keyring1']))
+ cephadm_module.cache.update_host_daemons('host1', {})
+
+ _mon_command.return_value = (0, 'my-keyring', '')
+
+ client_files = CephadmServe(cephadm_module)._calc_client_files()
+
+ assert 'host1' in client_files
+ assert '/etc/ceph/ceph.keyring1.keyring' in client_files['host1']
+ assert '/etc/ceph/ceph.conf' not in client_files['host1']
+
def test_etc_ceph_init(self):
with with_cephadm_module({'manage_etc_ceph_ceph_conf': True}) as m:
assert m.manage_etc_ceph_ceph_conf is True