Commit b5c3a4f2 authored by Guido Trotter's avatar Guido Trotter
Browse files

Ganeti.Rpc: use brackets for ipv6 addresses



We detect an IPv6 vs V4 address based on columns, rather than passing
the family from the cluster object to be more future proof (in case
we'll ever support mixed clusters).

Unfortunately quite a bit more code is required to test this: we need an
arbitrary node that does the right thing w.r.t. ip addresses and also
test-only exports. As such we'll do this out of the stable branch.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichele Tartara <mtartara@google.com>
parent 5378e8f1
......@@ -158,12 +158,19 @@ data HttpClientRequest = HttpClientRequest
, requestOpts :: [CurlOption] -- ^ The various curl options
}
-- | Check if a string represented address is IPv6
isIpV6 :: String -> Bool
isIpV6 ip = elem ':' ip
-- | Prepare url for the HTTP request.
prepareUrl :: (RpcCall a) => Node -> a -> String
prepareUrl node call =
let node_ip = nodePrimaryIp node
node_address = if isIpV6 node_ip
then "[" ++ node_ip ++ "]"
else node_ip
port = snd C.daemonsPortsGanetiNoded
path_prefix = "https://" ++ node_ip ++ ":" ++ show port
path_prefix = "https://" ++ node_address ++ ":" ++ show port
in path_prefix ++ "/" ++ rpcCallName call
-- | Create HTTP request for a given node provided it is online,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment