This commit is contained in:
Brandon Myers 2017-06-13 12:12:03 -05:00
Родитель 2b389b3e19
Коммит c632ed8250
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 8AA79AD83045BBC7
1 изменённых файлов: 5 добавлений и 7 удалений

Просмотреть файл

@ -9,7 +9,7 @@
# Brandon Myers bmyers@mozilla.com # Brandon Myers bmyers@mozilla.com
import os import os
from configlib import getConfig, OptionParser from configlib import getConfig
class message(object): class message(object):
@ -24,10 +24,8 @@ class message(object):
self.priority = 5 self.priority = 5
config_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "mozillaLocation.conf") config_location = os.path.join(os.path.dirname(os.path.abspath(__file__)), "mozillaLocation.conf")
parser = OptionParser() self.dc_code_list = getConfig('dc_code_list', '', config_location).split(',')
(self.options, args) = parser.parse_args() self.offices_code_list = getConfig('offices_code_list', '', config_location).split(',')
self.options.dc_code_list = getConfig('dc_code_list', '', config_location).split(',')
self.options.offices_code_list = getConfig('offices_code_list', '', config_location).split(',')
def onMessage(self, message, metadata): def onMessage(self, message, metadata):
if 'details' in message.keys() and 'hostname' in message['details'].keys(): if 'details' in message.keys() and 'hostname' in message['details'].keys():
@ -35,9 +33,9 @@ class message(object):
if len(hostnamesplit) == 5: if len(hostnamesplit) == 5:
if 'mozilla' == hostnamesplit[-2]: if 'mozilla' == hostnamesplit[-2]:
message['details']['site'] = hostnamesplit[-3] message['details']['site'] = hostnamesplit[-3]
if message['details']['site'] in self.options.dc_code_list: if message['details']['site'] in self.dc_code_list:
message['details']['sitetype'] = 'datacenter' message['details']['sitetype'] = 'datacenter'
elif message['details']['site'] in self.options.offices_code_list: elif message['details']['site'] in self.offices_code_list:
message['details']['sitetype'] = 'office' message['details']['sitetype'] = 'office'
else: else:
message['details']['sitetype'] = 'unknown' message['details']['sitetype'] = 'unknown'