def destroy(name, call=None):
    '''
    destroy a machine by name

    :param name: name given to the machine
    :param call: call value in this case is 'action'
    :return: array of booleans , true if successfully stopped and true if
             successfully removed

    CLI Example:

    .. code-block:: bash

        salt-cloud -d vm_name

    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The destroy action must be called with -d, --destroy, '
            '-a or --action.'
        )

    __utils__['cloud.fire_event'](
        'event',
        'destroying instance',
        'salt/cloud/{0}/destroying'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    datacenter_id = get_datacenter_id()
    conn = get_conn()
    node = get_node(conn, name)
    attached_volumes = None

    delete_volumes = config.get_cloud_config_value(
        'delete_volumes',
        get_configured_provider(),
        __opts__,
        search_global=False
    )
    # Get volumes before the server is deleted
    attached_volumes = conn.get_attached_volumes(
        datacenter_id=datacenter_id,
        server_id=node['id']
    )

    conn.delete_server(datacenter_id=datacenter_id, server_id=node['id'])

    # The server is deleted and now is safe to delete the volumes
    if delete_volumes:
        for vol in attached_volumes['items']:
            log.debug('Deleting volume %s', vol['id'])
            conn.delete_volume(
                datacenter_id=datacenter_id,
                volume_id=vol['id']
            )
            log.debug('Deleted volume %s', vol['id'])

    __utils__['cloud.fire_event'](
        'event',
        'destroyed instance',
        'salt/cloud/{0}/destroyed'.format(name),
        args={'name': name},
        sock_dir=__opts__['sock_dir'],
        transport=__opts__['transport']
    )

    if __opts__.get('update_cachedir', False) is True:
        __utils__['cloud.delete_minion_cachedir'](
            name,
            __active_provider_name__.split(':')[0],
            __opts__
        )

    return True
def destroy ( name , call = None ) : if call == 'function' : raise SaltCloudSystemExit ( 'The destroy action must be called with -d, --destroy, ' '-a or --action.' ) __utils__ [ 'cloud.fire_event' ] ( 'event' , 'destroying instance' , 'salt/cloud/{0}/destroying' . format ( name ) , args = { 'name' : name } , sock_dir = __opts__ [ 'sock_dir' ] , transport = __opts__ [ 'transport' ] ) datacenter_id = get_datacenter_id ( ) conn = get_conn ( ) node = get_node ( conn , name ) attached_volumes = None delete_volumes = config . get_cloud_config_value ( 'delete_volumes' , get_configured_provider ( ) , __opts__ , search_global = False ) attached_volumes = conn . get_attached_volumes ( datacenter_id = datacenter_id , server_id = node [ 'id' ] ) conn . delete_server ( datacenter_id = datacenter_id , server_id = node [ 'id' ] ) if delete_volumes : for vol in attached_volumes [ 'items' ] : log . debug ( 'Deleting volume %s' , vol [ 'id' ] ) conn . delete_volume ( datacenter_id = datacenter_id , volume_id = vol [ 'id' ] ) log . debug ( 'Deleted volume %s' , vol [ 'id' ] ) __utils__ [ 'cloud.fire_event' ] ( 'event' , 'destroyed instance' , 'salt/cloud/{0}/destroyed' . format ( name ) , args = { 'name' : name } , sock_dir = __opts__ [ 'sock_dir' ] , transport = __opts__ [ 'transport' ] ) if __opts__ . get ( 'update_cachedir' , False ) is True : __utils__ [ 'cloud.delete_minion_cachedir' ] ( name , __active_provider_name__ . split ( ':' ) [ 0 ] , __opts__ ) return True
destroy a machine by name

    :param name: name given to the machine
    :param call: call value in this case is 'action'
    :return: array of booleans , true if successfully stopped and true if
             successfully removed

    CLI Example:

    .. code-block:: bash

        salt-cloud -d vm_name