Skip to content

Instantly share code, notes, and snippets.

@moali87
Created July 21, 2015 17:42
Show Gist options
  • Save moali87/ad4ee89726b4bc9a5171 to your computer and use it in GitHub Desktop.
Save moali87/ad4ee89726b4bc9a5171 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
'''
This function gathers the grains uptime_minutes and assigns it to uptime_grain, if uptime_grain is more than 7 minutes,
it will destroy the instance given by instance name provided by grains ID.
'''
import salt.config
import salt.cloud.CloudClient as client
import salt.loader
def __virtual__():
return False if __grains__['uptime_minutes'] < 7 else True
def TestUptime():
'''
Destroy minion if __virtual__ is True
'''
client.destroy(names=[minion_name])
return minion_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment