This can be replace with a wait_for function, consider something like the following, (note the below is untested)

```python
from utils.wait import wait_for

cur_provider = mgmt_sys_api_clients[provider_key]
ec, tc, = wait_for(cur_provider.is_vm_running, [vm_name], num_sec=600)     #Will wait until the function is not False (by default)
# ec is the result of the function
# tc is the time taken (refer to documentation for inaccuracy notes)

cur_provider.stop_vm(vm_name)
ec, tc, = wait_for(cur_provider.is_vm_stopped, [vm_name], num_sec=600)
```

Something similar could be drafted for the rest of the function