From 54d24023edce344ad1790c3bf89e93817c3c98e6 Mon Sep 17 00:00:00 2001 From: Faiyaz Ahmed Date: Mon, 14 Jul 2008 22:00:52 +0000 Subject: [PATCH] Add check to see if sliver is_running() during ensure_created. Previously, if the object existed in the database, it was assumed the sliver was running and the start() operation would ignore the record. However, if a sliver is damaged, its best to query util-vserver to actually make sure the slice is indeed running. --- accounts.py | 6 ++++-- sliver_vs.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/accounts.py b/accounts.py index 3711a0d..a6dd6d2 100644 --- a/accounts.py +++ b/accounts.py @@ -95,7 +95,7 @@ class Account: def start(self, delay=0): pass def stop(self): pass - + def is_running(self): pass class Worker: # these semaphores are acquired before creating/destroying an account @@ -128,7 +128,7 @@ class Worker: finally: self._create_sem.release() if not isinstance(self._acct, next_class): self._acct = next_class(rec) else: self._acct.configure(rec) - if startingup: + if startingup or not self.is_running(): csd_lock.acquire() global cumstartdelay delay = cumstartdelay @@ -147,6 +147,8 @@ class Worker: def stop(self): self._q.put((self._stop,)) def _stop(self): self._acct.stop() + def is_running(self): self._acct.is_running() + def _destroy(self, curr_class): self._acct = None if curr_class: diff --git a/sliver_vs.py b/sliver_vs.py index 46b3a12..ee0b5d4 100644 --- a/sliver_vs.py +++ b/sliver_vs.py @@ -188,6 +188,8 @@ class Sliver_VS(accounts.Account, vserver.VServer): logger.log('%s: stopping' % self.name) vserver.VServer.stop(self) + def is_running(self): vserver.VServer.is_running(self) + def set_resources(self): disk_max = self.rspec['disk_max'] logger.log('%s: setting max disk usage to %d KiB' % (self.name, disk_max)) -- 2.43.0