getNodeInstances :: ConfigData -> String -> ([Instance], [Instance])
getNodeInstances cfg nname =
    let all_insts = M.elems . fromContainer . configInstances $ cfg
        all_disks = fromContainer . configDisks $ cfg

        pri_inst = filter ((== Just nname) . instPrimaryNode) all_insts

        find_disk :: String -> Maybe Disk
        find_disk d_uuid = M.lookup (UTF8.fromString d_uuid) all_disks

        inst_disks :: [(Instance, [Disk])]
        inst_disks = [(i, mapMaybe find_disk $ instDisks i) | i <- all_insts]

        sec_insts :: [Instance]
        sec_insts = [inst |
          (inst, disks) <- inst_disks,
          s_uuid <- mapMaybe (\d -> (instPrimaryNode inst) >>= (computeDiskSecondaryNode d)) disks,
          s_uuid == nname]
    in (pri_inst, sec_insts)
getNodeInstances :: ConfigData -> String -> ([Instance], [Instance])
getNodeInstances cfg nname =
    let all_insts = M.elems . fromContainer . configInstances $ cfg
        all_disks = fromContainer . configDisks $ cfg

        pri_inst = filter ((== Just nname) . instPrimaryNode) all_insts

        find_disk :: String -> Maybe Disk
        find_disk d_uuid = M.lookup (UTF8.fromString d_uuid) all_disks

        inst_disks :: [(Instance, [Disk])]
        inst_disks = [(i, mapMaybe find_disk $ instDisks i) | i <- all_insts]

        sec_insts :: [Instance]
        sec_insts = [inst |
          (inst, disks) <- inst_disks,
          s_uuid <- mapMaybe (\d -> (instPrimaryNode inst) >>= (computeDiskSecondaryNode d)) disks,
          s_uuid == nname]
    in (pri_inst, sec_insts)
getNodeInstances cfg nname =
    let all_insts = M.elems . fromContainer . configInstances $ cfg
        all_disks = fromContainer . configDisks $ cfg

        pri_inst = filter ((== Just nname) . instPrimaryNode) all_insts

        find_disk :: String -> Maybe Disk
        find_disk d_uuid = M.lookup (UTF8.fromString d_uuid) all_disks

        inst_disks :: [(Instance, [Disk])]
        inst_disks = [(i, mapMaybe find_disk $ instDisks i) | i <- all_insts]

        sec_insts :: [Instance]
        sec_insts = [inst |
          (inst, disks) <- inst_disks,
          s_uuid <- mapMaybe (\d -> (instPrimaryNode inst) >>= (computeDiskSecondaryNode d)) disks,
          s_uuid == nname]
    in (pri_inst, sec_insts)