MCPcopy Create free account
hub / github.com/StackStorm/st2 / main

Function main

st2common/bin/paramiko_ssh_evenlets_tester.py:31–60  ·  view source on GitHub ↗
(user, pkey, password, hosts_str, cmd, file_path, dir_path, delete_dir)

Source from the content-addressed store, hash-verified

29
30
31def main(user, pkey, password, hosts_str, cmd, file_path, dir_path, delete_dir):
32 hosts = hosts_str.split(",")
33 client = ParallelSSHClient(
34 user=user, pkey_file=pkey, password=password, hosts=hosts
35 )
36 pp = pprint.PrettyPrinter(indent=4)
37
38 if file_path:
39 if not os.path.exists(file_path):
40 raise Exception("File not found.")
41 results = client.put(file_path, "/home/lakshmi/test_file", mode="0660")
42 pp.pprint("Copy results: \n%s" % results)
43 results = client.run("ls -rlth")
44 pp.pprint("ls results: \n%s" % results)
45
46 if dir_path:
47 if not os.path.exists(dir_path):
48 raise Exception("File not found.")
49 results = client.put(dir_path, "/home/lakshmi/", mode="0660")
50 pp.pprint("Copy results: \n%s" % results)
51 results = client.run("ls -rlth")
52 pp.pprint("ls results: \n%s" % results)
53
54 if cmd:
55 results = client.run(cmd)
56 pp.pprint("cmd results: \n%s" % results)
57
58 if delete_dir:
59 results = client.delete_dir(delete_dir, force=True)
60 pp.pprint("Delete results: \n%s" % results)
61
62
63if __name__ == "__main__":

Callers 1

Calls 5

putMethod · 0.95
runMethod · 0.95
delete_dirMethod · 0.95
ParallelSSHClientClass · 0.90
existsMethod · 0.80

Tested by

no test coverage detected