Ejemplo n.º 1
0
class Contract(Component):
    """
    the template instance
    """
    implements(IContract)
    shortName = "contract"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    type = FieldProperty(IContract['type'])
    startDate = FieldProperty(IContract['startDate'])
    state = FieldProperty(IContract['state'])
    expirationDate = FieldProperty(IContract['expirationDate'])
    annualCharges = FieldProperty(IContract['annualCharges'])
    internalContractNumber = FieldProperty(IContract['internalContractNumber'])
    externalContractNumber = FieldProperty(IContract['externalContractNumber'])
    periodOfNotice = FieldProperty(IContract['periodOfNotice'])
    minimumTerm = FieldProperty(IContract['minimumTerm'])
    responsibles = RelationPropertyOut(Responsible4Contracts_ContactItems_RelManager)
    contractors = RelationPropertyOut(ClosedContracts_ContactItems_RelManager)
    component = RelationPropertyOut(Contracts_Component_RelManager)

    fullTextSearchFields = []
    fullTextSearchFields.extend(Component.fullTextSearchFields)
        


    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Contract)
        for (name, value) in data.items():
            if name in IContract.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Contract)

    def store_refs(self, **data):
        Component.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 2
0
class Contact(Component):
    """
    the template instance
    """
    implements(IContact)
    shortName = "contact"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    workOrder = RelationPropertyIn(WorkOrder_Contacts_RelManager)
    contactItems = RelationPropertyOut(Contact_ContactItems_RelManager)

    fullTextSearchFields = []
    fullTextSearchFields.extend(Component.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Contact)
        for (name, value) in data.items():
            if name in IContact.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def store_refs(self, **data):
        Component.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 3
0
class Person(ContactItem):
    """
    the template instance
    """
    implements(IPerson)
    shortName = "person"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    firstName = FieldProperty(IPerson['firstName'])
    lastName = FieldProperty(IPerson['lastName'])
    title = FieldProperty(IPerson['title'])
    inOUs = RelationPropertyOut(\
         Persons_OrganisationalUnits_RelManager)

    fullTextSearchFields = ['firstName', 'lastName', 'title']
    fullTextSearchFields.extend(ContactItem.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        ContactItem.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Person)
        for (name, value) in data.items():
            if name in IPerson.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Person)

    def store_refs(self, **data):
        ContactItem.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)

    def getDisplayTitle(self):
        """ display text for some views
        """
        if self.title is None:
            titleStr = u''
        else:
            titleStr = u'%s ' % self.title
        if self.firstName is None:
            firstNameStr = u''
        else:
            firstNameStr = u'%s ' % self.firstName
        if self.lastName is None:
            lastNameStr = u''
        else:
            lastNameStr = u'%s' % self.lastName
        return titleStr + firstNameStr + lastNameStr
Ejemplo n.º 4
0
class Device(PhysicalComponent):
    """
    the template instance
    """
    implements(IDevice)
    shortName = "device"
    __name__ = __parent__ = None
    cpuType = FieldProperty(IDevice['cpuType'])
    memsize = FieldProperty(IDevice['memsize'])

    #    room = RelationPropertyIn(Room_Devices_RelManager)
    interfaces = RelationPropertyOut(Device_Interface_RelManager)
    appsoftwares = RelationPropertyOut(Device_AppSoftware_RelManager)
    osoftwares = RelationPropertyOut(Device_OSoftware_RelManager)
    #    logicalDevices = RelationPropertyOut(Device_LogicalDevices_RelManager)
    logicalDevices = RelationPropertyOut(Devices_LogicalDevices_RelManager)
    physicalMedia = RelationPropertyOut(Devices_PhysicalMedia_RelManager)

    fullTextSearchFields = ['cpuType']
    fullTextSearchFields.extend(PhysicalComponent.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        PhysicalComponent.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Device)
        for (name, value) in data.items():
            if name in IDevice.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Device)

    def store_refs(self, **data):
        PhysicalComponent.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 5
