If your PureApplication System is protected by an uninterruptible power supply (UPS), you likely want to automate a graceful and orderly system shutdown in case of a power loss. To do this, you might create a Linux or AIX virtual machine nearby or even within your PureApplication System, have it monitor for SNMP traps indicating the UPS has detected a power loss, and then trigger an orderly shutdown of both the deployed application instances in your system, as well as triggering the shutdown of the system itself.
Here is a simple PureApplication command-line script that will stop all application instances on a system. If you are running this within the system itself, you should remember to exclude your own deployment from the list of deployments being stopped, and stop it last. This script stops all deployments without regard to dependencies between deployments. You may need to modify it so that dependent deployments are stopped in a particular order.
Finally, this script uses a different method than calling stop() on virtual system and virtual application objects. The built-in stop() method waits for each instance to complete stopping before moving to the next. Instead, this script initiates the stop of all instances in parallel, and then waits for all instances to complete stopping.
# Collect all deployments listOfVsysClassic = deployer.virtualsystems.list() listOfVsysRegular = deployer.virtualsysteminstances.list() listOfVApps = deployer.virtualapplicationinstances.list() # Initiate stops for all deployments for vsys in listOfVsysClassic : print "Stopping vsys classic: %s" % vsys.name vsys.stop() # vsys classic method does not wait for vsys in listOfVsysRegular : print "Stopping vsys: %s" % vsys.deployment_name deployer.http.putJSON(vsys.uri, {"operation": "stop"}) for vapp in listOfVApps : # This includes shared services print "Stopping vapp: %s" % vapp.deployment_name deployer.http.putJSON(vapp.uri, {"operation": "stop"}) # Wait for all deployments to reach a non-transient state print "Waiting for all instances to stop" for vsys in listOfVsysClassic : vsys.refresh() vsys.waitFor() for vsys in listOfVsysRegular : vsys.refresh() vsys.waitFor() for vapp in listOfVApps : vapp.refresh() vapp.waitFor()