diff options
author | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-05-26 11:24:26 +0200 |
---|---|---|
committer | Roberto Hueso Gómez <rhueso@soleta.eu> | 2020-05-26 11:24:26 +0200 |
commit | b29b2eb452b21c6abc1a203d2688b94482af1aaf (patch) | |
tree | 95267bb6b5baedd33ca8438b7c0784942508dfd2 /src/virtual | |
parent | 80b7023ecb51d7f6499e270b3d199e29c9dedbb5 (diff) |
Move check_vm_state_loop() into OgVirtualOperations
Improves code encapsulation by moving check_vm_state_loop method into
OgVirtualOperations class. This also fixes import error when running ogclient in
'linux' mode.
Diffstat (limited to 'src/virtual')
-rw-r--r-- | src/virtual/ogOperations.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/virtual/ogOperations.py b/src/virtual/ogOperations.py index 8e2eb23..9deb2e7 100644 --- a/src/virtual/ogOperations.py +++ b/src/virtual/ogOperations.py @@ -6,6 +6,7 @@ # Free Software Foundation, version 3. # +from src.ogRest import ThreadState import socket import errno import select @@ -221,6 +222,17 @@ class OgVirtualOperations: pass return installed_os + def check_vm_state_loop(self, ogRest): + POLLING_WAIT_TIME = 12 + while True: + time.sleep(POLLING_WAIT_TIME) + state = self.check_vm_state() + installed_os = self.get_installed_os() + if state == OgVM.State.STOPPED and \ + ogRest.state == ThreadState.IDLE and \ + len(installed_os) > 0: + self.poweroff_host() + def shellrun(self, request, ogRest): return |