Revision a86fbf36 htools/Ganeti/HTools/Cluster.hs

b/htools/Ganeti/HTools/Cluster.hs
916 916
                 -> Instance.List     -- ^ Instance list (cluster-wide)
917 917
                 -> EvacMode          -- ^ The evacuation mode
918 918
                 -> Instance.Instance -- ^ The instance to be evacuated
919
                 -> Gdx               -- ^ The group we're targetting
919 920
                 -> [Ndx]             -- ^ The list of available nodes
920 921
                                      -- for allocation
921 922
                 -> Result (Node.List, Instance.List, [OpCodes.OpCode])
922 923
nodeEvacInstance _ _ mode (Instance.Instance
923
                           {Instance.diskTemplate = dt@DTDiskless}) _ =
924
                           {Instance.diskTemplate = dt@DTDiskless}) _ _ =
924 925
                  failOnSecondaryChange mode dt >>
925 926
                  fail "Diskless relocations not implemented yet"
926 927

  
927 928
nodeEvacInstance _ _ _ (Instance.Instance
928
                        {Instance.diskTemplate = DTPlain}) _ =
929
                        {Instance.diskTemplate = DTPlain}) _ _ =
929 930
                  fail "Instances of type plain cannot be relocated"
930 931

  
931 932
nodeEvacInstance _ _ _ (Instance.Instance
932
                        {Instance.diskTemplate = DTFile}) _ =
933
                        {Instance.diskTemplate = DTFile}) _ _ =
933 934
                  fail "Instances of type file cannot be relocated"
934 935

  
935 936
nodeEvacInstance _ _ mode  (Instance.Instance
936
                            {Instance.diskTemplate = dt@DTSharedFile}) _ =
937
                            {Instance.diskTemplate = dt@DTSharedFile}) _ _ =
937 938
                  failOnSecondaryChange mode dt >>
938 939
                  fail "Shared file relocations not implemented yet"
939 940

  
940 941
nodeEvacInstance _ _ mode (Instance.Instance
941
                           {Instance.diskTemplate = dt@DTBlock}) _ =
942
                           {Instance.diskTemplate = dt@DTBlock}) _ _ =
942 943
                  failOnSecondaryChange mode dt >>
943 944
                  fail "Block device relocations not implemented yet"
944 945

  
945 946
nodeEvacInstance nl il ChangePrimary
946
                 inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8}) _ =
947
                 inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8})
948
                 _ _ =
947 949
  do
948 950
    (nl', inst', _, _) <- opToResult $ applyMove nl inst Failover
949 951
    let idx = Instance.idx inst
......
953 955

  
954 956
nodeEvacInstance nl il ChangeSecondary
955 957
                 inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8})
956
                 avail_nodes =
958
                 gdx avail_nodes =
957 959
  do
958
    let gdx = instancePriGroup nl inst
959 960
    (nl', inst', _, ndx) <- annotateResult "Can't find any good node" $
960 961
                            eitherToResult $
961 962
                            foldl' (evacDrbdSecondaryInner nl inst gdx)
......
967 968

  
968 969
nodeEvacInstance nl il ChangeAll
969 970
                 inst@(Instance.Instance {Instance.diskTemplate = DTDrbd8})
970
                 avail_nodes =
971
                 gdx avail_nodes =
971 972
  do
972 973
    let primary = Container.find (Instance.pNode inst) nl
973 974
        idx = Instance.idx inst
974
        gdx = instancePriGroup nl inst
975 975
        no_nodes = Left "no nodes available"
976 976
    -- if the primary is offline, then we first failover
977 977
    (nl1, inst1, ops1) <-
......
1092 1092
                      splitCluster ini_nl ini_il
1093 1093
        (fin_nl, fin_il, esol) =
1094 1094
            foldl' (\state@(nl, il, _) inst ->
1095
                        let gdx = instancePriGroup nl inst in
1095 1096
                        updateEvacSolution state (Instance.idx inst) $
1096 1097
                        availableGroupNodes group_ndx
1097
                          excl_ndx (instancePriGroup nl inst) >>=
1098
                        nodeEvacInstance nl il mode inst
1098
                          excl_ndx gdx >>=
1099
                        nodeEvacInstance nl il mode inst gdx
1099 1100
                   )
1100 1101
            (ini_nl, ini_il, emptyEvacSolution)
1101 1102
            (map (`Container.find` ini_il) idxs)
......
1147 1148
                                             (Just target_gdxs) inst ncnt
1148 1149
                              av_nodes <- availableGroupNodes group_ndx
1149 1150
                                          excl_ndx gdx
1150
                              nodeEvacInstance nl il ChangeAll inst av_nodes
1151
                              nodeEvacInstance nl il ChangeAll inst
1152
                                       gdx av_nodes
1151 1153
                        in updateEvacSolution state
1152 1154
                               (Instance.idx inst) solution
1153 1155
                   )

Also available in: Unified diff