コード例 #1
0
ファイル: eventcrossbar.py プロジェクト: mleist/ict-ok.org
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)
コード例 #2
0
ファイル: eventcrossbar.py プロジェクト: mleist/ict-ok.org
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)
コード例 #3
0
ファイル: interfaces.py プロジェクト: mleist/ict-ok.org
 def ensureMyIpNotAlreadyUsed(intfc):
     if intfc.netType == 'ethernet' and \
          intfc.__context__ is not None and \
        intfc.ipv4List is not None:
         my_catalog = zapi.getUtility(ICatalog)
         alreadyFound = []
         # new Object
         if IHost.providedBy(intfc.__context__):
             for obj in my_catalog.searchResults(\
                 interface_ip_index=convertIpV4(intfc.ipv4List)):
                 ifHost = obj.__parent__
                 ifString = u"%s/%s" % (ifHost.ikName, obj.ikName)
                 alreadyFound.append(ifString)
         # edit Object
         if IInterface.providedBy(intfc.__context__):
             for obj in my_catalog.searchResults(\
                 interface_ip_index=convertIpV4(intfc.ipv4List)):
                 # don't check object itself
                 if obj.objectID != intfc.__context__.objectID:
                     ifHost = obj.__parent__
                     ifString = u"%s/%s" % (ifHost.ikName, obj.ikName)
                     alreadyFound.append(ifString)
         if len(alreadyFound) > 0:
             raise Invalid("The IP address already used in interface %s" % \
                           " ".join(alreadyFound))
コード例 #4
0
def getAllHosts():
    """ get a list of all Hosts
    """
    retList = []
    uidutil = getUtility(IIntIds)
    for (myid, myobj) in uidutil.items():
        if IHost.providedBy(myobj.object):
            retList.append(myobj.object)
    return retList
コード例 #5
0
ファイル: interfaces.py プロジェクト: mleist/ict-ok.org
 def ensureMyIpInNetIpRange(intfc):
     if intfc.netType == 'ethernet' and \
        intfc.__context__ is not None and \
        intfc.ipv4List is not None:
         if IHost.providedBy(intfc.__context__):
             host = intfc.__context__
         else:
             host = intfc.__context__.__parent__
         net = host.__parent__
         if not net.containsIp(intfc.ipv4List):
             raise Invalid("The IP address is not in ip-range %s of the "\
                           "network '%s'" % (net.ipv4, net.ikName))
コード例 #6
0
ファイル: host.py プロジェクト: mleist/ict-ok.org
def AllHosts(dummy_context):
    """In which production state a host may be
    """
    terms = []
    uidutil = getUtility(IIntIds)
    for (oid, oobj) in uidutil.items():
        if IHost.providedBy(oobj.object):
            myString = u"%s" % (oobj.object.getDcTitle())
            terms.append(\
                SimpleTerm(oobj.object,
                           token=oid,
                           title=myString))
    return SimpleVocabulary(terms)
コード例 #7
0
ファイル: host.py プロジェクト: mleist/ict-ok.org
def AllHostTemplates(dummy_context):
    """Which MobilePhone templates exists
    """
    terms = []
    uidutil = getUtility(IIntIds)
    for (oid, oobj) in uidutil.items():
        if IHost.providedBy(oobj.object) and \
        oobj.object.isTemplate:
            myString = u"%s [T]" % (oobj.object.getDcTitle())
            terms.append(SimpleTerm(oobj.object,
                                    token=oid,
                                    title=myString))
    return SimpleVocabulary(terms)
コード例 #8
0
 def isUsedIn(self):
     """
     this object is used at least in one host (returns object list)
     """
     retList = []
     iid = zapi.getUtility(IIntIds, '')
     for (oid, oobj) in iid.items():
         if IHost.providedBy(oobj.object):
             if self.objectID in oobj.object.hostGroups:
                 retList.append(oobj.object)
     utilXbar = getUtility(IAdmUtilEventCrossbar)
     for (oid, obj) in utilXbar.items():
         if IAdmUtilEvent.providedBy(obj):
             if self.objectID == obj.hostGroup:
                 retList.append(obj)
     return retList
コード例 #9
0
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 \
           INet.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()))
    my_util = zapi.getUtility(IAdmUtilTicker)
    terms.append(\
        SimpleTerm(my_util.objectID,
                   str(my_util.objectID),
                   my_util.getDcTitle()))
    return SimpleVocabulary(terms)