python-tatuclient/doc/examples/zone_list_paging.py
sonu.kumar 866114dbf6 Replacing print with print() to provide py 2/3 compatibility
Replaced print in python 2 to print() to provide py 2/3 compatibility

Change-Id: I805ecdbdd07ea89c1595c045fc5b380f9bb42335
2015-07-20 15:01:42 +05:30

38 lines
840 B
Python

from __future__ import print_function
import logging
from keystoneclient.auth.identity import generic
from keystoneclient import session as keystone_session
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'),
tenant_name=shell.env('OS_TENANT_NAME'))
session = keystone_session.Session(auth=auth)
client = client.Client(session=session)
pages = []
fetch = 1
while fetch:
kw = {'limit': 3}
if pages:
# marker is the latest page with the last item.
kw['marker'] = pages[-1][-1]['id']
page = client.zones.list(**kw)
if not page:
break
pages.append(page)
for page in pages:
print(page)