python-designateclient/doc/examples/zone_create_secondary.py
Clenimar Filemon 69f4597bf1 Update doc examples to use keystoneauth
As keystoneclient's Session and auth plugins have been deprecated in
favor of keystoneauth, the documentation examples must reflect that.

This patch updates all examples in order to show keystoneauth Session
usage instead of deprecated keystoneclient Session. Also, the python API
bindings were updated too.

Change-Id: I4b64fee4f526cc5b4a5e36cc8edb61164ceded51
2016-05-06 21:06:04 -03:00

46 lines
1.0 KiB
Python

import logging
import uuid
from keystoneauth1.identity import generic
from keystoneauth1 import session as keystone_session
from designateclient import exceptions
from designateclient import shell
from designateclient.v2 import client
logging.basicConfig(level='DEBUG')
auth = generic.Password(
auth_url=shell.env('OS_AUTH_URL'),
username=shell.env('OS_USERNAME'),
password=shell.env('OS_PASSWORD'),
project_name=shell.env('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()