code: def parse_inventory(inventory_output=None):
      udi = {
          "name": "",
          "description": "",
          "pid": "",
          "vid": "",
          "sn": ""
      }
      if inventory_output is None:
          return udi
      capture_next = False
      chassis_udi_text = None
      for line in inventory_output.split('\n'):
          lc_line = line.lower()
          if ('chassis' in lc_line or 'switch system' in lc_line or 'rack' in lc_line) and 'name' in lc_line and 'descr':
              capture_next = True
              chassis_udi_text = line
              continue
          if capture_next:
              inventory_output = chassis_udi_text + "\n" + line
              break
      match = re.search(r"(?i)NAME: (?P<name>.*?),? (?i)DESCR", inventory_output, re.MULTILINE)
      if match:
          udi['name'] = match.group('name').strip('" ,')
      match = re.search(r"(?i)DESCR: (?P<description>.*)", inventory_output, re.MULTILINE)
      if match:
          udi['description'] = match.group('description').strip('" ')
      match = re.search(r"(?i)PID: (?P<pid>.*?),? ", inventory_output, re.MULTILINE)
      if match:
          udi['pid'] = match.group('pid')
      match = re.search(r"(?i)VID: (?P<vid>.*?),? ", inventory_output, re.MULTILINE)
      if match:
          udi['vid'] = match.group('vid')
      match = re.search(r"(?i)SN: (?P<sn>.*)", inventory_output, re.MULTILINE)
      if match:
          udi['sn'] = match.group('sn').strip()
      return udi