Created
August 12, 2015 16:12
-
-
Save moali87/0ab76f6badb312495186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Akhter Ali' | |
__date__ = '08/12/15' | |
__version__ = '0.1.0' | |
try: | |
import salt.cloud | |
CLOUDIMPORTED = True | |
print('salt.cloud successfully imported') | |
except ImportError: | |
CLOUDIMPORTED = False | |
print('Error: salt.cloud was not imported') | |
def __virtual__(): | |
''' | |
Only for machines running more than 5 minutes | |
''' | |
# return 'checkhighstate' if __grains__['uptime_minutes'] > 7 else False | |
if CLOUDIMPORTED: | |
return 'checkhighstate_test' | |
return False | |
# Return may need to return a text rather than a boolean | |
def destroy(): | |
''' | |
Destroy minion if __virtual__ is True | |
CLI Example:: | |
.. code-block:: bash | |
salt '*' checkhighstate_test.destroy | |
''' | |
client = salt.cloud.CloudClient('/etc/salt/cloud') | |
minion_name = __grains__['id'] | |
client.destroy(names=[minion_name]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akhterpod01.dev.aws.resonatedigital.net: | |
The minion function caused an exception: Traceback (most recent call last): | |
File "/usr/lib/python2.7/dist-packages/salt/minion.py", line 1020, in _thread_return | |
return_data = func(*args, **kwargs) | |
File "/var/cache/salt/minion/extmods/modules/checkhighstate_test.py", line 37, in destroy | |
client.destroy(names=[minion_name]) | |
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 361, in destroy | |
mapper.destroy(names) | |
File "/usr/lib/python2.7/dist-packages/salt/cloud/__init__.py", line 1064, in destroy | |
', '.join(names) | |
SaltCloudSystemExit: The following VM's were not found: akhterpod01.dev.aws.resonatedigital.net |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment