IBM内部RedHat补丁管理工具的简化工具

原生的程序不怎么好用,IBM的同事可以用下面的脚本对输出结果加工一下:

import os

patchDB = """C:\Users\qinth\Downloads\secfixdb.RedHat6Server"""

TARGET_LIST = ["2013:4865.1","2013:4627.1","2013:4789.1","2013:4784.1",
               "2013:4932.1","2013:4954.1","2013:4948.1","2013:4965.1",
               "2014:0053.1","2011:4114.1","2012:0239.1","2012:0799.1",
               "2012:1376.1","2012:1638.1","2012:2036.1","2012:2068.1",
               "2012:2293.1","2012:2576.1","2012:2739.1","2012:3187.1",
               "2012:3172.1","2012:3245.1","2012:3508.1","2012:3633.1",
               "2012:3731.1","2012:4015.1","2012:4160.1","2013:0491.1",
               "2013:0732.1","2013:1057.1","2013:1219.1","2013:1218.1","2013:1702.1"]
_patchDB = {}
PATCHES = []

pathchDBHandler = open(patchDB,'r')

key = ''
value = []    
for _ in pathchDBHandler:
    items = _.split(':')

    if items[0] == 'advisory':
        _patchDB[key] = value
        value = []
        key = ("%s:%s") % (items[3],items[4])
    if items[0] == 'package':
        pkg_name = items[7].replace('\n','')
        if len(items) < 11:
            pkg_version = ""
        else:
            pkg_version = items[10].replace('\n','')
        value.append([pkg_name,pkg_version])


for target in TARGET_LIST:
    if _patchDB.has_key(target):
        patches = _patchDB[target]
        for patch in patches:
            if patch[1] == '':
                _patch = patch[0]
            else:
                _patch = ("%s-%s") % (patch[0],patch[1])
            print _patch

pathchDBHandler.close()

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*