Make the server more flexible with configuration files

The server can only find files in /etc/kiloeyes directory. This
patch set will allow a configuration file to be specified at
the command line

Change-Id: Ie8128048f5ea958595c49a375ff56825c89efe0c
This commit is contained in:
Tong Li 2015-09-22 18:54:17 -04:00
parent 207c762df6
commit fb786600f4
4 changed files with 17 additions and 5 deletions

View File

@ -38,9 +38,14 @@ def api_app(conf):
constant.KILOEYES_LOG_LEVELS)
log.register_options(cfg.CONF)
cfg.CONF(args=[], project='kiloeyes')
if conf.get('name'):
name = conf.get('name')
else:
name = 'kiloeyes'
log.setup(cfg.CONF, 'kiloeyes')
cfg.CONF(args=[], project=name)
log.setup(cfg.CONF, name)
dispatcher_manager = named.NamedExtensionManager(
namespace=namespace.DISPATCHER_NS,

View File

@ -92,6 +92,8 @@ class ESConnection(object):
data = json.dumps(cond)
else:
data = {}
LOG.debug('The request path:%s?%s' % (self.search_path, q_string))
return requests.post(self.search_path + "?" + q_string, data=data)
def get_message_by_id(self, id):
@ -111,6 +113,8 @@ class ESConnection(object):
path = '%s%s%s/%s/' % (self.uri, self.index_prefix,
index, self.doc_type)
LOG.debug('The request path:%s' % path)
res = requests.post(path + id, data=msg)
LOG.debug('Msg post with response code: %s' % res.status_code)
return res.status_code

View File

@ -92,12 +92,15 @@ class AlarmDispatcher(object):
params = ('{"aggs": {"latest_state": {'
'"terms": {"field": "alarm_definition.name", "size": 0},'
'"aggs": {"top_state_hits": {"top_hits": {"sort": ['
'{"updated_timestamp": {"order": "desc"}}],'
'{"updated_timestamp": {"order": "desc", '
'"ignore_unmapped": true}}],'
'"_source": {"include": ['
'"state", "created_timestamp","updated_timestamp",'
'"metrics","sub_alarms","state_updated_timestamp",'
'"id", "alarm_definition"]},"size" : 1}}}}}}')
LOG.debug("params= %s" % params)
es_res = self._es_conn.get_messages(json.loads(params),
q_string='search_type=count')
res.status = getattr(falcon, 'HTTP_%s' % es_res.status_code)
@ -110,7 +113,7 @@ class AlarmDispatcher(object):
res.body = ''
result_elements = []
try:
if es_res["latest_state"]:
if es_res and es_res.get("latest_state"):
res_data = es_res["latest_state"]["buckets"]
res.body = '['
for bucket in res_data:

View File

@ -1,6 +1,6 @@
service_id=`keystone service-create --name=monitoring --type=monitoring --description="Kiloeyes monitoring service" | awk 'BEGIN {FS="|"} NR == 6 {print $(NF-1)}'`
service_id=`echo ${service_id}`
echo $service_id
keystone endpoint-create --region RegionOne --service-id=$service_id --publicurl=http://192.168.1.190:9090/v2.0 --internalurl=http://192.168.1.190:9090/v2.0 --adminurl=http://192.168.1.190/v2.0
keystone endpoint-create --region RegionOne --service-id=$service_id --publicurl=http://192.168.56.180:9090/v2.0 --internalurl=http://192.168.56.180:9090/v2.0 --adminurl=http://192.168.56.180/v2.0