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 Products.ZenModel.Link import ILink 1517 for iface in dev.os.interfaces(): 18 for ip in iface.ipaddresses(): 19 net = ip.network() 20 if net is None: 21 continue 22 else: 23 yield net2426 for ip in net.ipaddresses(): 27 dev = ip.device() 28 if dev is None: 29 continue 30 dcp = dev.getDeviceClassPath() 31 if not ( dcp.startswith(devclass) or 32 dcp.startswith('/Network/Router')): 33 continue 34 else: 35 yield dev36 4547 l = [x,y] 48 cmpf = lambda x,y:int(x.meta_type=='Device')-int(y.meta_type=='Device') 49 l.sort(cmpf) 50 return tuple(l)5153 """ Depth-first search of the network tree emanating from 54 rootnode, returning (network, device) edges. 55 """ 56 if depth: 57 for node in _get_related(rootnode, filter): 58 sorted = _sortedpair(rootnode, node) 59 pair = [x.id for x in sorted] 60 if pair not in pairs: 61 pairs.append(pair) 62 yield sorted 63 for childnode in _get_related(node, filter): 64 for n in _get_connections( 65 childnode, depth-1, pairs, filter): 66 yield n6769 """ Returns some edges """ 70 depth = int(depth) 71 g = _get_connections(rootnode, depth, [], filter) 72 def getColor(node): 73 if node.meta_type=='IpNetwork': 74 return '0xffffff' 75 summary = node.getEventSummary() 76 colors = '0xff0000 0xff8c00 0xffd700 0x00ff00 0x00ff00'.split() 77 color = '0x00ff00' 78 for i in range(5): 79 if summary[i][1]+summary[i][2]>0: 80 color = colors[i] 81 break 82 return color83 for nodea, nodeb in g: 84 if withIcons: 85 yield ((nodea.id, nodea.getIconPath(), getColor(nodea)), 86 (nodeb.id, nodeb.getIconPath(), getColor(nodeb))) 87 else: 88 yield (nodea.id, nodeb.id) 8991 """ Returns network links to other devices """ 92 visited = [] 93 ifaces = rootdevice.os.interfaces() 94 ifaceids = [x.getPrimaryId() for x in ifaces] 95 for iface in ifaces: 96 for ip in iface.ipaddresses.objectValuesGen(): 97 for ipsib in ip.network().ipaddresses.objectValuesGen(): 98 ifacesib = ipsib.interface() 99 if ifacesib is None: continue 100 if (ifacesib.getPrimaryId() in visited or 101 ifacesib.getPrimaryId() in ifaceids): 102 continue 103 visited.append(ifacesib.getPrimaryId()) 104 link = NetworkLink() 105 link.setEndpoints(iface, ifacesib) 106 yield link107 108 109111 """ Represents a link between two IpInterfaces 112 related by network connectivity. 113 Not a persistent object, so not managed 114 by a LinkManager. 115 Implements Products.ZenModel.Link.ILink. 116 """ 117 118 OSI_layer = '3' 119 pointa = None 120 pointb = None 121 126 131 134164136 eps = self.endpoints 137 if max([ep.getPingStatus() for ep in eps]) > 0: 138 return 5 139 zem = eps[0].dmd.ZenEventManager 140 return max(map(zem.getMaxSeverity,eps))141143 """ Return the addresses of the endpoints 144 aggregated for the generation of the context 145 """ 146 dmd = context.dmd 147 generation = len(context.getPrimaryPath())+1 148 def getancestoraddress(endpoint): 149 loc = endpoint.device().location() 150 if loc is None: return 151 path = loc.getPrimaryPath() 152 path = '/'.join(path[:generation]) 153 ancestor = dmd.getObjByPath(path) 154 if full: 155 return ancestor.getGeomapData() 156 else: 157 return ancestor.address158 result = map(getancestoraddress, self.endpoints) 159 result = filter(lambda x:x, result) 160 if len(result) < 2: return None 161 if result[0]==result[1]: return None 162 result.sort() 163 return tuple(result)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Thu Oct 25 16:28:29 2007 | http://epydoc.sourceforge.net |