Trees | Indices | Help |
|
---|
|
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 from Globals import InitializeClass 15 from AccessControl import ClassSecurityInfo 16 from ZenModelRM import ZenModelRM 17 from Products.ZenRelations.RelSchema import * 18 from Products.ZenUtils.ZenTales import talesCompile, getEngine 19 2022 """make a GraphReportElement 23 """ 24 element = GraphReportElement(id) 25 context._setObject(element.id, element) 26 if REQUEST is not None: 27 REQUEST['RESPONSE'].redirect(context.absolute_url()+'/manage_main')28 2931 32 meta_type = 'GraphReportElement' 33 34 deviceId = '' 35 componentPath = '' 36 graphId = '' 37 sequence = 0 38 summary = ('Device: ${dev/id}\n' 39 ' \n' 40 'Component: ${comp/id}\n' 41 ' \n' 42 'Graph: ${graph/id}\n') 43 comments = ('Device: ${dev/id}<br />\n' 44 'Component: ${comp/id}<br />\n' 45 '${graph/id}') 46 47 _properties = ZenModelRM._properties + ( 48 {'id':'deviceId', 'type':'string', 'mode':'w'}, 49 {'id':'componentPath', 'type':'string', 'mode':'w'}, 50 {'id':'graphId', 'type':'string', 'mode':'w'}, 51 {'id':'sequence', 'type':'int', 'mode':'w'}, 52 {'id':'summary', 'type':'text', 'mode':'w'}, 53 {'id':'comments', 'type':'text', 'mode':'w'}, 54 ) 55 56 _relations = ZenModelRM._relations + ( 57 ("report", 58 ToOne(ToManyCont,"Products.ZenModel.GraphReport", "elements")), 59 ) 60 61 factory_type_information = ( 62 { 63 'immediate_view' : 'editGraphReportElement', 64 'actions' : 65 ( 66 {'name' : 'Edit', 67 'action' : 'editGraphReportElement', 68 'permissions' : ("Manage DMD",), 69 }, 70 ) 71 }, 72 ) 73 74 security = ClassSecurityInfo() 75138 139 140 InitializeClass(GraphReportElement) 14177 dev = self.getDevice() 78 if not dev: 79 return 'Device %s could not be found' % self.deviceId 80 comp = self.getComponent() 81 if not comp: 82 return 'Component %s could not be found for %s' % ( 83 self.componentPath, self.deviceId) 84 graph = self.getGraphDef() 85 if not graph: 86 return 'Graph %s could not be found for %s' % ( 87 self.graphId, self.deviceId) 88 compiled = talesCompile('string:' + text) 89 e = {'dev':dev, 'device': dev, 90 'comp': comp, 'component':comp, 91 'graph': graph} 92 try: 93 result = compiled(getEngine().getContext(e)) 94 if isinstance(result, Exception): 95 result = 'Error: %s' % str(result) 96 except Exception, e: 97 result = 'Error: %s' % str(e) 98 return result99 100 105 110 111 114 115117 component = self.getDevice() 118 for part in self.componentPath.split('/'): 119 if part: 120 component = getattr(component, part) 121 return component122 123 127 128130 ''' Return the url for the graph 131 ''' 132 component = self.getComponent() 133 graph = component.getGraphDef(self.graphId) 134 url = '' 135 if graph: 136 url = component.getGraphDefUrl(graph, drange, graph.rrdTemplate()) 137 return url
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:27 2007 | http://epydoc.sourceforge.net |