mlos_bench.services.remote.azure.azure_vm_services module¶
A collection Service functions for managing VMs on Azure.
- class mlos_bench.services.remote.azure.azure_vm_services.AzureVMService(config: Dict[str, Any] | None = None, global_config: Dict[str, Any] | None = None, parent: Service | None = None, methods: Dict[str, Callable] | List[Callable] | None = None)¶
Bases:
AzureDeploymentService
,SupportsHostProvisioning
,SupportsHostOps
,SupportsOSOps
,SupportsRemoteExec
Helper methods to manage VMs on Azure.
- Attributes:
config_loader_service
Return a config loader service.
deploy_params
Get the deployment parameters.
Methods
deallocate_host
(params)Deallocates the VM on Azure by shutting it down then releasing the compute resources.
deprovision_host
(params)Deprovisions the VM on Azure by deleting it.
export
()Return a dictionary of functions available in this service.
get_remote_exec_results
(config)Get the results of the asynchronously running command.
merge_methods
(ext_methods, local_methods)Merge methods from the external caller with the local ones.
new
(class_name[, config, global_config, parent])Factory method for a new service with a given config.
pprint
()Produce a human-readable string listing all public methods of the service.
provision_host
(params)Check if Azure VM is ready.
reboot
(params[, force])Initiates a (graceful) shutdown of the Host/VM OS.
register
(services)Register new mix-in services.
remote_exec
(script, config, env_params)Run a command on Azure VM.
restart_host
(params[, force])Reboot the VM on Azure by initiating a graceful shutdown.
shutdown
(params[, force])Initiates a (graceful) shutdown of the Host/VM OS.
start_host
(params)Start the VM on Azure.
stop_host
(params[, force])Stops the VM on Azure by initiating a graceful shutdown.
wait_host_deployment
(params, *, is_setup)Waits for a pending operation on an Azure VM to resolve to SUCCEEDED or FAILED.
wait_host_operation
(params)Waits for a pending operation on an Azure VM to resolve to SUCCEEDED or FAILED.
wait_os_operation
(params)Waits for a pending operation on an OS to resolve to SUCCEEDED or FAILED.
- deallocate_host(params: dict) Tuple[Status, dict] ¶
Deallocates the VM on Azure by shutting it down then releasing the compute resources.
Note: This can cause the VM to arrive on a new host node when its restarted, which may have different performance characteristics.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- deprovision_host(params: dict) Tuple[Status, dict] ¶
Deprovisions the VM on Azure by deleting it.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- get_remote_exec_results(config: dict) Tuple[Status, dict] ¶
Get the results of the asynchronously running command.
- Parameters:
- configdict
Flat dictionary of (key, value) pairs of tunable parameters. Must have the “asyncResultsUrl” key to get the results. If the key is not present, return Status.PENDING.
- Returns:
- result(Status, dict)
A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT} A dict can have an “stdout” key with the remote output.
- provision_host(params: dict) Tuple[Status, dict] ¶
Check if Azure VM is ready. Deploy a new VM, if necessary.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters. HostEnv tunables are variable parameters that, together with the HostEnv configuration, are sufficient to provision a VM.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is the input params plus the parameters extracted from the response JSON, or {} if the status is FAILED. Status is one of {PENDING, SUCCEEDED, FAILED}
- reboot(params: dict, force: bool = False) Tuple[Status, dict] ¶
Initiates a (graceful) shutdown of the Host/VM OS.
- Parameters:
- params: dict
Flat dictionary of (key, value) pairs of tunable parameters.
- forcebool
If True, force restart the Host/VM.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- remote_exec(script: Iterable[str], config: dict, env_params: dict) Tuple[Status, dict] ¶
Run a command on Azure VM.
- Parameters:
- scriptIterable[str]
A list of lines to execute as a script on a remote VM.
- configdict
Flat dictionary of (key, value) pairs of the Environment parameters. They usually come from const_args and tunable_params properties of the Environment.
- env_paramsdict
Parameters to pass as shell environment variables into the script. This is usually a subset of config with some possible conversions.
- Returns:
- result(Status, dict)
A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED}
- restart_host(params: dict, force: bool = False) Tuple[Status, dict] ¶
Reboot the VM on Azure by initiating a graceful shutdown.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters.
- forcebool
If True, force restart the Host/VM.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- shutdown(params: dict, force: bool = False) Tuple[Status, dict] ¶
Initiates a (graceful) shutdown of the Host/VM OS.
- Parameters:
- params: dict
Flat dictionary of (key, value) pairs of tunable parameters.
- forcebool
If True, force stop the Host/VM.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- start_host(params: dict) Tuple[Status, dict] ¶
Start the VM on Azure.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- stop_host(params: dict, force: bool = False) Tuple[Status, dict] ¶
Stops the VM on Azure by initiating a graceful shutdown.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters.
- forcebool
If True, force stop the Host/VM.
- Returns:
- result(Status, dict={})
A pair of Status and result. The result is always {}. Status is one of {PENDING, SUCCEEDED, FAILED}
- wait_host_deployment(params: dict, *, is_setup: bool) Tuple[Status, dict] ¶
Waits for a pending operation on an Azure VM to resolve to SUCCEEDED or FAILED. Return TIMED_OUT when timing out.
- Parameters:
- paramsdict
Flat dictionary of (key, value) pairs of tunable parameters.
- is_setupbool
If True, wait for VM being deployed; otherwise, wait for successful deprovisioning.
- Returns:
- result(Status, dict)
A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT} Result is info on the operation runtime if SUCCEEDED, otherwise {}.
- wait_host_operation(params: dict) Tuple[Status, dict] ¶
Waits for a pending operation on an Azure VM to resolve to SUCCEEDED or FAILED. Return TIMED_OUT when timing out.
- Parameters:
- params: dict
Flat dictionary of (key, value) pairs of tunable parameters. Must have the “asyncResultsUrl” key to get the results. If the key is not present, return Status.PENDING.
- Returns:
- result(Status, dict)
A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT} Result is info on the operation runtime if SUCCEEDED, otherwise {}.
- wait_os_operation(params: dict) Tuple[Status, dict] ¶
Waits for a pending operation on an OS to resolve to SUCCEEDED or FAILED. Return TIMED_OUT when timing out.
- Parameters:
- params: dict
Flat dictionary of (key, value) pairs of tunable parameters. Must have the “asyncResultsUrl” key to get the results. If the key is not present, return Status.PENDING.
- Returns:
- result(Status, dict)
A pair of Status and result. Status is one of {PENDING, SUCCEEDED, FAILED, TIMED_OUT} Result is info on the operation runtime if SUCCEEDED, otherwise {}.