Beispiel #1
0
def check_and_reinit_kticket():
    has_kticket = has_kerberos_ticket()
    if debug_klist:
        log.info("Has k-ticket or not: {}".format(has_kticket))
    if has_kticket:
        if debug_klist:
            log.info("Renewing K-ticket")
            reinit_kticket_func()
        pass
    else:
        reinit_kticket_func()
Beispiel #2
0
def main():
    try:
        log.info("before starting threads ...")
        h = Thread(name="scheduler", target=logsched.main, daemon=True)
        t = Thread(name="bottle",
                   target=run,
                   kwargs=dict(app=app,
                               host='30.161.120.108',
                               port=45001,
                               debug=True,
                               reloader=True))
        h.start()
        t.start()
        h.join()
        t.join()
    except KeyboardInterrupt:
        sys.stdout.write("Aborted by user.\n")
        sys.exit(1)
Beispiel #3
0
def once_per():
    """
    If you lauch this script at time T, then this function will be called
    at T+60 minutes for the first time.
    Ex.: if you lauch the script at 13h07, then this function will be called at 14h07
    for the first time.
    """
    log.info('calling every 5 mins')
    check_and_reinit_kticket()
    log.info('f1 case ...')
    run_df_filter(spark)
    log.info('f2 case ...')
    run_df_write(spark)
Beispiel #4
0
def reinit_kticket_func():
    """
    USAGE.
        $ ktutil
        >> addent -password -p [email protected] -k 1 -e aes256-cts
        >> [Enter Password]
        >> wkt /home/af45008/AF45008.keytab
        >> exit

        $ kinit AF45008 -k -t /home/af45008/AF45008.keytab
        $ klist
        >>  Ticket cache: FILE:/tmp/krb5cc_928758424
        >>  Default principal: [email protected]

    """
    try:
        # For service id's
        username = getpass.getuser()
        homedir = os.environ['HOME']
        # For personal id's enable below line
        user = username[:1]
        if user != 's':
            username = username.upper()
        username_lo = username.lower()
        keytab = "./" + username + ".keytab"
        command = "kinit " + username + " -kt " + keytab
        p1 = subprocess.Popen(command, shell=True) # USE THIS LINE FOR OWN UDER ID's
        p1.wait()
        log.info("Renewing Kticket (first try)")
        log.info(" - homedir : {0}".format(keytab))
        log.info(" - command : {0}".format(command))
        if not has_kerberos_ticket():
            keytab = "./" + username_lo + ".keytab"
            command = "kinit " + username + " -kt " + keytab
            p1 = subprocess.Popen(command, shell=True)  # USE THIS LINE FOR OWN UDER ID's
            p1.wait()
            log.info("Renewing Kticket (second try)")
            log.info(" - homedir : {0}".format(keytab))
            log.info(" - command : {0}".format(command))
        if not has_kerberos_ticket():
            log.info("<Err> : Kinit: Failed to reinit kticket.", level='error')
            log.info("      : Please run the following command to reinit your DS keychains.", level='error')
            log.info("      : sh /app/hca/adva/utils/ds_utils/scripts/ds_keychain.sh", level='error')
        else:
            log.info("Done. All set")

    except Exception as e:
        log.info("<Err> Kinit: {0}".format(e), level='error')
Beispiel #5
0
 def wrapper(*args, **kwargs):
     beg_ts = time.time()
     retval = func(*args, **kwargs)
     end_ts = time.time()
     log.info("elapsed time: %fs" % (end_ts - beg_ts))
     return retval
Beispiel #6
0
def main():
    log.info('the scheduler is running...')
    sched.start()
Beispiel #7
0
def f2():
    if False:
        log.info("<something 2>, FAIL!")
    else:
        log.info("<something 2>, PASS!")
Beispiel #8
0
def f1():
    if False:
        log.info("<something 1>, FAIL!")
    else:
        log.info("<something 1>, PASS!")