def destroy(name): ''' Wrap core libcloudfuncs destroy method, adding check for termination protection ''' ret = {} newname = name if config.get_cloud_config_value('rename_on_destroy', get_configured_provider(), __opts__, search_global=False) is True: newname = '{0}-DEL{1}'.format(name, uuid.uuid4().hex) rename(name, kwargs={'newname': newname}, call='action') log.info( 'Machine will be identified as {0} until it has been ' 'cleaned up by AWS.'.format( newname ) ) ret['newname'] = newname try: result = libcloudfuncs_destroy(newname, get_conn()) ret.update({'Destroyed': result}) except Exception as exc: if not exc.message.startswith('OperationNotPermitted'): log.exception(exc) raise exc log.info( 'Failed: termination protection is enabled on {0}'.format( name ) ) return ret
def destroy(name): ''' Wrap core libcloudfuncs destroy method, adding check for termination protection ''' ret = {} newname = name if config.get_cloud_config_value('rename_on_destroy', get_configured_provider(), __opts__, search_global=False) is True: newname = '{0}-DEL{1}'.format(name, uuid.uuid4().hex) rename(name, kwargs={'newname': newname}, call='action') log.info('Machine will be identified as {0} until it has been ' 'cleaned up by AWS.'.format(newname)) ret['newname'] = newname try: result = libcloudfuncs_destroy(newname, get_conn()) ret.update({'Destroyed': result}) except Exception as exc: if not str(exc).startswith('OperationNotPermitted'): log.exception(exc) raise exc log.info( 'Failed: termination protection is enabled on {0}'.format(name)) if __opts__.get('update_cachedir', False) is True: salt.utils.cloud.delete_minion_cachedir( name, __active_provider_name__.split(':')[0], __opts__) return ret