Exemplo n.º 1
0
def list_changes(project_id, zone_name):
    client = dns.Client(project=project_id)
    zone = client.zone(zone_name, None)

    changes, _ = zone.list_changes()

    return [(change.started, change.status) for change in changes]
Exemplo n.º 2
0
def client(cloud_config):
    client = dns.Client(cloud_config.project)

    yield client

    # Delete anything created during the test.
    for zone in client.list_zones()[0]:
        zone.delete()
Exemplo n.º 3
0
def create_zone(project_id, name, dns_name, description):
    client = dns.Client(project=project_id)
    zone = client.zone(
        name,  # examplezonename
        dns_name=dns_name)  # example.com.
    zone.description = description
    zone.create()
    return zone
Exemplo n.º 4
0
def get_zone(project_id, name):
    client = dns.Client(project=project_id)
    zone = client.zone(name=name)

    try:
        zone.reload()
        return zone
    except NotFound:
        return None
Exemplo n.º 5
0
def list_resource_records(project_id, zone_name):
    client = dns.Client(project=project_id)
    zone = client.zone(zone_name, None)

    records, page_token = zone.list_resource_record_sets()
    while page_token is not None:
        next_batch, page_token = zone.list_resource_record_sets(
            page_token=page_token)
        records.extend(next_batch)

    return [(record.name, record.record_type, record.ttl, record.rrdatas)
            for record in records]
Exemplo n.º 6
0
def delete_zone(project_id, name):
    client = dns.Client(project=project_id)
    zone = client.zone(name, None)
    zone.delete()
Exemplo n.º 7
0
def list_zones(project_id):
    client = dns.Client(project=project_id)
    zones, _ = client.list_zones()
    return [zone.name for zone in zones]
Exemplo n.º 8
0
def get_zone(project_id, name):
    client = dns.Client(project=project_id)
    zones, _ = client.list_zones()
    zone = list(filter(lambda zone: zone.name == name, zones))
    return zone.pop() if zone else None