code: def device_info(device):
      
  
      status = subprocess.check_output([
          'ibstat', device, '-s']).splitlines()
  
      regexes = {
          "CA type: (.*)": "device_type",
          "Number of ports: (.*)": "num_ports",
          "Firmware version: (.*)": "fw_ver",
          "Hardware version: (.*)": "hw_ver",
          "Node GUID: (.*)": "node_guid",
          "System image GUID: (.*)": "sys_guid",
      }
  
      device = DeviceInfo()
  
      for line in status:
          for expression, key in regexes.items():
              matches = re.search(expression, line)
              if matches:
                  setattr(device, key, matches.group(1))
  
      return device
docs: Returns a DeviceInfo object with the current device settings