python-designateclient/doc/examples/zone_create_secondary.py
Erik Olof Gunnar Andersson 093d8d7170 Removing v1 api support
The v1 has officially been removed from Designate since
the Queens release, and was deperecated long before that.

Change-Id: Ic5b44761ff939e2b319924af87849b3a79f9cb07
2019-09-10 20:53:25 -07:00

45 lines
1012 B
Python

import logging
import os
import uuid
from keystoneauth1.identity import generic
from keystoneauth1 import session as keystone_session
from designateclient.v2 import client
logging.basicConfig(level='DEBUG')
auth = generic.Password(
auth_url=os.environ.get('OS_AUTH_URL'),
username=os.environ.get('OS_USERNAME'),
password=os.environ.get('OS_PASSWORD'),
project_name=os.environ.get('OS_PROJECT_NAME'),
project_domain_id='default',
user_domain_id='default')
session = keystone_session.Session(auth=auth)
client = client.Client(session=session)
# Primary Zone
primary = client.zones.create(
'primary-%s.io.' % str(uuid.uuid4()),
'PRIMARY',
'root@x.com')
# Secondary Zone
slave = client.zones.create(
'secondary-%s.io.' % str(uuid.uuid4()),
'SECONDARY',
masters=["127.0.1.1"])
# Try updating Masters for the Secondary
new_slave = client.zones.update(
slave['id'],
{"masters": ["10.0.0.1", "10.0.0.10"]}
)
# List all Zones
zones = client.zones.list()