0
class Interface(PhysicalComponent):
    """
    the template instance
    """

    implements(IInterface)
    shortName = "interface"
    # for ..Contained we have to:
    __name__ = __parent__ = None
    netType = FieldProperty(IInterface['netType'])
    mac = FieldProperty(IInterface['mac'])
    #ipv4List = FieldProperty(IInterface['ipv4List'])

    device = RelationPropertyIn(Device_Interface_RelManager)
    #host2 = RelationPropertyIn(Host_Interfaces_RelManager)
    connectorPinout = FieldProperty(IPhysicalConnector['connectorPinout'])
    links = RelationPropertyIn(PhysicalLinks_PhysicalConnectors_RelManager)

    #    physicalConnector = RelationPropertyOut(PhysicalConnector_Interface_RelManager)
    ipAddresses = RelationPropertyOut(Interface_IpAddresses_RelManager)

    fullTextSearchFields = ['netType', 'mac']
    fullTextSearchFields.extend(PhysicalComponent.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        PhysicalComponent.__init__(self, **data)
        #ipv4List = []
        refAttributeNames = getRefAttributeNames(Interface)
        for (name, value) in data.items():
            if name in IInterface.names():
                if name not in refAttributeNames:
                    setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Interface)

    def store_refs(self, **data):
        PhysicalComponent.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)

    def getAllPhysicalConnectors(self, connectorSet, maxDepth=10):
        if maxDepth < 0:
            raise Exception
        for link in self.links:
            if IPhysicalLink.providedBy(link):
                link.getAllPhysicalConnectors(connectorSet, maxDepth - 1)
Ejemplo n.º 6
0
class PhysicalLink(Component):
    """
    the template instance
    """
    implements(IPhysicalLink)
    shortName = "physicallink"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    length = FieldProperty(IPhysicalLink['length'])
    maxLength = FieldProperty(IPhysicalLink['maxLength'])
    mediaType = FieldProperty(IPhysicalLink['mediaType'])
    wired = FieldProperty(IPhysicalLink['wired'])
    connectorPinout = FieldProperty(IPhysicalLink['connectorPinout'])

    connectors = RelationPropertyOut(
        PhysicalLinks_PhysicalConnectors_RelManager)

    fullTextSearchFields = ['connectorPinout']
    fullTextSearchFields.extend(Component.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(PhysicalLink)
        for (name, value) in data.items():
            if name in IPhysicalLink.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(PhysicalLink)

    def store_refs(self, **data):
        Component.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)

    def getAllPhysicalConnectors(self, connectorSet, maxDepth=10):
        if maxDepth < 0:
            raise Exception
        for connector in self.connectors:
            if IPhysicalConnector.providedBy(connector):
                connectorSet.add(connector)
                connector.getAllPhysicalConnectors(connectorSet, maxDepth - 1)
Ejemplo n.º 7
0
class Rack(PhysicalComponent):
    """
    the template instance
    """
    implements(IRack)
    shortName = "rack"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    height = FieldProperty(IRack['height'])
    patchpanels = RelationPropertyOut(Rack_PatchPanels_RelManager)
    switches = RelationPropertyOut(Rack_Switches_RelManager)

    fullTextSearchFields = []
    fullTextSearchFields.extend(PhysicalComponent.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        PhysicalComponent.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Rack)
        for (name, value) in data.items():
            if name in IRack.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Rack)

    def store_refs(self, **data):
        PhysicalComponent.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 8
