summaryrefslogtreecommitdiffstats
path: root/src/ogRest.py
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-05-26 11:24:26 +0200
committerRoberto Hueso Gómez <rhueso@soleta.eu>2020-05-26 11:24:26 +0200
commitb29b2eb452b21c6abc1a203d2688b94482af1aaf (patch)
tree95267bb6b5baedd33ca8438b7c0784942508dfd2 /src/ogRest.py
parent80b7023ecb51d7f6499e270b3d199e29c9dedbb5 (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/ogRest.py')
-rw-r--r--src/ogRest.py17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/ogRest.py b/src/ogRest.py
index 31c1506..a52d8a5 100644
--- a/src/ogRest.py
+++ b/src/ogRest.py
@@ -96,17 +96,6 @@ class ogThread():
ogRest.state = ThreadState.IDLE
- def check_vm_state_loop(ogRest):
- POLLING_WAIT_TIME = 12
- while True:
- time.sleep(POLLING_WAIT_TIME)
- state = ogRest.operations.check_vm_state()
- installed_os = ogRest.operations.get_installed_os()
- if state == OgVM.State.STOPPED and \
- ogRest.state == ThreadState.IDLE and \
- len(installed_os) > 0:
- ogRest.operations.poweroff_host()
-
def poweroff(ogRest):
time.sleep(2)
ogRest.operations.poweroff()
@@ -252,10 +241,10 @@ class ogRest():
if self.mode == 'linux':
self.operations = OgLinuxOperations(self.CONFIG)
elif self.mode == 'virtual':
- from src.virtual.ogOperations import (OgVM,
- OgVirtualOperations)
+ from src.virtual.ogOperations import \
+ OgVirtualOperations
self.operations = OgVirtualOperations()
- threading.Thread(target=ogThread.check_vm_state_loop,
+ threading.Thread(target=self.operations.check_vm_state_loop,
args=(self,)).start()
else:
raise ValueError('Mode not supported.')