@@ -86,6 +86,7 @@ def create_vm(
8686 hyperv : "HyperV" = None ,
8787 connection_timeout : int = 3600 ,
8888 dynamic_mng_ip : bool = False ,
89+ wait_time : Optional [int ] = None ,
8990 ) -> VM :
9091 """Create a new VM using the specified vm_params.
9192
@@ -94,6 +95,7 @@ def create_vm(
9495 :param hyperv: Hyperv object that will be used by Vm instance
9596 :param connection_timeout: timeout of RPyCConnection to VM
9697 :param dynamic_mng_ip: To enable or disable dynamic mng ip allocation
98+ :param wait_time: amount of time a program waits
9799 """
98100 commands = [
99101 f'New-VM "{ vm_params .name } " -Generation { vm_params .generation } -Path { vm_params .vm_dir_path } ' ,
@@ -118,6 +120,9 @@ def create_vm(
118120 if dynamic_mng_ip :
119121 vm_params .mng_ip = mng_ip
120122
123+ if wait_time :
124+ time .sleep (wait_time )
125+
121126 vm_connection = RPyCConnection (ip = vm_params .mng_ip , connection_timeout = connection_timeout )
122127 vm = VM (vm_connection , vm_params , owner , hyperv , connection_timeout )
123128
@@ -183,7 +188,7 @@ def _vm_connectivity_test(self, ip_address: IPAddress, timeout: int = 10) -> boo
183188 results = ping .stop (ping_process )
184189 return results .fail_count == 0
185190
186- def wait_vm_functional (self , vm_name : str , vm_mng_ip : IPAddress , timeout : int = 300 ) -> None :
191+ def wait_vm_functional (self , vm_name : str , vm_mng_ip : IPAddress , timeout : int = 300 , wait_time : Optional [ int ] = None ) -> None :
187192 """Wait for Vm to be functional.
188193
189194 VM is considered running and functional if its state is running and its management interface can be pinged.
@@ -192,6 +197,8 @@ def wait_vm_functional(self, vm_name: str, vm_mng_ip: IPAddress, timeout: int =
192197 :param timeout: maximum time duration for VM to become pingable
193198 :raises: HyperVException when VM management IP cannot be pinged after several attempts indicating an issue
194199 """
200+ if wait_time :
201+ time .sleep (wait_time )
195202 timeout_counter = TimeoutCounter (timeout )
196203 while not timeout_counter :
197204 connectivity_result = self ._vm_connectivity_test (vm_mng_ip , int (timeout / 10 ))
0 commit comments