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

Source Code for Module ZenModel.zenbuild

  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   
 14  __doc__="""zenbuild 
 15   
 16  Build the zentinel portal object and the dmd database 
 17   
 18  $Id: DmdBuilder.py,v 1.11 2004/04/06 22:33:07 edahl Exp $""" 
 19   
 20  __version__ = "$Revision: 1.11 $"[11:-2] 
 21   
 22  import Globals 
 23  import transaction 
 24   
 25  from Products.ZenUtils.Utils import zenPath 
 26   
 27  from Products.ZenUtils import Security 
 28  from Products.ZenUtils.CmdBase import CmdBase 
 29  from Products.PluggableAuthService import plugins 
 30   
31 -class zenbuild(CmdBase):
32 33 sitename = "zport" 34
35 - def __init__(self):
36 CmdBase.__init__(self) 37 zopeconf = zenPath("etc/zope.conf") 38 import Zope2 39 Zope2.configure(zopeconf) 40 self.app = Zope2.app()
41 42
43 - def buildOptions(self):
44 CmdBase.buildOptions(self) 45 self.parser.add_option('-s','--evthost', dest="evthost", 46 default="127.0.0.1", help="events database hostname") 47 self.parser.add_option('-u','--evtuser', dest="evtuser", default="root", 48 help="username used to connect to the events database") 49 self.parser.add_option('-p','--evtpass', dest="evtpass", default="", 50 help="password used to connect to the events database") 51 self.parser.add_option('-d','--evtdb', dest="evtdb", default="events", 52 help="name of events database") 53 self.parser.add_option('-t','--evtport', dest="evtport", 54 type='int', default=3306, 55 help="port used to connect to the events database") 56 self.parser.add_option('--smtphost', dest="smtphost", default="localhost", 57 help="smtp host") 58 self.parser.add_option('--smtpport', dest="smtpport", default=25, 59 help="smtp port") 60 self.parser.add_option('--pagecommand', dest="pagecommand", default="$ZENHOME/bin/zensnpp localhost 444 $RECIPIENT", 61 help="page command")
62
63 - def build(self):
64 site = getattr(self.app, self.sitename, None) 65 if site is not None: 66 print "zport portal object exits; exiting." 67 return 68 69 from Products.ZenModel.ZentinelPortal import manage_addZentinelPortal 70 manage_addZentinelPortal(self.app, self.sitename) 71 site = self.app._getOb(self.sitename) 72 73 # build index_html 74 if self.app.hasObject('index_html'): 75 self.app._delObject('index_html') 76 from Products.PythonScripts.PythonScript import manage_addPythonScript 77 manage_addPythonScript(self.app, 'index_html') 78 newIndexHtml = self.app._getOb('index_html') 79 text = 'container.REQUEST.RESPONSE.redirect("/zport/dmd/")\n' 80 newIndexHtml.ZPythonScript_edit('', text) 81 82 # build standard_error_message 83 if self.app.hasObject('standard_error_message'): 84 self.app._delObject('standard_error_message') 85 file = open(zenPath('Products/ZenModel/dtml/standard_error_message.dtml')) 86 try: 87 text = file.read() 88 finally: 89 file.close() 90 import OFS.DTMLMethod 91 OFS.DTMLMethod.addDTMLMethod(self.app, id='standard_error_message', 92 file=text) 93 94 # Convert the acl_users folder at the root to a PAS folder and update 95 # the login form to use the Zenoss login form 96 Security.replaceACLWithPAS(self.app, deleteBackup=True) 97 98 # Add groupManager to zport.acl 99 acl = site.acl_users 100 if not hasattr(acl, 'groupManager'): 101 plugins.ZODBGroupManager.addZODBGroupManager(acl, 'groupManager') 102 acl.groupManager.manage_activateInterfaces(['IGroupsPlugin',]) 103 104 trans = transaction.get() 105 trans.note("Initial ZentinelPortal load by zenbuild.py") 106 trans.commit() 107 print "ZentinelPortal loaded at %s" % self.sitename 108 109 # build dmd 110 from Products.ZenModel.DmdBuilder import DmdBuilder 111 dmdBuilder = DmdBuilder(site, 112 self.options.evthost, 113 self.options.evtuser, 114 self.options.evtpass, 115 self.options.evtdb, 116 self.options.evtport, 117 self.options.smtphost, 118 self.options.smtpport, 119 self.options.pagecommand) 120 dmdBuilder.build() 121 transaction.commit() 122 123 # Load reports 124 from Products.ZenReports.ReportLoader import ReportLoader 125 rl = ReportLoader(noopts=True, app=self.app) 126 rl.loadDatabase() 127 128 # Load XML Data 129 from Products.ZenModel.XmlDataLoader import XmlDataLoader 130 dl = XmlDataLoader(noopts=True, app=self.app) 131 dl.loadDatabase()
132 133 134 if __name__ == "__main__": 135 zb = zenbuild() 136 zb.build() 137