Improve the logic in auto-installation
This commit is contained in:
@@ -286,7 +286,7 @@ def _install_virtual_machine(vm_name, vms_dir, downloaded_file_name, original_vm
|
|||||||
def start_vm(vm_path, max_retries=20):
|
def start_vm(vm_path, max_retries=20):
|
||||||
command = f'vmrun {get_vmrun_type()} start "{vm_path}" nogui'
|
command = f'vmrun {get_vmrun_type()} start "{vm_path}" nogui'
|
||||||
for attempt in range(max_retries):
|
for attempt in range(max_retries):
|
||||||
result = subprocess.run(command, shell=True, text=True, capture_output=True)
|
result = subprocess.run(command, shell=True, text=True, capture_output=True, encoding="utf-8")
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
print("Virtual machine started.")
|
print("Virtual machine started.")
|
||||||
return True
|
return True
|
||||||
@@ -306,7 +306,7 @@ def _install_virtual_machine(vm_name, vms_dir, downloaded_file_name, original_vm
|
|||||||
def get_vm_ip(vm_path, max_retries=20):
|
def get_vm_ip(vm_path, max_retries=20):
|
||||||
command = f'vmrun {get_vmrun_type()} getGuestIPAddress "{vm_path}" -wait'
|
command = f'vmrun {get_vmrun_type()} getGuestIPAddress "{vm_path}" -wait'
|
||||||
for attempt in range(max_retries):
|
for attempt in range(max_retries):
|
||||||
result = subprocess.run(command, shell=True, text=True, capture_output=True)
|
result = subprocess.run(command, shell=True, text=True, capture_output=True, encoding="utf-8")
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
return result.stdout.strip()
|
return result.stdout.strip()
|
||||||
else:
|
else:
|
||||||
@@ -347,7 +347,7 @@ def _install_virtual_machine(vm_name, vms_dir, downloaded_file_name, original_vm
|
|||||||
def create_vm_snapshot(vm_path, max_retries=20):
|
def create_vm_snapshot(vm_path, max_retries=20):
|
||||||
command = f'vmrun {get_vmrun_type()} snapshot "{vm_path}" "init_state"'
|
command = f'vmrun {get_vmrun_type()} snapshot "{vm_path}" "init_state"'
|
||||||
for attempt in range(max_retries):
|
for attempt in range(max_retries):
|
||||||
result = subprocess.run(command, shell=True, text=True, capture_output=True)
|
result = subprocess.run(command, shell=True, text=True, capture_output=True, encoding="utf-8")
|
||||||
if result.returncode == 0:
|
if result.returncode == 0:
|
||||||
print("Snapshot created.")
|
print("Snapshot created.")
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user