Пример #1
0
class IInterfaceSnmpScanWizard(Interface):
    """A interface object."""
    searchIpV4 = HostIpValid(min_length=1,
                             max_length=30,
                             title=_("IP address"),
                             default=u"127.0.0.1",
                             required=True)
    indexType = Choice(title=_("Index type"),
                       vocabulary="SnmpIndexTypes",
                       default=u"mac",
                       required=True)
Пример #2
0
class IAdmUtilEsxVim(ISupernode):
    """
    major component for registration and event distribution 
    """
    esxVimServerActive = Bool(title=_("ESX VIM active"),
                              description=_("Esx connector active"),
                              default=False,
                              required=False)

    esxVimServerIp = HostIpValid(
        min_length=1,
        max_length=30,
        title=_("ESX VIM IP"),
        description=_("Active IP address of esx vim-server"),
        default=u"0.0.0.0",
        required=False)

    esxVimServerPort = Int(min=1,
                           max=65535,
                           title=_("ESX VIM Port"),
                           description=_("Port of esx vim-server"),
                           default=443,
                           required=False)

    esxVimUsername = TextLine(
        title=_("ESX VIM Username"),
        description=_("Name of user with admin rights on esx vim-server"),
        default=u"username",
        required=False)

    esxVimPassword = Password(
        title=_("ESX VIM Password"),
        description=_("Password of user with admin rights on esx vim-server"),
        default=u"password",
        required=False)

    connStatus = Attribute("Connection State")
    apiFullName = Attribute("Fullname of ESX VIM Api")

    def keys(self):
        '''See interface `IReadContainer`'''

    def __iter__(self):
        '''See interface `IReadContainer`'''

    def __getitem__(self, key):
        '''See interface `IReadContainer`'''

    def get(self, key, default=None):
        '''See interface `IReadContainer`'''

    def values(self):
        '''See interface `IReadContainer`'''

    def __len__(self):
        '''See interface `IReadContainer`'''

    def items(self):
        '''See interface `IReadContainer`'''

    def __contains__(self, key):
        '''See interface `IReadContainer`'''

    def connect2VimServer(self):
        ''' '''
Пример #3
0
class IAdmUtilSupervisor(Interface):
    """
    major component for registration and event distribution 
    """

    nbrStarts = Int(
        min = 0,
        title = _("Starts"),
        description = _("Number of Starts"),
        default = 0,
        readonly = True,
        required = True)

    ipv4My = HostIpValid(
        min_length = 1,
        max_length = 30,
        title = _("My active IP"),
        description = _("Active IP address of this host."),
        default = u"0.0.0.0",
        readonly = True,
        required = True)
    
