@@ -92,26 +92,13 @@ def run(test, params, env):
9292 logging .debug (e )
9393 test .fail ("Failed to login with new password" )
9494
95- # Login with old password
96- try :
97- session = remote .wait_for_login ("ssh" , vm_ip , "22" , set_user_name , ori_passwd ,
98- r"[\#\$]\s*$" , timeout = 10 )
99- session .close ()
100- except remote .LoginAuthenticationError :
101- logging .debug ("Login with old password failed as expected." )
102-
103- # Change the password back in VM
104- ret = virsh .set_user_password (vm_name , set_user_name , ori_passwd , False ,
105- option = option , debug = True )
106- libvirt .check_exit_status (ret )
107-
108- # Login with the original password
109- try :
110- session = remote .wait_for_login ("ssh" , vm_ip , "22" , set_user_name , ori_passwd ,
111- r"[\#\$]\s*$" , timeout = 30 )
112- session .close ()
113- except remote .LoginAuthenticationError as e :
114- logging .debug (e )
95+ finally :
96+ # Recover VM
97+ if vm .is_alive ():
98+ # always restore root password in case previously case execution is broken
99+ if status_error != "yes" :
100+ virsh .set_user_password (vm_name , set_user_name , ori_passwd , False ,
101+ option = option , debug = True )
115102
116103 if start_ga :
117104 # Stop guest agent in vm
@@ -126,12 +113,5 @@ def run(test, params, env):
126113 test .error ("Deleting user '%s' got failed: '%s'" %
127114 (set_user_name , output ))
128115 session .close ()
129- finally :
130- # Recover VM
131- if vm .is_alive ():
132- # always restore root password in case previously case execution is broken
133- if status_error != "yes" :
134- virsh .set_user_password (vm_name , set_user_name , ori_passwd , False ,
135- option = option , debug = True )
136116 vm .destroy (gracefully = False )
137117 vmxml_bak .sync ()
0 commit comments