openstack-ansible/scripts/rabbitmq-test.py
Jean-Philippe Evrard edc3476b67 Add infra healthchecks
This adds a playbook, oriented for users, to automatically test
their installation after the setup infrastructure test.

These are connectivity tests to the infrastructure, and ensure
that containers would behave properly when running the openstack
playbooks.

These are based on the general assumption that ppl would use
a container management network.

Change-Id: Idb331dd6a72439c838708216500039f628b2760c
2017-11-02 18:29:16 +00:00

48 lines
1.5 KiB
Python
Executable File

#!/usr/bin/env python
#
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# (c) 2017, Jean-Philippe Evrard <jean-philippe.evrard@rackspace.co.uk>
#
"""Tests rabbitmq with our hardcoded test credentials"""
import argparse
import sys
try:
import pika
except Exception:
sys.exit("Can't import pika")
def rabbitmq_connect(ip=None):
"""Connects to ip using standard port and credentials."""
credentials = pika.credentials.PlainCredentials('testguest', 'secrete')
parameters = pika.ConnectionParameters(
host=ip, virtual_host='/test', credentials=credentials)
try:
connection = pika.BlockingConnection(parameters)
connection.channel()
except Exception:
sys.exit("Can't connect to %s" % ip)
else:
print("Connected.")
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("ip", help="The IP to connect to")
args = parser.parse_args()
rabbitmq_connect(args.ip)