#!/usr/bin/env python
# -*- coding: utf-8 -*-
#config.py for Config File in /home/loic/GitHub/Moustash/moustash
#
#Made by Loic Tosser, Findspire.com
#Login   <loic@wowi.io>
#
#

import ConfigParser
import redis
from utils import config_section_map

class Franck:
    def __init__(self, config_file):
        self.config = ConfigParser.ConfigParser()
        self.config.read(config_file)
        self.moustash_config = {}
        self.moustash_config["Moustash"] = config_section_map(self.config, "Moustash")
        self.moustash_config["Cuir"] = config_section_map(self.config, "Cuir")
        if self.moustash_config["Moustash"]["transport"] == "redis":
            self.broker = self.connect_to_redis()
            redis_namespace = "moustash"
            if "redis_namespace" in self.moustash_config["Moustash"]:
                redis_namespace = self.moustash_config["Moustash"]["redis_namespace"]
            self.broker_namespace = redis_namespace
        else:
            print("Not yet implemented : %s !" % moustash_config["Moustash"]["transport"])
    
    def connect_to_redis(self):
        redis_ip = "127.0.0.1"
        redis_port = "6379"
        redis_db = "0"
        if "redis_ip" in self.moustash_config["Moustash"]:
            redis_ip = self.moustash_config["Moustash"]["redis_ip"]
        if "redis_port" in self.moustash_config["Moustash"]:
            redis_port = self.moustash_config["Moustash"]["redis_port"]
        if "redis_db" in self.moustash_config["Moustash"]:
            redis_db = self.moustash_config["Moustash"]["redis_db"]
        r = redis.StrictRedis(host=redis_ip, port=int(redis_port), db=int(redis_db))
        return r

    def push_moustash(self, json_message):
        if self.moustash_config["Moustash"]["transport"] == "redis":
            self.broker.rpush(self.broker_namespace, json_message)


@@ -950,16 +950,1130 @@
 mespace%0A
+        else if self.moustash_config%5B%22Moustash%22%5D%5B%22transport%22%5D == %22rabbitmq%22:%0A            self.broker = %7B%7D%0A            rabbitmq_parameters = %7B%22rabbitmq_host%22 : %22localhost%22, %22rabbitmq_port%22: %225672%22, %22rabbitmq_ssl%22 : %220%22, %22rabbitmq_ssl_key%22 = None, %0A                                   %22rabbitmq_ssl_cert%22 = None, %22rabbitmq_ssl_cacert%22 = None, %22rabbitmq_vhost%22 = %22/%22, %22rabbitmq_username%22 = %22guest%22,%0A                                   %22rabbitmq_password%22 = %22guest%22, %22rabbitmq_queue%22 = %22logstash-queue%22, %22rabbitmq_queue_durable%22 = %220%22,%0A                                   %22rabbitmq_exchange_type%22 = %22direct%22, %22rabbitmq_exchange_durable%22 = %220%22, %22rabbitmq_key%22 = %22logstash-key%22,%0A                                   %22rabbitmq_exchange%22 = %22logstash-exchange%22%7D%0A            for rabbitmq_options, rabbitmq_options_value in rabbitmq_parameters.iteritems():%0A                if rabbitmq_options in self.moustash_config%5B%22Moustash%22%5D:%0A                    self.broker%5Brabbitmq_options%5D = self.moustash_config%5B%22Moustash%22%5D%5Brabbitmq_options%5D%0A                else:%0A                    self.broker%5Brabbitmq_options%5D = rabbitmq_options_value%0A
         

Add base rabbitmq in the transporter