@rest_initialiser(version_check=True)
def execute(self, opts):
    (result, errors) = self.rest.node_info()
    _exit_if_errors(errors)
    node = result['otpNode']
    cookie = result['otpCookie']
    if (opts.vm != 'ns_server'):
        (cookie, errors) = self.rest.get_babysitter_cookie()
        _exit_if_errors(errors)
        [short, _] = node.split('@')
        if (opts.vm == 'babysitter'):
            node = f'example@example.com'
        elif (opts.vm == 'couchdb'):
            node = f'example@example.com'
        else:
            _exit_if_errors([f'Unknown vm type `{opts.vm}`'])
    rand_chars = ''.join((random.choice(string.ascii_letters) for _ in range(20)))
    name = f'ctl-{rand_chars}@127.0.0.1'
    cb_erl = os.path.join(opts.erl_path, 'erl')
    if os.path.isfile(cb_erl):
        path = cb_erl
    else:
        _warning('Cannot locate Couchbase erlang. Attempting to use non-Couchbase erlang')
        path = 'erl'
    inetrc_file = os.path.join(CB_ETC_PATH, 'hosts.cfg')
    if os.path.isfile(inetrc_file):
        inetrc_opt = ['-kernel', 'inetrc', f'"{inetrc_file}"']
    else:
        inetrc_opt = []
    ns_server_ebin_path = os.path.join(CB_LIB_PATH, 'ns_server', 'erlang', 'lib', 'ns_server', 'ebin')
    with tempfile.NamedTemporaryFile() as temp:
        temp.write(f"[{{preferred_local_proto,{result['addressFamily']}_tcp_dist}}].".encode())
        temp.flush()
        temp_name = temp.name
        args = ([path, '-name', name, '-setcookie', cookie, '-hidden', '-remsh', node, '-proto_dist', 'cb', '-epmd_module', 'cb_epmd', '-pa', ns_server_ebin_path, '-kernel', 'dist_config_file', f'"{temp_name}"'] + inetrc_opt)
        if opts.debug:
            print(f"Running {' '.join(args)}")
        try:
            subprocess.call(args)
        except OSError:
            _exit_if_errors(['Unable to find the erl executable'])
@rest_initialiser(version_check=True)
def execute(self, opts):
    (result, errors) = self.rest.node_info()
    _exit_if_errors(errors)
    node = result['otpNode']
    cookie = result['otpCookie']
    if (opts.vm != 'ns_server'):
        (cookie, errors) = self.rest.get_babysitter_cookie()
        _exit_if_errors(errors)
        [short, _] = node.split('@')
        if (opts.vm == 'babysitter'):
            node = f'example@example.com'
        elif (opts.vm == 'couchdb'):
            node = f'example@example.com'
        else:
            _exit_if_errors([f'Unknown vm type `{opts.vm}`'])
    rand_chars = .join((random.choice(string.ascii_letters) for _ in range(20)))
    name = f'ctl-{rand_chars}@127.0.0.1'
    cb_erl = os.path.join(opts.erl_path, 'erl')
    if os.path.isfile(cb_erl):
        path = cb_erl
    else:
        _warning('Cannot locate Couchbase erlang. Attempting to use non-Couchbase erlang')
        path = 'erl'
    inetrc_file = os.path.join(CB_ETC_PATH, 'hosts.cfg')
    if os.path.isfile(inetrc_file):
        inetrc_opt = ['-kernel', 'inetrc', f'"{inetrc_file}"']
    else:
        inetrc_opt = []
    ns_server_ebin_path = os.path.join(CB_LIB_PATH, 'ns_server', 'erlang', 'lib', 'ns_server', 'ebin')
    with tempfile.NamedTemporaryFile() as temp:
        temp.write(f"[{{preferred_local_proto,{result['addressFamily']}_tcp_dist}}].".encode())
        temp.flush()
        temp_name = temp.name
        args = ([path, '-name', name, '-setcookie', cookie, '-hidden', '-remsh', node, '-proto_dist', 'cb', '-epmd_module', 'cb_epmd', '-pa', ns_server_ebin_path, '-kernel', 'dist_config_file', f'"{temp_name}"'] + inetrc_opt)
        if opts.debug:
            print(f"Running {' '.join(args)}")
        try:
            subprocess.call(args)
        except OSError:
            _exit_if_errors(['Unable to find the erl executable'])