def do_GET(self):
"""Get request functionality."""
self._set_headers()
- self.wfile.write("<html><body><h1>hi!</h1></body></html>")
def do_POST(self):
"""POST request function."""
post_data = post_data.decode()
except AttributeError:
pass
- self.wfile.write("<html><body><h1>POST!</h1></body></tml>")
log.info("This alarm was triggered: %s", json.loads(post_data))
# Generate a notify_alarm response for the SO
sev=values['severity'], date=a_date,
state=values['current'], vim_type="openstack")
producer.notify_alarm(
- 'notify_alarm', resp_message, 'alarm_response')
+ 'notify_alarm', resp_message)
log.info("Sent an alarm response to SO: %s", resp_message)
except Exception as exc:
log.exception("Couldn't notify SO of the alarm:")
[ "$_DISTRO" == "CentOS" -o "$_DISTRO" == "Red" ] && easy_install -U bottle
#required for vmware connector TODO move that to separete opt in install script
-sudo pip install --upgrade pip
-sudo pip install cherrypy
+pip install --upgrade pip
+pip install cherrypy
echo '
#################################################################
LABEL authors="Benjamín Díaz"
-ADD . /policy_module
-
RUN apt-get --yes update \
- && apt-get --yes install software-properties-common python-software-properties \
- && apt-get --yes install git python python-pip sudo libmysqlclient-dev libxext-dev libxrender-dev libxtst-dev \
- && pip install pip==9.0.3 \
- && pip install -r /policy_module/requirements.txt \
- && pip install /policy_module
+ && apt-get --yes install python3 python3-pip libmysqlclient-dev \
+ && pip3 install pip==9.0.3
+
+COPY requirements.txt /policy_module/requirements.txt
+
+RUN pip3 install -r /policy_module/requirements.txt
+
+COPY . /policy_module
+
+RUN pip3 install /policy_module
CMD bash /policy_module/scripts/gen_config_from_env.sh && osm-policy-agent --config osm_policy_agent.cfg
import argparse
import logging
import sys
+import logstash
from osm_policy_module.core.agent import PolicyModuleAgent
from osm_policy_module.core.config import Config
format='%(asctime)s %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p', filemode='a',
level=logging.INFO)
+ if cfg.get('policy_module', 'enable_logstash_handler') == 'true':
+ logstash_host = cfg.get('policy_module', 'logstash_host')
+ logstash_port = int(cfg.get('policy_module', 'logstash_port'))
+ root_logger = logging.getLogger()
+ root_logger.addHandler(logstash.TCPLogstashHandler(logstash_host, logstash_port, version=1))
+ root_logger.info("Logstash handler configured.")
log = logging.getLogger(__name__)
+ log.info("Config: %s", cfg)
log.info("Syncing database...")
db_manager = DatabaseManager()
db_manager.create_tables()
+ log.info("Database synced correctly.")
log.info("Starting policy module agent...")
agent = PolicyModuleAgent()
agent.run()
'kafka_server_host': '127.0.0.1',
'kafka_server_port': '9092',
'log_dir': 'stdout',
- 'log_level': 'INFO'
+ 'log_level': 'INFO',
+ 'enable_logstash_handler': 'false',
+ 'logstash_host': 'logstash',
+ 'logstash_port': '5000'
},
}
return self.config[group]
return self.config[group].get(name, default)
return default
+
+ def __str__(self):
+ return str(self.config)
kafka==1.3.*
peewee==3.1.*
jsonschema==2.6.*
-six
-pyyaml
\ No newline at end of file
+six==1.11.*
+pyyaml==3.*
+python-logstash==0.4.*
\ No newline at end of file
PORT=$(echo $BROKER_URI | cut -d: -f2)
echo "kafka_server_host=$HOST" >> $CONFIG_FILENAME
echo "kafka_server_port=$PORT" >> $CONFIG_FILENAME
+fi
+if ! [[ -z "${LOGSTASH_URI}" ]]; then
+ HOST=$(echo $LOGSTASH_URI | cut -d: -f1)
+ PORT=$(echo $LOGSTASH_URI | cut -d: -f2)
+ echo "enable_logstash_handler=true" >> $CONFIG_FILENAME
+ echo "logstash_host=$HOST" >> $CONFIG_FILENAME
+ echo "logstash_port=$PORT" >> $CONFIG_FILENAME
fi
\ No newline at end of file