Ich habe diesen Code, der die JSON-Daten an den Server sendet, aber es gibt den Fehler "unhashable type list"
hcatalog_nodes =["idh30-1.srv.acent.net.uk","idh30-2.srv.acent.net.uk","idh30-3.srv.acent.net.uk"]
for node in hcatalog_nodes:
data = json.dumps({[
{
"rolename": "HCatalog",
"hostname": node
}
]})
request = urllib2.Request("https://192.168.0.76:9443/restapi/acent/api/v2/cluster/"+cluster_name+"/services/hbase/roles")
base64string = base64.encodestring('%s:%s' % ("admin", "admin")).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string)
print "setting up HBase roles on node %s " % (node)
result = urllib2.urlopen(request,data)
print result.read()
Fehler:
Traceback (most recent call last):
File "/home/kshk/PycharmProjects/intelIDH/autoIDH.py", line 287, in
main()
File "/home/kshk/PycharmProjects/intelIDH/autoIDH.py", line 278, in main
add_hcatalogRoles()
File "/home/kshk/PycharmProjects/intelIDH/autoIDH.py", line 147, in add_hcatalogRoles
"hostname": node
TypeError: unhashable type: 'list'
Process finished with exit code 1
Irgendwelche Ideen, wie ich den Wert von "node" im JSON-Request setzen kann?