Revision f361a6ee
b/src/Ganeti/ConstantUtils.hs | ||
---|---|---|
38 | 38 |
-- |
39 | 39 |
-- See 'PyValue' instance for 'FrozenSet'. |
40 | 40 |
newtype FrozenSet a = FrozenSet { unFrozenSet :: Set a } |
41 |
deriving (Show) |
|
41 |
deriving (Eq, Show)
|
|
42 | 42 |
|
43 | 43 |
-- | Converts a Haskell 'Set' into a Python 'frozenset' |
44 | 44 |
-- |
b/src/Ganeti/HsConstants.hs | ||
---|---|---|
102 | 102 |
|
103 | 103 |
sshConsoleUser :: String |
104 | 104 |
sshConsoleUser = AutoConf.sshConsoleUser |
105 |
|
|
106 |
-- * SSH constants |
|
107 |
|
|
108 |
ssh :: String |
|
109 |
ssh = "ssh" |
|
110 |
|
|
111 |
scp :: String |
|
112 |
scp = "scp" |
|
113 |
|
|
114 |
-- * Daemons |
|
115 |
|
|
116 |
confd :: String |
|
117 |
confd = "ganeti-confd" |
|
118 |
|
|
119 |
masterd :: String |
|
120 |
masterd = "ganeti-masterd" |
|
121 |
|
|
122 |
mond :: String |
|
123 |
mond = "ganeti-mond" |
|
124 |
|
|
125 |
noded :: String |
|
126 |
noded = "ganeti-noded" |
|
127 |
|
|
128 |
luxid :: String |
|
129 |
luxid = "ganeti-luxid" |
|
130 |
|
|
131 |
rapi :: String |
|
132 |
rapi = "ganeti-rapi" |
|
133 |
|
|
134 |
daemons :: FrozenSet String |
|
135 |
daemons = |
|
136 |
mkSet [confd, |
|
137 |
luxid, |
|
138 |
masterd, |
|
139 |
mond, |
|
140 |
noded, |
|
141 |
rapi] |
|
142 |
|
|
143 |
-- * Possible values for NodeGroup.alloc_policy |
|
144 |
|
|
145 |
allocPolicyLastResort :: String |
|
146 |
allocPolicyLastResort = "last_resort" |
|
147 |
|
|
148 |
allocPolicyPreferred :: String |
|
149 |
allocPolicyPreferred = "preferred" |
|
150 |
|
|
151 |
allocPolicyUnallocable :: String |
|
152 |
allocPolicyUnallocable = "unallocable" |
|
153 |
|
|
154 |
validAllocPolicies :: [String] |
|
155 |
validAllocPolicies = |
|
156 |
[allocPolicyLastResort, |
|
157 |
allocPolicyPreferred, |
|
158 |
allocPolicyUnallocable] |
|
159 |
|
|
160 |
-- | Temporary external/shared storage parameters |
|
161 |
blockdevDriverManual :: String |
|
162 |
blockdevDriverManual = "manual" |
|
163 |
|
|
164 |
-- * Auto-repair tag prefixes |
|
165 |
|
|
166 |
autoRepairTagPrefix :: String |
|
167 |
autoRepairTagPrefix = "ganeti:watcher:autorepair:" |
|
168 |
|
|
169 |
autoRepairTagEnabled :: String |
|
170 |
autoRepairTagEnabled = autoRepairTagPrefix |
|
171 |
|
|
172 |
autoRepairTagPending :: String |
|
173 |
autoRepairTagPending = autoRepairTagPrefix ++ "pending:" |
|
174 |
|
|
175 |
autoRepairTagResult :: String |
|
176 |
autoRepairTagResult = autoRepairTagPrefix ++ "result:" |
|
177 |
|
|
178 |
autoRepairTagSuspended :: String |
|
179 |
autoRepairTagSuspended = autoRepairTagPrefix ++ "suspend:" |
|
180 |
|
|
181 |
-- * Auto-repair levels |
|
182 |
|
|
183 |
autoRepairFailover :: String |
|
184 |
autoRepairFailover = "failover" |
|
185 |
|
|
186 |
autoRepairFixStorage :: String |
|
187 |
autoRepairFixStorage = "fix-storage" |
|
188 |
|
|
189 |
autoRepairMigrate :: String |
|
190 |
autoRepairMigrate = "migrate" |
|
191 |
|
|
192 |
autoRepairReinstall :: String |
|
193 |
autoRepairReinstall = "reinstall" |
|
194 |
|
|
195 |
autoRepairAllTypes :: FrozenSet String |
|
196 |
autoRepairAllTypes = |
|
197 |
mkSet [autoRepairFailover, |
|
198 |
autoRepairFixStorage, |
|
199 |
autoRepairMigrate, |
|
200 |
autoRepairReinstall] |
|
201 |
|
|
202 |
-- * Auto-repair results |
|
203 |
|
|
204 |
autoRepairEnoperm :: String |
|
205 |
autoRepairEnoperm = "enoperm" |
|
206 |
|
|
207 |
autoRepairFailure :: String |
|
208 |
autoRepairFailure = "failure" |
|
209 |
|
|
210 |
autoRepairSuccess :: String |
|
211 |
autoRepairSuccess = "success" |
|
212 |
|
|
213 |
autoRepairAllResults :: FrozenSet String |
|
214 |
autoRepairAllResults = |
|
215 |
mkSet [autoRepairEnoperm, autoRepairFailure, autoRepairSuccess] |
|
216 |
|
|
217 |
-- | The version identifier for builtin data collectors |
|
218 |
builtinDataCollectorVersion :: String |
|
219 |
builtinDataCollectorVersion = "B" |
b/test/hs/Test/Ganeti/HTools/Types.hs | ||
---|---|---|
41 | 41 |
import Test.HUnit |
42 | 42 |
|
43 | 43 |
import Control.Applicative |
44 |
import Data.List (sort) |
|
45 | 44 |
import Control.Monad (replicateM) |
46 | 45 |
|
47 | 46 |
import Test.Ganeti.TestHelper |
... | ... | |
51 | 50 |
|
52 | 51 |
import Ganeti.BasicTypes |
53 | 52 |
import qualified Ganeti.Constants as C |
53 |
import Ganeti.ConstantUtils |
|
54 | 54 |
import qualified Ganeti.HTools.Types as Types |
55 | 55 |
|
56 | 56 |
{-# ANN module "HLint: ignore Use camelCase" #-} |
... | ... | |
185 | 185 |
, Types.ArFailover |
186 | 186 |
, Types.ArReinstall |
187 | 187 |
] |
188 |
all_hs_raw = map Types.autoRepairTypeToRaw [minBound..maxBound] |
|
188 |
all_hs_raw = mkSet $ map Types.autoRepairTypeToRaw [minBound..maxBound]
|
|
189 | 189 |
assertEqual "Haskell order" expected [minBound..maxBound] |
190 | 190 |
assertEqual "consistent with Python" C.autoRepairAllTypes all_hs_raw |
191 | 191 |
|
192 | 192 |
-- | Test 'AutoRepairResult' type is equivalent with Python codebase. |
193 | 193 |
case_AutoRepairResult_pyequiv :: Assertion |
194 | 194 |
case_AutoRepairResult_pyequiv = do |
195 |
let all_py_results = sort C.autoRepairAllResults
|
|
196 |
all_hs_results = sort $
|
|
195 |
let all_py_results = C.autoRepairAllResults |
|
196 |
all_hs_results = mkSet $
|
|
197 | 197 |
map Types.autoRepairResultToRaw [minBound..maxBound] |
198 | 198 |
assertEqual "for AutoRepairResult equivalence" all_py_results all_hs_results |
199 | 199 |
|
Also available in: Unified diff