@@ -209,6 +209,7 @@ def __init__(
209209 package_channel : Optional [str ] = None ,
210210 test_configuration : Optional [dict ] = None ,
211211 test_flavor : Optional [Dict [str , str ]] = None ,
212+ vm_alive : bool = False ,
212213 verbose : bool = False ,
213214 ):
214215 # Environment ID and working directory preparation
@@ -279,6 +280,7 @@ def __init__(
279280 self ._stats = {}
280281 self ._verbose = verbose
281282 self .package_channel = package_channel
283+ self .vm_alive = vm_alive
282284
283285 @property
284286 def artifacts (self ):
@@ -1634,6 +1636,7 @@ def __init__(
16341636 package_channel : Optional [str ] = None ,
16351637 test_configuration : Optional [dict ] = None ,
16361638 test_flavor : Optional [Dict [str , str ]] = None ,
1639+ vm_alive : bool = False ,
16371640 verbose : bool = False ,
16381641 ):
16391642 super ().__init__ (
@@ -1652,6 +1655,7 @@ def __init__(
16521655 self ._tests_dir = CONFIG .tests_base_dir
16531656 self ._ssh_client : Optional [Union [AsyncSSHClient , LongRunSSHClient ]] = None
16541657 self ._vm_ip = None
1658+ self ._vm_alive = vm_alive
16551659
16561660 def _wait_for_ssh (self , retries = 60 ):
16571661 ansible = local [self .ansible_binary ]
@@ -1746,12 +1750,13 @@ def setup(self, skip_provision: bool = False):
17461750 self ._ssh_client = LongRunSSHClient (** params )
17471751
17481752 def teardown (self , publish_artifacts : bool = True ):
1749- if self ._ssh_client :
1750- try :
1751- self ._ssh_client .close ()
1752- except :
1753- pass
1754- super ().teardown (publish_artifacts = publish_artifacts )
1753+ if not self ._vm_alive :
1754+ if self ._ssh_client :
1755+ try :
1756+ self ._ssh_client .close ()
1757+ except :
1758+ pass
1759+ super ().teardown (publish_artifacts = publish_artifacts )
17551760
17561761 def exec_command (self , * args , ** kwargs ) -> Tuple [int , str , str ]:
17571762 command = ' ' .join (args )
0 commit comments