def delete_device(name, safety_on=True):
 config = _get_vistara_configuration()
 if (not config):
  return False
 access_token = _get_oath2_access_token(config['client_key'], config['client_secret'])
 if (not access_token):
  return 'Vistara access token not available'
 query_string = 'dnsName:{0}'.format(name)
 devices = _search_devices(query_string, config['client_id'], access_token)
 if (not devices):
  return 'No devices found'
 device_count = len(devices)
 if (safety_on and (device_count != 1)):
  return 'Expected to delete 1 device and found {0}. Set safety_on=False to override.'.format(device_count)
 delete_responses = []
 for device in devices:
  device_id = device['id']
  log.debug(device_id)
  delete_response = _delete_resource(device_id, config['client_id'], access_token)
  if (not delete_response):
   return False
  delete_responses.append(delete_response)
 return delete_responses

def delete_device ( name , safety_on = True ) : config = _get_vistara_configuration ( ) if ( not config ) : return False access_token = _get_oath2_access_token ( config [ 'client_key' ] , config [ 'client_secret' ] ) if ( not access_token ) : return 'Vistara access token not available' query_string = 'dnsName:{0}' . format ( name ) devices = _search_devices ( query_string , config [ 'client_id' ] , access_token ) if ( not devices ) : return 'No devices found' device_count = len ( devices ) if ( safety_on and ( device_count != 1 ) ) : return 'Expected to delete 1 device and found {0}. Set safety_on=False to override.' . format ( device_count ) delete_responses = [ ] for device in devices : device_id = device [ 'id' ] log . debug ( device_id ) delete_response = _delete_resource ( device_id , config [ 'client_id' ] , access_token ) if ( not delete_response ) : return False delete_responses . append ( delete_response ) return delete_responses
deletes a device from vistara based on dns name or partial name .