git://git.onelab.eu
/
nodemanager.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added ReCreate. Also added try catch to api eval of rpc method.
[nodemanager.git]
/
accounts.py
diff --git
a/accounts.py
b/accounts.py
index
fe0af53
..
47e7af5
100644
(file)
--- a/
accounts.py
+++ b/
accounts.py
@@
-29,6
+29,12
@@
import logger
import tools
import tools
+# When this variable is true, start after any ensure_created
+Startingup = False
+# Cumulative delay for starts when Startingup is true
+csd_lock = threading.Lock()
+cumstartdelay = 0
+
# shell path -> account class association
shell_acct_class = {}
# account type -> account class association
# shell path -> account class association
shell_acct_class = {}
# account type -> account class association
@@
-64,10
+70,11
@@
class Account:
def __init__(self, rec):
self.name = rec['name']
self.keys = ''
def __init__(self, rec):
self.name = rec['name']
self.keys = ''
+ self.initscriptchanged = False
self.configure(rec)
@staticmethod
self.configure(rec)
@staticmethod
- def create(name): abstract
+ def create(name
, vref = None
): abstract
@staticmethod
def destroy(name): abstract
@staticmethod
def destroy(name): abstract
@@
-104,9
+111,9
@@
class Worker:
def ensure_created(self, rec):
"""Cause the account specified by <rec> to exist if it doesn't already."""
def ensure_created(self, rec):
"""Cause the account specified by <rec> to exist if it doesn't already."""
- self._q.put((self._ensure_created, rec.copy()))
+ self._q.put((self._ensure_created, rec.copy()
, Startingup
))
- def _ensure_created(self, rec):
+ def _ensure_created(self, rec
, startingup
):
curr_class = self._get_class()
next_class = type_acct_class[rec['type']]
if next_class != curr_class:
curr_class = self._get_class()
next_class = type_acct_class[rec['type']]
if next_class != curr_class:
@@
-116,7
+123,15
@@
class Worker:
finally: self._create_sem.release()
if not isinstance(self._acct, next_class): self._acct = next_class(rec)
else: self._acct.configure(rec)
finally: self._create_sem.release()
if not isinstance(self._acct, next_class): self._acct = next_class(rec)
else: self._acct.configure(rec)
- if next_class != curr_class: self._acct.start()
+ if startingup:
+ csd_lock.acquire()
+ global cumstartdelay
+ delay = cumstartdelay
+ cumstartdelay += 2
+ csd_lock.release()
+ self._acct.start(delay=delay)
+ elif next_class != curr_class or self._acct.initscriptchanged:
+ self._acct.start()
def ensure_destroyed(self): self._q.put((self._ensure_destroyed,))
def _ensure_destroyed(self): self._destroy(self._get_class())
def ensure_destroyed(self): self._q.put((self._ensure_destroyed,))
def _ensure_destroyed(self): self._destroy(self._get_class())
@@
-145,4
+160,5
@@
class Worker:
try:
cmd = self._q.get()
cmd[0](*cmd[1:])
try:
cmd = self._q.get()
cmd[0](*cmd[1:])
- except: logger.log_exc()
+ except:
+ logger.log_exc(self.name)