Trees | Indices | Help |
|
---|
|
1 ############################################################################## 2 # 3 # Copyright (C) Zenoss, Inc. 2007, all rights reserved. 4 # 5 # This content is made available according to terms specified in 6 # License.zenoss under the directory where your Zenoss product is installed. 7 # 8 ############################################################################## 9 10 11 from Products.ZenModel.Link import ILink 1214 for iface in dev.os.interfaces(): 15 for ip in iface.ipaddresses(): 16 net = ip.network() 17 if net is None or net.netmask == 32: 18 continue 19 else: 20 yield net2123 from Products.Zuul.catalog.global_catalog import IIndexableWrapper 24 for ip in net.ipaddresses(): 25 dev = ip.device() 26 if dev is None: 27 continue 28 paths = map('/'.join, IIndexableWrapper(dev).path()) 29 for path in paths: 30 if path.startswith(organizer) or path.startswith('/zport/dmd/Devices/Network/Router'): 31 yield dev 32 break33 4244 l = [x,y] 45 cmpf = lambda x,y:int(x.meta_type=='Device')-int(y.meta_type=='Device') 46 l.sort(cmpf) 47 return tuple(l)4850 """ Depth-first search of the network tree emanating from 51 rootnode, returning (network, device) edges. 52 """ 53 if not pairs: 54 pairs = [] 55 if depth: 56 for node in _get_related(rootnode, filter): 57 sorted = _sortedpair(rootnode, node) 58 pair = [x.id for x in sorted] 59 if pair not in pairs: 60 pairs.append(pair) 61 yield sorted 62 for childnode in _get_related(node, filter): 63 for n in _get_connections( 64 childnode, depth-1, pairs, filter): 65 yield n6668 """ Returns some edges """ 69 depth = int(depth) 70 g = _get_connections(rootnode, depth, [], filter) 71 def getColor(node): 72 if node.meta_type=='IpNetwork': 73 return '0xffffff' 74 summary = node.getEventSummary() 75 colors = '0xff0000 0xff8c00 0xffd700 0x00ff00 0x00ff00'.split() 76 color = '0x00ff00' 77 for i in range(5): 78 if summary[i][2]>0: 79 color = colors[i] 80 break 81 return color82 for nodea, nodeb in g: 83 if withIcons: 84 yield ((nodea.titleOrId(), nodea.getIconPath(), getColor(nodea)), 85 (nodeb.titleOrId(), nodeb.getIconPath(), getColor(nodeb))) 86 else: 87 yield (nodea.titleOrId(), nodeb.titleOrId()) 8890 """ Returns network links to other devices """ 91 visited = [] 92 ifaces = rootdevice.os.interfaces() 93 ifaceids = [x.getPrimaryId() for x in ifaces] 94 for iface in ifaces: 95 for ip in iface.ipaddresses.objectValuesGen(): 96 for ipsib in ip.network().ipaddresses.objectValuesGen(): 97 ifacesib = ipsib.interface() 98 if ifacesib is None: continue 99 if (ifacesib.getPrimaryId() in visited or 100 ifacesib.getPrimaryId() in ifaceids): 101 continue 102 visited.append(ifacesib.getPrimaryId()) 103 link = NetworkLink() 104 link.setEndpoints(iface, ifacesib) 105 yield link106 107 108110 """ Represents a link between two IpInterfaces 111 related by network connectivity. 112 Not a persistent object, so not managed 113 by a LinkManager. 114 Implements Products.ZenModel.Link.ILink. 115 """ 116 117 OSI_layer = '3' 118 pointa = None 119 pointb = None 120 124 129 132183134 eps = self.endpoints 135 if max(ep.getPingStatus() for ep in eps) > 0: 136 return 5 137 zem = eps[0].dmd.ZenEventManager 138 return max(map(zem.getMaxSeverity,eps))139 142144 if endpoint==self.pointa: return self.pointb 145 elif endpoint==self.pointb: return self.pointa 146 else: return None147149 # Eventually will return data for serialization 150 import json 151 return json.dumps([ 152 self.id, 153 self.getEndpointNames()[0], 154 self.getEndpointNames()[1], 155 self.OSI_layer, 156 self.link_type, 157 self.entry_type, 158 self.id 159 ])160162 """ Return the addresses of the endpoints 163 aggregated for the generation of the context 164 """ 165 dmd = context.dmd 166 generation = len(context.getPrimaryPath())+1 167 def getancestoraddress(endpoint): 168 loc = endpoint.device().location() 169 if loc is None: return 170 path = loc.getPrimaryPath() 171 path = '/'.join(path[:generation]) 172 ancestor = dmd.getObjByPath(path) 173 if full: 174 return ancestor.getGeomapData() 175 else: 176 return ancestor.address177 result = map(getancestoraddress, self.endpoints) 178 result = filter(lambda x:x, result) 179 if len(result) < 2: return None 180 if result[0]==result[1]: return None 181 result.sort() 182 return tuple(result)
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1.1812 on Mon Jul 30 17:11:30 2012 | http://epydoc.sourceforge.net |