Skip to content

Instantly share code, notes, and snippets.

@qrtt1
Created July 14, 2012 15:53
Show Gist options
  • Save qrtt1/3111884 to your computer and use it in GitHub Desktop.
Save qrtt1/3111884 to your computer and use it in GitHub Desktop.
wlst sample
def wait_to_done(progress, wait_time=120, mesg=""):
import time
for i in range(wait_time):
if mesg != "":
print "%s" % mesg, progress.getState()
if "failed" == progress.getState():
return 0
if i > 7:
# a work around for stuck wlst script
edit()
activate(200 * 1000, block='true')
time.sleep(1)
if progress.isCompleted():
progress.printStatus()
return 1
progress.printStatus()
return 0
def login():
connect('weblogic', 'weblogic_password', 'localhost:7001')
def _start(app):
try:
po = startApplication(app, block='false')
wait_to_done(po, mesg="start %s" % app)
except WLSTException:
pass
def _stop(app):
try:
po = stopApplication(app, block='false')
wait_to_done(po, mesg="stop %s" % app)
except WLSTException:
pass
def _undeploy(app):
try:
po = undeploy(app, block='false')
wait_to_done(po, mesg="undeploy %s" % app)
except WLSTException:
pass
def _deploy(app):
try:
app_path = '/root/webapps/%s' % app
po = deploy(app, app_path, stageMode='nostage', block='false')
print po
wait_to_done(po, mesg="deploy %s" % app)
except WLSTException:
pass
# :: BEGIN ::
app = "YourWebContext"
app_path = '/root/webapps/%s' % app
login()
_stop(app)
_undeploy(app)
_deploy(app)
_start(app)
# :: END ::
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment