rpc_key_test.py 930 B

1234567891011121314151617181920212223242526
  1. import rpyc
  2. s1={'ip':'192.168.192.199','names':['poi1','poi2']}
  3. s2={'ip':'192.168.192.58','names':['poi1','poi2']}
  4. s3={'ip':'192.168.192.146','names':['poi1','poi2']}
  5. s4={'ip':'192.168.192.45','names':['poi1','poi2']}
  6. s5={'ip':'192.168.192.156','names':['hhhclick1','hhhclick2','seo1','seo2']}
  7. servers=[s1,s2,s3,s4,s5]
  8. #conn = rpyc.ssl_connect("192.168.192.199", port = 18812, keyfile="c:/tmp/client.key",
  9. # certfile="c:/tmp/client.cer")
  10. for srv in servers:
  11. print(srv['ip'])
  12. conn = rpyc.classic.connect(srv['ip'], port = 18812)
  13. ros=conn.modules.os
  14. conn.execute('import docker')
  15. rdocker=conn.modules.docker
  16. client = rdocker.from_env()
  17. lst=client.containers.list()
  18. cur_names=[]
  19. for l in lst:
  20. cur_names.append(l.name)
  21. for n in srv['names']:
  22. if n not in cur_names:
  23. print("calling: " +n)
  24. ros.system('docker container restart '+n)