You can subscribe to this list here.
2007 |
Jan
|
Feb
(65) |
Mar
(276) |
Apr
(544) |
May
(638) |
Jun
(225) |
Jul
(204) |
Aug
(294) |
Sep
(532) |
Oct
(506) |
Nov
(324) |
Dec
(359) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(208) |
Feb
(225) |
Mar
(248) |
Apr
(388) |
May
(222) |
Jun
(47) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <sv...@ze...> - 2007-03-20 12:51:45
|
Author: ian Date: 2007-03-20 08:51:35 -0400 (Tue, 20 Mar 2007) New Revision: 4320 Modified: trunk/Products/ZenModel/migrate/menus.py Log: * Added a failsafe menu deletion step to the migration script Modified: trunk/Products/ZenModel/migrate/menus.py =================================================================== --- trunk/Products/ZenModel/migrate/menus.py 2007-03-19 21:28:43 UTC (rev 4319) +++ trunk/Products/ZenModel/migrate/menus.py 2007-03-20 12:51:35 UTC (rev 4320) @@ -188,6 +188,7 @@ }) + dmd.Networks.manage_deleteZenMenu('Context') dmd.Networks.buildMenus( {'Context':[ dict( |
From: <sv...@ze...> - 2007-03-19 21:28:43
|
Author: abray Date: 2007-03-19 17:28:43 -0400 (Mon, 19 Mar 2007) New Revision: 4319 Added: trunk/inst/docs/ZenossAdminGuide1.1.x.doc Log: Added: trunk/inst/docs/ZenossAdminGuide1.1.x.doc Property changes on: trunk/inst/docs/ZenossAdminGuide1.1.x.doc ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <sv...@ze...> - 2007-03-19 20:36:11
|
Author: edahl Date: 2007-03-19 16:36:03 -0400 (Mon, 19 Mar 2007) New Revision: 4318 Modified: trunk/Products/ZenModel/IpAddress.py trunk/Products/ZenModel/ServiceClass.py trunk/Products/ZenModel/WinService.py Log: * forgot more stuff Modified: trunk/Products/ZenModel/IpAddress.py =================================================================== --- trunk/Products/ZenModel/IpAddress.py 2007-03-19 20:33:23 UTC (rev 4317) +++ trunk/Products/ZenModel/IpAddress.py 2007-03-19 20:36:03 UTC (rev 4318) @@ -100,7 +100,7 @@ ManagedEntity.__init__(self, id) self._netmask = maskToBits(netmask) self.ptrName = None - self.setPtrName() + #self.setPtrName() def setPtrName(self): Modified: trunk/Products/ZenModel/ServiceClass.py =================================================================== --- trunk/Products/ZenModel/ServiceClass.py 2007-03-19 20:33:23 UTC (rev 4317) +++ trunk/Products/ZenModel/ServiceClass.py 2007-03-19 20:36:03 UTC (rev 4318) @@ -53,9 +53,7 @@ _properties = ( {'id':'name', 'type':'string', 'mode':'w'}, {'id':'serviceKeys', 'type':'lines', 'mode':'w'}, - {'id':'caption', 'type':'string', 'mode':'w'}, {'id':'description', 'type':'text', 'mode':'w'}, - {'id':'contact', 'type':'string', 'mode':'w'}, ) _relations = ZenPackable._relations + ( Modified: trunk/Products/ZenModel/WinService.py =================================================================== --- trunk/Products/ZenModel/WinService.py 2007-03-19 20:33:23 UTC (rev 4317) +++ trunk/Products/ZenModel/WinService.py 2007-03-19 20:36:03 UTC (rev 4318) @@ -23,7 +23,16 @@ serviceType = "" startMode = "" startName = "" - + + _properties = Service._properties + ( + {'id': 'acceptPause', 'type':'boolean', 'mode':'w'}, + {'id': 'acceptStop', 'type':'boolean', 'mode':'w'}, + {'id': 'pathName', 'type':'string', 'mode':'w'}, + {'id': 'serviceType', 'type':'string', 'mode':'w'}, + {'id': 'startMode', 'type':'string', 'mode':'w'}, + {'id': 'startName', 'type':'string', 'mode':'w'}, + ) + _relations = Service._relations + ( ("os", ToOne(ToManyCont, "OperatingSystem", "winservices")), ) |
From: <sv...@ze...> - 2007-03-19 20:33:25
|
Author: edahl Date: 2007-03-19 16:33:23 -0400 (Mon, 19 Mar 2007) New Revision: 4317 Modified: sandboxen/edahl/zenrelrefactor/ZenModel/IpAddress.py sandboxen/edahl/zenrelrefactor/ZenModel/ServiceClass.py sandboxen/edahl/zenrelrefactor/ZenModel/WinService.py Log: * forgot more stuff! Modified: sandboxen/edahl/zenrelrefactor/ZenModel/IpAddress.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/IpAddress.py 2007-03-19 20:22:11 UTC (rev 4316) +++ sandboxen/edahl/zenrelrefactor/ZenModel/IpAddress.py 2007-03-19 20:33:23 UTC (rev 4317) @@ -100,7 +100,7 @@ ManagedEntity.__init__(self, id) self._netmask = maskToBits(netmask) self.ptrName = None - self.setPtrName() + #self.setPtrName() def setPtrName(self): Modified: sandboxen/edahl/zenrelrefactor/ZenModel/ServiceClass.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/ServiceClass.py 2007-03-19 20:22:11 UTC (rev 4316) +++ sandboxen/edahl/zenrelrefactor/ZenModel/ServiceClass.py 2007-03-19 20:33:23 UTC (rev 4317) @@ -53,9 +53,7 @@ _properties = ( {'id':'name', 'type':'string', 'mode':'w'}, {'id':'serviceKeys', 'type':'lines', 'mode':'w'}, - {'id':'caption', 'type':'string', 'mode':'w'}, {'id':'description', 'type':'text', 'mode':'w'}, - {'id':'contact', 'type':'string', 'mode':'w'}, ) _relations = ZenPackable._relations + ( Modified: sandboxen/edahl/zenrelrefactor/ZenModel/WinService.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/WinService.py 2007-03-19 20:22:11 UTC (rev 4316) +++ sandboxen/edahl/zenrelrefactor/ZenModel/WinService.py 2007-03-19 20:33:23 UTC (rev 4317) @@ -23,7 +23,16 @@ serviceType = "" startMode = "" startName = "" - + + _properties = Service._properties + ( + {'id': 'acceptPause', 'type':'boolean', 'mode':'w'}, + {'id': 'acceptStop', 'type':'boolean', 'mode':'w'}, + {'id': 'pathName', 'type':'string', 'mode':'w'}, + {'id': 'serviceType', 'type':'string', 'mode':'w'}, + {'id': 'startMode', 'type':'string', 'mode':'w'}, + {'id': 'startName', 'type':'string', 'mode':'w'}, + ) + _relations = Service._relations + ( ("os", ToOne(ToManyCont, "OperatingSystem", "winservices")), ) |
From: <sv...@ze...> - 2007-03-19 20:22:17
|
Author: ian Date: 2007-03-19 16:22:11 -0400 (Mon, 19 Mar 2007) New Revision: 4316 Modified: trunk/Products/ZenModel/migrate/menus.py Log: * Fixed an improperly defined lines field Modified: trunk/Products/ZenModel/migrate/menus.py =================================================================== --- trunk/Products/ZenModel/migrate/menus.py 2007-03-19 20:04:40 UTC (rev 4315) +++ trunk/Products/ZenModel/migrate/menus.py 2007-03-19 20:22:11 UTC (rev 4316) @@ -194,7 +194,7 @@ id= 'discover', description= 'Discover Devices', action= 'discoverDevices', - allowed_classes='IpNetwork' + allowed_classes= ('IpNetwork',) ), ] }) |
From: <sv...@ze...> - 2007-03-19 20:04:53
|
Author: edahl Date: 2007-03-19 16:04:40 -0400 (Mon, 19 Mar 2007) New Revision: 4315 Modified: trunk/inst/zen2load.py Log: * number of args in dmdbuilder changed Modified: trunk/inst/zen2load.py =================================================================== --- trunk/inst/zen2load.py 2007-03-19 20:02:33 UTC (rev 4314) +++ trunk/inst/zen2load.py 2007-03-19 20:04:40 UTC (rev 4315) @@ -302,7 +302,7 @@ # build dmd from Products.ZenModel.DmdBuilder import DmdBuilder - dmdBuilder = DmdBuilder(site, "", '','','','','','') + dmdBuilder = DmdBuilder(site, "", '','','','','','','') dmdBuilder.build() # trans = transaction.get() # trans.note("Initial load by zen2load.py") |
From: <sv...@ze...> - 2007-03-19 20:02:48
|
Author: edahl Date: 2007-03-19 16:02:33 -0400 (Mon, 19 Mar 2007) New Revision: 4314 Added: trunk/inst/zen2load.py Log: * forgot zen2load! Added: trunk/inst/zen2load.py Property changes on: trunk/inst/zen2load.py ___________________________________________________________________ Name: svn:executable + * |
From: <sv...@ze...> - 2007-03-19 19:52:32
|
Author: edahl Date: 2007-03-19 15:52:18 -0400 (Mon, 19 Mar 2007) New Revision: 4313 Added: trunk/Products/ZenModel/migrate/zlocal.py trunk/Products/ZenRelations/ZItem.py Modified: trunk/Products/ZenEvents/DbAccessBase.py trunk/Products/ZenModel/Device.py trunk/Products/ZenModel/DeviceClass.py trunk/Products/ZenModel/IpInterface.py trunk/Products/ZenModel/IpNetwork.py trunk/Products/ZenModel/IpRouteEntry.py trunk/Products/ZenModel/ManagedEntity.py trunk/Products/ZenModel/MonitorClass.py trunk/Products/ZenModel/UserSettings.py trunk/Products/ZenModel/migrate/__init__.py trunk/Products/ZenModel/migrate/menus.py trunk/Products/ZenModel/tests/testIpRouteEntry.py trunk/Products/ZenModel/zenbuild.py trunk/Products/ZenRelations/ExportDevices.py trunk/Products/ZenRelations/ImportRM.py trunk/Products/ZenRelations/PrimaryPathObjectManager.py trunk/Products/ZenRelations/RelCopySupport.py trunk/Products/ZenRelations/RelationshipBase.py trunk/Products/ZenRelations/RelationshipManager.py trunk/Products/ZenRelations/ToManyContRelationship.py trunk/Products/ZenRelations/ToManyRelationship.py trunk/Products/ZenRelations/ToManyRelationshipBase.py trunk/Products/ZenRelations/ToOneRelationship.py trunk/Products/ZenRelations/tests/dataImportExport.py trunk/Products/ZenUtils/Utils.py Log: * merged zenrelrefactor r4231 to r4307 into the trunk Modified: trunk/Products/ZenEvents/DbAccessBase.py =================================================================== --- trunk/Products/ZenEvents/DbAccessBase.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenEvents/DbAccessBase.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -6,9 +6,6 @@ _cpool = DbConnectionPool() - def __init__(self): - self.close(self.connect()) # Create and return a connection - def close(self, conn): self._cpool.put(conn) Modified: trunk/Products/ZenModel/Device.py =================================================================== --- trunk/Products/ZenModel/Device.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/Device.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -1315,5 +1315,12 @@ environ.update({'dev': context, 'device': context,}) return environ + + def exportXmlHook(self, ofile, ignorerels): + """Add export of our child objects. + """ + map(lambda o: o.exportXml(ofile, ignorerels), (self.hw, self.os)) + + InitializeClass(Device) Modified: trunk/Products/ZenModel/DeviceClass.py =================================================================== --- trunk/Products/ZenModel/DeviceClass.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/DeviceClass.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -551,7 +551,10 @@ devs._setProperty("zSysedgeDiskMapIgnoreNames", "") devs._setProperty("zIpServiceMapMaxPort", 1024, type="int") devs._setProperty("zDeviceTemplates", ["Device"], type="lines") + devs._setProperty("zLocalIpAddresses", "^127|^0\.0|^169\.254|^224") + devs._setProperty("zLocalInterfaceNames", "^lo|^vmnet") + # RRD properties #FIXME - should this be added to allow for more flexability of # RRDTemplate binding? Modified: trunk/Products/ZenModel/IpInterface.py =================================================================== --- trunk/Products/ZenModel/IpInterface.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/IpInterface.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -29,6 +29,7 @@ from Products.ZenRelations.RelSchema import * from IpAddress import IpAddress, findIpAddress +from Products.ZenUtils.Utils import localIpCheck, localInterfaceCheck from Products.ZenUtils.IpUtil import * from ConfmonPropManager import ConfmonPropManager @@ -60,7 +61,7 @@ # indexes are id and description #default_catalog = 'interfaceSearch' - ifindex = 0 + ifindex = '0' interfaceName = '' macaddress = "" type = "" @@ -221,7 +222,7 @@ ipids = self.ipaddresses.objectIdsAll() localips = copy.copy(self._ipAddresses) for ip in ips: - if self.localipcheck(ip) or self.localintcheck(self.id): + if localIpCheck(self, ip) or localInterfaceCheck(self, self.id): if not ip in localips: self.addLocalIpAddress(ip) else: Modified: trunk/Products/ZenModel/IpNetwork.py =================================================================== --- trunk/Products/ZenModel/IpNetwork.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/IpNetwork.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -56,7 +56,7 @@ # when an ip is added the defaul location will be # into class A->B->C network tree -defaultNetworkTree = (8,16,24) +defaultNetworkTree = (32,) class IpNetwork(DeviceOrganizer): """IpNetwork object""" Modified: trunk/Products/ZenModel/IpRouteEntry.py =================================================================== --- trunk/Products/ZenModel/IpRouteEntry.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/IpRouteEntry.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -18,6 +18,7 @@ from Globals import InitializeClass from AccessControl import ClassSecurityInfo +from Products.ZenUtils.Utils import localIpCheck from Products.ZenRelations.RelSchema import * from IpAddress import findIpAddress @@ -143,7 +144,7 @@ def setNextHopIp(self, nextHopIp): """if the nexthop is a 127. or 0. address store locally else link to it in the network hierarchy""" - if self.ipcheck(nextHopIp) or not nextHopIp: + if localIpCheck(self, nextHopIp) or not nextHopIp: self._nexthop = nextHopIp else: ip = findIpAddress(self, nextHopIp) @@ -166,7 +167,7 @@ def setTarget(self, netip): """Set this route target netip in the form 10.0.0.0/24. """ - if self.ipcheck(netip): + if localIpCheck(self, netip): self._target = netip else: net = self.getDmdRoot("Networks").createNet(netip) Modified: trunk/Products/ZenModel/ManagedEntity.py =================================================================== --- trunk/Products/ZenModel/ManagedEntity.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/ManagedEntity.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -36,13 +36,13 @@ monitor = True _properties = ( - {'id':'snmpindex', 'type':'int', 'mode':'w'}, + {'id':'snmpindex', 'type':'string', 'mode':'w'}, {'id':'monitor', 'type':'boolean', 'mode':'w'}, ) _relations = ( - ("dependenices", ToMany(ToMany, "ManagedEntity", "dependants")), - ("dependants", ToMany(ToMany, "ManagedEntity", "dependenices")), + ("dependencies", ToMany(ToMany, "ManagedEntity", "dependents")), + ("dependents", ToMany(ToMany, "ManagedEntity", "dependencies")), ) def device(self): Modified: trunk/Products/ZenModel/MonitorClass.py =================================================================== --- trunk/Products/ZenModel/MonitorClass.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/MonitorClass.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -133,4 +133,12 @@ if id: child._setObject(id, ctor(id)) if REQUEST: return self.callZenScreen(REQUEST) + + def exportXmlHook(self, ofile, ignorerels): + """patch to export all device components + """ + for o in self.objectValues(): + if hasattr(aq_base(o), 'exportXml'): + o.exportXml(ofile, ignorerels) + InitializeClass(MonitorClass) Modified: trunk/Products/ZenModel/UserSettings.py =================================================================== --- trunk/Products/ZenModel/UserSettings.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/UserSettings.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -272,6 +272,9 @@ return filter(rolefilter, self.valid_roles()) + def exportXmlHook(self,ofile, ignorerels): + map(lambda x: x.exportXml(ofile, ignorerels), self.getAllUserSettings()) + def manage_addUserSettings(context, id, title = None, REQUEST = None): Modified: trunk/Products/ZenModel/migrate/__init__.py =================================================================== --- trunk/Products/ZenModel/migrate/__init__.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/migrate/__init__.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -65,6 +65,7 @@ import defaultcommandtimeout import eventclassmapping import zenuilayer -import packs +#import packs import menus import deviceTemplatesProperty +import zlocal Modified: trunk/Products/ZenModel/migrate/menus.py =================================================================== --- trunk/Products/ZenModel/migrate/menus.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/migrate/menus.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -24,28 +24,28 @@ def cutover(self, dmd): dmd.buildRelations() - for dev in dmd.Devices.getSubDevices(): - dev.buildRelations() - for name in ['Devices', 'Systems', 'Groups', 'Locations', - 'Services', 'Processes']: - top = getattr(dmd, name) - orgs = top.getSubOrganizers() - orgs.insert(0, top) - for o in orgs: - o.buildRelations() - if name == 'Devices': - for d in o.devices(): - d.buildRelations() - if getattr(d, 'os', None): - for n in ['ipservices', 'winservices', 'processes']: - for p in getattr(d.os, n)(): - p.buildRelations() - if name == 'Services': - for sc in o.serviceclasses(): - sc.buildRelations() - if name == 'Processes': - for pc in o.osProcessClasses(): - pc.buildRelations() +# for dev in dmd.Devices.getSubDevices(): +# dev.buildRelations() +# for name in ['Devices', 'Systems', 'Groups', 'Locations', +# 'Services', 'Processes']: +# top = getattr(dmd, name) +# orgs = top.getSubOrganizers() +# orgs.insert(0, top) +# for o in orgs: +# o.buildRelations() +# if name == 'Devices': +# for d in o.devices(): +# d.buildRelations() +# if getattr(d, 'os', None): +# for n in ['ipservices', 'winservices', 'processes']: +# for p in getattr(d.os, n)(): +# p.buildRelations() +# if name == 'Services': +# for sc in o.serviceclasses(): +# sc.buildRelations() +# if name == 'Processes': +# for pc in o.osProcessClasses(): +# pc.buildRelations() # Add menus. dmd.buildMenus( Copied: trunk/Products/ZenModel/migrate/zlocal.py (from rev 4312, sandboxen/edahl/zenrelrefactor/ZenModel/migrate/zlocal.py) Modified: trunk/Products/ZenModel/tests/testIpRouteEntry.py =================================================================== --- trunk/Products/ZenModel/tests/testIpRouteEntry.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/tests/testIpRouteEntry.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -28,14 +28,14 @@ tmpo = IpInterface('test0') self.dev.os.interfaces._setObject('test0',tmpo) - self.iface0 = self.dev.os.interfaces()[0] + self.iface0 = self.dev.os.interfaces._getOb('test0') self.iface0.setIpAddresses('1.2.3.4/24') self.iface0.ifindex = 0 self.iface0.interfaceName = 'iface0' tmpo = IpInterface('test1') self.dev.os.interfaces._setObject('test1',tmpo) - self.iface1 = self.dev.os.interfaces()[1] + self.iface1 = self.dev.os.interfaces._getOb('test1') self.iface1.setIpAddresses('2.3.4.5/24') self.iface1.ifindex = 1 self.iface1.interfaceName = 'iface1' Modified: trunk/Products/ZenModel/zenbuild.py =================================================================== --- trunk/Products/ZenModel/zenbuild.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenModel/zenbuild.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -117,7 +117,7 @@ self.options.snpphost, self.options.snppport) dmdBuilder.build() - + transaction.commit() # Set smtp and snpp values Modified: trunk/Products/ZenRelations/ExportDevices.py =================================================================== --- trunk/Products/ZenRelations/ExportDevices.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/ExportDevices.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -81,7 +81,8 @@ root = self.dmd.Devices buffer = StringIO.StringIO() if hasattr(root, "exportXml"): - buffer.write("""<?xml version="1.0"?>\n""") + buffer = self.outfile + buffer.write("""<?xml version="1.0"? encoding='latin-1'>\n""") buffer.write("<objects>\n") root.exportXml(buffer,self.options.ignorerels,True) buffer.write("</objects>\n") Modified: trunk/Products/ZenRelations/ImportRM.py =================================================================== --- trunk/Products/ZenRelations/ImportRM.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/ImportRM.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -22,6 +22,7 @@ from xml.sax.handler import ContentHandler from Acquisition import aq_base +from zExceptions import NotFound from DateTime import DateTime @@ -101,7 +102,7 @@ obj = getObjByPath(self.app, id) else: obj = self.context()._getOb(id) - except (KeyError, AttributeError): pass + except (KeyError, AttributeError, NotFound): pass if obj is None: klass = importClass(attrs.get('module'), attrs.get('class')) if id.find("/") > -1: @@ -111,8 +112,8 @@ obj = klass(id) self.context()._setObject(obj.id, obj) obj = self.context()._getOb(obj.id) - transaction.savepoint() self.objectnumber += 1 + if self.objectnumber % 5000 == 0: transaction.savepoint() self.log.debug("Added object %s to database" % obj.getPrimaryId()) else: self.log.warn("Object %s already exists skipping" % id) @@ -136,9 +137,12 @@ except IndexError: proptype = 'string' if proptype == "date": + try: value = float(value) + except ValueError: pass value = DateTime(value) elif proptype != "string" and proptype != 'text': - value = eval(value) + try: value = eval(value) + except SyntaxError: pass if not obj.hasProperty(name): obj._setProperty(name, value, type=proptype, setter=setter) else: @@ -164,7 +168,7 @@ except: self.log.critical( "Failed linking relation %s to object %s",relid,objid) - raise + #raise Modified: trunk/Products/ZenRelations/PrimaryPathObjectManager.py =================================================================== --- trunk/Products/ZenRelations/PrimaryPathObjectManager.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/PrimaryPathObjectManager.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -12,19 +12,23 @@ # base classes for PrimaryPathObjectManager from RelCopySupport import RelCopyContainer +from OFS.Traversable import Traversable +from Acquisition import Implicit, aq_base from OFS.ObjectManager import ObjectManager from AccessControl.Role import RoleManager -from OFS.SimpleItem import Item +import App.Undo -from Acquisition import aq_base +from ZItem import ZItem + from Products.ZenUtils.Utils import getObjByPath from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2 -class PrimaryPathManager(object): +class PrimaryPathManager(ZItem, Implicit, RoleManager): + def getPrimaryPath(self, fromNode=None): """ Return the primary path of this object by following __primary_parent__ @@ -73,21 +77,19 @@ -class PrimaryPathObjectManagerBase(PrimaryPathManager): +class PrimaryPathObjectManager( + RelCopyContainer, + ObjectManager, + PrimaryPathManager, + App.Undo.UndoSupport, + ): """ - ZenRelations adds relationships to Zope's normal containment style data - system. Relationships give us a networked data model as opposed to a - simple hierarchy. It is difficult to path through a network of objects - so PrimaryPathObjectManager gives us a consistant hierarchical mechanism - for pathing to an object. This allows our network database to pretend to - Zope that it is really just hierarchical. It also lets us set our - acquisition chain to equal our primary path. This lets us do acquistion - within the networked database. + PrimaryPathObjectManager with basic Zope persistent classes. + """ + manage_options = (ObjectManager.manage_options + + RoleManager.manage_options + + ZItem.manage_options) - The primary path of an object is maintained through the attribute - __primary_parent__. This is set every time an object is added to the - database using _setObject. - """ def _setObject(self, id, obj, roles=None, user=None, set_owner=1): """Track __primary_parent__ when we are set into an object""" obj.__primary_parent__ = aq_base(self) @@ -101,17 +103,18 @@ obj.__primary_parent__ = None -class PrimaryPathObjectManager(PrimaryPathObjectManagerBase, ObjectManager, - RelCopyContainer, RoleManager, Item): +class PrimaryPathBTreeFolder2(BTreeFolder2): """ - PrimaryPathObjectManager with basic Zope persistent classes. + BTreeFolder2 PrimaryPathObjectManager. """ - manage_options = (ObjectManager.manage_options + - RoleManager.manage_options + - Item.manage_options) + def _setObject(self, id, obj, roles=None, user=None, set_owner=1): + """Track __primary_parent__ when we are set into an object""" + obj.__primary_parent__ = aq_base(self) + return ObjectManager._setObject(self, id, obj, roles, user, set_owner) -class PrimaryPathBTreeFolder2(PrimaryPathObjectManagerBase, BTreeFolder2): - """ - BTreeFolder2 PrimaryPathObjectManager. - """ + def _delObject(self, id, dp=1): + """When deleted clear __primary_parent__.""" + obj = self._getOb(id) + ObjectManager._delObject(self, id, dp) + obj.__primary_parent__ = None Modified: trunk/Products/ZenRelations/RelCopySupport.py =================================================================== --- trunk/Products/ZenRelations/RelCopySupport.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/RelCopySupport.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -18,6 +18,7 @@ import types # base class for RelCopyContainer +from OFS.ObjectManager import checkValidId from OFS.CopySupport import CopyContainer from Acquisition import aq_base @@ -34,7 +35,7 @@ def manage_renameObject(self, id, new_id, REQUEST=None): """Rename a particular sub-object""" - try: self._checkId(new_id) + try: checkValidId(self, new_id) except: raise CopyError, MessageDialog( title='Invalid Id', message=sys.exc_info()[1], Modified: trunk/Products/ZenRelations/RelationshipBase.py =================================================================== --- trunk/Products/ZenRelations/RelationshipBase.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/RelationshipBase.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -24,6 +24,7 @@ from Products.ZenRelations.Exceptions import * from Products.ZenRelations.utils import importClass + from PrimaryPathObjectManager import PrimaryPathManager class RelationshipBase(PrimaryPathManager): @@ -37,7 +38,11 @@ """Return the contents of this relation.""" raise NotImplementedError - + + def getId(self): + return self.id + + def hasobject(self, obj): """Does this relationship relate to obj.""" raise NotImplementedError Modified: trunk/Products/ZenRelations/RelationshipManager.py =================================================================== --- trunk/Products/ZenRelations/RelationshipManager.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/RelationshipManager.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -279,16 +279,22 @@ for prop in self._properties: if not prop.has_key('id'): continue id = prop['id'] - type = prop['type'] + ptype = prop['type'] value = getattr(aq_base(self), id, None) # use aq_base? - if not value and type not in ("int","float","boolean"): continue + if not value and ptype not in ("int","float","boolean"): continue stag = [] stag.append('<property') - stag.extend(["%s=%s" % (k,saxutils.quoteattr(str(v))) \ - for k,v in prop.items()]) + for k, v in prop.items(): + if ptype != 'selection' and k == 'select_variable': continue + v = saxutils.quoteattr(str(v)) + stag.append('%s=%s' % (k, v)) stag.append('>') ofile.write(' '.join(stag)+"\n") - ofile.write(saxutils.escape(str(value))+"\n") + if type(value) not in types.StringTypes: + value = unicode(value) + elif type(value) == types.StringType: + value = value.decode('latin-1') + ofile.write(saxutils.escape(value).encode('utf-8')+"\n") ofile.write("</property>\n") Modified: trunk/Products/ZenRelations/ToManyContRelationship.py =================================================================== --- trunk/Products/ZenRelations/ToManyContRelationship.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/ToManyContRelationship.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -15,6 +15,7 @@ from Globals import InitializeClass from AccessControl import ClassSecurityInfo from Acquisition import aq_base +from OFS.ObjectManager import checkValidId from BTrees.OOBTree import OOBTree @@ -43,7 +44,9 @@ meta_type = "ToManyContRelationship" + security = ClassSecurityInfo() + def __init__(self, id): """set our instance values""" self.id = id @@ -87,20 +90,57 @@ """ObjectManager interface to add contained object.""" object.__primary_parent__ = aq_base(self) self.addRelation(object) + object.manage_afterAdd(object, self) return object.getId() + def manage_afterAdd(self, item, container): + """ + Copied code from ObjectManager + """ + for object in self.objectValues(): + try: s=object._p_changed + except: s=0 + if hasattr(aq_base(object), 'manage_afterAdd'): + object.manage_afterAdd(item, container) + if s is None: object._p_deactivate() + + + def manage_afterClone(self, item): + """ + Copied code from ObjectManager + """ + for object in self.objectValues(): + try: s=object._p_changed + except: s=0 + if hasattr(aq_base(object), 'manage_afterClone'): + object.manage_afterClone(item) + if s is None: object._p_deactivate() + + def manage_beforeDelete(self, item, container): """ - there are 4 possible states for _operation during beforeDelete - -1 = object being deleted remove relation - 0 = copy, 1 = move, 2 = rename - ToManyCont will propagate beforeDelete because its a container + Copied code from ObjectManager """ - if getattr(item, "_operation", -1) < 1: - self._remoteRemove() - ToManyRelationshipBase.manage_beforeDelete(self, item, container) - + for object in self.objectValues(): + try: s=object._p_changed + except: s=0 + try: + if hasattr(aq_base(object), 'manage_beforeDelete'): + object.manage_beforeDelete(item, container) + except BeforeDeleteException, ob: + raise + except ConflictError: + raise + except: + LOG('Zope',ERROR,'manage_beforeDelete() threw', + error=sys.exc_info()) + # In debug mode when non-Manager, let exceptions propagate. + if getConfiguration().debug_mode: + if not getSecurityManager().getUser().has_role('Manager'): + raise + if s is None: object._p_deactivate() + def _add(self,obj): """add an object to one side of a ToManyContRelationship. @@ -108,13 +148,10 @@ id = obj.id if self._objects.has_key(id): raise RelationshipExistsError - #del self._objects[id] - v=self._checkId(id) + v=checkValidId(self, id) if v is not None: id=v self._objects[id] = aq_base(obj) obj = aq_base(obj).__of__(self) - self._count=len(self._objects) - self._p_changed = 1 def _remove(self, obj=None): @@ -132,8 +169,7 @@ del self._objects[id] else: self._objects = OOBTree() - self._count=len(self._objects) - self._p_changed = 1 + self.__primary_parent__._p_changed = True def _remoteRemove(self, obj=None): @@ -158,6 +194,7 @@ return default + security.declareProtected('View', 'objectIds') def objectIds(self, spec=None): """only return contained objects""" if spec: @@ -168,6 +205,7 @@ objectIdsAll = objectIds + security.declareProtected('View', 'objectValues') def objectValues(self, spec=None): """over ride to only return owned objects for many to many rel""" if spec: @@ -176,6 +214,7 @@ return [ob.__of__(self) for ob in self._objects.values() \ if ob.meta_type in spec] return [ob.__of__(self) for ob in self._objects.values()] + security.declareProtected('View', 'objectValuesAll') objectValuesAll = objectValues @@ -240,12 +279,4 @@ ofile.write("</tomanycont>\n") - def checkRelation(self, repair=False): - """Check to make sure that relationship bidirectionality is ok. - """ - if repair and len(self._objects) != self._count: - log.warn("resetting count on %s", self.getPrimaryId()) - self._resetCount() - - InitializeClass(ToManyContRelationship) Modified: trunk/Products/ZenRelations/ToManyRelationship.py =================================================================== --- trunk/Products/ZenRelations/ToManyRelationship.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/ToManyRelationship.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -47,6 +47,7 @@ meta_type = "ToManyRelationship" + security = ClassSecurityInfo() def __init__(self, id): """ToManyRelationships use an array to store related objects""" @@ -90,8 +91,7 @@ """add an object to one side of this toMany relationship""" if obj in self._objects: raise RelationshipExistsError self._objects.append(aq_base(obj)) - self._count=len(self._objects) - self._p_changed = 1 + self.__primary_parent__._p_changed = True def _remove(self, obj=None): @@ -105,8 +105,7 @@ (obj.id, self.id)) else: self._objects = [] - self._count=len(self._objects) - self._p_changed = 1 + self.__primary_parent__._p_changed = True def _remoteRemove(self, obj=None): @@ -161,6 +160,7 @@ return [] + security.declareProtected('View', 'objectValuesAll') def objectValuesAll(self): """return all related object values""" return [ob.__of__(self) for ob in self._objects] @@ -258,7 +258,7 @@ if repair: log.warn("removing rel to:%s", obj.getPrimaryId()) self._objects.remove(obj) - self._p_changed = 1 + self.__primary_parent__._p_changed = True # find duplicate objects keycount = {} @@ -282,10 +282,5 @@ except KeyError: log.critical("obj %s not found in database", key) - # Fix bad count cache - if repair and len(self._objects) != self._count: - log.warn("resetting count on %s", self.getPrimaryId()) - self._resetCount() - InitializeClass(ToManyRelationship) Modified: trunk/Products/ZenRelations/ToManyRelationshipBase.py =================================================================== --- trunk/Products/ZenRelations/ToManyRelationshipBase.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/ToManyRelationshipBase.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -10,8 +10,11 @@ __version__ = "$Revision: 1.48 $"[11:-2] # Base classes for ToManyRelationshipBase -from PrimaryPathObjectManager import PrimaryPathObjectManager +#from PrimaryPathObjectManager import PrimaryPathObjectManager from RelationshipBase import RelationshipBase +from RelCopySupport import RelCopyContainer +from OFS.Traversable import Traversable +from Acquisition import Implicit from Globals import DTMLFile from Acquisition import aq_base, aq_parent @@ -21,7 +24,10 @@ from Products.ZenRelations.Exceptions import zenmarker -class ToManyRelationshipBase(PrimaryPathObjectManager, RelationshipBase): +class ToManyRelationshipBase( + RelCopyContainer, + RelationshipBase + ): """ Abstract base class for all ToMany relationships. """ @@ -32,19 +38,12 @@ _operation = -1 # if a Relationship's are only deleted - _count = 0 def countObjects(self): """Return the number of objects in this relationship""" - return self._count + return len(self._objects) - def _resetCount(self): - """Reset the count of the total objects in this relation. - """ - self._count = len(self._objects) - - def findObjectsById(self, partid): """Return a list of objects by running find on their id""" objects = [] @@ -58,6 +57,7 @@ """Emulate ObjectManager deletetion.""" obj = self._getOb(id) self.removeRelation(obj) + obj.__primary_parent__ = None def _setOb(self, id, obj): Modified: trunk/Products/ZenRelations/ToOneRelationship.py =================================================================== --- trunk/Products/ZenRelations/ToOneRelationship.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/ToOneRelationship.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -21,7 +21,6 @@ # Base classes for ToOneRelationship from RelationshipBase import RelationshipBase -from OFS.SimpleItem import SimpleItem from Globals import InitializeClass from Globals import DTMLFile @@ -43,7 +42,7 @@ addToOneRelationship = DTMLFile('dtml/addToOneRelationship',globals()) -class ToOneRelationship(RelationshipBase, SimpleItem): +class ToOneRelationship(RelationshipBase): """ToOneRelationship represents a to one Relationship on a RelationshipManager""" @@ -73,12 +72,14 @@ if obj == self.obj: raise RelationshipExistsError self._remoteRemove() self.obj = aq_base(obj) + self.__primary_parent__._p_changed = True def _remove(self,obj=None): """remove the to one side of a relationship""" if obj == None or obj == self.obj: self.obj = None + self.__primary_parent__._p_changed = True else: raise ObjectNotFound @@ -114,6 +115,14 @@ return rel + def manage_afterAdd(self, item, container): + """Don't do anything here because we have on containment""" + pass + + def manage_afterClone(self, item): + """Don't do anything here because we have on containment""" + pass + def manage_beforeDelete(self, item, container): """ There are 4 possible states during when beforeDelete is called. @@ -125,7 +134,8 @@ ToOne doesn't call beforeDelete on its related object because its not a container. """ - if getattr(item, "_operation", -1) < 1: + if (getattr(item, "_operation", -1) < 1 + and self.remoteTypeName() != 'ToManyCont'): self._remoteRemove() Copied: trunk/Products/ZenRelations/ZItem.py (from rev 4312, sandboxen/edahl/zenrelrefactor/ZenRelations/ZItem.py) Modified: trunk/Products/ZenRelations/tests/dataImportExport.py =================================================================== --- trunk/Products/ZenRelations/tests/dataImportExport.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenRelations/tests/dataImportExport.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -6,7 +6,7 @@ objwithprops = \ """<object id='dev' module='Products.ZenRelations.tests.TestSchema' class='Device'> -<property setter='setPingStatus' type='int' id='pingStatus' mode='w' > +<property setter="setPingStatus" type="int" id="pingStatus" mode="w" > 0 </property> </object> @@ -14,7 +14,7 @@ objwithtoone = \ """<object id='dev' module='Products.ZenRelations.tests.TestSchema' class='Device'> -<property setter='setPingStatus' type='int' id='pingStatus' mode='w' > +<property setter="setPingStatus" type="int" id="pingStatus" mode="w" > 0 </property> <toone id='location' objid='loc'/> @@ -31,7 +31,7 @@ objwithtomanycont = \ """<object id='dev' module='Products.ZenRelations.tests.TestSchema' class='Device'> -<property setter='setPingStatus' type='int' id='pingStatus' mode='w' > +<property setter="setPingStatus" type="int" id="pingStatus" mode="w" > 0 </property> <tomanycont id='interfaces'> Modified: trunk/Products/ZenUtils/Utils.py =================================================================== --- trunk/Products/ZenUtils/Utils.py 2007-03-19 19:23:05 UTC (rev 4312) +++ trunk/Products/ZenUtils/Utils.py 2007-03-19 19:52:18 UTC (rev 4313) @@ -463,4 +463,19 @@ else: result = (True, '') return result - + + +def zdecode(context, value): + if type(value) in types.StringTypes: + decoding = getattr(obj, 'zCollectorDecoding', 'latin-1') + value = value.decode(decoding) + return value + + +def localIpCheck(context, ip): + """Test to see if ip it should not be included in the network map.""" + return re.search(getattr(context, 'zLocalIpAddresses', '^$'), ip) + +def localInterfaceCheck(context, intname): + """Test to see if ips on an in should not be included in the network map.""" + return re.search(getattr(context, 'zLoaclInterfaceNames', '^$'), intname) |
From: <sv...@ze...> - 2007-03-19 19:23:26
|
Author: edahl Date: 2007-03-19 15:23:05 -0400 (Mon, 19 Mar 2007) New Revision: 4312 Modified: trunk/inst/zen2dump.py Log: * many changes to zen2dump Modified: trunk/inst/zen2dump.py =================================================================== --- trunk/inst/zen2dump.py 2007-03-19 19:00:53 UTC (rev 4311) +++ trunk/inst/zen2dump.py 2007-03-19 19:23:05 UTC (rev 4312) @@ -13,21 +13,142 @@ __version__ = "$Revision: 1.1 $"[11:-2] -import sys, os, types +import sys, os, types, re import zipfile +from threading import Lock import Globals -def exportXmlHook(self, ofile, ignorerels): +from Acquisition import aq_base +from AccessControl.SecurityManagement import newSecurityManager +from AccessControl.SecurityManagement import noSecurityManager + +from Products.ZenUtils.ZenDaemon import ZenDaemon +from Products.ZenUtils.Utils import getObjByPath +from Products.ZenUtils.Exceptions import ZentinelException + +killbad = re.compile('[\x00-\x08\x0b\x0c\x0e-\x1f]').sub + +def DeviceExportXmlHook(self, ofile, ignorerels): """patch to export all device components """ - map(lambda o: o.exportXml(ofile, ignorerels), (self.hw, self.os)) + ignorerels = ['iproutes', 'routes', 'software'] + map(lambda o: o.exportXml(ofile, ignorerels), (self.os,self.hw)) from Products.ZenModel.Device import Device -Device.exportXmlHook = exportXmlHook +Device.exportXmlHook = DeviceExportXmlHook + +def MonitorClassExportXmlHook(self, ofile, ignorerels): + """patch to export all device components + """ + for o in self.objectValues(): + if hasattr(aq_base(o), 'exportXml'): + o.exportXml(ofile, ignorerels) +from Products.ZenModel.MonitorClass import MonitorClass +MonitorClass.exportXmlHook = MonitorClassExportXmlHook + + +def UserSettingsManagerExportXmlHook(self,ofile, ignorerels): + map(lambda x: x.exportXml(ofile, ignorerels), self.getAllUserSettings()) +from Products.ZenModel.UserSettings import UserSettingsManager +UserSettingsManager.exportXmlHook = UserSettingsManagerExportXmlHook + + +from Products.ZenModel.Location import Location +OldLocationExportXml = Location.exportXml +def LocationExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['devices',] + OldLocationExportXml(self, ofile, ignorerels, root) +Location.exportXml = LocationExportXml + + +from Products.ZenModel.DeviceGroup import DeviceGroup +OldDeviceGroupExportXml = DeviceGroup.exportXml +def DeviceGroupExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['devices',] + OldDeviceGroupExportXml(self, ofile, ignorerels, root) +DeviceGroup.exportXml = DeviceGroupExportXml + + +from Products.ZenModel.System import System +OldSystemExportXml = System.exportXml +def SystemExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['devices',] + OldSystemExportXml(self, ofile, ignorerels, root) +System.exportXml = SystemExportXml + + +from Products.ZenModel.HardwareClass import HardwareClass +OldHardwareClassExportXml = HardwareClass.exportXml +def HardwareClassExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['instances',] + OldHardwareClassExportXml(self, ofile, ignorerels, root) +HardwareClass.exportXml = HardwareClassExportXml + + +from Products.ZenModel.SoftwareClass import SoftwareClass +OldSoftwareClassExportXml = SoftwareClass.exportXml +def SoftwareClassExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['instances',] + OldSoftwareClassExportXml(self, ofile, ignorerels, root) +SoftwareClass.exportXml = SoftwareClassExportXml + + +from Products.ZenModel.ServiceClass import ServiceClass +OldServiceClassExportXml = ServiceClass.exportXml +def ServiceClassExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['instances',] + OldServiceClassExportXml(self, ofile, ignorerels, root) +ServiceClass.exportXml = ServiceClassExportXml + + +from Products.ZenModel.OSProcessClass import OSProcessClass +OldOSProcessClassExportXml = OSProcessClass.exportXml +def OSProcessClassExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['instances',] + OldOSProcessClassExportXml(self, ofile, ignorerels, root) +OSProcessClass.exportXml = OSProcessClassExportXml + + +from Products.ZenModel.IpNetwork import IpNetwork +OldIpNetworkExportXml = IpNetwork.exportXml +def IpNetworkExportXml(self, ofile, ignorerels=[], root=False): + """patch to export all device components + """ + ignorerels = ['clientroutes',] + OldIpNetworkExportXml(self, ofile, ignorerels, root) +IpNetwork.exportXml = IpNetworkExportXml + + +from Products.ZenModel.Service import Service +from Products.ZenModel.WinService import WinService +WinService._properties = Service._properties + ( + {'id': 'acceptPause', 'type':'boolean', 'mode':'w'}, + {'id': 'acceptStop', 'type':'boolean', 'mode':'w'}, + {'id': 'pathName', 'type':'string', 'mode':'w'}, + {'id': 'serviceType', 'type':'string', 'mode':'w'}, + {'id': 'startMode', 'type':'string', 'mode':'w'}, + {'id': 'startName', 'type':'string', 'mode':'w'}, + ) + + + def exportXmlProperties(self,ofile): """Patch to handle unicode strings""" - from Acquisition import aq_base from xml.sax import saxutils for prop in self._properties: if not prop.has_key('id'): continue @@ -37,39 +158,218 @@ if not value and ptype not in ("int","float","boolean"): continue stag = [] stag.append('<property') - stag.extend(["%s=%s" % (k,saxutils.quoteattr(str(v))) \ - for k,v in prop.items()]) + for k, v in prop.items(): + if ptype != 'selection' and k == 'select_variable': continue + v = saxutils.quoteattr(str(v)) + stag.append('%s=%s' % (k, v)) stag.append('>') ofile.write(' '.join(stag)+"\n") if type(value) not in types.StringTypes: value = unicode(value) elif type(value) == types.StringType: value = value.decode('latin-1') - ofile.write(saxutils.escape(value.encode('utf-8'))+"\n") + value = killbad('', value) + ofile.write(saxutils.escape(value).encode('utf-8')+"\n") ofile.write("</property>\n") from Products.ZenRelations.RelationshipManager import RelationshipManager RelationshipManager.exportXmlProperties = exportXmlProperties +def EMB_exportXml(self, ofile, ignorerels=[], root=False): + """Return an xml based representation of a RelationshipManager + <object id='/Devices/Servers/Windows/dhcp160.confmon.loc' + module='Products.Confmon.IpInterface' class='IpInterface'> + <property id='name'>jim</property> + <toone></toone> + <tomany></tomany> + <tomanycont></tomanycont> + </object> + """ + modname = self.__class__.__module__ + classname = self.__class__.__name__ + id = root and self.getPrimaryId() or self.id + stag = "<object id='%s' module='%s' class='%s'>\n" % ( + id , modname, classname) + ofile.write(stag) + self.exportXmlProperties(ofile) + self.exportXmlRelationships(ofile, ignorerels) + exportHook = getattr(aq_base(self), 'exportXmlHook', None) + if exportHook and callable(exportHook): exportHook(ofile, ignorerels) + ofile.write("</object>\n") + + +def EMB_exportXmlRelationships(self, ofile, ignorerels=[]): + """Return an xml representation of Relationships""" + for rel in self.getRelationships(): + if rel.id in ignorerels: continue + rel.exportXml(ofile, ignorerels) + +from Products.ZenEvents.EventManagerBase import EventManagerBase +EventManagerBase.exportXml = EMB_exportXml +EventManagerBase.exportXmlProperties = exportXmlProperties +EventManagerBase.exportXmlRelationships = EMB_exportXmlRelationships + + def getDmdRoots(self): """Put Networks at the front of the list of roots to export because if devices are loaded the networks will be auto created. """ roots = filter(lambda o: o.isInTree, self.objectValues()) - roots.insert(0, self._getOb('Networks')) return roots from Products.ZenModel.DataRoot import DataRoot DataRoot.getDmdRoots = getDmdRoots -def exportXmlHook(self,ofile, ignorerels): - map(lambda x: x.exportXml(ofile, ignorerels), self.getAllUserSettings()) -from Products.ZenModel.UserSettings import UserSettingsManager -UserSettingsManager.exportXmlHook = exportXmlHook +import os +defaultCacheDir = os.getenv('ZENHOME') +if defaultCacheDir is not None: + defaultCacheDir = os.path.join(defaultCacheDir, 'var') -from Products.ZenUtils.ZCmdBase import ZCmdBase +class DataRootError(Exception):pass +class ZCmdBase(ZenDaemon): + + + def __init__(self, noopts=0, app=None, keeproot=False): + ZenDaemon.__init__(self, noopts, keeproot) + self.dataroot = None + self.app = app + self.db = None + if not app: + from ZEO import ClientStorage + from ZODB import DB + addr = (self.options.host, self.options.port) + storage=ClientStorage.ClientStorage(addr, + client=self.options.pcachename, + var=self.options.pcachedir, + cache_size=self.options.pcachesize*1024*1024) + self.db=DB(storage, cache_size=self.options.cachesize) + self.poollock = Lock() + self.getDataRoot() + self.login() + + + def login(self, name='admin', userfolder=None): + '''Logs in.''' + if userfolder is None: + userfolder = self.app.acl_users + user = userfolder.getUserById(name) + if user is None: return + if not hasattr(user, 'aq_base'): + user = user.__of__(userfolder) + newSecurityManager(None, user) + + + def logout(self): + '''Logs out.''' + noSecurityManager() + + + def getConnection(self): + """Return a wrapped app connection from the connection pool. + """ + if not self.db: + raise ZentinelException( + "running inside zope can't open connections.") + try: + self.poollock.acquire() + connection=self.db.open() + root=connection.root() + app=root['Application'] + self.getContext(app) + app._p_jar.sync() + return app + finally: + self.poollock.release() + + + def closeAll(self): + """Close all connections in both free an inuse pools. + """ + self.db.close() + + + def opendb(self): + if self.app: return + self.connection=self.db.open() + root=self.connection.root() + self.app=root['Application'] + self.getContext(self.app) + + + def syncdb(self): + self.connection.sync() + + + def closedb(self): + self.connection.close() + #self.db.close() + self.app = None + self.dataroot = None + self.dmd = None + + + def getDataRoot(self): + if not self.app: self.opendb() + if not self.dataroot: + self.dataroot = getObjByPath(self.app, self.options.dataroot) + self.dmd = self.dataroot + + + def getContext(self, app): + from ZPublisher.HTTPRequest import HTTPRequest + from ZPublisher.HTTPResponse import HTTPResponse + from ZPublisher.BaseRequest import RequestContainer + resp = HTTPResponse(stdout=None) + env = { + 'SERVER_NAME':'localhost', + 'SERVER_PORT':'8080', + 'REQUEST_METHOD':'GET' + } + req = HTTPRequest(None, env, resp) + return app.__of__(RequestContainer(REQUEST = req)) + + + def getDmdObj(self, path): + """return an object based on a path starting from the dmd""" + return getObjByPath(self.app, self.options.dataroot+path) + + + def findDevice(self, name): + """return a device based on its FQDN""" + devices = self.dataroot.getDmdRoot("Devices") + return devices.findDevice(name) + + + def buildOptions(self): + """basic options setup sub classes can add more options here""" + ZenDaemon.buildOptions(self) + self.parser.add_option('--host', + dest="host",default="localhost", + help="hostname of zeo server") + self.parser.add_option('--port', + dest="port",type="int", default=8100, + help="port of zeo server") + self.parser.add_option('-R', '--dataroot', + dest="dataroot", + default="/zport/dmd", + help="root object for data load (i.e. /zport/dmd)") + self.parser.add_option('--cachesize', + dest="cachesize",default=10000, type='int', + help="in memory cachesize default: 10000") + self.parser.add_option('--pcachename', + dest="pcachename",default=None, + help="persistent cache file name default:None") + self.parser.add_option('--pcachedir', + dest="pcachedir",default=defaultCacheDir, + help="persistent cache file directory") + self.parser.add_option('--pcachesize', + dest="pcachesize",default=10, type='int', + help="persistent cache file size in MB") + + + class ExportRM(ZCmdBase): def __init__(self): @@ -94,8 +394,11 @@ def export(self, root=None): if not root: root = self.dataroot - if hasattr(root, 'Networks'): - root.ZenUsers.isInTree = True + root.Networks.isInTree = True + root.ZenUsers.isInTree = True + root.Services.isInTree = True + root.Processes.isInTree = True + if hasattr(aq_base(root.ZenEventManager), 'exportXml'): root.ZenEventManager.isInTree = True root.ZenEventHistory.isInTree = True if hasattr(root, "exportXml"): |
From: <sv...@ze...> - 2007-03-19 19:00:59
|
Author: jstevens Date: 2007-03-19 15:00:53 -0400 (Mon, 19 Mar 2007) New Revision: 4311 Removed: trunk/Products/ZenUtils/TwistedAuth.py Log: fixes 1092 * This has been supplanted by twisted.xmlprc.Proxy which now supports basic auth. Deleted: trunk/Products/ZenUtils/TwistedAuth.py |
From: <sv...@ze...> - 2007-03-19 18:59:41
|
Author: jstevens Date: 2007-03-19 14:59:40 -0400 (Mon, 19 Mar 2007) New Revision: 4310 Modified: trunk/Products/ZenRRD/RRDDaemon.py Log: refs *1092 * Using twisted for basic auth xmlrpc instead of TwistedAuth class Modified: trunk/Products/ZenRRD/RRDDaemon.py =================================================================== --- trunk/Products/ZenRRD/RRDDaemon.py 2007-03-19 18:55:56 UTC (rev 4309) +++ trunk/Products/ZenRRD/RRDDaemon.py 2007-03-19 18:59:40 UTC (rev 4310) @@ -20,11 +20,12 @@ from Products.ZenEvents import Event from Products.ZenEvents.ZenEventClasses import Perf_Snmp, App_Start, App_Stop from Products.ZenEvents.ZenEventClasses import Heartbeat -from Products.ZenUtils.TwistedAuth import AuthProxy +#from Products.ZenUtils.TwistedAuth import AuthProxy from Products.ZenUtils.Utils import basicAuthUrl from twisted.internet import reactor, error from twisted.python import failure +from twisted.web.xmlrpc import Proxy from Products.ZenUtils.ZCmdBase import ZCmdBase as Base @@ -168,8 +169,8 @@ self.zem = self.buildProxy(self.options.zem) def buildProxy(self, url): - "create AuthProxy objects with our config and the given url" - return AuthProxy(url, + "create Proxy objects with our config and the given url" + return Proxy(url, self.options.zopeusername, self.options.zopepassword) |
From: <sv...@ze...> - 2007-03-19 18:55:58
|
Author: jstevens Date: 2007-03-19 14:55:56 -0400 (Mon, 19 Mar 2007) New Revision: 4309 Added: trunk/inst/externallibs/Twisted-2.5.0.patch01 trunk/inst/externallibs/Twisted-2.5.0.tar.bz2 Removed: trunk/inst/externallibs/Twisted-2.4.0.patch01 trunk/inst/externallibs/Twisted-2.4.0.tar.bz2 Log: refs #1092 * Switching from Twisted 2.4 to Twisted 2.5 Deleted: trunk/inst/externallibs/Twisted-2.4.0.patch01 Deleted: trunk/inst/externallibs/Twisted-2.4.0.tar.bz2 Added: trunk/inst/externallibs/Twisted-2.5.0.patch01 Added: trunk/inst/externallibs/Twisted-2.5.0.tar.bz2 Property changes on: trunk/inst/externallibs/Twisted-2.5.0.tar.bz2 ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <sv...@ze...> - 2007-03-19 18:29:12
|
Author: jstevens Date: 2007-03-19 14:29:09 -0400 (Mon, 19 Mar 2007) New Revision: 4308 Modified: trunk/inst/GNUmakefile Log: Fixes #1091 * Don't build win-exe on macs. Modified: trunk/inst/GNUmakefile =================================================================== --- trunk/inst/GNUmakefile 2007-03-19 17:50:32 UTC (rev 4307) +++ trunk/inst/GNUmakefile 2007-03-19 18:29:09 UTC (rev 4308) @@ -17,6 +17,11 @@ ZOPEUSER=admin ZOPEHOME= $(ZENHOME) +DARWIN=0 +ifeq ($(shell python -c 'import sys; print sys.platform'),darwin) + DARWIN=1 +endif + DESTDIR= / INSTDIR= $(PWD) RRDTOOL= $(ZENHOME) @@ -130,18 +135,33 @@ fi -products-install: \ - zope-install \ - twistedsnmp-install \ - mysql-python-install \ - rrdtool-install \ - epydoc-install \ - snpp-install \ - yapps-install \ - nagios-install \ - libsmi-install \ - simplejson-install \ - winexe-install +# don't build winexe-install on a mac +ifeq ($(DARWIN),1) + products-install: \ + zope-install \ + twistedsnmp-install \ + mysql-python-install \ + rrdtool-install \ + epydoc-install \ + snpp-install \ + yapps-install \ + nagios-install \ + libsmi-install \ + simplejson-install +else + products-install: \ + zope-install \ + twistedsnmp-install \ + mysql-python-install \ + rrdtool-install \ + epydoc-install \ + snpp-install \ + yapps-install \ + nagios-install \ + libsmi-install \ + simplejson-install \ + winexe-install +endif # twill provides pyparsing pydot-install: graphviz-install twill-install |
From: <sv...@ze...> - 2007-03-19 17:50:33
|
Author: edahl Date: 2007-03-19 13:50:32 -0400 (Mon, 19 Mar 2007) New Revision: 4307 Modified: sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py Log: * take pack migrate script away its just building relaitons * take select_variable out of all attrs except selection Modified: sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py 2007-03-19 15:23:35 UTC (rev 4306) +++ sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py 2007-03-19 17:50:32 UTC (rev 4307) @@ -65,6 +65,6 @@ import defaultcommandtimeout import eventclassmapping import zenuilayer -import packs +#import packs import menus import zlocal Modified: sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py 2007-03-19 15:23:35 UTC (rev 4306) +++ sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py 2007-03-19 17:50:32 UTC (rev 4307) @@ -284,15 +284,17 @@ if not value and ptype not in ("int","float","boolean"): continue stag = [] stag.append('<property') - stag.extend(["%s=%s" % (k,saxutils.quoteattr(str(v))) \ - for k,v in prop.items()]) + for k, v in prop.items(): + if ptype != 'selection' and k == 'select_variable': continue + v = saxutils.quoteattr(str(v)) + stag.append('%s=%s' % (k, v)) stag.append('>') ofile.write(' '.join(stag)+"\n") if type(value) not in types.StringTypes: value = unicode(value) elif type(value) == types.StringType: value = value.decode('latin-1') - ofile.write(saxutils.escape(value.encode('utf-8'))+"\n") + ofile.write(saxutils.escape(value).encode('utf-8')+"\n") ofile.write("</property>\n") |
From: <sv...@ze...> - 2007-03-19 15:24:01
|
Author: ecn Date: 2007-03-19 11:23:35 -0400 (Mon, 19 Mar 2007) New Revision: 4306 Modified: trunk/Products/ZenModel/OSProcess.py Log: thresholds are not a list; they are a dictionary Modified: trunk/Products/ZenModel/OSProcess.py =================================================================== --- trunk/Products/ZenModel/OSProcess.py 2007-03-19 15:22:25 UTC (rev 4305) +++ trunk/Products/ZenModel/OSProcess.py 2007-03-19 15:23:35 UTC (rev 4306) @@ -69,9 +69,9 @@ def getOSProcessConf(self): """Return information used to monitor this process. """ - thresholds = [] + thresholds = {} for templ in self.getRRDTemplates(): - thresholds.append(self.getThresholds(templ)) + thresholds.update(self.getThresholds(templ)) return (self.id, self.name(), self.osProcessClass().ignoreParameters, self.alertOnRestart(), self.getFailSeverity(), thresholds) |
From: <sv...@ze...> - 2007-03-19 15:22:33
|
Author: ecn Date: 2007-03-19 11:22:25 -0400 (Mon, 19 Mar 2007) New Revision: 4305 Modified: trunk/Products/ZenRRD/RRDDaemon.py Log: log errors with full stacktrace using log.exception Modified: trunk/Products/ZenRRD/RRDDaemon.py =================================================================== --- trunk/Products/ZenRRD/RRDDaemon.py 2007-03-19 15:11:34 UTC (rev 4304) +++ trunk/Products/ZenRRD/RRDDaemon.py 2007-03-19 15:22:25 UTC (rev 4305) @@ -269,10 +269,7 @@ def logError(self, msg, error): if isinstance(error, failure.Failure): - from StringIO import StringIO - s = StringIO() - error.printTraceback(s) - self.log.error('%s: %s', msg, s.getvalue()) + self.log.exception(error) else: self.log.error('%s %s', msg, error) |
From: <sv...@ze...> - 2007-03-19 15:12:09
|
Author: ecn Date: 2007-03-19 11:11:34 -0400 (Mon, 19 Mar 2007) New Revision: 4304 Modified: trunk/Products/ZenModel/RRDDataPoint.py Log: #1089, force # on the color of a src in case the user didn't put it there Modified: trunk/Products/ZenModel/RRDDataPoint.py =================================================================== --- trunk/Products/ZenModel/RRDDataPoint.py 2007-03-17 19:02:48 UTC (rev 4303) +++ trunk/Products/ZenModel/RRDDataPoint.py 2007-03-19 15:11:34 UTC (rev 4304) @@ -136,8 +136,10 @@ (dest,src,self.limit,src)) src = dest - if not self.color: src += defaultcolor - else: src += self.color + color = defaultcolor + if self.color: + color = self.color + src += '#%s' % color.lstrip('#') if not self.linetype: type = defaulttype else: type = self.linetype |
From: <sv...@ze...> - 2007-03-17 19:02:52
|
Author: edahl Date: 2007-03-17 15:02:48 -0400 (Sat, 17 Mar 2007) New Revision: 4303 Modified: trunk/inst/zen2dump.py trunk/inst/zenUsers2dump.py Log: * export users folder * put exported files into one zip file * make sure that zenusers zeneventmanger and zenhistorymanager are exported * ignore nagiosTemplates * put Networks at the font of the export file Modified: trunk/inst/zen2dump.py =================================================================== --- trunk/inst/zen2dump.py 2007-03-17 18:58:16 UTC (rev 4302) +++ trunk/inst/zen2dump.py 2007-03-17 19:02:48 UTC (rev 4303) @@ -1,3 +1,4 @@ +#!/usr/bin/env python ################################################################# # # Copyright (c) 2003 Zenoss, Inc. All rights reserved. @@ -12,7 +13,8 @@ __version__ = "$Revision: 1.1 $"[11:-2] -import sys +import sys, os, types +import zipfile import Globals @@ -30,21 +32,42 @@ for prop in self._properties: if not prop.has_key('id'): continue id = prop['id'] - type = prop['type'] + ptype = prop['type'] value = getattr(aq_base(self), id, None) # use aq_base? - if not value and type not in ("int","float","boolean"): continue + if not value and ptype not in ("int","float","boolean"): continue stag = [] stag.append('<property') stag.extend(["%s=%s" % (k,saxutils.quoteattr(str(v))) \ for k,v in prop.items()]) stag.append('>') ofile.write(' '.join(stag)+"\n") - value = unicode(value) + if type(value) not in types.StringTypes: + value = unicode(value) + elif type(value) == types.StringType: + value = value.decode('latin-1') ofile.write(saxutils.escape(value.encode('utf-8'))+"\n") ofile.write("</property>\n") from Products.ZenRelations.RelationshipManager import RelationshipManager RelationshipManager.exportXmlProperties = exportXmlProperties + +def getDmdRoots(self): + """Put Networks at the front of the list of roots to export + because if devices are loaded the networks will be auto created. + """ + roots = filter(lambda o: o.isInTree, self.objectValues()) + roots.insert(0, self._getOb('Networks')) + return roots +from Products.ZenModel.DataRoot import DataRoot +DataRoot.getDmdRoots = getDmdRoots + + +def exportXmlHook(self,ofile, ignorerels): + map(lambda x: x.exportXml(ofile, ignorerels), self.getAllUserSettings()) +from Products.ZenModel.UserSettings import UserSettingsManager +UserSettingsManager.exportXmlHook = exportXmlHook + + from Products.ZenUtils.ZCmdBase import ZCmdBase class ExportRM(ZCmdBase): @@ -61,10 +84,10 @@ """basic options setup sub classes can add more options here""" ZCmdBase.buildOptions(self) self.parser.add_option('-o', '--outfile', - dest="outfile", + dest="outfile", default="dump_zenoss.xml", help="output file for export default is stdout") self.parser.add_option('--ignore', action="append", - dest="ignorerels", default=[], + dest="ignorerels", default=['nagiosTemplates',], help="relations that should be ignored can be many") @@ -72,17 +95,35 @@ if not root: root = self.dataroot if hasattr(root, 'Networks'): - root.Networks.isInTree = True + root.ZenUsers.isInTree = True + root.ZenEventManager.isInTree = True + root.ZenEventHistory.isInTree = True if hasattr(root, "exportXml"): self.outfile.write("""<?xml version="1.0" encoding='utf-8'?>\n""") self.outfile.write("<objects>\n") root.exportXml(self.outfile,self.options.ignorerels,True) self.outfile.write("</objects>\n") + self.outfile.close() else: print "ERROR: root object not a exportable (exportXml not found)" + def exportACLUsers(self): + acl = self.app.zport.acl_users + acl._p_jar.exportFile(acl._p_oid, 'dump_acl_users.zexp') + + def makezip(self): + zf = zipfile.ZipFile('zendump.zip', 'w', zipfile.ZIP_DEFLATED) + zf.write('dump_zenoss.xml') + zf.write('dump_acl_users.zexp') + zf.close() + os.remove('dump_zenoss.xml') + os.remove('dump_acl_users.zexp') + + if __name__ == '__main__': ex = ExportRM() ex.export() + ex.exportACLUsers() + ex.makezip() Modified: trunk/inst/zenUsers2dump.py =================================================================== --- trunk/inst/zenUsers2dump.py 2007-03-17 18:58:16 UTC (rev 4302) +++ trunk/inst/zenUsers2dump.py 2007-03-17 19:02:48 UTC (rev 4303) @@ -1,4 +1,5 @@ import Globals +import transaction from Products.ZenUtils.ZCmdBase import ZCmdBase @@ -10,7 +11,7 @@ acl = zport.acl_users acl._p_jar.exportFile(acl._p_oid, 'acl_users.zexp') - def importACLUsers(): + def importACLUsers(self): app = self.dmd.getPhysicalRoot() zport = app.zport zport._importObjectFromFile('acl_users.zexp', verify=0) @@ -20,12 +21,13 @@ zu = self.dmd.ZenUsers zu._p_jar.exportFile(zu._p_oid, 'ZenUsers.zexp') - def importZenUsers(): + def importZenUsers(self): self.dmd._importObjectFromFile('ZenUsers.zexp', verify=0) transaction.commit() if __name__ == '__main__': zu2d = zenUsers2dump() - zu2d.exportACLUsers() - zu2d.exportZenUsers() \ No newline at end of file + #zu2d.exportACLUsers() + #zu2d.exportZenUsers() + zu2d.importACLUsers() |
From: <sv...@ze...> - 2007-03-17 18:58:49
|
Author: edahl Date: 2007-03-17 14:58:16 -0400 (Sat, 17 Mar 2007) New Revision: 4302 Added: sandboxen/edahl/zenrelrefactor/ZenModel/migrate/zlocal.py Modified: sandboxen/edahl/zenrelrefactor/ZenModel/Device.py sandboxen/edahl/zenrelrefactor/ZenModel/DeviceClass.py sandboxen/edahl/zenrelrefactor/ZenModel/IpInterface.py sandboxen/edahl/zenrelrefactor/ZenModel/IpNetwork.py sandboxen/edahl/zenrelrefactor/ZenModel/IpRouteEntry.py sandboxen/edahl/zenrelrefactor/ZenModel/ManagedEntity.py sandboxen/edahl/zenrelrefactor/ZenModel/UserSettings.py sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py sandboxen/edahl/zenrelrefactor/ZenModel/migrate/menus.py sandboxen/edahl/zenrelrefactor/ZenModel/skins/zenmodel/serviceOrganizerOverview.pt sandboxen/edahl/zenrelrefactor/ZenRelations/ExportDevices.py sandboxen/edahl/zenrelrefactor/ZenRelations/ImportRM.py sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py sandboxen/edahl/zenrelrefactor/ZenRelations/ToManyContRelationship.py sandboxen/edahl/zenrelrefactor/ZenUtils/Utils.py Log: * add zproperties for local ips and interfaces * change default tree to (32,) * fix spelling error in dependency relations * handle strings with high bytes better in export Modified: sandboxen/edahl/zenrelrefactor/ZenModel/Device.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/Device.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/Device.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -1298,5 +1298,12 @@ environ.update({'dev': context, 'device': context,}) return environ + + def exportXmlHook(self, ofile, ignorerels): + """Add export of our child objects. + """ + map(lambda o: o.exportXml(ofile, ignorerels), (self.hw, self.os)) + + InitializeClass(Device) Modified: sandboxen/edahl/zenrelrefactor/ZenModel/DeviceClass.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/DeviceClass.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/DeviceClass.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -584,7 +584,10 @@ devs._setProperty("zFileSystemMapIgnoreNames", "") devs._setProperty("zSysedgeDiskMapIgnoreNames", "") devs._setProperty("zIpServiceMapMaxPort", 1024, type="int") + devs._setProperty("zLocalIpAddresses", "^127|^0\.0|^169\.254|^224") + devs._setProperty("zLocalInterfaceNames", "^lo|^vmnet") + # RRD properties #FIXME - should this be added to allow for more flexability of # RRDTemplate binding? Modified: sandboxen/edahl/zenrelrefactor/ZenModel/IpInterface.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/IpInterface.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/IpInterface.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -29,6 +29,7 @@ from Products.ZenRelations.RelSchema import * from IpAddress import IpAddress, findIpAddress +from Products.ZenUtils.Utils import localIpCheck, localInterfaceCheck from Products.ZenUtils.IpUtil import * from ConfmonPropManager import ConfmonPropManager @@ -60,7 +61,7 @@ # indexes are id and description #default_catalog = 'interfaceSearch' - ifindex = 0 + ifindex = '0' interfaceName = '' macaddress = "" type = "" @@ -221,7 +222,7 @@ ipids = self.ipaddresses.objectIdsAll() localips = copy.copy(self._ipAddresses) for ip in ips: - if self.localipcheck(ip) or self.localintcheck(self.id): + if localIpCheck(self, ip) or localInterfaceCheck(self, self.id): if not ip in localips: self.addLocalIpAddress(ip) else: Modified: sandboxen/edahl/zenrelrefactor/ZenModel/IpNetwork.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/IpNetwork.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/IpNetwork.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -56,7 +56,7 @@ # when an ip is added the defaul location will be # into class A->B->C network tree -defaultNetworkTree = (8,16,24) +defaultNetworkTree = (32,) class IpNetwork(DeviceOrganizer): """IpNetwork object""" Modified: sandboxen/edahl/zenrelrefactor/ZenModel/IpRouteEntry.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/IpRouteEntry.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/IpRouteEntry.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -18,6 +18,7 @@ from Globals import InitializeClass from AccessControl import ClassSecurityInfo +from Products.ZenUtils.Utils import localIpCheck from Products.ZenRelations.RelSchema import * from IpAddress import findIpAddress @@ -143,7 +144,7 @@ def setNextHopIp(self, nextHopIp): """if the nexthop is a 127. or 0. address store locally else link to it in the network hierarchy""" - if self.ipcheck(nextHopIp) or not nextHopIp: + if localIpCheck(self, nextHopIp) or not nextHopIp: self._nexthop = nextHopIp else: ip = findIpAddress(self, nextHopIp) @@ -166,7 +167,7 @@ def setTarget(self, netip): """Set this route target netip in the form 10.0.0.0/24. """ - if self.ipcheck(netip): + if localIpCheck(self, netip): self._target = netip else: net = self.getDmdRoot("Networks").createNet(netip) Modified: sandboxen/edahl/zenrelrefactor/ZenModel/ManagedEntity.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/ManagedEntity.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/ManagedEntity.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -36,13 +36,13 @@ monitor = True _properties = ( - {'id':'snmpindex', 'type':'int', 'mode':'w'}, + {'id':'snmpindex', 'type':'string', 'mode':'w'}, {'id':'monitor', 'type':'boolean', 'mode':'w'}, ) _relations = ( - ("dependenices", ToMany(ToMany, "ManagedEntity", "dependants")), - ("dependants", ToMany(ToMany, "ManagedEntity", "dependenices")), + ("dependencies", ToMany(ToMany, "ManagedEntity", "dependents")), + ("dependents", ToMany(ToMany, "ManagedEntity", "dependencies")), ) def device(self): Modified: sandboxen/edahl/zenrelrefactor/ZenModel/UserSettings.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/UserSettings.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/UserSettings.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -272,6 +272,9 @@ return filter(rolefilter, self.valid_roles()) + def exportXmlHook(self,ofile, ignorerels): + map(lambda x: x.exportXml(ofile, ignorerels), self.getAllUserSettings()) + def manage_addUserSettings(context, id, title = None, REQUEST = None): Modified: sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/migrate/__init__.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -67,3 +67,4 @@ import zenuilayer import packs import menus +import zlocal Modified: sandboxen/edahl/zenrelrefactor/ZenModel/migrate/menus.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/migrate/menus.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/migrate/menus.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -24,28 +24,28 @@ def cutover(self, dmd): dmd.buildRelations() - for dev in dmd.Devices.getSubDevices(): - dev.buildRelations() - for name in ['Devices', 'Systems', 'Groups', 'Locations', - 'Services', 'Processes']: - top = getattr(dmd, name) - orgs = top.getSubOrganizers() - orgs.insert(0, top) - for o in orgs: - o.buildRelations() - if name == 'Devices': - for d in o.devices(): - d.buildRelations() - if getattr(d, 'os', None): - for n in ['ipservices', 'winservices', 'processes']: - for p in getattr(d.os, n)(): - p.buildRelations() - if name == 'Services': - for sc in o.serviceclasses(): - sc.buildRelations() - if name == 'Processes': - for pc in o.osProcessClasses(): - pc.buildRelations() +# for dev in dmd.Devices.getSubDevices(): +# dev.buildRelations() +# for name in ['Devices', 'Systems', 'Groups', 'Locations', +# 'Services', 'Processes']: +# top = getattr(dmd, name) +# orgs = top.getSubOrganizers() +# orgs.insert(0, top) +# for o in orgs: +# o.buildRelations() +# if name == 'Devices': +# for d in o.devices(): +# d.buildRelations() +# if getattr(d, 'os', None): +# for n in ['ipservices', 'winservices', 'processes']: +# for p in getattr(d.os, n)(): +# p.buildRelations() +# if name == 'Services': +# for sc in o.serviceclasses(): +# sc.buildRelations() +# if name == 'Processes': +# for pc in o.osProcessClasses(): +# pc.buildRelations() # Add menus. dmd.buildMenus( Added: sandboxen/edahl/zenrelrefactor/ZenModel/migrate/zlocal.py Modified: sandboxen/edahl/zenrelrefactor/ZenModel/skins/zenmodel/serviceOrganizerOverview.pt =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenModel/skins/zenmodel/serviceOrganizerOverview.pt 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenModel/skins/zenmodel/serviceOrganizerOverview.pt 2007-03-17 18:58:16 UTC (rev 4302) @@ -23,8 +23,8 @@ tableName,'primarySortKey','Name')"/> <th tal:replace="structure python:here.ZenTableManager.getTableHeader( tableName,'countChildren','Sub-Folders')"/> - <th tal:replace="structure python:here.ZenTableManager.getTableHeader( - tableName,'countClasses','Services')"/> + <!--<th tal:replace="structure python:here.ZenTableManager.getTableHeader( + tableName,'countClasses','Services')"/>--> </tr> <tal:block tal:repeat="svcorg batch"> <tr tal:define="odd repeat/svcorg/odd" @@ -39,7 +39,9 @@ </td> <td class="tablevalues" align=center tal:content="svcorg/countChildren"/> + <!-- <td class="tablevalues" align=center tal:content="svcorg/countClasses"/> + --> </tr> </tal:block> <tr> Modified: sandboxen/edahl/zenrelrefactor/ZenRelations/ExportDevices.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenRelations/ExportDevices.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenRelations/ExportDevices.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -80,7 +80,8 @@ root = self.dmd.Devices buffer = StringIO.StringIO() if hasattr(root, "exportXml"): - buffer.write("""<?xml version="1.0"?>\n""") + buffer = self.outfile + buffer.write("""<?xml version="1.0"? encoding='latin-1'>\n""") buffer.write("<objects>\n") root.exportXml(buffer,self.options.ignorerels,True) buffer.write("</objects>\n") Modified: sandboxen/edahl/zenrelrefactor/ZenRelations/ImportRM.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenRelations/ImportRM.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenRelations/ImportRM.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -22,6 +22,7 @@ from xml.sax.handler import ContentHandler from Acquisition import aq_base +from zExceptions import NotFound from DateTime import DateTime @@ -101,7 +102,7 @@ obj = getObjByPath(self.app, id) else: obj = self.context()._getOb(id) - except (KeyError, AttributeError): pass + except (KeyError, AttributeError, NotFound): pass if obj is None: klass = importClass(attrs.get('module'), attrs.get('class')) if id.find("/") > -1: @@ -111,8 +112,8 @@ obj = klass(id) self.context()._setObject(obj.id, obj) obj = self.context()._getOb(obj.id) - transaction.savepoint() self.objectnumber += 1 + if self.objectnumber % 5000 == 0: transaction.savepoint() self.log.debug("Added object %s to database" % obj.getPrimaryId()) else: self.log.warn("Object %s already exists skipping" % id) @@ -136,9 +137,12 @@ except IndexError: proptype = 'string' if proptype == "date": + try: value = float(value) + except ValueError: pass value = DateTime(value) elif proptype != "string" and proptype != 'text': - value = eval(value) + try: value = eval(value) + except SyntaxError: pass if not obj.hasProperty(name): obj._setProperty(name, value, type=proptype, setter=setter) else: @@ -164,7 +168,7 @@ except: self.log.critical( "Failed linking relation %s to object %s",relid,objid) - raise + #raise Modified: sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenRelations/RelationshipManager.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -279,16 +279,20 @@ for prop in self._properties: if not prop.has_key('id'): continue id = prop['id'] - type = prop['type'] + ptype = prop['type'] value = getattr(aq_base(self), id, None) # use aq_base? - if not value and type not in ("int","float","boolean"): continue + if not value and ptype not in ("int","float","boolean"): continue stag = [] stag.append('<property') stag.extend(["%s=%s" % (k,saxutils.quoteattr(str(v))) \ for k,v in prop.items()]) stag.append('>') ofile.write(' '.join(stag)+"\n") - ofile.write(saxutils.escape(str(value))+"\n") + if type(value) not in types.StringTypes: + value = unicode(value) + elif type(value) == types.StringType: + value = value.decode('latin-1') + ofile.write(saxutils.escape(value.encode('utf-8'))+"\n") ofile.write("</property>\n") Modified: sandboxen/edahl/zenrelrefactor/ZenRelations/ToManyContRelationship.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenRelations/ToManyContRelationship.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenRelations/ToManyContRelationship.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -169,6 +169,7 @@ del self._objects[id] else: self._objects = OOBTree() + self.__primary_parent__._p_changed = True def _remoteRemove(self, obj=None): Modified: sandboxen/edahl/zenrelrefactor/ZenUtils/Utils.py =================================================================== --- sandboxen/edahl/zenrelrefactor/ZenUtils/Utils.py 2007-03-16 21:15:34 UTC (rev 4301) +++ sandboxen/edahl/zenrelrefactor/ZenUtils/Utils.py 2007-03-17 18:58:16 UTC (rev 4302) @@ -463,4 +463,19 @@ else: result = (True, '') return result - + + +def zdecode(context, value): + if type(value) in types.StringTypes: + decoding = getattr(obj, 'zCollectorDecoding', 'latin-1') + value = value.decode(decoding) + return value + + +def localIpCheck(context, ip): + """Test to see if ip it should not be included in the network map.""" + return re.search(getattr(context, 'zLocalIpAddresses', '^$'), ip) + +def localInterfaceCheck(context, intname): + """Test to see if ips on an in should not be included in the network map.""" + return re.search(getattr(context, 'zLoaclInterfaceNames', '^$'), intname) |
From: <sv...@ze...> - 2007-03-16 21:15:34
|
Author: marc Date: 2007-03-16 17:15:34 -0400 (Fri, 16 Mar 2007) New Revision: 4301 Modified: trunk/Products/ZenModel/PerformanceConf.py Log: #1084 * fixed call to ZenEventManager Modified: trunk/Products/ZenModel/PerformanceConf.py =================================================================== --- trunk/Products/ZenModel/PerformanceConf.py 2007-03-16 20:58:26 UTC (rev 4300) +++ trunk/Products/ZenModel/PerformanceConf.py 2007-03-16 21:15:34 UTC (rev 4301) @@ -169,7 +169,7 @@ counts = {} try: # get all the events with /Status/Snmp - zem = self.ZenEventManager + zem = self.dmd.ZenEventManager conn = zem.connect() try: curs = conn.cursor() @@ -206,8 +206,7 @@ curs.execute(query) for device, component, count in curs.fetchall(): down[device] = (component, count) - finally: - conn.close() + finally: zem.close(conn) result = [] for dev in self.devices(): try: |
From: <sv...@ze...> - 2007-03-16 20:58:28
|
Author: ecn Date: 2007-03-16 16:58:26 -0400 (Fri, 16 Mar 2007) New Revision: 4300 Modified: trunk/Products/ZenModel/PerformanceConf.py Log: * don't close the connection until you know you opened it Modified: trunk/Products/ZenModel/PerformanceConf.py =================================================================== --- trunk/Products/ZenModel/PerformanceConf.py 2007-03-16 20:51:19 UTC (rev 4299) +++ trunk/Products/ZenModel/PerformanceConf.py 2007-03-16 20:58:26 UTC (rev 4300) @@ -169,9 +169,9 @@ counts = {} try: # get all the events with /Status/Snmp + zem = self.ZenEventManager + conn = zem.connect() try: - zem = self.ZenEventManager - conn = zem.connect() curs = conn.cursor() cmd = ('SELECT device, sum(count) ' + ' FROM status ' + |
Author: chris Date: 2007-03-16 16:51:19 -0400 (Fri, 16 Mar 2007) New Revision: 4299 Added: trunk/inst/docs/Syslog-HOWTO_Screens/ trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/ trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/.typeAttributes.dict trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/Contents/ trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/Contents/PkgInfo trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/color-profile trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/index.apxl.gz trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/thumbs/ trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/thumbs/st0.tiff trunk/inst/docs/Syslog-HOWTO_Screens/loghost.png Log: refs #987 Added: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/.typeAttributes.dict Added: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/Contents/PkgInfo Added: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/color-profile Property changes on: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/color-profile ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/index.apxl.gz Property changes on: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/index.apxl.gz ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/thumbs/st0.tiff Property changes on: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.key/thumbs/st0.tiff ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.png Property changes on: trunk/inst/docs/Syslog-HOWTO_Screens/loghost.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream |
From: <sv...@ze...> - 2007-03-16 20:50:33
|
Author: chris Date: 2007-03-16 16:50:32 -0400 (Fri, 16 Mar 2007) New Revision: 4298 Added: trunk/inst/docs/Syslog-HOWTO.txt Log: fixes #987 Added: trunk/inst/docs/Syslog-HOWTO.txt |
From: <sv...@ze...> - 2007-03-16 18:50:39
|
Author: ian Date: 2007-03-16 14:50:36 -0400 (Fri, 16 Mar 2007) New Revision: 4297 Modified: trunk/Products/ZenWidgets/skins/zentablemanager/zenTableNavigation.pt Log: * Fixed an unbalanced div issue Modified: trunk/Products/ZenWidgets/skins/zentablemanager/zenTableNavigation.pt =================================================================== --- trunk/Products/ZenWidgets/skins/zentablemanager/zenTableNavigation.pt 2007-03-16 13:34:33 UTC (rev 4296) +++ trunk/Products/ZenWidgets/skins/zentablemanager/zenTableNavigation.pt 2007-03-16 18:50:36 UTC (rev 4297) @@ -151,8 +151,8 @@ tal:define="ts python:here.ZenTableManager.getTableState(tableName); message request/SESSION/message | nothing;" style="border:0; padding-top:2px;margin-bottom:2px;"> + <div style="padding-left: 10px; float: left; text-align:left;"> <!-- Filter boxes moved up into table header - <div style="padding-left: 10px; float: left; text-align:left;"> Filter <input class="tableheader" type="text" name="filter" size=40 value="" onkeypress="submitViaEnter(event)" |
From: <sv...@ze...> - 2007-03-16 13:34:33
|
Author: marc Date: 2007-03-16 09:34:33 -0400 (Fri, 16 Mar 2007) New Revision: 4296 Modified: trunk/Products/ZenRRD/RenderServer.py Log: #827 * unquote of file data Modified: trunk/Products/ZenRRD/RenderServer.py =================================================================== --- trunk/Products/ZenRRD/RenderServer.py 2007-03-16 13:29:55 UTC (rev 4295) +++ trunk/Products/ZenRRD/RenderServer.py 2007-03-16 13:34:33 UTC (rev 4296) @@ -124,6 +124,7 @@ urllib.urlopen(remoteUrl) def packageRRDFiles(self, device, REQUEST=None): + """Tar a package of RRDFiles""" srcdir = performancePath('/Devices/%s' % device) tarfilename = '%s/%s.tgz' % (self.tmpdir, device) tar = tarfile.open(tarfilename, "w:gz") @@ -132,6 +133,7 @@ tar.close() def unpackageRRDFiles(self, device, REQUEST=None): + """Untar a package of RRDFiles""" destdir = performancePath('/Devices/%s' % device) tarfilename = '%s/%s.tgz' % (self.tmpdir, device) tar = tarfile.open(tarfilename, "r:gz") @@ -140,32 +142,33 @@ tar.close() def moveRRDFiles(self, device, server, REQUEST=None): - tarfilename = '%s/%s.tgz' % (self.tmpdir, device) - f=open(tarfilename, 'rb') + """Untar a package of RRDFiles""" + tarfilename = '%s.tgz' % device + f=open('%s/%s' % (self.tmpdir, tarfilename), 'rb') tarfilebody=f.read() f.close() # urlencode the id, title and file - params = urllib.urlencode({'id': tarfilename, - 'title':tarfilename, - 'file':tarfilebody}) + params = urllib.urlencode({'tarfilename': tarfilename, + 'tarfile':tarfilebody}) # send the file to zope - port = 8080 - remoteUrl = 'http://%s:%s/zport/RenderServer/receiveRRDFiles' % (server, port) - f=urllib.urlopen(remoteUrl, params) + remoteUrl = 'http://%s/zport/RenderServer/receiveRRDFiles' % server + urllib.urlopen(remoteUrl, params) - def receiveRRDFiles(self, id, title, file, REQUEST=None): - #tarfilename = '%s/%s' % (self.tmpdir, id) - tarfilename='/tmp/renderserver/test.tgz' - f=open(tarfilename, 'wb') - f.write(file) - f.close() + def receiveRRDFiles(self, REQUEST=None): + """receive a device's RRD Files from another server""" + if REQUEST: + tarfile = REQUEST.get('tarfile') + tarfilename = REQUEST.get('tarfilename') + f=open('%s/%s' % (self.tmpdir, tarfilename), 'wb') + f.write(urllib.unquote(tarfile)) + f.close() def sendRRDFiles(self, device, server, REQUEST=None): + """send a device's RRD Files to another server""" self.packageRRDFiles(device, REQUEST) self.moveRRDFiles(device, server, REQUEST) - port = 8080 - remoteUrl = 'http://%s:%s/zport/RenderServer/unpackageRRDFiles?device=%s' % (server, port, device) - urllib.urlopen(remoteUrl).read() + remoteUrl = 'http://%s/zport/RenderServer/unpackageRRDFiles?device=%s' % (server, device) + urllib.urlopen(remoteUrl) security.declareProtected('View', 'plugin') def plugin(self, name, REQUEST=None): |