Python boto 模块,route53() 实例源码

我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用boto.route53()

项目:paas-tools    作者:imperodesign    | 项目源码 | 文件源码
def create_cname(args):
    conn = boto.route53.connect_to_region(args['--region'])
    zone = conn.get_zone(args['<zone>'])
    name = args['<name>']
    status = zone.add_cname(name, args['<value>'], ttl=args['--ttl'])
    print("waiting for record to sync: {}".format(status))
    while status.update() != "INSYNC":
        time.sleep(2)
    print(status)
    print('waiting for wildcard domain to become available...', end='')
    # AWS docs say it can take up to 30 minutes for route53 changes to happen, although
    # it seems to be almost immediate.
    for i in xrange(120):
        try:
            random_hostname = str(uuid.uuid4())[:8]
            if socket.gethostbyname("{}.{}".format(random_hostname, name)):
                print('ok')
                break
        except socket.gaierror:
            time.sleep(15)
项目:paas-tools    作者:imperodesign    | 项目源码 | 文件源码
def create_cname(args):
    conn = boto.route53.connect_to_region(args['--region'])
    zone = conn.get_zone(args['<zone>'])
    name = args['<name>']
    status = zone.add_cname(name, args['<value>'], ttl=args['--ttl'])
    print("waiting for record to sync: {}".format(status))
    while status.update() != "INSYNC":
        time.sleep(2)
    print(status)
    print('waiting for wildcard domain to become available...', end='')
    # AWS docs say it can take up to 30 minutes for route53 changes to happen, although
    # it seems to be almost immediate.
    for i in xrange(120):
        try:
            random_hostname = str(uuid.uuid4())[:8]
            if socket.gethostbyname("{}.{}".format(random_hostname, name)):
                print('ok')
                break
        except socket.gaierror:
            time.sleep(15)
项目:paas-tools    作者:imperodesign    | 项目源码 | 文件源码
def delete_cname(args, block=False):
    conn = boto.route53.connect_to_region(args['--region'])
    zone = conn.get_zone(args['<zone>'])
    status = zone.delete_cname(args['<name>'])
    if block:
        print("waiting for record to sync: {}".format(status))
        while status.update() != "INSYNC":
            time.sleep(2)
        print(status)
项目:paas-tools    作者:imperodesign    | 项目源码 | 文件源码
def delete_cname(args, block=False):
    conn = boto.route53.connect_to_region(args['--region'])
    zone = conn.get_zone(args['<zone>'])
    status = zone.delete_cname(args['<name>'])
    if block:
        print("waiting for record to sync: {}".format(status))
        while status.update() != "INSYNC":
            time.sleep(2)
        print(status)
项目:cuny-bdif    作者:aristotle-tek    | 项目源码 | 文件源码
def _required_auth_capability(self):
        return ['route53']
项目:DevOps    作者:YoLoveLife    | 项目源码 | 文件源码
def commit(changes, retry_interval, wait, wait_timeout):
    """Commit changes, but retry PriorRequestNotComplete errors."""
    result = None
    retry = 10
    while True:
        try:
            retry -= 1
            result = changes.commit()
            break
        except boto.route53.exception.DNSServerError as e:
            code = e.body.split("<Code>")[1]
            code = code.split("</Code>")[0]
            if code != 'PriorRequestNotComplete' or retry < 0:
                raise e
            time.sleep(float(retry_interval))

    if wait:
        timeout_time = time.time() + wait_timeout
        connection = changes.connection
        change = result['ChangeResourceRecordSetsResponse']['ChangeInfo']
        status = Status(connection, change)
        while status.status != 'INSYNC' and time.time() < timeout_time:
            time.sleep(WAIT_RETRY_SLEEP)
            status.update()
        if time.time() >= timeout_time:
            raise TimeoutError()
        return result

# Shamelessly copied over from https://git.io/vgmDG
项目:learneveryword    作者:karan    | 项目源码 | 文件源码
def _required_auth_capability(self):
        return ['route53']
项目:alfred-ec2    作者:SoMuchToGrok    | 项目源码 | 文件源码
def _required_auth_capability(self):
        return ['route53']
项目:ansible-roles-route53    作者:danvaida    | 项目源码 | 文件源码
def main():
    argument_spec = ec2_argument_spec()
    argument_spec.update(dict(
        zone=dict(required=True),
        state=dict(default='present', choices=['present', 'absent']),
        vpc_id=dict(default=None),
        vpc_region=dict(default=None),
        comment=dict(default=''),
        hosted_zone_id=dict()))
    module = AnsibleModule(argument_spec=argument_spec)

    if not HAS_BOTO:
        module.fail_json(msg='boto required for this module')

    zone_in = module.params.get('zone').lower()
    state = module.params.get('state').lower()
    vpc_id = module.params.get('vpc_id')
    vpc_region = module.params.get('vpc_region')

    if not zone_in.endswith('.'):
        zone_in += "."

    private_zone = bool(vpc_id and vpc_region)

    _, _, aws_connect_kwargs = get_aws_connection_info(module)

    # connect to the route53 endpoint
    try:
        conn = Route53Connection(**aws_connect_kwargs)
    except boto.exception.BotoServerError as e:
        module.fail_json(msg=e.error_message)

    zones = find_zones(conn, zone_in, private_zone)
    if state == 'present':
        changed, result = create(conn, module, matching_zones=zones)
    elif state == 'absent':
        changed, result = delete(conn, module, matching_zones=zones)

    module.exit_json(changed=changed, result=result)