Package ZenModel :: Module XmlDataLoader
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.XmlDataLoader

 1  ########################################################################### 
 2  # 
 3  # This program is part of Zenoss Core, an open source monitoring platform. 
 4  # Copyright (C) 2007, Zenoss Inc. 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify it 
 7  # under the terms of the GNU General Public License version 2 as published by 
 8  # the Free Software Foundation. 
 9  # 
10  # For complete information please visit: http://www.zenoss.com/oss/ 
11  # 
12  ########################################################################### 
13  import os 
14  import transaction 
15  import Globals 
16   
17  from Products.ZenRelations.ImportRM import ImportRM 
18   
19 -class XmlDataLoader(ImportRM):
20
21 - def loadDatabase(self):
22 datadir = os.path.join(os.path.dirname(__file__),"data") 23 self.log.info("loading data from:%s", datadir) 24 for path, dirname, filenames in os.walk(datadir): 25 for filename in filter(lambda f: f.endswith(".xml"), filenames): 26 self.options.infile = os.path.join(path,filename) 27 self.log.info("loading: %s", self.options.infile) 28 ImportRM.loadDatabase(self) 29 # Reindex ProductKeys and EventClassKeys after XML load 30 self.dmd.Manufacturers.reIndex() 31 self.dmd.Events.reIndex() 32 transaction.commit()
33 34 35 if __name__ == "__main__": 36 rl = XmlDataLoader() 37 rl.loadDatabase() 38