diff --git a/Ganeti/HTools/Node.hs b/Ganeti/HTools/Node.hs index cdb375db7efb18c21c4a05f571b9fe0162c9cc73..ece5e7b7ce39309c1b81d24f8a58c53c324e2715 100644 --- a/Ganeti/HTools/Node.hs +++ b/Ganeti/HTools/Node.hs @@ -6,7 +6,7 @@ {- -Copyright (C) 2009 Google Inc. +Copyright (C) 2009, 2010 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -119,7 +119,7 @@ data Node = Node , utilPool :: T.DynUtil -- ^ Total utilisation capacity , utilLoad :: T.DynUtil -- ^ Sum of instance utilisation , pTags :: TagMap -- ^ Map of primary instance tags and their count - } deriving (Show) + } deriving (Show, Eq) instance T.Element Node where nameOf = name diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs index 28410d409745a56ea0d351178b270a15e2c50292..1f2a460c36b3dd4e97dbd06e50be549c89dc01b4 100644 --- a/Ganeti/HTools/QC.hs +++ b/Ganeti/HTools/QC.hs @@ -456,11 +456,19 @@ prop_Text_Load_Node name tm nm fm td fd tc fo = prop_Text_Load_NodeFail fields = length fields /= 8 ==> isNothing $ Text.loadNode fields +prop_Text_NodeLSIdempotent node = + (Text.loadNode . + Utils.sepSplit '|' . Text.serializeNode) n == + Just (Node.name n, n) + -- override failN1 to what loadNode returns by default + where n = node { Node.failN1 = True, Node.offline = False } + testText = [ run prop_Text_Load_Instance , run prop_Text_Load_InstanceFail , run prop_Text_Load_Node , run prop_Text_Load_NodeFail + , run prop_Text_NodeLSIdempotent ] -- Node tests diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs index fcccbd8f2437618814de36c2e1449abc39f717f8..55d8f42e1d9986823dea4e5af7dd2914c95f7e5e 100644 --- a/Ganeti/HTools/Text.hs +++ b/Ganeti/HTools/Text.hs @@ -32,6 +32,7 @@ module Ganeti.HTools.Text , loadInst , loadNode , serializeInstances + , serializeNode , serializeNodes ) where diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs index dbdac0594dab4560007305a5947ab7cf52553db9..7cab64113fb4365bc855480f80353fb7c4d34fae 100644 --- a/Ganeti/HTools/Types.hs +++ b/Ganeti/HTools/Types.hs @@ -4,7 +4,7 @@ {- -Copyright (C) 2009 Google Inc. +Copyright (C) 2009, 2010 Google Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -83,7 +83,7 @@ data DynUtil = DynUtil , memWeight :: Weight -- ^ Standardised memory load , dskWeight :: Weight -- ^ Standardised disk I\/O usage , netWeight :: Weight -- ^ Standardised network usage - } deriving (Show) + } deriving (Show, Eq) -- | Initial empty utilisation zeroUtil :: DynUtil