added brackets in JSON output
This commit is contained in:
parent
00f714cc27
commit
bfcc4bdc39
|
|
@ -5,7 +5,6 @@ import json
|
|||
USERNAME = "zabbix@pve"
|
||||
PASSWORD = "zabbix"
|
||||
HOST = "172.16.3.11:8006"
|
||||
NODE = 'h1'
|
||||
|
||||
conn = PVEApi(HOST, USERNAME, PASSWORD)
|
||||
|
||||
|
|
@ -15,7 +14,7 @@ parser.add_argument("type", choices=['vm', 'cluster', 'node'], help='categories'
|
|||
parser.add_argument("-l", "--list", dest='listing', action='store_true')
|
||||
parser.add_argument("-n", "--name", dest='name')
|
||||
args = parser.parse_args()
|
||||
|
||||
NODE = args.node
|
||||
|
||||
def get_vmnames(vmlist, node, **kwargs):
|
||||
"""
|
||||
|
|
@ -56,8 +55,14 @@ def listofdicts_to_zabbix_json(dlist):
|
|||
:param dlist: list of dicts you want to convert
|
||||
:return: JSON string for zabbix-get
|
||||
"""
|
||||
dlist = {"data": dlist}
|
||||
zabbixjson = json.dumps(dlist)
|
||||
newdlist=list()
|
||||
for d in dlist:
|
||||
for k,v in d.iteritems():
|
||||
k = '{'+k+'}'
|
||||
newdict = {k: v}
|
||||
newdlist.append(newdict)
|
||||
newdlist = {"data": newdlist}
|
||||
zabbixjson = json.dumps(newdlist)
|
||||
return zabbixjson
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue