Пример #1
0
def prompt_for_oauth_config(context):
    do_oauth = prompt("Would you like to configure oauth2_proxy to authorize a GitHub team? (y/N)",
        "^[yYnN]?$"
    )
    if not do_oauth or do_oauth.lower() != 'y':
        context['skip_oauth'] = True
        return
    else:
        context['skip_oauth'] = False
    context['github_org'] = prompt('Enter the GitHub org', '^[a-z0-9-_]+$')
    context['github_team'] = prompt('Enter the GitHub team (optional)', '^[a-z0-9-_]*$')
    context['oauth_client_id'] = prompt('Enter the OAuth Client ID', '^[a-z0-9-]+$')
    context['oauth_client_secret'] = prompt('Enter the OAuth Client Secret', '^[a-z0-9-]+$')
    context['oauth_cookie_name'] = '_ghoauth'
    context['oauth_cookie_secret'] = random_token()
    context['ssl_crt'] = prompt('Enter the path to the SSL certificate', readFile=True)
    context['ssl_key'] = prompt('Enter the path to the SSL private key', readFile=True)
Пример #2
0
def setup(my_config=None):
    global config

    def __get_balanced_tokens(node_count, partitioner='murmur3'):
        if partitioner == 'murmur3':
            return [str(((2**64 / node_count) * i) - 2**63)
                    for i in range(node_count)]
        elif partitioner == 'random':
            return [str(i*(2**127/node_count)) for i in range(0, node_count)]
        else:
            raise ValueError('Unknonwn partitioner: %s' % partitioner)

    ########################################
    ### Default config:
    ########################################
    default_config = {
        # Product to test: cassandra or dse
        'product': 'cassandra',
        # The git revision id or tag to use:
        'revision': 'trunk',
        # Override version, tell ant to build with a given version name:
        'override_version': None,
        # Cluster name
        'cluster_name': 'cstar_perf {random_string}'.format(random_string=random_token()),
        # Ant tarball:
        'ant_tarball': 'http://www.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.bz2',
        # The user to install as
        'user': '******',
        'partitioner': 'murmur3',  # murmur3 or random
        'git_repo': 'git://github.com/apache/cassandra.git',
        # Enable vnodes:
        'use_vnodes': True,
        'token_allocation': 'random',  # random, static-random, static-algorithmic, non-vnodes
        # Number of vnodes per node. Ignored if use_vnodes == False:
        'num_tokens': 256,
        # Directories:
        'data_file_directories': ['/var/lib/cassandra/data'],
        'commitlog_directory': '/var/lib/cassandra/commitlog',
        'saved_caches_directory': '/var/lib/cassandra/saved_caches',
        'flush_directory': '/var/lib/cassandra/flush',
        'cdc_directory': '/var/lib/cassandra/cdc',
        'cdc_overflow_directory': '/var/lib/cassandra/cdc_overflow',
        # Log file:
        'log_dir': '~/fab/cassandra/logs',
        # Device readahead setting. None means use system default.
        'blockdev_readahead': None,
        # Block devices that above readahead setting affects:
        'block_devices': [],
        # Force loading JNA on <2.0 (2.1+ has it by default):
        'use_jna': True,
        # Extra environment settings to prepend to cassandra-env.sh:
        'env': '',
        'java_home': '~/fab/java',
        'yourkit_profiler': False,
        'debug_logging': False
    }

    public_ips = "node0, node1, node2, node3"
    private_ips = "192.168.1.141,192.168.1.145,192.168.1.143,192.168.1.133"
    public_ips = public_ips.replace(" ","").split(",")
    private_ips = private_ips.replace(" ","").split(",")

    tokens = __get_balanced_tokens(len(public_ips), default_config['partitioner'])
    default_config.setdefault('hosts', {})
    first_node = True
    for i, public, private, token in zip(
            xrange(len(public_ips)), public_ips, private_ips, tokens):
        if not default_config['hosts'].has_key(public):
            default_config['hosts'][public] = {
                #Local hostname to give the host:
                'hostname': 'node%s' % i,
                #Internal IP address of the host:
                'internal_ip': private,
                }
            if not default_config['use_vnodes']:
                default_config['hosts'][public]['initial_token'] = token
            # Make the first node a seed:
            if first_node:
                default_config['hosts'][public]['seed'] = True
                first_node = False

    ########################################
    ### End default config
    ########################################

    # Use default values where not specified:
    if not my_config:
        config = default_config
    else:
        config = dict(default_config.items() + my_config.items())

    # Retokenize if needed:
    for node in config['hosts'].values():
        if not config['use_vnodes'] and not node.has_key('initial_token'):
            # At least one node was missing it's token, retokenize all the nodes:
            tokens = __get_balanced_tokens(len(config['hosts']), config['partitioner'])
            for node,token in zip(config['hosts'].values(), tokens):
                node['initial_token'] = token
            break

    #Aggregate those nodes which are seeds into a single list:
    config['seeds'] = [v.get('external_ip', v['internal_ip']) for v in config['hosts'].values()
                      if v.get('seed',False)]

    # Tell fabric which hosts to use, unless some were
    # specified on the command line:
    if not CMD_LINE_HOSTS_SPECIFIED:
        fab.env.hosts = [h for h in config['hosts']]
    fab.env.user = config['user']
