Merge "Add python-zaqarclient to python runtime"

This commit is contained in:
Zuul 2017-11-01 20:49:38 +00:00 committed by Gerrit Code Review
commit b2d82ee744
3 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,45 @@
import os
import requests
from zaqarclient.queues import client
def _send_message(z_client, queue_name, status, message=''):
queue_name = queue_name or 'test_queue'
queue = z_client.queue(queue_name)
queue.post({"body": {'status': status, 'message': message}})
print 'message posted.'
def check_and_trigger(context, **kwargs):
file_name = 'count.txt'
r = requests.get('http://httpbin.org/status/500')
if r.status_code != requests.codes.ok:
if not os.path.isfile(file_name):
count = 1
with open(file_name, 'w') as f:
f.write(str(count))
else:
with open(file_name, 'r+') as f:
count = int(f.readline())
count += 1
if count >= 3:
z_client = client.Client(
session=context['os_session'],
version=2,
)
_send_message(z_client, kwargs.get('queue'), r.status_code,
'Service Not Available!')
count = 0
f.seek(0)
f.write(str(count))
f.truncate()
print('new count: %s' % count)
else:
try:
os.remove(file_name)
except OSError:
pass

View File

@ -3,4 +3,7 @@ python-openstackclient>=3.3.0,!=3.10.0 # Apache-2.0
python-neutronclient>=6.3.0 # Apache-2.0
python-swiftclient>=3.2.0 # Apache-2.0
python-ceilometerclient>=2.5.0 # Apache-2.0
python-zaqarclient>=1.0.0 # Apache-2.0
python-octaviaclient>=1.0.0 # Apache-2.0
python-mistralclient>=3.1.0 # Apache-2.0
keystoneauth1>=2.21.0 # Apache-2.0

View File

@ -34,4 +34,4 @@ function delete_resources(){
fi
}
delete_resources
delete_resources $1