Stopping all instances on your PureApplication System

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.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 :
for vsys in listOfVsysRegular :
for vapp in listOfVApps :

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s