Bootstrap ceph cluster. :param ctx: the argparse.Namespace object :param config: the config dict
(ctx, config)
| 670 | |
| 671 | @contextlib.contextmanager |
| 672 | def ceph_bootstrap(ctx, config): |
| 673 | """ |
| 674 | Bootstrap ceph cluster. |
| 675 | |
| 676 | :param ctx: the argparse.Namespace object |
| 677 | :param config: the config dict |
| 678 | """ |
| 679 | cluster_name = config['cluster'] |
| 680 | testdir = teuthology.get_testdir(ctx) |
| 681 | fsid = ctx.ceph[cluster_name].fsid |
| 682 | |
| 683 | bootstrap_remote = ctx.ceph[cluster_name].bootstrap_remote |
| 684 | first_mon = ctx.ceph[cluster_name].first_mon |
| 685 | first_mon_role = ctx.ceph[cluster_name].first_mon_role |
| 686 | mons = ctx.ceph[cluster_name].mons |
| 687 | |
| 688 | ctx.cluster.run(args=[ |
| 689 | 'sudo', 'mkdir', '-p', '/etc/ceph', |
| 690 | ]); |
| 691 | ctx.cluster.run(args=[ |
| 692 | 'sudo', 'chmod', '777', '/etc/ceph', |
| 693 | ]); |
| 694 | try: |
| 695 | # write seed config |
| 696 | log.info('Writing seed config...') |
| 697 | conf_fp = BytesIO() |
| 698 | seed_config = build_initial_config(ctx, config) |
| 699 | seed_config.write(conf_fp) |
| 700 | bootstrap_remote.write_file( |
| 701 | path='{}/seed.{}.conf'.format(testdir, cluster_name), |
| 702 | data=conf_fp.getvalue()) |
| 703 | log.debug('Final config:\n' + conf_fp.getvalue().decode()) |
| 704 | ctx.ceph[cluster_name].conf = seed_config |
| 705 | |
| 706 | # register initial daemons |
| 707 | ctx.daemons.register_daemon( |
| 708 | bootstrap_remote, 'mon', first_mon, |
| 709 | cluster=cluster_name, |
| 710 | fsid=fsid, |
| 711 | logger=log.getChild('mon.' + first_mon), |
| 712 | wait=False, |
| 713 | started=True, |
| 714 | ) |
| 715 | if not ctx.ceph[cluster_name].roleless: |
| 716 | first_mgr = ctx.ceph[cluster_name].first_mgr |
| 717 | ctx.daemons.register_daemon( |
| 718 | bootstrap_remote, 'mgr', first_mgr, |
| 719 | cluster=cluster_name, |
| 720 | fsid=fsid, |
| 721 | logger=log.getChild('mgr.' + first_mgr), |
| 722 | wait=False, |
| 723 | started=True, |
| 724 | ) |
| 725 | |
| 726 | # bootstrap |
| 727 | log.info('Bootstrapping...') |
| 728 | cmd = [ |
| 729 | 'sudo', |
no test coverage detected