Beispiel #1
0
def main(arguments):
    """main function"""

    client = get_client()

    zones = []
    for zone_name in arguments[1:]:
        zone_name = dns.name.from_text(zone_name)
        print("Creating zone: {}".format(zone_name))
        try:
            zoneid, ns_set, caller_ref, change_info = create_zone(
                client, zone_name.to_text())
            _ = change_info
        except (R53Error, ClientError) as error:
            print("ERROR:", error)
            continue
        zone = Zone(zone_name, zoneid, ns_set, caller_ref)
        zones.append(zone)
        zone.info()

    for parentzone, childzone in delegation_list(zones):
        print("Creating delegation: {} -> {}".format(parentzone.name,
                                                     childzone.name))
        add_delegation(client, parentzone, childzone)
Beispiel #2
0
    createpubzone.py foopublic.test

"""

import os
import sys
import time
import botocore
from r53utils import (get_client, create_zone, wait_for_insync, R53Error)

if __name__ == '__main__':

    if len(sys.argv) != 2:
        print("Usage: {} <zonename>".format(os.path.basename(sys.argv[0])))
        sys.exit(1)

    zonename = sys.argv[1]

    client = get_client()
    print("Creating zone: {}".format(zonename))
    try:
        zoneid, _, caller_ref, change_info = create_zone(client, zonename)
    except (R53Error, botocore.exceptions.ClientError) as err:
        print("ERROR:", err)
    else:
        print("Zone created. Waiting for IN-SYNC ...")
        t0 = time.time()
        wait_for_insync(client, change_info['Id'], polltime=3)
        elapsed = time.time() - t0
        print("Time to IN-SYNC: {:.2f}s".format(elapsed))