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

Source Code for Module Products.ZenModel.XmlDataLoader

 1  ############################################################################## 
 2  #  
 3  # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 
 4  #  
 5  # This content is made available according to terms specified in 
 6  # License.zenoss under the directory where your Zenoss product is installed. 
 7  #  
 8  ############################################################################## 
 9   
10   
11  import os 
12  import transaction 
13  import Globals 
14   
15  from Products.ZenRelations.ImportRM import ImportRM 
16   
17 -class XmlDataLoader(ImportRM):
18
19 - def loadDatabase(self):
20 21 # This is an initial load, so we can forgo incremental commits 22 self.options.chunk_size = 0 23 24 datadir = os.path.join(os.path.dirname(__file__),"data") 25 self.log.info("loading data from:%s", datadir) 26 for path, dirname, filenames in os.walk(datadir): 27 filenames.sort() 28 for filename in filter(lambda f: f.endswith(".xml"), filenames): 29 self.options.infile = os.path.join(path,filename) 30 self.log.info("loading: %s", self.options.infile) 31 ImportRM.loadDatabase(self) 32 # Reindex ProductKeys and EventClassKeys after XML load 33 self.dmd.Manufacturers.reIndex() 34 self.dmd.Events.reIndex() 35 transaction.commit()
36 37 38 if __name__ == "__main__": 39 rl = XmlDataLoader() 40 rl.loadDatabase() 41