7 re-create the amqp client certificate – HP OneView User Manual

Page 224

Advertising
background image

channel.basic_ack(msg.delivery_tag)

#
# Cancel this callback
#
if msg.body == 'quit':
channel.basic_cancel(msg.consumer_tag)

def main():
parser = OptionParser()
parser.add_option('--host', dest='host',
help='AMQP server to connect to (default: %default)',
default='localhost',
)

options, args = parser.parse_args()
host = options.host+":5671"
# Pem Files needed, be sure to replace the \n returned from the APIs with CR/LF
# caroot.pem - the CA Root certificate - GET /rest/certificates/ca
# client.pem, first POST /rest/certificates/client/rabbitmq Request body:
{"type":"RabbitMqClientCert","commonName":"default"}
# GET /rest/certificates/client/rabbitmq/keypair/default
# client.pem is the key with -----BEGIN CERTIFICATE-----
# key.pem is the key with -----BEGIN RSA PRIVATE KEY-----

ssl_options = ({"ca_certs": "caroot.pem",
"certfile": "client.pem",
"keyfile": "key.pem",
# "cert_reqs": CERT_REQUIRED,
"server_side": False})

print ('Connecting to host %s, to change use --host hostName ' %host)

conn = amqp.Connection(host, login_method='EXTERNAL',
ssl=ssl_options)

print ('Successfully connected, creating and binding to queue')

ch = conn.channel()

qname, _, _ = ch.queue_declare()
ch.queue_bind(qname, 'scmb', 'scmb.#')
ch.basic_consume(qname, callback=partial(callback, ch))

print ('Successfully bound to queue, waiting for messages')

#pyamqp://

#
# Loop as long as the channel has callbacks registered
#
while ch.callbacks:
ch.wait()

ch.close()
conn.close()

if __name__ == '__main__':
main()

30.7 Re-create the AMQP client certificate

If you change the appliance name, you must re-create the AMQP client certificate.

224 Using the State-Change Message Bus (SCMB)

Advertising