import Network.Curl.Code
import Data.Either ()
import Data.Maybe
+import Data.List
import Control.Monad
import Text.JSON (JSObject, JSValue)
import Text.Printf (printf)
_ -> fail $ printf "Curl error for '%s', error %s"
url (show code))
+-- | Append the default port if not passed in
+formatHost :: String -> String
+formatHost master =
+ if elem ':' master then master
+ else "https://" ++ master ++ ":5080"
+
getInstances :: String -> IO (Result String)
getInstances master = do
- let url2 = printf "https://%s:5080/2/instances?bulk=1" master
+ let url2 = printf "%s/2/instances?bulk=1" (formatHost master)
body <- getUrl url2
return $ (body >>= \x -> do
arr <- loadJSArray x
getNodes :: String -> IO (Result String)
getNodes master = do
- let url2 = printf "https://%s:5080/2/nodes?bulk=1" master
+ let url2 = printf "%s/2/nodes?bulk=1" (formatHost master)
body <- getUrl url2
return $ (body >>= \x -> do
arr <- loadJSArray x
.BI "-m" cluster
Collect data not from files but directly from the
.I cluster
-given as an argument via RAPI. This work for both Ganeti 1.2 and
-Ganeti 2.0.
+given as an argument via RAPI. If the argument doesn't contain a colon
+(:), then it is converted into a fully-built URL via prepending
+https:// and appending the default RAPI port, otherwise it's
+considered a fully-specified URL and is used unchanged.
.TP
.BI "-l" N ", --max-length=" N
.BI "-m" cluster
Collect data not from files but directly from the
.I cluster
-given as an argument via RAPI. This work for both Ganeti 1.2 and
-Ganeti 2.0.
+given as an argument via RAPI. If the argument doesn't contain a colon
+(:), then it is converted into a fully-built URL via prepending
+https:// and appending the default RAPI port, otherwise it's
+considered a fully-specified URL and is used unchanged.
.TP
.BI "-d" DEPTH ", --depth=" DEPTH