Package ZenModel :: Module UBRRouter
[hide private]
[frames] | no frames]

Source Code for Module ZenModel.UBRRouter

 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  __doc__="""UBRRouter 
15   
16  UBRRouter class represents a Ubr Router 
17   
18  $Id: UBRRouter.py,v 1.12 2004/04/12 16:20:44 edahl Exp $""" 
19   
20  __version__ = "$Revision: 1.12 $"[11:-2] 
21   
22  from AccessControl import ClassSecurityInfo 
23  from Globals import DTMLFile 
24  from Globals import InitializeClass 
25   
26  from AccessControl import Permissions as permissions 
27   
28  from Products.ZenRelations.RelSchema import * 
29   
30  from IpAddress import findIpAddress 
31  from Device import Device 
32   
33 -def manage_addUBRRouter(context, id, title = None, REQUEST = None):
34 """make a device""" 35 serv = UBRRouter(id, title) 36 context._setObject(serv.id, serv) 37 38 if REQUEST is not None: 39 REQUEST['RESPONSE'].redirect(context.absolute_url() 40 +'/manage_main')
41 42 43 addUBRRouter = DTMLFile('dtml/addUBRRouter',globals()) 44 45
46 -class UBRRouter(Device):
47 """UBRRouter object""" 48 portal_type = meta_type = 'UBRRouter' 49 50 _relations = Device._relations + ( 51 ("dhcpservers", ToMany(ToMany, "Products.ZenModel.Device", "dhcpubrclients")), 52 ) 53 54 55 security = ClassSecurityInfo() 56
57 - def setDhcpHelpers(self, ips):
58 dhcpservers = self.dhcpservers.objectValuesAll() 59 sys = self.systems() 60 if len(sys): sys = sys[0] 61 else: sys = None 62 for ip in ips: 63 dip = findIpAddress(self, ip) 64 if not dip: continue 65 dserv = dip.getDevice() 66 if dserv in dhcpservers: 67 dhcpservers.remove(dserv) 68 continue 69 if sys: dserv.addRelation("systems", sys) 70 self.addRelation("dhcpservers", dserv) 71 for dserv in dhcpservers: 72 dserv.removeRelation("systems", sys) 73 self.removeRelation("dhcpservers", dserv)
74 75 76 InitializeClass(UBRRouter) 77