コード例 #1
0
ファイル: run.py プロジェクト: cchery101/neckbeard
def run():
    """
    Sets the env.hosts variable to contain all of the app servers in the
    appropriate generation and deployment.
    """
    require('_deployment_name')
    require('_deployment_confs')
    require('_active_gen')

    deployment = Deployment(
        env._deployment_name,
        env._deployment_confs['ec2'],
        env._deployment_confs['rds'],
        env._deployment_confs['elb'],
    )
    deployment.verify_deployment_state()

    # All rds and ec2 nodes, rds nodes first
    dep_confs = []
    dep_confs.append(('rds', sorted(env._deployment_confs['rds'].items())))
    dep_confs.append(('ec2', sorted(env._deployment_confs['ec2'].items())))

    hosts = []
    for aws_type, node_confs in dep_confs:
        for node_name, conf_ in node_confs:
            if aws_type != 'ec2':
                continue

            if env._active_gen:
                node = deployment.get_active_node('ec2', node_name)
            else:
                node = deployment.get_pending_node('ec2', node_name)

            if (not node
                    or not node.boto_instance
                    or not node.boto_instance.public_dns_name):
                continue

            # Set the user value, only the last value holds
            conf_key = env._deployment_confs[aws_type][node_name]['conf_key']
            if 'user' in env.INSTANCES[conf_key]:
                env.user = env.INSTANCES[conf_key]['user']

            hosts.append(node.boto_instance.public_dns_name)

    env.hosts = hosts
コード例 #2
0
ファイル: run.py プロジェクト: panozzaj/neckbeard
def run():
    """
    Sets the env.hosts variable to contain all of the app servers in the
    appropriate generation and deployment.
    """
    require('_deployment_name')
    require('_deployment_confs')
    require('_active_gen')

    deployment = Deployment(
        env._deployment_name,
        env._deployment_confs['ec2'],
        env._deployment_confs['rds'],
        env._deployment_confs['elb'],
    )
    deployment.verify_deployment_state()

    # All rds and ec2 nodes, rds nodes first
    dep_confs = []
    dep_confs.append(('rds', sorted(env._deployment_confs['rds'].items())))
    dep_confs.append(('ec2', sorted(env._deployment_confs['ec2'].items())))

    hosts = []
    for aws_type, node_confs in dep_confs:
        for node_name, conf_ in node_confs:
            if aws_type != 'ec2':
                continue

            if env._active_gen:
                node = deployment.get_active_node('ec2', node_name)
            else:
                node = deployment.get_pending_node('ec2', node_name)

            if (not node or not node.boto_instance
                    or not node.boto_instance.public_dns_name):
                continue

            # Set the user value, only the last value holds
            conf_key = env._deployment_confs[aws_type][node_name]['conf_key']
            if 'user' in env.INSTANCES[conf_key]:
                env.user = env.INSTANCES[conf_key]['user']

            hosts.append(node.boto_instance.public_dns_name)

    env.hosts = hosts
