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

Function create_simple_monmap

qa/tasks/ceph.py:609–666  ·  view source on GitHub ↗

Writes a simple monmap based on current ceph.conf into path, or /monmap by default. Assumes ceph_conf is up to date. Assumes mon sections are named "mon.*", with the dot. :return the FSID (as a string) of the newly created monmap

(ctx, remote, conf, mons,
                         path=None,
                         mon_bind_addrvec=False)

Source from the content-addressed store, hash-verified

607 return conf
608
609def create_simple_monmap(ctx, remote, conf, mons,
610 path=None,
611 mon_bind_addrvec=False):
612 """
613 Writes a simple monmap based on current ceph.conf into path, or
614 <testdir>/monmap by default.
615
616 Assumes ceph_conf is up to date.
617
618 Assumes mon sections are named "mon.*", with the dot.
619
620 :return the FSID (as a string) of the newly created monmap
621 """
622
623 addresses = list(mons.items())
624 assert addresses, "There are no monitors in config!"
625 log.debug('Ceph mon addresses: %s', addresses)
626
627 try:
628 log.debug('writing out conf {c}'.format(c=conf))
629 except:
630 log.debug('my conf logging attempt failed')
631 testdir = teuthology.get_testdir(ctx)
632 tmp_conf_path = '{tdir}/ceph.tmp.conf'.format(tdir=testdir)
633 conf_fp = BytesIO()
634 conf.write(conf_fp)
635 conf_fp.seek(0)
636 teuthology.write_file(remote, tmp_conf_path, conf_fp)
637 args = [
638 'adjust-ulimits',
639 'ceph-coverage',
640 '{tdir}/archive/coverage'.format(tdir=testdir),
641 'monmaptool',
642 '-c',
643 '{conf}'.format(conf=tmp_conf_path),
644 '--create',
645 '--clobber',
646 ]
647 if mon_bind_addrvec:
648 args.extend(['--enable-all-features'])
649 for (role, addr) in addresses:
650 _, _, n = teuthology.split_role(role)
651 if mon_bind_addrvec and (',' in addr or 'v' in addr or ':' in addr):
652 args.extend(('--addv', n, addr))
653 else:
654 args.extend(('--add', n, addr))
655 if not path:
656 path = '{tdir}/monmap'.format(tdir=testdir)
657 args.extend([
658 '--print',
659 path
660 ])
661
662 monmap_output = remote.sh(args)
663 fsid = re.search("generated fsid (.+)$",
664 monmap_output, re.MULTILINE).group(1)
665 teuthology.delete_file(remote, tmp_conf_path)
666 return fsid

Callers 1

clusterFunction · 0.85

Calls 10

extendMethod · 0.80
listFunction · 0.50
itemsMethod · 0.45
debugMethod · 0.45
formatMethod · 0.45
writeMethod · 0.45
seekMethod · 0.45
write_fileMethod · 0.45
groupMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected