]>
git.proxmox.com Git - ceph.git/blob - ceph/examples/boto3/topic_with_endpoint.py
6 from botocore
.client
import Config
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]
18 print('Usage: ' + sys
.argv
[0] + ' <topic name> [region name]')
21 # endpoint and keys from vstart
22 endpoint
= 'http://127.0.0.1:8000'
23 access_key
='0555b35654ad1656d804'
24 secret_key
='h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
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'))
33 # to see the list of available "regions" use:
34 # radosgw-admin realm zonegroup list
36 # this is standard AWS services call, using custom attributes to add AMQP endpoint information to the topic
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)}
41 print(client
.create_topic(Name
=topic_name
, Attributes
=attributes
))