-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract_all.py
54 lines (44 loc) · 1.81 KB
/
extract_all.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from extract_excel import ExtractExcel
from extract_oem import ExtractOEM11G
from extract_ops import ExtractOPS
from extract_vcenter import ExtractVcenter
from extract_zabbix import ExtractZabbix
from pymongo import MongoClient
import logging
from logging.config import fileConfig
import configparser
fileConfig('logger_config.ini')
logger=logging.getLogger('infoLogger')
class ExtractAll():
def __init__(self):
self.cfg = configparser.ConfigParser()
self.cfg.read("config.ini")
cmdb_db = self.cfg.get("cmdb","db")
cmdb_str = self.cfg.get("cmdb","conn_str")
self.client = MongoClient(cmdb_str)
self.db = self.client[cmdb_db]
def truncate_cmdb(self, coll_name):
coll = self.db[coll_name]
result = coll.delete_many({})
logging.info("%s deleted %s" % (coll_name, str(result.deleted_count)))
def main(self):
coll_list = ['excel_server','excel_storage','excel_network','oem_server','oem_database','ops_database','vcenter_server','vcenter_virtualmachine','vcenter_logicalvolume','zabbix_weblogic','zabbix_oc4j','zabbix_solr','zabbix_bw','zabbix_ems','zabbix_nginx','zabbix_ohs','zabbix_spotfirewebplayer','zabbix_spotfire','zabbix_gfs','zabbix_zookeeper','zabbix_others']
logger.info('start clear cmdb collections')
for coll in coll_list:
self.truncate_cmdb(coll)
logger.info('end clear cmdb collections')
logger.info('start extract cmdb collections')
ex = ExtractExcel()
ex.main()
oem = ExtractOEM11G()
oem.main()
ops = ExtractOPS()
ops.main()
vc = ExtractVcenter()
vc.main()
zb = ExtractZabbix()
zb.main()
logger.info('end extract cmdb collections')
if __name__ == '__main__':
ext = ExtractAll()
ext.main()