Revision b5c3a4f2 src/Ganeti/Rpc.hs

b/src/Ganeti/Rpc.hs
158 158
  , requestOpts :: [CurlOption] -- ^ The various curl options
159 159
  }
160 160

  
161
-- | Check if a string represented address is IPv6
162
isIpV6 :: String -> Bool
163
isIpV6 ip = elem ':' ip
164

  
161 165
-- | Prepare url for the HTTP request.
162 166
prepareUrl :: (RpcCall a) => Node -> a -> String
163 167
prepareUrl node call =
164 168
  let node_ip = nodePrimaryIp node
169
      node_address = if isIpV6 node_ip
170
                     then "[" ++ node_ip ++ "]"
171
                     else node_ip
165 172
      port = snd C.daemonsPortsGanetiNoded
166
      path_prefix = "https://" ++ node_ip ++ ":" ++ show port
173
      path_prefix = "https://" ++ node_address ++ ":" ++ show port
167 174
  in path_prefix ++ "/" ++ rpcCallName call
168 175

  
169 176
-- | Create HTTP request for a given node provided it is online,

Also available in: Unified diff