示例#1
0
def main():
    ssllog.log.initLog("./sslmakecert.log", "WARNING")
    ssllog.log.main_logger.warning("Starting")

    sleepInSecs            = sslconfig.sslConfig.sleepSecs
    sslCertDestinationPath = sslconfig.sslConfig.sslCertDestinationPath
    lastTimestamp          = sslconfig.sslConfig.lastTimestamp
    myHostname             = socket.gethostname()

    # Create a connection to the database
    datastore = SSLDataStore(sslconfig.sslConfig.databaseHost, \
        sslconfig.sslConfig.databaseUser, \
        sslconfig.sslConfig.databasePass, \
        sslconfig.sslConfig.databaseName)
    if not datastore:
        ssllog.log.main_logger.error("Houston, we have a problem with connecting to the database.")
        exit(1)

    try:
        datastore.connect()
        if datastore.con.open:
            datastore.cursor = datastore.con.cursor()
        else:
            ssllog.log.main_logger.error("Houston, we have a problem with connecting to the database.")
            exit(1)
    except mdb.Error, e:
        ssllog.log.main_logger.error("Error %d: %s" % (e.args[0],e.args[1]))
示例#2
0
def main():

    cont = 1

    ssllog.log.initLog(sslconfig.sslConfig.logFilename, sslconfig.sslConfig.logLevel)
    if options.runOnceMode:
        ssllog.log.enableLogToConsole()

    ssllog.log.main_logger.debug("Starting main()")

    sleepInSecs            = sslconfig.sslConfig.sleepSecs
    sslCertDestinationPath = sslconfig.sslConfig.sslCertDestinationPath
    lastTimestamp          = sslconfig.sslConfigTimestamp.lastTimestamp

    myHostname = socket.gethostname()
    ssllog.log.main_logger.info("My hostname: " + myHostname)

    datastore = SSLDataStore(sslconfig.sslConfig.databaseHost, \
        sslconfig.sslConfig.databaseUser, \
        sslconfig.sslConfig.databasePass, \
        sslconfig.sslConfig.databaseName)

    if not datastore:
        ssllog.log.main_logger.critical("Error: Problem connecting to the "\
                "database. Exiting!")
        exit(2)

    #
    # Let's see whats changed since we were last here
    #
    dbConnected = 0
    dbSleep = 60
    while not dbConnected:
        try:
            datastore.connect()
        except mdb.Error, e:
            ssllog.log.main_logger.error("Error: Problem getting current state " \
                    "from the database. Sleeping for %d before trying again." \
                    % (dbSleep))
            ssllog.log.main_logger.error("Error %d: %s" % (e.args[0],e.args[1]))
            time.sleep(dbSleep)

        if datastore.con and datastore.con.open:
            dbConnected = 1
            datastore.cursor = datastore.con.cursor()

            # Parse out the starting ss-multicert.conf file into a hash (past
            # state)
            pastSSLConfigHash = atsParseSSLMultiCertConfig()
            # Grab all of the XIDs in the SSL datastore (present state)
            originTimestamp = datetime.datetime(1970, 1, 1, 0, 0, 0)
            presentSSLConfigHash = sslcertdatabase.getXIDsNewerThanTimestamp(\
                    datastore, originTimestamp)
        else:
            ssllog.log.main_logger.error("Error: Problem getting opening " \
                    "connection to database in order to obtain the current " \
                "state from the database. Sleeping for %d before trying again." \
                    % (dbSleep))
            time.sleep(dbSleep)