Exemple #1
0
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)
Exemple #2
0
 def __init__(self, **data):
     """
     constructor of the object
     """
     LogicalDevice.__init__(self, **data)
     refAttributeNames = getRefAttributeNames(Host)
     # initialize OS List
     self.osList = []
     self.eventInpObjs_shutdown = set([])
     for (name, value) in data.items():
         if name in IHost.names() or \
            name in IEventIfEventHost.names():
             if name not in refAttributeNames:
                 setattr(self, name, value)
     self.ikRevision = __version__
     self.workflows[WfPdNagios.id] = nagios_wf = WfPdNagios()
     setattr(nagios_wf.workflowRelevantData, "ddd", 5)
     setattr(nagios_wf.workflowRelevantData, "state", "-")
     setattr(nagios_wf.workflowRelevantData, "object", self)
     setattr(nagios_wf.workflowRelevantData, "new_state", "2_start")
     nagios_wf.start()
     #health
     self._counter = {'r': 500}
     self._health = 1.0
     self._weight = {'r': 1.0}
     self._weight_user = 0.5
Exemple #3
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 \
           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)
Exemple #4
0
 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))
Exemple #5
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
Exemple #6
0
 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))
Exemple #7
0
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)
Exemple #8
0
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)
Exemple #9
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
Exemple #10
0
 def __init__(self, **data):
     """
     constructor of the object
     """
     Component.__init__(self, **data)
     # initialize OS List
     self.osList = []
     self.eventInpObjs_shutdown = set([])
     for (name, value) in data.items():
         if name in IHost.names() or \
            name in IEventIfEventHost.names():
             setattr(self, name, value)
     self.ikRevision = __version__
     self.workflows[WfPdNagios.id] = nagios_wf = WfPdNagios()
     setattr(nagios_wf.workflowRelevantData, "ddd", 5)
     setattr(nagios_wf.workflowRelevantData, "state", "-")
     setattr(nagios_wf.workflowRelevantData, "object", self)
     setattr(nagios_wf.workflowRelevantData, "new_state", "2_start")
     nagios_wf.start()
Exemple #11
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)