###
# Licensed Materials - Property of IBM* and/or HCL**
# (c) Copyright IBM Corporation 2017. All Rights Reserved.
# (c) Copyright HCL Technologies Ltd. 2018. All Rights Reserved.
#
# U.S. Government Users Restricted Rights - Use, duplication or disclosure restricted by
# GSA ADP Schedule Contract with IBM Corp.
#
# * Trademark of International Business Machines
# ** Trademark of HCL Technologies Limited
#
# Filename: disableAutoAppStart.jython
#
###

import sys

appName          = sys.argv[0]
deployments      = AdminConfig.getid("/Deployment:"+str(appName)+"/")

if not deployments:
    raise "There is no application with the given name. Please check 'Application Name' in the plugin step"

deploymentObject = AdminConfig.showAttribute(deployments, 'deployedObject')
targetMap        = AdminConfig.showAttribute(deploymentObject, 'targetMappings')
targetMappings   = targetMap[1:len(targetMap)-1].split(" ")

for targetMapping in targetMappings:
    AdminConfig.modify(targetMapping, [["enable", "false"]])

AdminConfig.save()
success = AdminNodeManagement.syncActiveNodes()

if(success == 1):
    sys.stdout.write("Active Nodes Synchronization successful")
else:
    raise "Problem occurred in node synchronization. Please try from wsadmin console"