#    objectID = ObjectIdValid(
#        title = _("My object id"),
#        description = _("object id of this supervisor"),
#        readonly = True,
#        required = True)
    
    ipv4Master = HostIpValid(
        min_length = 1,
        max_length = 30,
        title = _("Master IP"),
        description = _("IP address of master."),
        default = u"0.0.0.0",
        readonly = False,
        required = False)
    
    oidMaster = ObjectIdValid(
        title = _("Master object id"),
        description = _("object id of our master supervisor"),
        readonly = False,
        required = False)

    lastSeenMaster = Datetime(
        title=_("last seen Master"),
        description=_("Time since last contact with the Master"),
        required=False)
    
    status2Master = Choice(
        title = _("status2Master"),
        description = _("Status of connection to master."),
        values = [ u"no master", u"connecting", u"permission denied", \
                   u"unknown system", u"connected", u"interrupted", \
                   u"will be a slave"],
        readonly = False,
        required = False )

    ipv4Slave = HostIpValid(
        min_length = 1,
        max_length = 30,
        title = _("Slave IP"),
        description = _("IP address of slave."),
        default = u"0.0.0.0",
        readonly = False,
        required = False)
    
    oidSlave = ObjectIdValid(
        title = _("Slave object id"),
        description = _("object id of our slave supervisor"),
        readonly = False,
        required = False)
    
    lastSeenSlave = Datetime(
        title=_("last seen Slave"),
        description=_("Time since last contact with the slave"),
        required=False)

    def appendEventHistory(msg):
        """
        This method will append a text on the application history
        """

    def getlastEvents():
        """getter for event list
        """

    def getStartCnt():
        """getter for start counter of all starts
        """

    def generateOid(*args ):
        """
          Generates a universally unique ID.
          Any arguments only create more randomness.
        """

    def getSystemVersion():
        """
        Version string of System
        no args, returns string
        """
        
    def getNetworkDevList():
        """
        get a list of network device names
        no args, returns list of strings
        """
    
    def getLocalMacAddress(dev="eth0"):
        """
        get the mac address of the running system device
        argument is device name, default is 'eth0'
        returns string
        """
    
    def getLocalIpV4AddressList(dev="eth0"):
        """
        get the IpV4 addresses of the running system device
        argument is device name, default is 'eth0'
        returns list of strings
        """
        
    def getNetworkInfoDict():
        """
        returns an informational dictonary with network device settings
        """
        
    def getCpuVendorId():
        """
        get the cpu vendor of the running system
        no args, returns string
        """
    
    def getCpuModelName():
        """
        get the cpu model of the running system
        no args, returns string
        """
    
    def getKernelVersion():
        """
        get the kernel version of the running system
        no args, returns string
        """
        
    def getNodeName():
        """
        get the name of the running system
        no args, returns string
        """
    
    def getSystemUptime():
        """
        get the uptime of the running system
        no args, returns string
        """
    
    def getSystemLoad():
        """
        get the cpu load of the running system
        no args, returns string
        """
        
    def appendSlave(msgHeader):
        """
        append oid to slave list
        """
        
    def isMaster():
        """
        this supervisor is a master?
        """

    def isSlave():
        """
        this supervisor is a slave?
        """

    def sendPing():
        """
        send ping request
        """
            
    def sendPong(msgHeader, nodename=None):
        """
        revert message header and sends a pong as response to the ping
        """

    def receivedPing(msgHeader):
        """
        we have received a ping request
        """

    def receivedPong(msgHeader):
        """
        we have received a pong response
        """

    def addObject(msgHeader, msgOldparent, msgNewparent, msgObj):
        """
        a new object should be created
        """

    def removeObject(msgHeader, msgOldparent, msgNewparent, msgObjectOid):
        """
        an object should be removed
        """
        
    def modifyObject(msgHeader, msgObj):
        """
        an object should be modified
        """

    def moveObject(msgHeader, msgOldparent,
                   msgNewparent, msgObjectOid):
        """
        an object should be moved
        """
        
    #def setStatus2Master(self, statustext):
        #"""
        #setter for status2master
        #"""

    def reindex_db():
        """
        will reindex the catalogs of all tables in database
        """
        
    def remove_indices():
        """
        will remove all indices in database
        """
        
    def create_indices():
        """
        will create all non existent indices in database
        """
        
    def exportAllData():
        """get data file for all objects"""

    def importAllData(xml_str):
        """get data file for all objects"""
