Skip to content

Instantly share code, notes, and snippets.

@antoviaque
Last active July 1, 2016 12:24
Show Gist options
  • Save antoviaque/cac3a5fc7593134b777a1126fa32c976 to your computer and use it in GitHub Desktop.
Save antoviaque/cac3a5fc7593134b777a1126fa32c976 to your computer and use it in GitHub Desktop.
Terminate old VMs of an instance, keep the last one
def terminate_old_instance_vms(domain):
inst = OpenEdXInstance.objects.get(internal_lms_domain=domain)
for appserver in inst.appserver_set.all().order_by('-created')[1:]:
appserver.terminate_vm()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment