Using v2 interface in example

This patch revises examples to use v2 interface which
is long-term supported.

Change-Id: I66fe67e1a1e81c092b2f37eaa6d2ad11f6166e22
This commit is contained in:
yanyanhu 2016-09-05 02:48:30 -04:00
parent 03fe685473
commit ad370a3e55
4 changed files with 16 additions and 5 deletions

View File

@ -15,10 +15,13 @@
import time
from zaqarclient.queues.v1 import client
from zaqarclient.queues.v2 import client
URL = 'http://localhost:8888'
# Note: credential information should be provided using `conf`
# keyword argument if authentication is enabled at server side.
# Please refer to keystone_auth.py for more information.
cli = client.Client(URL)
queue = cli.queue('worker-jobs')

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from zaqarclient.queues.v1 import client
from zaqarclient.queues.v2 import client
URL = 'http://localhost:8888'

View File

@ -18,7 +18,11 @@ URL = 'http://localhost:8888'
def healthy():
cli = client.Client(url=URL, version=1)
# Note: credential information should be provided
# using `conf` keyword argument if authentication
# is enabled at server side. Please refer to
# keystone_auth.py for more information.
cli = client.Client(url=URL, version=2)
return True if cli.health() else False
if __name__ == '__main__':

View File

@ -14,7 +14,7 @@
# NOTE(flaper87): Client should be moved to
# an upper package. It's version agnostic.
from zaqarclient.queues.v1 import client
from zaqarclient.queues.v2 import client
URL = 'http://localhost:8888'
@ -30,7 +30,11 @@ def create_post_delete(queue_name, messages):
:params messages: Messages to post.
:type messages: list
"""
cli = client.Client(URL, version=1.1)
# Note: credential information should be provided
# using `conf` keyword argument if authentication
# is enabled at server side. Please refer to
# keystone_auth.py for more information.
cli = client.Client(URL, version=2)
queue = cli.queue(queue_name)
queue.post(messages)