55from lib .commands import ssh , SSHCommandFailed
66from lib .common import wait_for
77
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+
814class AnswerFile :
915 def __init__ (self , kind , / ):
1016 from data import BASE_ANSWERFILES
@@ -62,36 +68,41 @@ def _defn_to_xml_et(defn, /, *, parent=None):
6268
6369def poweroff (ip ):
6470 try :
65- ssh (ip , ["poweroff" ])
71+ ssh (ip , ["/sbin/ poweroff" ], options = SSHOPTS )
6672 except SSHCommandFailed as e :
6773 # ignore connection closed by reboot
6874 if e .returncode == 255 and "closed by remote host" in e .stdout :
6975 logging .info ("sshd closed the connection" )
7076 pass
77+ elif e .returncode == 255 :
78+ logging .info ("sshd misbehaving?" )
7179 else :
7280 raise
7381
7482def monitor_install (* , ip ):
7583 # 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" ,
7785 "'DISPATCH: NEW PHASE: Completing installation'" ,
7886 "/tmp/install-log" ],
7987 check = False , simple_output = False ,
80- ).returncode == 0 ,
88+ options = SSHOPTS ,
89+ ).stdout ,
8190 "Wait for rpm installation to succeed" ,
8291 timeout_secs = 40 * 60 ) # FIXME too big
8392
8493 # wait for install to finish
85- wait_for (lambda : ssh (ip , ["grep" ,
94+ wait_for (lambda : "The installation completed successfully" in ssh (ip , ["grep" ,
8695 "'The installation completed successfully'" ,
8796 "/tmp/install-log" ],
8897 check = False , simple_output = False ,
89- ).returncode == 0 ,
98+ options = SSHOPTS ,
99+ ).stdout ,
90100 "Wait for system installation to succeed" ,
91101 timeout_secs = 40 * 60 ) # FIXME too big
92102
93103 wait_for (lambda : ssh (ip , ["ps a|grep '[0-9]. python /opt/xensource/installer/init'" ],
94104 check = False , simple_output = False ,
105+ options = SSHOPTS ,
95106 ).returncode == 1 ,
96107 "Wait for installer to terminate" )
97108
@@ -101,6 +112,7 @@ def monitor_upgrade(*, ip):
101112 "'DISPATCH: NEW PHASE: Reading package information'" ,
102113 "/tmp/install-log" ],
103114 check = False , simple_output = False ,
115+ options = SSHOPTS ,
104116 ).returncode == 0 ,
105117 "Wait for upgrade preparations to finish" ,
106118 timeout_secs = 40 * 60 ) # FIXME too big
@@ -110,6 +122,7 @@ def monitor_upgrade(*, ip):
110122 "'DISPATCH: NEW PHASE: Completing installation'" ,
111123 "/tmp/install-log" ],
112124 check = False , simple_output = False ,
125+ options = SSHOPTS ,
113126 ).returncode == 0 ,
114127 "Wait for rpm installation to succeed" ,
115128 timeout_secs = 40 * 60 ) # FIXME too big
@@ -119,12 +132,14 @@ def monitor_upgrade(*, ip):
119132 "'The installation completed successfully'" ,
120133 "/tmp/install-log" ],
121134 check = False , simple_output = False ,
135+ options = SSHOPTS ,
122136 ).returncode == 0 ,
123137 "Wait for system installation to succeed" ,
124138 timeout_secs = 40 * 60 ) # FIXME too big
125139
126140 wait_for (lambda : ssh (ip , ["ps a|grep '[0-9]. python /opt/xensource/installer/init'" ],
127141 check = False , simple_output = False ,
142+ options = SSHOPTS ,
128143 ).returncode == 1 ,
129144 "Wait for installer to terminate" )
130145
@@ -134,6 +149,7 @@ def monitor_restore(*, ip):
134149 "'Restoring backup'" ,
135150 "/tmp/install-log" ],
136151 check = False , simple_output = False ,
152+ options = SSHOPTS ,
137153 ).returncode == 0 ,
138154 "Wait for data restoration to start" ,
139155 timeout_secs = 40 * 60 ) # FIXME too big
@@ -143,6 +159,7 @@ def monitor_restore(*, ip):
143159 "'Data restoration complete. About to re-install bootloader.'" ,
144160 "/tmp/install-log" ],
145161 check = False , simple_output = False ,
162+ options = SSHOPTS ,
146163 ).returncode == 0 ,
147164 "Wait for data restoration to complete" ,
148165 timeout_secs = 40 * 60 ) # FIXME too big
@@ -154,6 +171,7 @@ def monitor_restore(*, ip):
154171 "'ran .*swaplabel.*rc 0'" ,
155172 "/tmp/install-log" ],
156173 check = False , simple_output = False ,
174+ options = SSHOPTS ,
157175 ).returncode == 0 ,
158176 "Wait for installer to hopefully finish" ,
159177 timeout_secs = 40 * 60 ) # FIXME too big
0 commit comments