service.py: multi-access safe call - bugfix
If `service_manager` is called multiple times, its previous instance is
used. The problem arises if different runner is used. Because it leads
to situation when service commands are passed to wrong VM or service is
run as systemd insted of SysVinit or vice versa. Global variables,
where information from previous run were stored were thus removed as well as
then unused functions. Selftest for two different calls was also added.
Steps to invoke:
```
ssn_c = vm_client.vm.wait_for_login()
runner = remote.RemoteRunner(session=ssn_c)
vdagentd = service.specific_service_manager("spice-vdagentd", run=runner.run)
vdagentd.stop() # send to vm_client
ssn_g = vm_guest.vm.wait_for_login()
runner = remote.RemoteRunner(session=ssn_g)
vdagentd = service.specific_service_manager("spice-vdagentd", run=runner.run)
vdagentd.stop() # send to vm_client (again!)
```
As a trade-off this may affect speed when invoked in a loop since
`service_manager` won't be cached any more.
Signed-off-by: NRadek Duda <rduda@redhat.com>
Showing
想要评论请 注册 或 登录