allow executing XML files from daemon from Register Message
(like a Python script) added start flag to xmlutils.opensessionxml(), XML file will be parsed into a live running session (Boeing r1792)
This commit is contained in:
parent
93f96c7707
commit
1e8abc4c1e
3 changed files with 44 additions and 34 deletions
|
@ -221,19 +221,16 @@ class Session(object):
|
|||
self._time = time.time()
|
||||
self._state = state
|
||||
replies = []
|
||||
|
||||
if not self.isconnected():
|
||||
return replies
|
||||
if info:
|
||||
if self.isconnected() and info:
|
||||
statename = coreapi.state_name(state)
|
||||
self._handlerslock.acquire()
|
||||
for handler in self._handlers:
|
||||
handler.info("SESSION %s STATE %d: %s at %s" % \
|
||||
(self.sessionid, state, statename, time.ctime()))
|
||||
self._handlerslock.release()
|
||||
with self._handlerslock:
|
||||
for handler in self._handlers:
|
||||
handler.info("SESSION %s STATE %d: %s at %s" % \
|
||||
(self.sessionid, state, statename,
|
||||
time.ctime()))
|
||||
self.writestate(state)
|
||||
self.runhook(state)
|
||||
if sendevent:
|
||||
if self.isconnected() and sendevent:
|
||||
tlvdata = ""
|
||||
tlvdata += coreapi.CoreEventTlv.pack(coreapi.CORE_TLV_EVENT_TYPE,
|
||||
state)
|
||||
|
@ -587,6 +584,24 @@ class Session(object):
|
|||
# nodes on slave servers that will be booted and those servers will
|
||||
# send a node status response message
|
||||
self.checkruntime()
|
||||
|
||||
def getnodecount(self):
|
||||
''' Returns the number of CoreNodes and CoreNets, except for those
|
||||
that are not considered in the GUI's node count.
|
||||
'''
|
||||
|
||||
with self._objslock:
|
||||
count = len(filter(lambda(x): \
|
||||
not isinstance(x, (nodes.PtpNet, nodes.CtrlNet)),
|
||||
self.objs()))
|
||||
# on Linux, GreTapBridges are auto-created, not part of
|
||||
# GUI's node count
|
||||
if 'GreTapBridge' in globals():
|
||||
count -= len(filter(lambda(x): \
|
||||
isinstance(x, GreTapBridge) and not \
|
||||
isinstance(x, nodes.TunnelNode),
|
||||
self.objs()))
|
||||
return count
|
||||
|
||||
def checkruntime(self):
|
||||
''' Check if we have entered the runtime state, that all nodes have been
|
||||
|
@ -601,20 +616,7 @@ class Session(object):
|
|||
if self.getstate() == coreapi.CORE_EVENT_RUNTIME_STATE:
|
||||
return
|
||||
session_node_count = int(self.node_count)
|
||||
nc = 0
|
||||
with self._objslock:
|
||||
for obj in self.objs():
|
||||
# these networks may be added by the daemon and are not
|
||||
# considered in the GUI's node count
|
||||
if isinstance(obj, (nodes.PtpNet, nodes.CtrlNet)):
|
||||
continue
|
||||
# on Linux, GreTapBridges are auto-created, not part of GUI's
|
||||
# node count
|
||||
if 'GreTapBridge' in globals():
|
||||
if isinstance(obj, GreTapBridge) and \
|
||||
not isinstance(obj, nodes.TunnelNode):
|
||||
continue
|
||||
nc += 1
|
||||
nc = self.getnodecount()
|
||||
# count booted nodes not emulated on this server
|
||||
# TODO: let slave server determine RUNTIME and wait for Event Message
|
||||
# broker.getbootocunt() counts all CoreNodes from status reponse
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue