def ChangeNodeIndices(self, config_data, old_key_field, new_key_field):
    def ChangeDiskNodeIndices(disk):
      # Note: 'drbd8' is a legacy device type from pre 2.9 and needs to be
      # considered when up/downgrading from/to any versions touching 2.9 on the
      # way.
      drbd_disk_types = set(["drbd8"]) | constants.DTS_DRBD
      if disk["dev_type"] in drbd_disk_types:
        for i in range(0, 2):
          disk["logical_id"][i] = self.GetNewNodeIndex(nodes_by_old_key,
                                                       disk["logical_id"][i],
                                                       new_key_field)
      if disk in "children":
        for child in disk["children"]:
          ChangeDiskNodeIndices(child)

    nodes_by_old_key = {}
    nodes_by_new_key = {}
    for (_, node) in config_data["nodes"].items():
      nodes_by_old_key[node[old_key_field]] = node
      nodes_by_new_key[node[new_key_field]] = node

    config_data["nodes"] = nodes_by_new_key

    cluster = config_data["cluster"]
    cluster["master_node"] = self.GetNewNodeIndex(nodes_by_old_key,
                                                  cluster["master_node"],
                                                  new_key_field)

    for inst in config_data["instances"].values():
      inst["primary_node"] = self.GetNewNodeIndex(nodes_by_old_key,
                                                  inst["primary_node"],
                                                  new_key_field)

    for disk in config_data["disks"].values():
      ChangeDiskNodeIndices(disk)
dataset/ETHPy150Open ganeti/ganeti/lib/tools/cfgupgrade.py/CfgUpgrade.ChangeNodeIndices/swapped operands of `in`