コード例 #3
0
ファイル: override.py プロジェクト: cchery101/neckbeard
def override():
    """
    Manually fix the generational config for the given generation.

    This is required for initial setup of the generational system. We are only
    modifying the simpledb records of the instances, not the instances
    themselves.
    """
    require('_deployment_name')
    require('_deployment_confs')

    generation_target = _get_gen_target()

    deployment = Deployment(
        env._deployment_name,
        env._deployment_confs['ec2'],
        env._deployment_confs['rds'],
        env._deployment_confs['elb'],
    )
    deployment.verify_deployment_state()

    if generation_target not in ['ACTIVE', 'PENDING']:
        exit(1)

    opts = ['Y', 'N']
    for aws_type, confs in env._deployment_confs.items():
        for node_name, node_confs in confs.items():
            if generation_target == 'ACTIVE':
                node = deployment.get_active_node(aws_type, node_name)
            else:
                node = deployment.get_pending_node(aws_type, node_name)

            if node:
                print "Existing node found for %s: %s\n" % (node_name, node)
                replace_node = ''
                while replace_node not in opts:
                    replace_node = prompt("Change this node? (Y/N)")
                if replace_node == 'N':
                    continue
            else:
                print "No node for %s: %s\n" % (aws_type, node_name)

            retire_alter_opts = ['Retire', 'Alter']
            retire_alter_response = ''
            should_alter_node = False
            should_retire_node = False

            while retire_alter_response not in retire_alter_opts:
                retire_alter_response = prompt(
                    "Retire or Alter node? (Retire/Alter)")
            if retire_alter_response == 'Retire':
                should_retire_node = True
            else:
                should_alter_node = True

            if should_alter_node:
                # Prompt if the node doesn't already exist
                if not node:
                    add_node = ''
                    while add_node not in opts:
                        add_node = prompt(
                            'No node record found for <%s>-%s. Add one? '
                            '(Y/N)' % (aws_type, node_name)
                        )
                    if add_node == 'N':
                        should_alter_node = False
            if should_retire_node and not node:
                logger.critical(
                    "No node record found. Can't retire a non-existent node.")
                continue

            if should_alter_node:
                _override_node(
                    node, deployment, aws_type, node_name)
            elif should_retire_node:
                logger.info("Retiring: %s", node)
                confirm = ''
                while confirm not in opts:
                    confirm = prompt(
                        "Are you sure you want to RETIRE this node? (Y/N)")
                if confirm == 'Y':
                    node.make_fully_inoperative()
                    node.retire()
コード例 #4
0
def override():
    """
    Manually fix the generational config for the given generation.

    This is required for initial setup of the generational system. We are only
    modifying the simpledb records of the instances, not the instances
    themselves.
    """
    require('_deployment_name')
    require('_deployment_confs')

    generation_target = _get_gen_target()

    deployment = Deployment(
        env._deployment_name,
        env._deployment_confs['ec2'],
        env._deployment_confs['rds'],
        env._deployment_confs['elb'],
    )
    deployment.verify_deployment_state()

    if generation_target not in ['ACTIVE', 'PENDING']:
        exit(1)

    opts = ['Y', 'N']
    for aws_type, confs in env._deployment_confs.items():
        for node_name, node_confs in confs.items():
            if generation_target == 'ACTIVE':
                node = deployment.get_active_node(aws_type, node_name)
            else:
                node = deployment.get_pending_node(aws_type, node_name)

            if node:
                print "Existing node found for %s: %s\n" % (node_name, node)
                replace_node = ''
                while replace_node not in opts:
                    replace_node = prompt("Change this node? (Y/N)")
                if replace_node == 'N':
                    continue
            else:
                print "No node for %s: %s\n" % (aws_type, node_name)

            retire_alter_opts = ['Retire', 'Alter']
            retire_alter_response = ''
            should_alter_node = False
            should_retire_node = False

            while retire_alter_response not in retire_alter_opts:
                retire_alter_response = prompt(
                    "Retire or Alter node? (Retire/Alter)")
            if retire_alter_response == 'Retire':
                should_retire_node = True
            else:
                should_alter_node = True

            if should_alter_node:
                # Prompt if the node doesn't already exist
                if not node:
                    add_node = ''
                    while add_node not in opts:
                        add_node = prompt(
                            'No node record found for <%s>-%s. Add one? '
                            '(Y/N)' % (aws_type, node_name))
                    if add_node == 'N':
                        should_alter_node = False
            if should_retire_node and not node:
                logger.critical(
                    "No node record found. Can't retire a non-existent node.")
                continue

            if should_alter_node:
                _override_node(node, deployment, aws_type, node_name)
            elif should_retire_node:
                logger.info("Retiring: %s", node)
                confirm = ''
                while confirm not in opts:
                    confirm = prompt(
                        "Are you sure you want to RETIRE this node? (Y/N)")
                if confirm == 'Y':
                    node.make_fully_inoperative()
                    node.retire()