code: def is_valid_device_id(device_id):
      
      valid = valid_device_id.match(device_id)
      if not valid:
          logging.error("A valid device identifier contains "
                        "only ascii word characters or dashes. "
                        "Device '%s' not added.", device_id)
      return valid
docs: Check if device identifier is valid.
  
      A valid device identifier contains only ascii word characters or dashes.
  
      :param device_id: Device identifier
      :returns: Valid or not.