From: Iustin Pop <ius...@google.com> Do this in cases where this should already be the case: - some functions are explicitly denoted to take UUIDs (documentation/parameter name) - some functions (e.g. clusterMasterNode, disk IDs, instance primary node) we know return an UUID
But still, this might be a behaviour change, although unlikely. Signed-off-by: Iustin Pop <ius...@google.com> --- src/Ganeti/Confd/Server.hs | 4 ++-- src/Ganeti/Config.hs | 7 ++++--- src/Ganeti/Query/Cluster.hs | 2 +- src/Ganeti/Query/Instance.hs | 4 ++-- src/Ganeti/WConfd/Ssconf.hs | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Ganeti/Confd/Server.hs b/src/Ganeti/Confd/Server.hs index 3356600..25b1cf5 100644 --- a/src/Ganeti/Confd/Server.hs +++ b/src/Ganeti/Confd/Server.hs @@ -132,7 +132,7 @@ getNodePipByInstanceIp cfg linkipmap link instip = -- | Returns a node name for a given UUID uuidToNodeName :: ConfigData -> String -> Result String -uuidToNodeName cfg uuid = gntErrorToResult $ nodeName <$> getNode cfg uuid +uuidToNodeName cfg uuid = gntErrorToResult $ nodeName <$> getNodeByUuid cfg uuid -- | Encodes a list of minors into a JSON representation, converting UUIDs to -- names in the process @@ -154,7 +154,7 @@ buildResponse cdata req@(ConfdRequest { confdRqType = ReqClusterMaster }) = EmptyQuery -> liftM ((ReplyStatusOk,,serial) . J.showJSON) master_name PlainQuery _ -> return queryArgumentError DictQuery reqq -> do - mnode <- gntErrorToResult $ getNode cfg master_uuid + mnode <- gntErrorToResult $ getNodeByUuid cfg master_uuid mname <- master_name let fvals = map (\field -> case field of ReqFieldName -> mname diff --git a/src/Ganeti/Config.hs b/src/Ganeti/Config.hs index cacb682..ca192b6 100644 --- a/src/Ganeti/Config.hs +++ b/src/Ganeti/Config.hs @@ -51,6 +51,7 @@ module Ganeti.Config , getMasterNetworkParameters , getOnlineNodes , getNode + , getNodeByUuid , getInstance , getDisk , getFilterRule @@ -452,15 +453,15 @@ getInstPrimaryNode :: ConfigData -> String -> ErrorResult Node getInstPrimaryNode cfg name = getInstanceByExactName cfg name >>= withMissingParam "Instance without primary node" return . instPrimaryNode - >>= getNode cfg + >>= getNodeByUuid cfg -- | Retrieves all nodes hosting a DRBD disk getDrbdDiskNodes :: ConfigData -> Disk -> [Node] getDrbdDiskNodes cfg disk = let retrieved = case diskLogicalId disk of Just (LIDDrbd8 nodeA nodeB _ _ _ _) -> - justOk [getNode cfg nodeA, getNode cfg nodeB] - _ -> [] + justOk [getNodeByUuid cfg nodeA, getNodeByUuid cfg nodeB] + _ -> [] in retrieved ++ concatMap (getDrbdDiskNodes cfg) (diskChildren disk) -- | Retrieves all the nodes of the instance. diff --git a/src/Ganeti/Query/Cluster.hs b/src/Ganeti/Query/Cluster.hs index a1d4255..33690cf 100644 --- a/src/Ganeti/Query/Cluster.hs +++ b/src/Ganeti/Query/Cluster.hs @@ -54,7 +54,7 @@ clusterMasterNodeName :: ConfigData -> ErrorResult String clusterMasterNodeName cfg = let cluster = configCluster cfg masterNodeUuid = clusterMasterNode cluster - in liftM nodeName $ getNode cfg masterNodeUuid + in liftM nodeName $ getNodeByUuid cfg masterNodeUuid isWatcherPaused :: IO (Maybe Integer) isWatcherPaused = do diff --git a/src/Ganeti/Query/Instance.hs b/src/Ganeti/Query/Instance.hs index 27db5b0..9384c01 100644 --- a/src/Ganeti/Query/Instance.hs +++ b/src/Ganeti/Query/Instance.hs @@ -728,7 +728,7 @@ isPrimaryOffline :: ConfigData -> Instance -> Bool isPrimaryOffline cfg inst = let pNodeResult = maybe (Bad $ ParameterError "no primary node") return (instPrimaryNode inst) - >>= getNode cfg + >>= getNodeByUuid cfg in case pNodeResult of Ok pNode -> nodeOffline pNode Bad _ -> error "Programmer error - result assumed to be OK is Bad!" @@ -946,7 +946,7 @@ collectLiveData liveDataEnabled cfg fields instances nub . justOk $ map ( maybe (Bad $ ParameterError "no primary node") return . instPrimaryNode - >=> getNode cfg) instances + >=> getNodeByUuid cfg) instances goodNodes = nodesWithValidConfig cfg instanceNodes instInfoRes <- executeRpcCall goodNodes (RpcCallAllInstancesInfo hvSpecs) consInfoRes <- diff --git a/src/Ganeti/WConfd/Ssconf.hs b/src/Ganeti/WConfd/Ssconf.hs index 941733d..740fbda 100644 --- a/src/Ganeti/WConfd/Ssconf.hs +++ b/src/Ganeti/WConfd/Ssconf.hs @@ -101,7 +101,7 @@ mkSSConf cdata = SSConf . M.fromList $ , (SSMasterNetmask, return . show $ clusterMasterNetmask cluster) , (SSMasterNode, return . genericResult (const "NO MASTER") nodeName - . getNode cdata $ clusterMasterNode cluster) + . getNodeByUuid cdata $ clusterMasterNode cluster) , (SSNodeList, mapLines nodeName nodes) , (SSNodePrimaryIps, mapLines (spcPair . (nodeName &&& nodePrimaryIp)) nodes ) -- 2.8.1