(user, pkey, password, hosts_str, cmd, file_path, dir_path, delete_dir)
| 29 | |
| 30 | |
| 31 | def 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 | |
| 63 | if __name__ == "__main__": |
no test coverage detected