mirror of
https://github.com/ceph/ceph
synced 2024-12-28 22:43:29 +00:00
cephadm: shell: allow -e
Set environment variables for shell commands. Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
366d3fc33e
commit
3346765dd0
@ -109,6 +109,7 @@ systemctl status docker && ( $CEPHADM --docker version | grep 'ceph version' )
|
||||
|
||||
## test shell before bootstrap, when crash dir isn't (yet) present on this host
|
||||
$CEPHADM shell --fsid $FSID -- ceph -v | grep 'ceph version'
|
||||
$CEPHADM shell --fsid $FSID -e FOO=BAR -- printenv | grep FOO=BAR
|
||||
|
||||
## bootstrap
|
||||
ORIG_CONFIG=`mktemp -p $TMPDIR`
|
||||
|
@ -1488,8 +1488,9 @@ class CephContainer:
|
||||
volume_mounts={},
|
||||
cname='',
|
||||
container_args=[],
|
||||
envs=None,
|
||||
privileged=False):
|
||||
# type: (str, str, List[str], Dict[str, str], str, List[str], Optional[bool]) -> None
|
||||
# type: (str, str, List[str], Dict[str, str], str, List[str], Optional[List[str]], Optional[bool]) -> None
|
||||
self.image = image
|
||||
self.entrypoint = entrypoint
|
||||
self.args = args
|
||||
@ -1497,6 +1498,7 @@ class CephContainer:
|
||||
self.cname = cname
|
||||
self.container_args = container_args
|
||||
self.privileged = privileged
|
||||
self.envs = envs
|
||||
|
||||
def run_cmd(self):
|
||||
# type: () -> List[str]
|
||||
@ -1519,6 +1521,9 @@ class CephContainer:
|
||||
'-e', 'CONTAINER_IMAGE=%s' % self.image,
|
||||
'-e', 'NODE_NAME=%s' % get_hostname(),
|
||||
]
|
||||
if self.envs:
|
||||
for e in self.envs:
|
||||
envs.extend(['-e', e])
|
||||
cname = ['--name', self.cname] if self.cname else []
|
||||
return [
|
||||
str(container_path),
|
||||
@ -1547,6 +1552,9 @@ class CephContainer:
|
||||
'-e', 'CONTAINER_IMAGE=%s' % self.image,
|
||||
'-e', 'NODE_NAME=%s' % get_hostname(),
|
||||
]
|
||||
if self.envs:
|
||||
for e in self.envs:
|
||||
envs.extend(['-e', e])
|
||||
cmd_args = [] # type: List[str]
|
||||
if cmd:
|
||||
cmd_args = ['-c'] + cmd
|
||||
@ -2085,6 +2093,7 @@ def command_shell():
|
||||
args=[],
|
||||
container_args=container_args,
|
||||
volume_mounts=mounts,
|
||||
envs=args.env,
|
||||
privileged=True)
|
||||
command = c.shell_cmd(command)
|
||||
|
||||
@ -2996,6 +3005,11 @@ def _get_parser():
|
||||
parser_shell.add_argument(
|
||||
'--keyring', '-k',
|
||||
help='ceph.keyring to pass through to the container')
|
||||
parser_shell.add_argument(
|
||||
'--env', '-e',
|
||||
action='append',
|
||||
default=[],
|
||||
help='set environment variable')
|
||||
parser_shell.add_argument(
|
||||
'command', nargs='*',
|
||||
help='command (optional)')
|
||||
|
Loading…
Reference in New Issue
Block a user