3 # remove a node from nodegroup - to be called with an argument (the ip or hostname of the plc)
12 sys.path.append('/usr/share/plc_api')
16 print('I need the first argument (the pi or hostname address of the plc)')
22 user = raw_input('Insert your user:')
23 password= getpass.getpass('Insert your password:')
24 hostname = raw_input('Insert the node hostname:')
25 nodegroup=raw_input('Insert the group:')
30 auth['AuthMethod'] = 'password'
31 auth['Username'] = user
32 auth['AuthString'] = password
35 plc = xmlrpclib.ServerProxy('https://'+plc_ip+'/PLCAPI/', allow_none=True)
38 authorized = plc.AuthCheck(auth)
41 print 'We are authorized!'
43 node_fields = {'nodegroups' : [] }
45 nodes = plc.GetNodes(auth, hostname, ['node_id'])
48 print 'I found %d node with that hostname' % len(nodes)
52 print 'I haven\'t found any nodes with that hostname'
55 node_id=nodes[0]['node_id']
57 if plc.UpdateNode (auth, node_id, node_fields) != 1:
58 print "Couldn't remove from nodegroup - error in UpdateNode api";