我正在尝试获取EBS卷ID,以便创建LLD Zabbix发现
https://github.com/omni-lchen/zabbix-cloudwatch/blob/master/awsLLD.py
def getEBS(a, r):
account = a
aws_account = awsAccount(account)
aws_access_key_id = aws_account._aws_access_key_id
aws_secret_access_key = aws_account._aws_secret_access_key
aws_region = r
#component = c
# Init LLD Data
lldlist = []
llddata = {"data":lldlist}
# Connect to EC2 service
conn = awsConnection()
conn.ebsConnect(aws_region, aws_access_key_id, aws_secret_access_key)
ebsConn = conn._aws_connection
# Save EBS function results in a list
functionResultsList = []
# Save volume names in a list
tdata = []
# Get a list of EBS volumes
functionResults = ebsConn.get_all_volumes()
输出:
[Volume:vol-029213f06d66eadac, Volume:vol-00fbd5dfaebd79e83, Volume:vol-0eeb126d13ecf0eed, Volume:vol-09a1f3446b3f78ea5]
我在解析输出结果时遇到问题
vol-029213f06d66eadac
vol-0eeb126d13ecf0eed
vol-09a1f3446b3f78ea5
我知道我需要写一些类似的东西:
for la in functionResultsList:
print la[0]
获取第一个元素 但不知道如何继续
答案 0 :(得分:0)
已删除列表并使用:
for la in range(len(functionResults)):
print functionResults[la]
输出:
Volume:vol-029213f06d66eadac
Volume:vol-00fbd5dfaebd79e83
Volume:vol-0eeb126d13ecf0eed
Volume:vol-09a1f3446b3f78ea5
Python的新手,实际上不知道列表是什么-但我不认为这是低俗的原因