]> git.proxmox.com Git - ceph.git/blob - ceph/examples/boto3/topic_with_endpoint.py
buildsys: change download over to reef release
[ceph.git] / ceph / examples / boto3 / topic_with_endpoint.py
1 #!/usr/bin/python
2
3 import boto3
4 import sys
5 import urlparse
6 from botocore.client import Config
7
8 if len(sys.argv) == 3:
9 # topic name as first argument
10 topic_name = sys.argv[1]
11 # region name as second argument
12 region_name = sys.argv[2]
13 elif len(sys.argv) == 2:
14 # topic name as first argument
15 topic_name = sys.argv[1]
16 region_name = ""
17 else:
18 print('Usage: ' + sys.argv[0] + ' <topic name> [region name]')
19 sys.exit(1)
20
21 # endpoint and keys from vstart
22 endpoint = 'http://127.0.0.1:8000'
23 access_key='0555b35654ad1656d804'
24 secret_key='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
25
26 client = boto3.client('sns',
27 endpoint_url=endpoint,
28 aws_access_key_id=access_key,
29 region_name=region_name,
30 aws_secret_access_key=secret_key,
31 config=Config(signature_version='s3'))
32
33 # to see the list of available "regions" use:
34 # radosgw-admin realm zonegroup list
35
36 # this is standard AWS services call, using custom attributes to add AMQP endpoint information to the topic
37
38 endpoint_args = 'push-endpoint=amqp://127.0.0.1:5672&amqp-exchange=ex1&amqp-ack-level=broker'
39 attributes = {nvp[0] : nvp[1] for nvp in urlparse.parse_qsl(endpoint_args, keep_blank_values=True)}
40
41 print(client.create_topic(Name=topic_name, Attributes=attributes))