Jared %!s(int64=3) %!d(string=hai) anos
pai
achega
706ff3de9f
Modificáronse 1 ficheiros con 26 adicións e 0 borrados
  1. 26 0
      tests/rpc_key_test.py

+ 26 - 0
tests/rpc_key_test.py

@@ -0,0 +1,26 @@
+import rpyc
+s1={'ip':'192.168.192.199','names':['poi1','poi2']}
+s2={'ip':'192.168.192.58','names':['poi1','poi2']}
+s3={'ip':'192.168.192.146','names':['poi1','poi2']}
+s4={'ip':'192.168.192.45','names':['poi1','poi2']}
+s5={'ip':'192.168.192.156','names':['hhhclick1','hhhclick2','seo1','seo2']}
+
+servers=[s1,s2,s3,s4,s5]
+#conn = rpyc.ssl_connect("192.168.192.199", port = 18812, keyfile="c:/tmp/client.key",
+#                        certfile="c:/tmp/client.cer")
+
+for srv in servers:
+    print(srv['ip'])
+    conn = rpyc.classic.connect(srv['ip'], port = 18812)
+    ros=conn.modules.os
+    conn.execute('import docker')
+    rdocker=conn.modules.docker
+    client = rdocker.from_env()
+    lst=client.containers.list()
+    cur_names=[]
+    for l in lst:
+        cur_names.append(l.name)
+    for n in srv['names']:
+        if n not in cur_names:
+            print("calling: " +n)
+            ros.system('docker container restart '+n)