def zmanage_importObjects(self, context=None, REQUEST=None): """Import an XML file as the Zenoss objects and properties it represents. """ # XXX # for right now, we're only using this through the web, so a REQUEST is # always define; when we have a use-case for imports via command line, # we will add that code here if not context: context = self.getPhysicalRoot() # get the submitted data filenames = REQUEST.form.get('filenames') urlnames = REQUEST.form.get('urlnames') doDelete = REQUEST.form.get('dodelete') xmlfiles = [] for collection in [filenames, urlnames]: if collection: if isinstance(collection, list): xmlfiles.extend(collection) else: xmlfiles.append(collection) # load the objects into Zenoss im = ImportRM(noopts=True, app=self.getPhysicalRoot()) for xmlfile in xmlfiles: im.loadObjectFromXML(context, xmlfile) if doDelete and xmlfile in filenames: os.unlink(xmlfile) if REQUEST: messaging.IMessageSender(self).sendToBrowser( 'Import Objects', 'Objects imported') return self.callZenScreen(REQUEST)
def cutover(self, dmd): dmd.buildMenus({ 'PerformanceMonitor_list': [ { 'action': 'performanceTemplates', 'description': 'Templates', 'id': 'performanceTemplates', 'ordering': 16.0, 'permissions': ('View Device',), }], 'StatusMonitor_list': [ { 'action': 'performanceTemplates', 'description': 'Templates', 'id': 'performanceTemplates', 'ordering': 16.0, 'permissions': ('View Device',), }], }) for c in dmd.Monitors.objectValues(spec='MonitorClass'): c.buildRelations() for c in dmd.Monitors.objectValues(spec='Monitor'): c.buildRelations() dmd.Monitors.buildRelations() if len(dmd.Monitors.rrdTemplates()) == 0: from Products.ZenRelations.ImportRM import ImportRM from Products.ZenUtils.Utils import zenPath template = zenPath('Products/ZenModel/migrate/monitorTemplate.xml') im = ImportRM(noopts=True, app=dmd.zport) im.loadObjectFromXML(xmlfile=template)
def cutover(self, dmd): from Products.ZenModel.MonitorClass import manage_addMonitorClass if not hasattr(dmd.Monitors, 'Performance'): manage_addMonitorClass(dmd.Monitors, 'Performance') from Products.ZenModel.PerformanceConf import manage_addPerformanceConf if hasattr(dmd.Monitors, 'Cricket'): for c in dmd.Monitors.Cricket.objectValues(): if not hasattr(dmd.Monitors.Performance, c.id): manage_addPerformanceConf(dmd.Monitors.Performance, c.id) p = dmd.Monitors.Performance._getOb(c.id) p.renderurl = c.cricketurl p.renderuser = c.cricketuser p.renderpass = c.cricketpass if hasattr(dmd.Monitors.Cricket, 'localhost'): dmd.Monitors.Cricket._delObject('localhost') dmd.Monitors._delObject("Cricket") for dev in dmd.Devices.getSubDevices(): dev.buildRelations() if hasattr(dev, 'cricket') and dev.cricket.getRelatedId(): dev.setPerformanceMonitor(dev.cricket.getRelatedId()) if hasattr(dev, '_snmpUpTime'): delattr(dev, '_snmpUpTime') for fs in dev.os.filesystems(): if not callable(fs.totalBytes): delattr(fs, 'totalBytes') if not callable(fs.usedBytes): delattr(fs, 'usedBytes') if not callable(fs.availBytes): delattr(fs, 'availBytes') if not callable(fs.availFiles): delattr(fs, 'availFiles') if not callable(fs.capacity): delattr(fs, 'capacity') if not callable(fs.inodeCapacity): delattr(fs, 'inodeCapacity') for dc in dmd.Devices.getSubOrganizers(): self.convert(dc) self.convert(dmd.Devices) if not hasattr(dmd.Devices, 'zProdStateThreshold'): dmd.Devices._setProperty("zProdStateThreshold", 500, type="int") if getattr(dmd.Devices.rrdTemplates, 'Device', None) is None: from Products.ZenRelations.ImportRM import ImportRM imp = ImportRM(noopts=True, app=dmd.getPhysicalRoot()) imp.options.noCommit = True imp.options.infile = zenPath('Products', 'ZenModel', 'data', 'rrdconfig.update') imp.loadDatabase()
def cutover(self, dmd): if hasattr(dmd, 'Processes'): if not dmd.Processes.hasProperty('zFailSeverity'): dmd.Processes._setProperty("zFailSeverity", 4, type="int") return from Products.ZenModel.OSProcessOrganizer \ import manage_addOSProcessOrganizer manage_addOSProcessOrganizer(dmd, 'Processes') if getattr(dmd.Devices.rrdTemplates, 'OSProcess', None) is None: from Products.ZenRelations.ImportRM import ImportRM imp = ImportRM(noopts=True, app=dmd.getPhysicalRoot()) imp.options.noCommit = True imp.options.noindex = True imp.options.infile = zenPath('Products', 'ZenModel', 'data', 'osproc.update') imp.loadDatabase()