
Result of running $ pyupgrade --py38-plus $(git ls-files | grep ".py$") This was inspired by Nova [1] and Octavia [2] Fixed PEP8 errors introduced by pyupgrade by running: $ autopep8 --select=E127,E128,E501 --max-line-length 79 -r \ --in-place designate and manual updates. [1]: https://review.opendev.org/c/openstack/nova/+/896986 [2]: https://review.opendev.org/c/openstack/octavia/+/899263 Change-Id: I27d09edb7e75081379002615f4ecdb1aa007dbcf
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
import logging
|
|
import os
|
|
|
|
from designateclient.v2 import client
|
|
from designateclient import exceptions
|
|
|
|
from keystoneauth1.identity import generic
|
|
from keystoneauth1 import session as keystone_session
|
|
|
|
|
|
logging.basicConfig(level='DEBUG')
|
|
|
|
"""
|
|
Example script to create or get a domain and add some records to it.
|
|
"""
|
|
|
|
|
|
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)
|
|
|
|
|
|
try:
|
|
zone = client.zones.create('i.io.', email='i@i.io')
|
|
except exceptions.RemoteError:
|
|
zone = {z['name']: z for z in client.zones.list()}['i.io.']
|
|
|
|
print("Recordset list...")
|
|
for rs in client.recordsets.list(zone['id']):
|
|
print(rs)
|
|
|
|
# Here's an example of just passing "www" as the record name vs "www.i.io."
|
|
records = ["10.0.0.1"]
|
|
rs = client.recordsets.create(zone['id'], 'www', 'A', records)
|
|
|
|
# Here we're replacing the records with new ones
|
|
records = ["10.0.0.1", "10.0.0.5"]
|
|
client.recordsets.update(zone['id'], rs['id'], {'records': records})
|