Пример #4
0
class IAdmUtilLinuxHa(Interface):
    """
    major component for registration and event distribution 
    """
    linuxHaServerActive = Bool(
        title = _("HA-Cluster active"),
        description = _("HA-Cluster connector active"),
        default = False,
        required = False)

    linuxHaServerIp = HostIpValid(
        min_length = 1,
        max_length = 30,
        title = _("HA-Cluster IP"),
        description = _("Active IP address of the ha cluster"),
        default = u"0.0.0.0",
        required = False)
    
    linuxHaServerPort = Int(
        min = 1,
        max = 65535,
        title = _("HA-Cluster Port"),
        description = _("Port of of the ha cluster"),
        default = 5560,
        required = False)
    
    linuxHaUsername = TextLine(
        title = _("HA-Cluster Username"),
        description = _("Name of user with admin rights on ha cluster"),
        default = u"username",
        required = False)

    linuxHaPassword = Password(
        title = _("HA-Cluster Password"),
        description = _("Password of user with admin rights on ha cluster"),
        default = u"password",
        required = False)

    connState = Attribute("Connection State")

    def keys(self):
        '''See interface `IReadContainer`'''

    def __iter__(self):
        '''See interface `IReadContainer`'''

    def __getitem__(self, key):
        '''See interface `IReadContainer`'''

    def get(self, key, default=None):
        '''See interface `IReadContainer`'''

    def values(self):
        '''See interface `IReadContainer`'''

    def __len__(self):
        '''See interface `IReadContainer`'''

    def items(self):
        '''See interface `IReadContainer`'''

    def __contains__(self, key):
        '''See interface `IReadContainer`'''

    def connect2HaCluster(self):
        ''' '''
    def getNodes(self):
        """ list of all cluster nodes objects
Пример #5
0
class INotifierJabber(INotifier):
    """
    component for notifying with jabber
    """
    ipv4Connector = HostIpValid(
        min_length=1,
        max_length=30,
        title=_("Connector IP"),
        description=_("IP address of the jabber connector."),
        default=u"127.0.0.1",
        readonly=False,
        required=False)

    portConnector = Int(min=0,
                        max=65535,
                        title=_("Connector Port"),
                        description=_("Port of the jabber connector"),
                        default=8551,
                        required=False)

    hostnameServer = TextLine(max_length=80,
                              title=_("Jabber servername"),
                              description=_("Servername or IP of im server"),
                              default=u"jabber.org",
                              required=False)

    portServer = Int(min=0,
                     max=65535,
                     title=_("Jabber serverport"),
                     description=_("Port of the im server"),
                     default=5222,
                     required=False)

    authname = TextLine(max_length=80,
                        title=_("Username"),
                        description=_("Username for im-login"),
                        default=u"",
                        required=False)

    authpasswd = Password(max_length=80,
                          title=_("Password"),
                          description=_("Password for im-login"),
                          default=u"",
                          required=False)

    lastSeenConnector = Datetime(
        title=_("last seen Connector"),
        description=_("Time since last contact with the jabber connector"),
        required=False)

    connectorType = Attribute("Connector Type")
    connectorVersion = Attribute("Connector Version")
    enableConnector = Attribute("Connector enabled")

    def getObjectId(self):
        """
        get 'Universe ID' of object
        returns str
        """

    def sendNotify(self, notifyEvent=None, notifyObj=None):
        """ sending the real notification to the user
        """

    def start_connector(self):
        """ connects to the configured jabber-system
        """

    def stop_connector(self):
        """ disconnects to the configured jabber-system
        """

    def get_isUp(self):
        """ ask for an existing jabber-connector
        """

    def connect_server(self):
        """ connect the xmlrpc-agent with the jabber-server
        """

    def send_test(self):
        """ send a test message to an existing jabber-server
Пример #6
0
class IInterface(IComponent):
    """A interface object."""

    contains('org.ict_ok.components.service.interfaces.IService',
             'org.ict_ok.components.snmpvalue.interfaces.ISnmpValue')

    netType = Choice(
        title=_("interface type"),
        description=_("Networktype of this interface (OSI Layer1-2)"),
        default="ethernet",
        values=['ethernet', 'fddi', 'wlan', 'token bus', 'token ring'],
        required=True)

    mac = MacValid(max_length=40,
                   title=_("MAC address"),
                   description=_("MAC address of the host."),
                   default=u"00:00:00:00:00:00",
                   required=False)

    #wait for z3c.form list of textlines
    #ipv4List = List (
    #title = _("IPv4 addresses"),
    #description = _("list of all configured IPv4 addresses"),
    #value_type = HostIpValid(
    #min_length=1,
    #max_length=30,
    #title=_("IP address"),
    #description=_("IP address of the host."),
    #default=u"192.168.1.100",
    #required=True),
    #default = [],
    #required = False)
    ipv4List = HostIpValid(min_length=1,
                           max_length=30,
                           title=_("IP address"),
                           description=_("IP address of the host."),
                           default=u"192.168.1.100",
                           required=False)

    #connectedInterfaces

    @invariant
    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))

    @invariant
    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))