def make_offsite_copies_primary():
"""multi-threaded function to update OFFSITE_PREFIX volumes to primary."""
start_date = time.strftime("%m/%d/%y",
time.localtime(time.time() - DR_TAPE_DATE_RANGE))
for pool in run_command([vmpool, "-listall", "-b"]).readlines():
if pool.startswith(OFFSITE_PREFIX):
pool = pool.split()[0]
logentry("***\tupdating images for pool: %s" % (pool))
command = [bpchangeprimary, "-pool", pool, "-sd", start_date]
RunMTCommand.lck.acquire()
# If we've reached maxthreads, then wait for one to finish
if len(RunMTCommand.tlist) >= RunMTCommand.maxthreads:
RunMTCommand.lck.release()
RunMTCommand.evnt.wait()
else:
RunMTCommand.lck.release()
# For some reason, we often get a "-15" RC, when updating the
# MLC-Duplication pool. Let's just ignore it for now.
RunMTCommand.newthread(command, [0, 13, -15])
for bpchange_thread in RunMTCommand.tlist:
bpchange_thread.join()
該函數發出NetBackup命令,將備份的副本提升爲主副本。如何使用python腳本調試錯誤而不出現跟蹤錯誤?
當該腳本運行時,它開始在終端登錄預期:
Mon Aug 24 10:04:08 2015 - 17684 - *** updating images for pool: MLC-2week
Mon Aug 24 10:04:08 2015 - 17684 - *** updating images for pool: MLC-1month
Mon Aug 24 10:04:08 2015 - 17684 - *** updating images for pool: MLC-1year
Mon Aug 24 10:04:08 2015 - 17684 - *** updating images for pool: MLC-Shadow-2week
Mon Aug 24 10:04:08 2015 - 17684 - *** updating images for pool: MLC-2week-DR-Files
Mon Aug 24 10:04:08 2015 - 17684 - *** updating images for pool: MLC-Offsite
etc.
然而,bpchangeprimary命令的似乎沒有要在腳本中調用,因爲備份副本並沒有改變。
如果直接從命令行鍵入「bpchangeprimary -pool MLC-LTO4-Offsite -sd 08/22/2015」,則會對備份副本進行預期的更改。不過,此行內部功能:
command = [bpchangeprimary, "-pool", pool, "-sd", start_date]
要做到同樣的事情,但它不是,所以我猜的東西是錯誤使用此功能。更糟糕的是,沒有回溯錯誤。
任何幫助,或提示如何解決這個問題將不勝感激。
您是否嘗試過使用pdb(或ipdb)? – Ben
在你的'RunMTCommand'類中,記錄子進程通過STDOUT和STDERR管道放置的內容。 – CasualDemon
你是什麼意思的子進程? – stephan