]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge PR #31698 into master
authorSage Weil <sage@redhat.com>
Fri, 22 Nov 2019 17:24:27 +0000 (11:24 -0600)
committerSage Weil <sage@redhat.com>
Fri, 22 Nov 2019 17:24:27 +0000 (11:24 -0600)
* refs/pull/31698/head:
rpm,deb: add cephdaemon user and sudoers file
ceph-daemon: use mgr/ssh command to create the ssh key
mgr/ssh: add 'ssh generate-key' and 'ssh clear-key' commands
mgr/ssh: add mode option
mgr/ssh: add 'ssh get-pub-key' and 'ssh get-user' commands
mgr/ssh: convert to command decorations
mgr/orchestrator: move command annotation helpers to orchestrator.py

Reviewed-by: Sebastian Wagner <swagner@suse.com>
1  2 
ceph.spec.in
src/ceph-daemon/ceph-daemon

diff --cc ceph.spec.in
Simple merge
index e3179a97ce62f15b0feefee789a96f12856616fb,207e1b71681e8d8470e3404838e9c0a1866d98ff..9e4216f3b3d1c18492c398349eb40482a41b9814
@@@ -60,28 -60,8 +60,9 @@@ except ImportError
  import uuid
  
  from distutils.spawn import find_executable
 +from functools import wraps
  from glob import glob
  
- try:
-     from tempfile import TemporaryDirectory # py3
- except ImportError:
-     # define a minimal (but sufficient) equivalent for <= py 3.2
-     class TemporaryDirectory(object): # type: ignore
-         def __init__(self):
-             self.name = tempfile.mkdtemp()
-         def __enter__(self):
-             if not self.name:
-                 self.name = tempfile.mkdtemp()
-             return self.name
-         def cleanup(self):
-             shutil.rmtree(self.name)
-         def __exit__(self, exc_type, exc_value, traceback):
-             self.cleanup()
  
  container_path = None
  
@@@ -1184,42 -1111,10 +1141,21 @@@ def command_bootstrap()
          logger.info('Adding key to root@localhost\'s authorized_keys...')
          if not os.path.exists('/root/.ssh'):
              os.mkdir('/root/.ssh', 0o700)
 -        with open('/root/.ssh/authorized_keys', 'a') as f:
 +        auth_keys_file = '/root/.ssh/authorized_keys'
 +        add_newline = False
 +        if os.path.exists(auth_keys_file):
 +            with open(auth_keys_file, 'r') as f:
 +                f.seek(0, 2)
 +                if f.tell() > 0:
 +                    f.seek(-1, 2)  # go to last character
 +                    if f.read() != '\n':
 +                        add_newline = True
 +        with open(auth_keys_file, 'a') as f:
              os.fchmod(f.fileno(), 0o600)  # just in case we created it
 +            if add_newline:
 +                f.write('\n')
              f.write(ssh_pub.strip() + '\n')
  
-         logger.info('Enabling ssh module...')
-         cli(['mgr', 'module', 'enable', 'ssh'])
-         logger.info('Setting orchestrator backend to ssh...')
-         cli(['orchestrator', 'set', 'backend', 'ssh'])
          host = get_hostname()
          logger.info('Adding host %s...' % host)
          cli(['orchestrator', 'host', 'add', host])