Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zoe
main
Commits
d7966968
Commit
d7966968
authored
Mar 10, 2017
by
Francesco Pace
Browse files
Add credentials to RabbitMQ connection
Signed-off-by:
Francesco Pace
<
pace.francesco.g@gmail.com
>
parent
bdb69a95
Changes
3
Show whitespace changes
Inline
Side-by-side
zoe_lib/applications.py
View file @
d7966968
...
...
@@ -198,7 +198,7 @@ def _storage_plugin_check(data):
def
_channel_check
(
data
):
required_keys
=
[
'protocol'
,
'host'
]
required_keys
=
[
'protocol'
,
'host'
,
'username'
,
'password'
]
for
k
in
required_keys
:
if
k
not
in
data
:
raise
InvalidApplicationDescription
(
msg
=
"Missing required key: %s"
%
k
)
...
...
zoe_master/plugins/connectors.py
View file @
d7966968
...
...
@@ -17,12 +17,15 @@ import pika
class
RabbitMQ
:
def
__init__
(
self
,
host
):
def
__init__
(
self
,
username
,
password
,
host
):
self
.
username
=
username
self
.
password
=
password
self
.
host
=
host
self
.
channel
=
None
def
open_connection
(
self
):
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
self
.
host
))
credentials
=
pika
.
PlainCredentials
(
self
.
username
,
self
.
password
)
connection
=
pika
.
BlockingConnection
(
pika
.
ConnectionParameters
(
self
.
host
,
credentials
=
credentials
))
self
.
channel
=
connection
.
channel
()
def
send_message
(
self
,
queue
,
message
):
...
...
zoe_master/plugins/storage/crystal.py
View file @
d7966968
...
...
@@ -23,7 +23,7 @@ class Crystal:
def
transmit_policy
(
self
,
tenant
,
policy
):
message
=
"{}:{}"
.
format
(
tenant
,
policy
)
if
self
.
channel
[
'protocol'
]
is
'rabbitmq'
:
rmq
=
RabbitMQ
(
self
.
channel
[
'host'
])
rmq
=
RabbitMQ
(
self
.
channel
[
'username'
],
self
.
channel
[
'password'
],
self
.
channel
[
'host'
])
rmq
.
open_connection
()
rmq
.
send_message
(
self
.
channel
[
'queue'
],
message
)
rmq
.
close_connection
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment