| 1925 | |
| 1926 | @contextlib.contextmanager |
| 1927 | def initialize_config(ctx, config): |
| 1928 | cluster_name = config['cluster'] |
| 1929 | testdir = teuthology.get_testdir(ctx) |
| 1930 | |
| 1931 | ctx.ceph[cluster_name].thrashers = [] |
| 1932 | # fixme: setup watchdog, ala ceph.py |
| 1933 | |
| 1934 | ctx.ceph[cluster_name].roleless = False # see below |
| 1935 | |
| 1936 | first_ceph_cluster = False |
| 1937 | if not hasattr(ctx, 'daemons'): |
| 1938 | first_ceph_cluster = True |
| 1939 | |
| 1940 | # cephadm mode? |
| 1941 | if 'cephadm_mode' not in config: |
| 1942 | config['cephadm_mode'] = 'root' |
| 1943 | assert config['cephadm_mode'] in ['root', 'cephadm-package'] |
| 1944 | if config['cephadm_mode'] == 'root': |
| 1945 | ctx.cephadm = testdir + '/cephadm' |
| 1946 | else: |
| 1947 | ctx.cephadm = 'cephadm' # in the path |
| 1948 | |
| 1949 | if first_ceph_cluster: |
| 1950 | # FIXME: this is global for all clusters |
| 1951 | ctx.daemons = DaemonGroup( |
| 1952 | use_cephadm=ctx.cephadm) |
| 1953 | |
| 1954 | # uuid |
| 1955 | fsid = str(uuid.uuid1()) |
| 1956 | log.info('Cluster fsid is %s' % fsid) |
| 1957 | ctx.ceph[cluster_name].fsid = fsid |
| 1958 | |
| 1959 | # mon ips |
| 1960 | log.info('Choosing monitor IPs and ports...') |
| 1961 | remotes_and_roles = _cephadm_remotes(ctx) |
| 1962 | ips = [host for (host, port) in |
| 1963 | (remote.ssh.get_transport().getpeername() for (remote, role_list) in remotes_and_roles)] |
| 1964 | |
| 1965 | if config.get('roleless', False): |
| 1966 | # mons will be named after hosts |
| 1967 | first_mon = None |
| 1968 | max_mons = config.get('max_mons', 5) |
| 1969 | for remote, _ in remotes_and_roles: |
| 1970 | ctx.cluster.remotes[remote].append('mon.' + remote.shortname) |
| 1971 | if not first_mon: |
| 1972 | first_mon = remote.shortname |
| 1973 | bootstrap_remote = remote |
| 1974 | max_mons -= 1 |
| 1975 | if not max_mons: |
| 1976 | break |
| 1977 | log.info('No mon roles; fabricating mons') |
| 1978 | |
| 1979 | roles = [role_list for (remote, role_list) in ctx.cluster.remotes.items()] |
| 1980 | |
| 1981 | ctx.ceph[cluster_name].mons = get_mons( |
| 1982 | roles, ips, cluster_name, |
| 1983 | mon_bind_msgr2=config.get('mon_bind_msgr2', True), |
| 1984 | mon_bind_addrvec=config.get('mon_bind_addrvec', True), |