def AllObjectInstancesWithEventInputs(dummy_context): """Which objects are there """ iid = zapi.getUtility(IIntIds, '') terms = [] for (oid, oobj) in iid.items(): if ISite.providedBy(oobj.object) or \ IIpNet.providedBy(oobj.object) or \ IHost.providedBy(oobj.object) or \ IInterface.providedBy(oobj.object) or \ IService.providedBy(oobj.object) or \ ISnmpValue.providedBy(oobj.object) or \ IEventLogic.providedBy(oobj.object): inpEventNames = oobj.object.getAllInpEventNames().keys() if len(inpEventNames) > 0: for inpEventName in inpEventNames: myId = oobj.object.objectID + u'.' + inpEventName terms.append(\ SimpleTerm(myId, str(myId), oobj.object.getDcTitle() + \ u'->' + inpEventName)) for iface in [INotifierEmail]: my_util = queryUtility(iface) if my_util is not None: inpEventNames = my_util.getAllInpEventNames().keys() if len(inpEventNames) > 0: for inpEventName in inpEventNames: myId = my_util.objectID + u'.' + inpEventName terms.append(\ SimpleTerm(myId, str(myId), my_util.getDcTitle()+ u'->' + inpEventName)) return SimpleVocabulary(terms)
def AllObjectInstances(dummy_context): """Which objects are there """ iid = zapi.getUtility(IIntIds, '') terms = [] for (oid, oobj) in iid.items(): if ISite.providedBy(oobj.object) or \ IIpNet.providedBy(oobj.object) or \ IHost.providedBy(oobj.object) or \ IInterface.providedBy(oobj.object) or \ IService.providedBy(oobj.object) or \ ISnmpValue.providedBy(oobj.object) or \ IEventLogic.providedBy(oobj.object): terms.append(\ SimpleTerm(oobj.object.objectID, str(oobj.object.objectID), oobj.object.getDcTitle())) for iface in [INotifierEmail]: my_util = queryUtility(iface) if my_util is not None: terms.append(\ SimpleTerm(my_util.objectID, str(my_util.objectID), my_util.getDcTitle())) return SimpleVocabulary(terms)
def eventInp_inward_relaying_shutdown(self, eventMsg=None): """ forward the event to all objects in this container through the signal filter """ print "Site.eventInp_inward_relaying_shutdown()" for name, obj in self.items(): if ISite.providedBy(obj): targetFunctionName = "inward_relaying_shutdown" elif IIpNet.providedBy(obj): targetFunctionName = "inward_relaying_shutdown" else: targetFunctionName = None if eventMsg is not None: inst_event = MsgEvent(senderObj = self, oidEventObject = eventMsg.oidEventObject, logText = u"inward relaying by site '%s'"\ % self.ikName, targetFunctionName = targetFunctionName) eventMsg.stopit(self, u"relaying by site '%s'" % self.ikName) else: inst_event = MsgEvent(senderObj = self, logText = u"inward relaying by site '%s'"\ % self.ikName, targetFunctionName = targetFunctionName) obj.injectInpEQueue(inst_event)
def AllValidSubIpNets(dummy_context): uidutil = getUtility(IIntIds) validObjects = [] if IIpNet.providedBy(dummy_context): myIpNetIp = IP(dummy_context.ipv4) for (oid, oobj) in uidutil.items(): if IIpNet.providedBy(oobj.object): i_IpNetIp = IP(oobj.object.ipv4) if i_IpNetIp in myIpNetIp and \ oobj.object != dummy_context: validObjects.append(oobj.object) else: for (oid, oobj) in uidutil.items(): if IIpNet.providedBy(oobj.object): validObjects.append(oobj.object) return ComponentsFromObjList(dummy_context, validObjects, 'ipv4')
def eventInp_inward_relaying_shutdown(self, eventMsg=None): """ forward the event to all objects in this container through the signal filter """ print "IpNet.eventInp_inward_relaying_shutdown()" for name, obj in self.items(): # first call if IIpNet.providedBy(obj): targetFunctionName = "inward_relaying_shutdown" logText = u"inward relaying to net '%s'" % obj.ikName elif IHostVMwareEsx.providedBy(obj): targetFunctionName = "inward_relaying_shutdown" logText = u"inward relaying to esx host '%s'" % obj.ikName elif IHostVMwareVm.providedBy(obj): targetFunctionName = None else: targetFunctionName = "shutdown" logText = u"send shutdown to '%s'" % obj.ikName if targetFunctionName is not None: if eventMsg is not None: inst_event = MsgEvent( senderObj=self, oidEventObject=eventMsg.oidEventObject, logText=logText, targetFunctionName=targetFunctionName) eventMsg.stopit(self, u"relaying by site '%s'" % self.ikName) else: inst_event = MsgEvent( senderObj=self, logText=logText, targetFunctionName=targetFunctionName) obj.injectInpEQueue(inst_event) # second call if IHostVMwareEsx.providedBy(obj): targetFunctionName = "shutdown" logText = u"send shutdown to esx host '%s'" % obj.ikName else: targetFunctionName = None if targetFunctionName is not None: if eventMsg is not None: inst_event = MsgEvent( senderObj=self, oidEventObject=eventMsg.oidEventObject, logText=logText, targetFunctionName=targetFunctionName) eventMsg.stopit(self, u"relaying by site '%s'" % self.ikName) else: inst_event = MsgEvent( senderObj=self, logText=logText, targetFunctionName=targetFunctionName) obj.injectInpEQueue(inst_event)
def __init__(self, **data): """ constructor of the object """ Component.__init__(self, **data) refAttributeNames = getRefAttributeNames(IpNet) for (name, value) in data.items(): if name in IIpNet.names(): if name not in refAttributeNames: setattr(self, name, value) self.eventInpObjs_inward_relaying_shutdown = set([]) self.ikRevision = __version__