# - bring over some of the protections from ceph-deploy that guard against
# multiple bootstrapping / initialization
-def _name_to_entity_name(name):
+CEPH_TYPES = ['mon', 'mgr', 'osd', 'mds', 'rbd-mirror', 'rgw', 'crash']
+
+def name_to_config_section(name):
"""
Map from daemon names to ceph entity names (as seen in config)
"""
- if name.startswith('rgw.') or name.startswith('rbd-mirror'):
+ daemon_type = name.split('.', 1)[0]
+ if daemon_type in ['rgw', 'rbd-mirror', 'crash']:
return 'client.' + name
- else:
+ elif daemon_type in ['mon', 'osd', 'mds', 'mgr', 'client']:
return name
+ else:
+ return 'mon'
def assert_valid_host(name):
p = re.compile('^[a-zA-Z0-9-]+$')
'prefix': 'config set',
'name': 'container_image',
'value': target_name,
- 'who': daemon_type + '.' + d.daemon_id,
+ 'who': name_to_config_section(daemon_type + '.' + d.daemon_id),
})
self._daemon_action(
d.daemon_type,
ret, image, err = self.mon_command({
'prefix': 'config rm',
'name': 'container_image',
- 'who': daemon_type,
+ 'who': name_to_config_section(daemon_type),
})
self.log.info('Upgrade: Complete!')
no_fsid=False,
error_ok=False,
image=None):
+ # type: (str, Optional[str], str, List[str], Optional[str], Optional[str], bool, bool, Optional[str]) -> Tuple[List[str], List[str], int]
"""
Run cephadm on the remote host with the given command + args
"""
conn, connr = self._get_connection(addr)
try:
+ assert image or entity
if not image:
- # get container image
- ret, image, err = self.mon_command({
- 'prefix': 'config get',
- 'who': _name_to_entity_name(entity),
- 'key': 'container_image',
- })
- image = image.strip()
+ daemon_type = entity.split('.', 1)[0] # type: ignore
+ if daemon_type in CEPH_TYPES:
+ # get container image
+ ret, image, err = self.mon_command({
+ 'prefix': 'config get',
+ 'who': name_to_config_section(entity),
+ 'key': 'container_image',
+ })
+ image = image.strip() # type: ignore
self.log.debug('%s container image %s' % (entity, image))
- final_args = [
- '--image', image,
- command
- ]
+ final_args = []
+ if image:
+ final_args.extend(['--image', image])
+ final_args.append(command)
+
if not no_fsid:
final_args += ['--fsid', self._cluster_fsid]
final_args += args