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
335145a6
Commit
335145a6
authored
Mar 10, 2017
by
Francesco Pace
Browse files
Add debug log messages
Signed-off-by:
Francesco Pace
<
pace.francesco.g@gmail.com
>
parent
be2421e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
zoe_master/plugins/connectors.py
View file @
335145a6
...
...
@@ -12,10 +12,13 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
logging
import
pika
log
=
logging
.
getLogger
(
__name__
)
class
RabbitMQ
:
def
__init__
(
self
,
username
,
password
,
host
):
self
.
username
=
username
...
...
@@ -24,11 +27,13 @@ class RabbitMQ:
self
.
channel
=
None
def
open_connection
(
self
):
log
.
debug
(
"Opening connection to RabbitMQ: {}"
.
format
(
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
):
log
.
debug
(
"Sending message to RabbitMQ. Message -> {} // Queue -> {}"
.
format
(
message
,
queue
))
self
.
channel
.
basic_publish
(
exchange
=
''
,
routing_key
=
queue
,
body
=
message
)
...
...
zoe_master/plugins/storage/crystal.py
View file @
335145a6
...
...
@@ -12,9 +12,12 @@
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
logging
from
zoe_master.plugins.connectors
import
RabbitMQ
log
=
logging
.
getLogger
(
__name__
)
class
Crystal
:
def
__init__
(
self
,
channel
):
...
...
@@ -23,6 +26,7 @@ class Crystal:
def
transmit_policy
(
self
,
tenant
,
policy
):
message
=
"{}:{}"
.
format
(
tenant
,
policy
)
if
self
.
channel
[
'protocol'
]
is
'rabbitmq'
:
log
.
debug
(
"Transmitting policy to Crystal via RabbitMQ"
)
rmq
=
RabbitMQ
(
self
.
channel
[
'username'
],
self
.
channel
[
'password'
],
self
.
channel
[
'host'
])
rmq
.
open_connection
()
rmq
.
send_message
(
self
.
channel
[
'queue'
],
message
)
...
...
zoe_master/scheduler/scheduler.py
View file @
335145a6
...
...
@@ -113,6 +113,7 @@ class ZoeSimpleScheduler(ZoeBaseScheduler):
if
'storage'
in
plugins
:
for
plugin
in
plugins
[
'storage'
]:
if
plugin
[
'name'
]
is
'crystal'
:
log
.
debug
(
"Transmitting policy to Storage Plugin: Crystal"
)
Crystal
(
plugin
[
'channel'
]).
transmit_policy
(
plugin
[
'tenant'
],
plugin
[
'policy'
])
except
ZoeStartExecutionRetryException
as
ex
:
...
...
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