)
-def activate_disk(cluster, disk, init):
+def activate_disk(conn, logger, cluster, disk, init):
"""
Run on the osd node, activates a disk.
"""
- def subproc_call(*args, **kwargs):
- """
- call subproc that might fail, collect returncode and stderr/stdout
- to be used in pushy.compile()d functions. Returns 4-tuple of
- (process exit code, command, stdout contents, stderr contents)
- """
- import subprocess
- import tempfile
-
- otmp = tempfile.TemporaryFile()
- etmp = tempfile.TemporaryFile()
- cmd = ' '.join(kwargs['args'])
- ret = 0
- errtxt = ''
- kwargs.update(dict(stdout=otmp, stderr=etmp))
- try:
- subprocess.check_call(*args, **kwargs)
- except subprocess.CalledProcessError as e:
- ret = e.returncode
- except Exception as e:
- ret = -1
- # OSError has errno
- if hasattr(e, 'errno'):
- ret = e.errno
- errtxt = str(e)
- otmp.seek(0)
- etmp.seek(0)
- return (ret, cmd, otmp.read(), errtxt + etmp.read())
-
- return subproc_call(
+ return check_call(
+ conn,
+ logger,
args=[
'ceph-disk-activate',
'--mark-init',
init,
'--mount',
disk,
- ])
+ ],
+ )
def prepare(args, cfg, activate_prepared_disk):
)
LOG.debug('Host %s is now ready for osd use.', hostname)
+ distro.sudo_conn.close()
except RuntimeError as e:
LOG.error(e)
for hostname, disk, journal in args.disk:
# TODO username
- sudo = args.pushy(get_transport(hostname))
-
- LOG.debug('Activating host %s disk %s', hostname, disk)
+ distro = hosts.get(hostname)
+ LOG.info(
+ 'Distro info: %s %s %s',
+ distro.name,
+ distro.release,
+ distro.codename
+ )
+ rlogger = logging.getLogger(hostname)
- (distro, release, codename) = lsb.get_lsb_release(sudo)
- init = lsb.choose_init(distro, codename)
- LOG.debug('Distro %s codename %s, will use %s',
- distro, codename, init)
+ LOG.debug('activating host %s disk %s', hostname, disk)
+ LOG.debug('will use init type: %s', distro.init)
- activate_disk_r = sudo.compile(activate_disk)
- err, cmd, stdout, stderr = activate_disk_r(
+ activate_disk(
+ distro.sudo_conn,
+ rlogger,
cluster=args.cluster,
disk=disk,
- init=init,
- )
- sudo.close()
- if err:
- s = '{cmd} returned {ret}\n{out}\n{err}'.format(
- cmd=cmd, ret=ret, out=out, err=err)
- raise RuntimeError(s)
+ init=distro.init,
+ )
+
+ distro.sudo_conn.close()
+
# NOTE: this mirrors ceph-disk-prepare --zap-disk DEV
def zap(dev):
LOG.error('Not yet implemented; see http://tracker.ceph.com/issues/5071')
sys.exit(1)
+
def osd(args):
cfg = conf.load(args)
sys.exit(1)
-
def disk(args):
cfg = conf.load(args)