Пример #3
0
def setup(my_config=None):
    global config

    def __get_balanced_tokens(node_count, partitioner='murmur3'):
        if partitioner == 'murmur3':
            return [
                str(((2**64 / node_count) * i) - 2**63)
                for i in range(node_count)
            ]
        elif partitioner == 'random':
            return [
                str(i * (2**127 / node_count)) for i in range(0, node_count)
            ]
        else:
            raise ValueError('Unknonwn partitioner: %s' % partitioner)

    ########################################
    ### Default config:
    ########################################
    default_config = {
        # Product to test: cassandra or dse
        'product':
        'cassandra',
        # The git revision id or tag to use:
        'revision':
        'trunk',
        # Override version, tell ant to build with a given version name:
        'override_version':
        None,
        # Cluster name
        'cluster_name':
        'cstar_perf {random_string}'.format(random_string=random_token()),
        # Ant tarball:
        'ant_tarball':
        'http://www.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.bz2',
        # The user to install as
        'user':
        '******',
        'partitioner':
        'murmur3',  #murmur3 or random
        'git_repo':
        'git://github.com/apache/cassandra.git',
        # Enable vnodes:
        'use_vnodes':
        True,
        # Number of vnodes per node. Ignored if use_vnodes == False:
        'num_tokens':
        256,
        # Directories:
        'data_file_directories': ['/var/lib/cassandra/data'],
        'commitlog_directory':
        '/var/lib/cassandra/commitlog',
        'saved_caches_directory':
        '/var/lib/cassandra/saved_caches',
        'flush_directory':
        '/var/lib/cassandra/flush',
        # Log file:
        'log_dir':
        '~/fab/cassandra/logs',
        # Device readahead setting. None means use system default.
        'blockdev_readahead':
        None,
        # Block devices that above readahead setting affects:
        'block_devices': [],
        # Force loading JNA on <2.0 (2.1+ has it by default):
        'use_jna':
        True,
        # Extra environment settings to prepend to cassandra-env.sh:
        'env':
        '',
        'java_home':
        '~/fab/java'
    }

    public_ips = "node0, node1, node2, node3"
    private_ips = "192.168.1.141,192.168.1.145,192.168.1.143,192.168.1.133"
    public_ips = public_ips.replace(" ", "").split(",")
    private_ips = private_ips.replace(" ", "").split(",")

    tokens = __get_balanced_tokens(len(public_ips),
                                   default_config['partitioner'])
    default_config.setdefault('hosts', {})
    first_node = True
    for i, public, private, token in zip(xrange(len(public_ips)), public_ips,
                                         private_ips, tokens):
        if not default_config['hosts'].has_key(public):
            default_config['hosts'][public] = {
                #Local hostname to give the host:
                'hostname': 'node%s' % i,
                #Internal IP address of the host:
                'internal_ip': private,
            }
            if not default_config['use_vnodes']:
                default_config['hosts'][public]['initial_token'] = token
            # Make the first node a seed:
            if first_node:
                default_config['hosts'][public]['seed'] = True
                first_node = False

    ########################################
    ### End default config
    ########################################

    # Use default values where not specified:
    if not my_config:
        config = default_config
    else:
        config = dict(default_config.items() + my_config.items())

    # Retokenize if needed:
    for node in config['hosts'].values():
        if not config['use_vnodes'] and not node.has_key('initial_token'):
            # At least one node was missing it's token, retokenize all the nodes:
            tokens = __get_balanced_tokens(len(config['hosts']),
                                           config['partitioner'])
            for node, token in zip(config['hosts'].values(), tokens):
                node['initial_token'] = token
            break

    #Aggregate those nodes which are seeds into a single list:
    config['seeds'] = [
        v.get('external_ip', v['internal_ip'])
        for v in config['hosts'].values() if v.get('seed', False)
    ]

    # Tell fabric which hosts to use, unless some were
    # specified on the command line:
    if not CMD_LINE_HOSTS_SPECIFIED:
        fab.env.hosts = [h for h in config['hosts']]
    fab.env.user = config['user']
