Commit 335145a6 authored by Francesco Pace's avatar Francesco Pace
Browse files

Add debug log messages


Signed-off-by: default avatarFrancesco Pace <pace.francesco.g@gmail.com>
parent be2421e6
......@@ -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)
......
......@@ -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)
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment