-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatchController.py
More file actions
executable file
·38 lines (32 loc) · 884 Bytes
/
patchController.py
File metadata and controls
executable file
·38 lines (32 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
import scp
import json
from paramiko import SSHClient
from scp import SCPClient
from time import sleep
host="10.91.55.11"
user="admin"
password="Avi123$%"
patch='controller_patch.17.2.9-3p2.pkg'
ssh = SSHClient()
ssh.load_system_host_keys()
ssh.connect(host, username=user, password=password)
scp = SCPClient(ssh.get_transport())
scp.put('../' + patch, remote_path='/tmp')
session = ssh.get_transport().open_session()
session.set_combine_stderr(True)
session.get_pty()
session.exec_command('shell')
stdin = session.makefile('wb', -1)
stdout = session.makefile('rb', -1)
stdin.write(user + '\n')
print(stdout.read().decode("utf-8"))
stdin.write(password + '\n')
print(stdout.read().decode("utf-8"))
stdin.write('patch system image_path /tmp/' + patch + '\n')
print(stdout.read().decode("utf-8"))
stdin.flush()
sleep(120)
session.close()
scp.close()
ssh.close()