Пример #4
0
def setup(my_config=None):
    global config

    def __get_balanced_tokens(node_count, partitioner="murmur3"):
        if partitioner == "murmur3":
            return [str(((2 ** 64 / node_count) * i) - 2 ** 63) for i in range(node_count)]
        elif partitioner == "random":
            return [str(i * (2 ** 127 / node_count)) for i in range(0, node_count)]
        else:
            raise ValueError("Unknonwn partitioner: %s" % partitioner)

    ########################################
    ### Default config:
    ########################################
    default_config = {
        # Product to test: cassandra or dse
        "product": "cassandra",
        # The git revision id or tag to use:
        "revision": "trunk",
        # Override version, tell ant to build with a given version name:
        "override_version": None,
        # Cluster name
        "cluster_name": "cstar_perf {random_string}".format(random_string=random_token()),
        # Ant tarball:
        "ant_tarball": "http://www.apache.org/dist/ant/binaries/apache-ant-1.8.4-bin.tar.bz2",
        # The user to install as
        "user": "******",
        "partitioner": "murmur3",  # murmur3 or random
        "git_repo": "git://github.com/apache/cassandra.git",
        # Enable vnodes:
        "use_vnodes": True,
        # Number of vnodes per node. Ignored if use_vnodes == False:
        "num_tokens": 256,
        # Directories:
        "data_file_directories": ["/var/lib/cassandra/data"],
        "commitlog_directory": "/var/lib/cassandra/commitlog",
        "saved_caches_directory": "/var/lib/cassandra/saved_caches",
        "flush_directory": "/var/lib/cassandra/flush",
        # Log file:
        "log_dir": "~/fab/cassandra/logs",
        # Device readahead setting. None means use system default.
        "blockdev_readahead": None,
        # Block devices that above readahead setting affects:
        "block_devices": [],
        # Force loading JNA on <2.0 (2.1+ has it by default):
        "use_jna": True,
        # Extra environment settings to prepend to cassandra-env.sh:
        "env": "",
        "java_home": "~/fab/java",
    }

    public_ips = "node0, node1, node2, node3"
    private_ips = "192.168.1.141,192.168.1.145,192.168.1.143,192.168.1.133"
    public_ips = public_ips.replace(" ", "").split(",")
    private_ips = private_ips.replace(" ", "").split(",")

    tokens = __get_balanced_tokens(len(public_ips), default_config["partitioner"])
    default_config.setdefault("hosts", {})
    first_node = True
    for i, public, private, token in zip(xrange(len(public_ips)), public_ips, private_ips, tokens):
        if not default_config["hosts"].has_key(public):
            default_config["hosts"][public] = {
                # Local hostname to give the host:
                "hostname": "node%s" % i,
                # Internal IP address of the host:
                "internal_ip": private,
            }
            if not default_config["use_vnodes"]:
                default_config["hosts"][public]["initial_token"] = token
            # Make the first node a seed:
            if first_node:
                default_config["hosts"][public]["seed"] = True
                first_node = False

    ########################################
    ### End default config
    ########################################

    # Use default values where not specified:
    if not my_config:
        config = default_config
    else:
        config = dict(default_config.items() + my_config.items())

    # Retokenize if needed:
    for node in config["hosts"].values():
        if not config["use_vnodes"] and not node.has_key("initial_token"):
            # At least one node was missing it's token, retokenize all the nodes:
            tokens = __get_balanced_tokens(len(config["hosts"]), config["partitioner"])
            for node, token in zip(config["hosts"].values(), tokens):
                node["initial_token"] = token
            break

    # Aggregate those nodes which are seeds into a single list:
    config["seeds"] = [v.get("external_ip", v["internal_ip"]) for v in config["hosts"].values() if v.get("seed", False)]

    # Tell fabric which hosts to use, unless some were
    # specified on the command line:
    if not CMD_LINE_HOSTS_SPECIFIED:
        fab.env.hosts = [h for h in config["hosts"]]
    fab.env.user = config["user"]