代码拉取完成,页面将自动刷新
#!/usr/bin/python3.4
# -*- coding=utf-8 -*-
from xml.etree.ElementTree import parse
import pprint
mapping = {}
tree = parse('PolicyConfig.xml')
root = tree.getroot()
rules = root.find('Policies').find('Authentication').find('rules').findall('rule')
mapping = {}
for rule in rules:
try:
name = rule.attrib['name']
result = rule.find('Result')
resultname = result.attrib['name']
id_source_rult = rule.find('IdentitySourceRules').find('rule').find('IdentitySourceResult')
id_source_name = id_source_rult.attrib['name']
print(('RuleName: ' + '%-25s' + ' Allowed_Proto:' + '%-20s') % (name, resultname))
print('\nID_Source:' + id_source_name)
print('-' * 75)
except:
pass
#####################################################################################################################
[root@Fedora python]# ./xmltest.py
RuleName: CCNPSecurity Allowed_Proto:PAP
ID_Source:QYTANG
---------------------------------------------------------------------------
RuleName: ASA Allowed_Proto:Default Network Access
ID_Source:QYTANG
---------------------------------------------------------------------------
RuleName: Wireless-Dot1x Allowed_Proto:Default Network Access
ID_Source:QYTANG_Cert
---------------------------------------------------------------------------
RuleName: Wired-Dot1x Allowed_Proto:Default Network Access
ID_Source:QYTANG_Cert
---------------------------------------------------------------------------
RuleName: Security-Rack-AAA Allowed_Proto:PAP
ID_Source:QYTANG
---------------------------------------------------------------------------
RuleName: Production-Network-AAA Allowed_Proto:PAP
ID_Source:QYTANG
---------------------------------------------------------------------------
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。