MCPcopy Create free account
hub / github.com/ceph/ceph / shell

Function shell

qa/tasks/cephadm.py:1570–1603  ·  view source on GitHub ↗

Execute (shell) commands

(ctx, config)

Source from the content-addressed store, hash-verified

1568
1569
1570def shell(ctx, config):
1571 """
1572 Execute (shell) commands
1573 """
1574 cluster_name = config.get('cluster', 'ceph')
1575
1576 args = []
1577 for k in config.pop('env', []):
1578 args.extend(['-e', k + '=' + ctx.config.get(k, '')])
1579 for k in config.pop('volumes', []):
1580 args.extend(['-v', k])
1581
1582 config = template.expand_roles(ctx, config)
1583 config = template.transform(ctx, config, config)
1584 for role, cmd in config.items():
1585 (remote,) = ctx.cluster.only(role).remotes.keys()
1586 log.info('Running commands on role %s host %s', role, remote.name)
1587 if isinstance(cmd, list):
1588 for cobj in cmd:
1589 sh_cmd, stdin = _shell_command(cobj)
1590 _shell(
1591 ctx,
1592 cluster_name,
1593 remote,
1594 ['bash', '-c', sh_cmd],
1595 extra_cephadm_args=args,
1596 stdin=stdin,
1597 )
1598
1599 else:
1600 assert isinstance(cmd, str)
1601 _shell(ctx, cluster_name, remote,
1602 ['bash', '-ex', '-c', cmd],
1603 extra_cephadm_args=args)
1604
1605
1606def _shell_command(obj):

Callers

nothing calls this directly

Calls 10

_shell_commandFunction · 0.85
extendMethod · 0.80
onlyMethod · 0.80
_shellFunction · 0.70
getMethod · 0.45
popMethod · 0.45
transformMethod · 0.45
itemsMethod · 0.45
keysMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected