def aws_resume_instances(all_instances, moz_instance_type, start_count,
                         regions, region_priorities, dryrun, slaveset):
    """Create up to `start_count` on-demand instances"""

    start_count_per_region = distribute_in_region(start_count, regions,
                                                  region_priorities)

    started = 0
    instance_config = load_instance_config(moz_instance_type)
    for region, count in start_count_per_region.iteritems():
        # TODO: check region limits
        ami = get_ami(region=region, moz_instance_type=moz_instance_type)
        for _ in range(count):
            try:
                r = do_request_instance(
                    region=region,
                    moz_instance_type=moz_instance_type,
                    price=None,
                    availability_zone=None,
                    ami=ami,
                    instance_config=instance_config,
                    instance_type=instance_config[region]["instance_type"],
                    slaveset=slaveset,
                    is_spot=False,
                    dryrun=dryrun,
                    all_instances=all_instances)
                if r:
                    started += 1
            except EC2ResponseError, e:
                # TODO: Handle e.code
                log.warn("On-demand failure: %s; giving up", e.code)
                log.warn("Cannot start", exc_info=True)
                break
            except Exception:
                log.warn("Cannot start", exc_info=True)
def aws_resume_instances(all_instances, moz_instance_type, start_count,
                         regions, region_priorities, dryrun):
    """Create up to `start_count` on-demand instances"""

    start_count_per_region = distribute_in_region(start_count, regions,
                                                  region_priorities)

    started = 0
    instance_config = load_instance_config(moz_instance_type)
    for region, count in start_count_per_region.iteritems():
        # TODO: check region limits
        ami = get_ami(region=region, moz_instance_type=moz_instance_type)
        for _ in range(count):
            try:
                r = do_request_instance(
                    region=region,
                    moz_instance_type=moz_instance_type,
                    price=None, availability_zone=None,
                    ami=ami, instance_config=instance_config,
                    instance_type=instance_config[region]["instance_type"],
                    is_spot=False, dryrun=dryrun,
                    all_instances=all_instances)
                if r:
                    started += 1
            except EC2ResponseError, e:
                # TODO: Handle e.code
                log.warn("On-demand failure: %s; giving up", e.code)
                log.warn("Cannot start", exc_info=True)
                break
            except Exception:
                log.warn("Cannot start", exc_info=True)
示例#3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-r", "--region", action="append", dest="regions")
    parser.add_argument("-t",
                        "--type",
                        action="append",
                        dest="moz_instance_types")

    args = parser.parse_args()
    regions = args.regions
    moz_instance_types = args.moz_instance_types
    if not args.regions:
        regions = DEFAULT_REGIONS
    if not moz_instance_types:
        moz_instance_types = [
            "bld-linux64", "try-linux64", "tst-linux64", "tst-linux32",
            "tst-emulator64", "av-linux64"
        ]

    for region in regions:
        for moz_instance_type in moz_instance_types:
            ami = get_ami(region=region, moz_instance_type=moz_instance_type)
            print "%s, %s: %s (%s, %s)" % (moz_instance_type, region, ami.id,
                                           ami.tags.get("Name"),
                                           ami.root_device_type)
def main():
    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s")
    log.setLevel(logging.INFO)

    parser = argparse.ArgumentParser()
    parser.add_argument("-f",
                        "--from-region",
                        required=True,
                        help="Region to copy from")
    parser.add_argument("-t",
                        "--to-region",
                        action="append",
                        required=True,
                        dest="to_regions",
                        help="Regions to copy to")
    parser.add_argument("moz_instance_types",
                        metavar="moz_type",
                        nargs="+",
                        help="moz_instance_types to be copied")
    args = parser.parse_args()

    amis_to_copy = [
        get_ami(region=args.from_region, moz_instance_type=t)
        for t in args.moz_instance_types
    ]
    for ami in amis_to_copy:
        for r in args.to_regions:
            log.info("Copying %s (%s) to %s", ami.id, ami.tags.get("Name"), r)
            new_ami = copy_ami(ami, r)
            log.info("New AMI created. AMI ID: %s", new_ami.id)
示例#5
0
def main():
    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s")
    log.setLevel(logging.INFO)

    parser = argparse.ArgumentParser()
    parser.add_argument("-f", "--from-region", required=True,
                        help="Region to copy from")
    parser.add_argument("-t", "--to-region", action="append", required=True,
                        dest="to_regions", help="Regions to copy to")
    parser.add_argument("moz_instance_types", metavar="moz_type", nargs="+",
                        help="moz_instance_types to be copied")
    args = parser.parse_args()

    amis_to_copy = [get_ami(region=args.from_region, moz_instance_type=t)
                    for t in args.moz_instance_types]
    for ami in amis_to_copy:
        for r in args.to_regions:
            log.info("Copying %s (%s) to %s", ami.id, ami.tags.get("Name"), r)
            new_ami = copy_ami(ami, r)
            log.info("New AMI created. AMI ID: %s", new_ami.id)
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-r", "--region", action="append", dest="regions")
    parser.add_argument("-t", "--type", action="append",
                        dest="moz_instance_types")

    args = parser.parse_args()
    regions = args.regions
    moz_instance_types = args.moz_instance_types
    if not args.regions:
        regions = DEFAULT_REGIONS
    if not moz_instance_types:
        moz_instance_types = ["bld-linux64", "try-linux64", "tst-linux64",
                              "tst-linux32", "tst-emulator64", "av-linux64"]

    for region in regions:
        for moz_instance_type in moz_instance_types:
            ami = get_ami(region=region, moz_instance_type=moz_instance_type)
            print "%s, %s: %s (%s, %s)" % (moz_instance_type, region, ami.id,
                                           ami.tags.get("Name"),
                                           ami.root_device_type)
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-c",
                        "--config",
                        required=True,
                        type=argparse.FileType('r'),
                        help="instance configuration to use")
    parser.add_argument("-r",
                        "--region",
                        help="region to use",
                        default="us-east-1")
    parser.add_argument("-k",
                        "--secrets",
                        type=argparse.FileType('r'),
                        required=True,
                        help="file where secrets can be found")
    parser.add_argument("-s", "--key-name", help="SSH key name", required=True)
    parser.add_argument("--ssh-key",
                        required=True,
                        help="SSH key to be used by Fabric")
    parser.add_argument("-i",
                        "--instance-data",
                        help="instance specific data",
                        type=argparse.FileType('r'),
                        required=True)
    parser.add_argument("--no-verify",
                        action="store_true",
                        help="Skip DNS related checks")
    parser.add_argument("-v",
                        "--verbose",
                        action="store_const",
                        dest="log_level",
                        const=logging.DEBUG,
                        default=logging.INFO,
                        help="Increase logging verbosity")
    parser.add_argument("-l", "--loaned-to", help="Loaner contact e-mail")
    parser.add_argument("-b", "--bug", help="Loaner bug number")
    parser.add_argument("hosts",
                        metavar="host",
                        nargs="+",
                        help="hosts to be processed")
    parser.add_argument("--create-ami",
                        action="store_true",
                        help="Generate AMI and terminate the instance")
    parser.add_argument("--ignore-subnet-check",
                        action="store_true",
                        help="Do not check subnet IDs")
    parser.add_argument("-t",
                        "--copy-to-region",
                        action="append",
                        default=[],
                        dest="copy_to_regions",
                        help="Regions to copy AMI to")
    parser.add_argument(
        "--max-attempts",
        help="The number of attempts to try after each failure")

    args = parser.parse_args()

    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s",
                        level=args.log_level)

    try:
        config = json.load(args.config)[args.region]
    except KeyError:
        parser.error("unknown configuration")
    if not os.path.exists(args.ssh_key):
        parser.error("Cannot read %s" % args.ssh_key)

    secrets = json.load(args.secrets)
    deploypass = secrets["deploy_password"]

    instance_data = json.load(args.instance_data)
    if not args.no_verify:
        log.info("Sanity checking DNS entries...")
        verify(args.hosts, config, args.region, args.ignore_subnet_check)
    make_instances(names=args.hosts,
                   config=config,
                   region=args.region,
                   key_name=args.key_name,
                   ssh_key=args.ssh_key,
                   instance_data=instance_data,
                   deploypass=deploypass,
                   loaned_to=args.loaned_to,
                   loan_bug=args.bug,
                   create_ami=args.create_ami,
                   ignore_subnet_check=args.ignore_subnet_check,
                   max_attempts=args.max_attempts)
    for r in args.copy_to_regions:
        ami = get_ami(region=args.region, moz_instance_type=config["type"])
        log.info("Copying %s (%s) to %s", ami.id, ami.tags.get("Name"), r)
        new_ami = copy_ami(ami, r)
        log.info("New AMI created. AMI ID: %s", new_ami.id)
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-c", "--config", required=True,
                        type=argparse.FileType('r'),
                        help="instance configuration to use")
    parser.add_argument("-r", "--region", help="region to use",
                        default="us-east-1")
    parser.add_argument("-k", "--secrets", type=argparse.FileType('r'),
                        required=True, help="file where secrets can be found")
    parser.add_argument("-s", "--key-name", help="SSH key name", required=True)
    parser.add_argument("--ssh-key", required=True,
                        help="SSH key to be used by Fabric")
    parser.add_argument("-i", "--instance-data", help="instance specific data",
                        type=argparse.FileType('r'), required=True)
    parser.add_argument("--no-verify", action="store_true",
                        help="Skip DNS related checks")
    parser.add_argument("-v", "--verbose", action="store_const",
                        dest="log_level", const=logging.DEBUG,
                        default=logging.INFO,
                        help="Increase logging verbosity")
    parser.add_argument("-l", "--loaned-to", help="Loaner contact e-mail")
    parser.add_argument("-b", "--bug", help="Loaner bug number")
    parser.add_argument("hosts", metavar="host", nargs="+",
                        help="hosts to be processed")
    parser.add_argument("--create-ami", action="store_true",
                        help="Generate AMI and terminate the instance")
    parser.add_argument("--ignore-subnet-check", action="store_true",
                        help="Do not check subnet IDs")
    parser.add_argument("-t", "--copy-to-region", action="append", default=[],
                        dest="copy_to_regions", help="Regions to copy AMI to")
    parser.add_argument("--max-attempts",
                        help="The number of attempts to try after each failure"
                        )

    args = parser.parse_args()

    logging.basicConfig(format="%(asctime)s - %(levelname)s - %(message)s",
                        level=args.log_level)

    try:
        config = json.load(args.config)[args.region]
    except KeyError:
        parser.error("unknown configuration")
    if not os.path.exists(args.ssh_key):
        parser.error("Cannot read %s" % args.ssh_key)

    secrets = json.load(args.secrets)
    deploypass = secrets["deploy_password"]

    instance_data = json.load(args.instance_data)
    if not args.no_verify:
        log.info("Sanity checking DNS entries...")
        verify(args.hosts, config, args.region, args.ignore_subnet_check)
    make_instances(names=args.hosts, config=config, region=args.region,
                   key_name=args.key_name, ssh_key=args.ssh_key,
                   instance_data=instance_data, deploypass=deploypass,
                   loaned_to=args.loaned_to, loan_bug=args.bug,
                   create_ami=args.create_ami,
                   ignore_subnet_check=args.ignore_subnet_check,
                   max_attempts=args.max_attempts)
    for r in args.copy_to_regions:
        ami = get_ami(region=args.region, moz_instance_type=config["type"])
        log.info("Copying %s (%s) to %s", ami.id, ami.tags.get("Name"), r)
        new_ami = copy_ami(ami, r)
        log.info("New AMI created. AMI ID: %s", new_ami.id)