# Variables Pre-populated by Build process and available for use:
# adminUser
# adminPassword
# adminUrl
# domainName
# clusterName
SessionMBean = ""

try:
    connect(adminUser,adminPassword,adminUrl)

    domainRuntime()
    sessionName = String("SessionScript"+Long(System.currentTimeMillis()).toString())
    SessionMBean = findService("SessionManagement", "com.bea.wli.sb.management.configuration.SessionManagementMBean")
    SessionMBean.createSession(sessionName)

    edit()
    startEdit()

###########################################################################
### This code generated by WLST Record functionality, then manually updated
### to abstract out any hard-coded Domain and Cluster information


### End of auto-generated/modified Code
###########################################################################

    activate()

except weblogic.descriptor.BeanAlreadyExistsException:
    print '===> Object already exists. No action was performed.'
    cancelEdit('y')
    exit()

except:
    print "Unexpected error: ", sys.exc_info()[0]
    if SessionMBean != None:
        SessionMBean.discardSession(sessionName)

    cancelEdit('y')
    dumpStack()
    raise