0
class Category(Supernode):
    """Implementation of host group entry."""

    implements(ICategory)
    components = RelationPropertyOut(Categories_Components_RelManager)
    requirements = RelationPropertyOut(Categories_Requirements_RelManager)

    def __init__(self, **data):
        """
        constructor of the object
        """
        Supernode.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Category)
        for (name, value) in data.items():
            if name in ICategory.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def store_refs(self, **data):
        refAttributeNames = getRefAttributeNames(Category)
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 9
0
class ContactItem(Component):
    """
    the template instance
    """
    implements(IContactItem)
    shortName = "contact_item"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    contact = RelationPropertyIn(Contact_ContactItems_RelManager)
    workOrder = RelationPropertyIn(WorkOrder_ContactItems_RelManager)
    adresses = RelationPropertyOut(ContactItem_Addresses_RelManager)
    roles = RelationPropertyIn(Roles_ContactItems_RelManager)
    groups = RelationPropertyIn(Group_ContactItems_RelManager)
    closedContracts = RelationPropertyIn(
        ClosedContracts_ContactItems_RelManager)
    responsible4Contracts = RelationPropertyIn(
        Responsible4Contracts_ContactItems_RelManager)

    fullTextSearchFields = []
    fullTextSearchFields.extend(Component.fullTextSearchFields)

    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(ContactItem)
        for (name, value) in data.items():
            if name in IContactItem.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(ContactItem)

    def store_refs(self, **data):
        Component.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 10
0
class OrganisationalUnit(ContactItem):
    """
    the template instance
    """
    implements(IOrganisationalUnit)
    shortName = "organisational_unit"
    # for ..Contained we have to:
    __name__ = __parent__ = None

    name = FieldProperty(IOrganisationalUnit['name'])
    subOUs = RelationPropertyOut(\
         OrganisationalUnit_OrganisationalUnits_RelManager)
    parent_O_OU = RelationPropertyIn(\
         OrganisationalUnit_OrganisationalUnits_RelManager)

    fullTextSearchFields = ['name']
    fullTextSearchFields.extend(ContactItem.fullTextSearchFields)
        


    def __init__(self, **data):
        """
        constructor of the object
        """
        ContactItem.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(OrganisationalUnit)
        for (name, value) in data.items():
            if name in IOrganisationalUnit.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(OrganisationalUnit)

    def store_refs(self, **data):
        ContactItem.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 11
0
class Building(Component):
    """
    the template instance
    """

    implements(IBuilding)
    shortName = "building"
    containerIface = IBuildingFolder
    # for ..Contained we have to:
    __name__ = __parent__ = None
    #ikAttr = FieldProperty(IBuilding['ikAttr'])
    coordinates = FieldProperty(IBuilding['coordinates'])
    gmapsurl = FieldProperty(IBuilding['gmapsurl'])
    gmapcode = FieldProperty(IBuilding['gmapcode'])

    location = RelationPropertyIn(Location_Buildings_RelManager)
    rooms = RelationPropertyOut(Building_Rooms_RelManager)

    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Building)
        for (name, value) in data.items():
            if name in IBuilding.names():
                if name not in refAttributeNames:
                    setattr(self, name, value)
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Building)

    def store_refs(self, **data):
        Component.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)
Ejemplo n.º 12
0
class Net(Component):
    """
    the template instance
    """

    implements(INet, IEventIfEventNet)
    shortName = "net"
    # for ..Contained we have to:
    __name__ = __parent__ = None
    ipv4 = FieldProperty(INet['ipv4'])

    subnets = RelationPropertyOut(Net_Nets_RelManager)
    parentnet = RelationPropertyIn(Net_Nets_RelManager)

    eventInpObjs_inward_relaying_shutdown = FieldProperty(\
        IEventIfEventNet['eventInpObjs_inward_relaying_shutdown'])

    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Net)
        for (name, value) in data.items():
            if name in INet.names():
                if name not in refAttributeNames:
                    setattr(self, name, value)
        self.eventInpObjs_inward_relaying_shutdown = set([])
        self.ikRevision = __version__

    def getRefAttributeNames(self):
        return getRefAttributeNames(Net)

    def store_refs(self, **data):
        Component.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)

    def containsIp(self, ipString):
        """ is ip(String) part of this network?
        """
        myIp = IP(self.ipv4)
        testIp = IP(ipString)
        return testIp in myIp

    def eventInp_inward_relaying_shutdown(self, eventMsg=None):
        """
        forward the event to all objects in this container through the signal filter
        """
        print "Net.eventInp_inward_relaying_shutdown()"
        for name, obj in self.items():
            # first call
            if INet.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 get_wcnt(self):
        """
        weighted count of accesses
        """
        sum_wcnt = 0
        for host in self.values():
            sum_wcnt += host.get_wcnt()
        return sum_wcnt

    def get_health(self):
        """
        output of health, 0-1 (float)
        """
        if len(self.keys()) > 0:
            health = 0.0
            for host in self.values():
                if host.get_health() is not None:
                    health += host.get_health() * \
                           (float(host.get_wcnt()) / self.get_wcnt())
        else:
            health = None
        return health
Ejemplo n.º 13
0
class Device(PhysicalComponent):
    """
    the template instance
    """
    implements(IDevice, INagiosCheck)
    shortName = "device"
    __name__ = __parent__ = None
    cpuType = FieldProperty(IDevice['cpuType'])
    memsize = FieldProperty(IDevice['memsize'])

#    room = RelationPropertyIn(Room_Devices_RelManager)
    interfaces = RelationPropertyOut(Device_Interface_RelManager)
    appsoftwares = RelationPropertyOut(Device_AppSoftware_RelManager)
    osoftwares = RelationPropertyOut(Device_OSoftware_RelManager)
#    logicalDevices = RelationPropertyOut(Device_LogicalDevices_RelManager)
    logicalDevices = RelationPropertyOut(Devices_LogicalDevices_RelManager)
    physicalMedia = RelationPropertyOut(Devices_PhysicalMedia_RelManager)

    fullTextSearchFields = ['cpuType']
    fullTextSearchFields.extend(PhysicalComponent.fullTextSearchFields)

    genNagios = FieldProperty(INagiosCheck['genNagios'])
    
    # Workflows
    wf_pd_dict = {}
    wf_pd_dict[WfPdNagios.id] = WfPdNagios
    AdmUtilWFMC.wf_pd_dict[WfPdNagios.id] = WfPdNagios

    def __init__(self, **data):
        """
        constructor of the object
        """
        PhysicalComponent.__init__(self, **data)
        refAttributeNames = getRefAttributeNames(Device)
        for (name, value) in data.items():
            if name in IDevice.names() and \
               name not in refAttributeNames:
                setattr(self, name, value)
        self.ikRevision = __version__
        self.workflows[WfPdNagios.id] = nagios_wf = WfPdNagios()
        setattr(nagios_wf.workflowRelevantData, "state", "-")
        setattr(nagios_wf.workflowRelevantData, "object", self)
        setattr(nagios_wf.workflowRelevantData, "new_state", "2_start")
        nagios_wf.start()

    def getRefAttributeNames(self):
        return getRefAttributeNames(Device)

    def store_refs(self, **data):
        PhysicalComponent.store_refs(self, **data)
        refAttributeNames = self.getRefAttributeNames()
        for (name, value) in data.items():
            if name in refAttributeNames:
                setattr(self, name, value)

    def trigger_online(self):
        """
        trigger workflow
        """
#        print "trigger_online"
        lastWorkItem = list(self.wf_worklist)[-1]
        wfd = lastWorkItem.participant.activity.process.workflowRelevantData
        wfd.new_state = "online"
        lastWorkItem.change()

    def trigger_offline(self):
        """
        trigger workflow
        """
#        print "trigger_offline"
        lastWorkItem = list(self.wf_worklist)[-1]
        wfd = lastWorkItem.participant.activity.process.workflowRelevantData
        wfd.new_state = "offline"
        lastWorkItem.change()

    def trigger_not1(self):
        """
        trigger workflow
        """
#        print "trigger_not1"
        lastWorkItem = list(self.wf_worklist)[-1]
        wfd = lastWorkItem.participant.activity.process.workflowRelevantData
        wfd.new_state = "notification1"
        lastWorkItem.change()