|
|
|
|
|
Sync
Action : was.sync (Category : was, Name : sync, By : kikonf)
Complete Name : was.sync.by.kikonf Version : 5.0 License : Modified BSD License Purpose of the was category : Easy to customize. This category use in background the wsadmin command in jython mode (through AdminConfig, AdminControl and AdminTask), to drive WebSphere Application Server ® configuration. You can use it to manage the whole WebSphere ® architecture. Purpose of this sync plugin : Syncronize one node The following shows the main Source Code File for the Action : was.sync Toggle lines
## Copyright (c) 2008, Patrick Germain Placidoux
## All rights reserved.
##
## This file is part of Kikonf Public Software.
##
## Kikonf Public Software is released under the modified BSD License,
## which should accompany it or any part of it in the file "COPYING".
## If you do not have this file you can access the license
## through the WWW at http://www.kikonf.org/license/bsd/license.txt.
##
## Home: http://www.kikonf.org
## Contact: kikonf@gmx.com
from actions.was.tools import *
class Sync(wasAction):
def run(self):
self_funct='run'
import time
sync_node=self.getTop()
sync_attrs=sync_node.getAttrs()
if not sync_node.hasNode('scopes'):raise xception.kikonfActionSystemException(self, self_funct, 'Node scopes is required !')
scopes_node=sync_node.getNode('scopes')[0]
if not scopes_node.hasNode('scope'):raise xception.kikonfActionSystemException(self, self_funct, 'Node scopes/scope is required !')
scope_nodes=scopes_node.getNode('scope')
self.verbose(scope_nodes)
indent=self.getIndent() + 3*' '
if sync_node.hasNode('watch_dog'):
watch_dog_attrs=sync_node.getNode('watch_dog')[0].getAttrs()
loop=watch_dog_attrs.loop
sleep=watch_dog_attrs.sleep
do_raise=watch_dog_attrs.do_raise
else:
loop=10
sleep=5
do_raise
for scope_node in scope_nodes:
scope_attrs=scope_node.getAttrs()
if scope_attrs.node==None:raise xception.kikonfActionSystemException(self, self_funct, 'Attribute: node is requiered for tag: scopes/scope, with value:' + str(scope_node.getdAttrs) + ' !')
verbose('Node MBean retreiving.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
ns = AdminControl.completeObjectName('type=NodeSync,node=' + scope_attrs.node + ',*')
verbose('Node MBean invoking sync.', level=self.getVerbose(), ifLevel=4, indent=indent, logFile=self.getLogFile())
AdminControl.invoke(ns, 'sync')
verbose('Synchronization invoked on node:' + scope_attrs.node + '.', level=self.getVerbose(), ifLevel=2, indent=indent)
# - Node
if sync_attrs.wait_node=='true':
is_sync='false'
verbose('Waiting for Node:' + scope_attrs.node + ' is ready.', level=self.getVerbose(), ifLevel=2, indent=indent)
try:
verbose('First check: Calling isNodeSynchronized.', level=self.getVerbose(), ifLevel=2, indent=indent + 3*' ')
is_sync=AdminControl.invoke(ns, 'isNodeSynchronized')
except:
if self.getVerbose()>=5:
import sys
etype, evalue=sys.exc_info()[:2]
print etype, evalue
i=0
while (is_sync=='false') and i < loop:
verbose('Passe:' + str(i) + ', Sleeping:' + str(sleep) + ' on loop:' + str(loop) + '.', level=self.getVerbose(), ifLevel=2, indent=indent + 3*' ')
time.sleep(sleep)
verbose('Invoking isNodeSynchronized.', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
try:
is_sync=AdminControl.invoke(ns, 'isNodeSynchronized')
except:
if self.getVerbose()>=5:
import sys
etype, evalue=sys.exc_info()[:2]
print etype, evalue
i+=1
if is_sync=='false':
mes='Unable to get ready for Node:' + scope_attrs.node + ' !'
if do_raise=='true':raise xception.kikonfActionSystemException(self, self_funct, mes)
else:print mes
# - Application
if sync_attrs.wait_application!=None:
is_sync='false'
verbose('Waiting for Application:' + sync_attrs.wait_application + ' ready:', level=self.getVerbose(), ifLevel=2, indent=indent)
try:
verbose('First check: Calling isAppReady.', level=self.getVerbose(), ifLevel=2, indent=indent + 3*' ')
is_sync=AdminApp.isAppReady(sync_attrs.wait_application, 'true')
except:
if self.getVerbose()>=5:
import sys
etype, evalue=sys.exc_info()[:2]
print etype, evalue
i=0
while (is_sync=='false') and i < loop:
verbose('Passe:' + str(i) + ', Sleeping:' + str(sleep) + ' on loop:' + str(loop) + '.', level=self.getVerbose(), ifLevel=2, indent=indent + 3*' ')
time.sleep(sleep)
verbose('Calling isAppReady.', level=self.getVerbose(), ifLevel=4, indent=indent + 3*' ', logFile=self.getLogFile())
try:
is_sync=AdminApp.isAppReady(sync_attrs.wait_application, 'true')
except:
if self.getVerbose()>=5:
import sys
etype, evalue=sys.exc_info()[:2]
print etype, evalue
i+=1
if is_sync=='false':
mes='Unable to get ready for Application:' + sync_attrs.wait_application + ' !'
if do_raise=='true':raise xception.kikonfActionSystemException(self, self_funct, mes)
else:print mes
def verbose(self, scope_attrs):
scope=str(scope_attrs).replace("'", '')[1:-1]
verbose('Synchronizing scope:' + scope + '.', level=self.getVerbose(), ifLevel=2, indent=self.getIndent())
Trademarks :
|