5
5
from lib .commands import ssh , SSHCommandFailed
6
6
from lib .common import wait_for
7
7
8
+ # FIXME should only be used for <7.0
9
+ SSHOPTS = ("-o KexAlgorithms=+diffie-hellman-group1-sha1" ,
10
+ "-o HostKeyAlgorithms=+ssh-rsa" ,
11
+ "-o PubkeyAcceptedKeyTypes=+ssh-rsa" ,
12
+ "-c +aes256-cbc" )
13
+
8
14
class AnswerFile :
9
15
def __init__ (self , kind , / ):
10
16
from data import BASE_ANSWERFILES
@@ -62,36 +68,41 @@ def _defn_to_xml_et(defn, /, *, parent=None):
62
68
63
69
def poweroff (ip ):
64
70
try :
65
- ssh (ip , ["poweroff" ])
71
+ ssh (ip , ["/sbin/ poweroff" ], options = SSHOPTS )
66
72
except SSHCommandFailed as e :
67
73
# ignore connection closed by reboot
68
74
if e .returncode == 255 and "closed by remote host" in e .stdout :
69
75
logging .info ("sshd closed the connection" )
70
76
pass
77
+ elif e .returncode == 255 :
78
+ logging .info ("sshd misbehaving?" )
71
79
else :
72
80
raise
73
81
74
82
def monitor_install (* , ip ):
75
83
# wait for "yum install" phase to finish
76
- wait_for (lambda : ssh (ip , ["grep" ,
84
+ wait_for (lambda : "DISPATCH: NEW PHASE: Completing installation" in ssh (ip , ["grep" ,
77
85
"'DISPATCH: NEW PHASE: Completing installation'" ,
78
86
"/tmp/install-log" ],
79
87
check = False , simple_output = False ,
80
- ).returncode == 0 ,
88
+ options = SSHOPTS ,
89
+ ).stdout ,
81
90
"Wait for rpm installation to succeed" ,
82
91
timeout_secs = 40 * 60 ) # FIXME too big
83
92
84
93
# wait for install to finish
85
- wait_for (lambda : ssh (ip , ["grep" ,
94
+ wait_for (lambda : "The installation completed successfully" in ssh (ip , ["grep" ,
86
95
"'The installation completed successfully'" ,
87
96
"/tmp/install-log" ],
88
97
check = False , simple_output = False ,
89
- ).returncode == 0 ,
98
+ options = SSHOPTS ,
99
+ ).stdout ,
90
100
"Wait for system installation to succeed" ,
91
101
timeout_secs = 40 * 60 ) # FIXME too big
92
102
93
103
wait_for (lambda : ssh (ip , ["ps a|grep '[0-9]. python /opt/xensource/installer/init'" ],
94
104
check = False , simple_output = False ,
105
+ options = SSHOPTS ,
95
106
).returncode == 1 ,
96
107
"Wait for installer to terminate" )
97
108
@@ -101,6 +112,7 @@ def monitor_upgrade(*, ip):
101
112
"'DISPATCH: NEW PHASE: Reading package information'" ,
102
113
"/tmp/install-log" ],
103
114
check = False , simple_output = False ,
115
+ options = SSHOPTS ,
104
116
).returncode == 0 ,
105
117
"Wait for upgrade preparations to finish" ,
106
118
timeout_secs = 40 * 60 ) # FIXME too big
@@ -110,6 +122,7 @@ def monitor_upgrade(*, ip):
110
122
"'DISPATCH: NEW PHASE: Completing installation'" ,
111
123
"/tmp/install-log" ],
112
124
check = False , simple_output = False ,
125
+ options = SSHOPTS ,
113
126
).returncode == 0 ,
114
127
"Wait for rpm installation to succeed" ,
115
128
timeout_secs = 40 * 60 ) # FIXME too big
@@ -119,12 +132,14 @@ def monitor_upgrade(*, ip):
119
132
"'The installation completed successfully'" ,
120
133
"/tmp/install-log" ],
121
134
check = False , simple_output = False ,
135
+ options = SSHOPTS ,
122
136
).returncode == 0 ,
123
137
"Wait for system installation to succeed" ,
124
138
timeout_secs = 40 * 60 ) # FIXME too big
125
139
126
140
wait_for (lambda : ssh (ip , ["ps a|grep '[0-9]. python /opt/xensource/installer/init'" ],
127
141
check = False , simple_output = False ,
142
+ options = SSHOPTS ,
128
143
).returncode == 1 ,
129
144
"Wait for installer to terminate" )
130
145
@@ -134,6 +149,7 @@ def monitor_restore(*, ip):
134
149
"'Restoring backup'" ,
135
150
"/tmp/install-log" ],
136
151
check = False , simple_output = False ,
152
+ options = SSHOPTS ,
137
153
).returncode == 0 ,
138
154
"Wait for data restoration to start" ,
139
155
timeout_secs = 40 * 60 ) # FIXME too big
@@ -143,6 +159,7 @@ def monitor_restore(*, ip):
143
159
"'Data restoration complete. About to re-install bootloader.'" ,
144
160
"/tmp/install-log" ],
145
161
check = False , simple_output = False ,
162
+ options = SSHOPTS ,
146
163
).returncode == 0 ,
147
164
"Wait for data restoration to complete" ,
148
165
timeout_secs = 40 * 60 ) # FIXME too big
@@ -154,6 +171,7 @@ def monitor_restore(*, ip):
154
171
"'ran .*swaplabel.*rc 0'" ,
155
172
"/tmp/install-log" ],
156
173
check = False , simple_output = False ,
174
+ options = SSHOPTS ,
157
175
).returncode == 0 ,
158
176
"Wait for installer to hopefully finish" ,
159
177
timeout_secs = 40 * 60 ) # FIXME too big
0 commit comments