def main(): opts = parse_args() # Display the pid in each log message to distinguish concurrent runs log_format = 'pid={}:[%(levelname)s] %(message)s'.format(os.getpid()) logging.basicConfig(format=log_format, level='INFO') log.setLevel(logging.DEBUG) log.info('Clearing proxy environment variables') for name in ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY']: os.environ.pop(name, None) os.environ.pop(name.lower(), None) if 'master' in get_roles(): exhibitor.wait(opts.master_count) b = bootstrap.Bootstrapper(opts.zk) for service in opts.services: if service not in bootstrappers: log.error('Unknown service: {}'.format(service)) sys.exit(1) apply_service_configuration(service) log.info('bootstrapping {}'.format(service)) bootstrappers[service](b, opts)
def main(): if os.getuid() != 0: log.error('bootstrap must be run as root') sys.exit(1) opts = parse_args() logging.basicConfig(format='[%(levelname)s] %(message)s', level='INFO') log.setLevel(logging.DEBUG) log.info('Clearing proxy environment variables') for name in ['HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY']: os.environ.pop(name, None) os.environ.pop(name.lower(), None) exhibitor.wait(opts.master_count) b = bootstrap.Bootstrapper(opts.zk) for service in opts.services: if service not in bootstrappers: log.error('Unknown service: {}'.format(service)) sys.exit(1) log.debug('bootstrapping {}'.format(service)) bootstrappers[service](b, opts)
def _check_consensus(methodname, monkeypatch, tmpdir): orig_getpwnam = pwd.getpwnam def mock_getpwnam(user): return orig_getpwnam(getpass.getuser()) monkeypatch.setattr(pwd, 'getpwnam', mock_getpwnam) b = bootstrap.Bootstrapper(zk_hosts) path = tmpdir.join('/cluster-id') assert not path.exists() method = getattr(b, methodname) id1 = method(str(path)) path.remove() id2 = method(str(path)) assert id1 == id2
#!/opt/mesosphere/bin/python import sys sys.path.append('/opt/mesosphere/lib/python3.6/site-packages') from dcos_internal_utils import bootstrap if len(sys.argv) == 1: print( "Usage: ./bootstrap-certs.py <CN> <PATH> | ./bootstrap-certs.py etcd /var/lib/dcos/etcd/certs" ) sys.exit(1) b = bootstrap.Bootstrapper(bootstrap.parse_args()) b.read_agent_secrets() cn = sys.argv[1] location = sys.argv[2] keyfile = location + '/' + cn + '.key' crtfile = location + '/' + cn + '.crt' b.ensure_key_certificate(cn, keyfile, crtfile, service_account='dcos_bootstrap_agent')