@@ -55,16 +55,26 @@ main :: IO ()
56 args <- getArgs
56 args <- getArgs
57 case args of
57 case args of
59+ -- Pass execution to 'onVmMain' if we are running on the VM
58− "onvm":args' -> onVmMain __remoteTable args'
60+ onVmMain __remoteTable args'
59 "list":sid:x509:pkey:_ -> do
62 "list":sid:x509:pkey:_ -> do
63+ -- List all available cloud services
64+ -- (useful, but not strictly necessary for the example)
60 params <- defaultAzureParameters sid x509 pkey
65 params <- defaultAzureParameters sid x509 pkey
61 css <- cloudServices (azureSetup params)
66 css <- cloudServices (azureSetup params)
62 mapM_ print css
67 mapM_ print css
63 cmd:sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
69 cmd:sid:x509:pkey:user:cloudService:virtualMachine:port:_ -> do
70+ -- Initialize the backend and find the right VM
64 params <- defaultAzureParameters sid x509 pkey
71 params <- defaultAzureParameters sid x509 pkey
65 let params' = params { azureSshUserName = user }
72 let params' = params { azureSshUserName = user }
66 backend <- initializeBackend params' cloudService
73 backend <- initializeBackend params' cloudService
67 Just vm <- findNamedVM backend virtualMachine
74 Just vm <- findNamedVM backend virtualMachine
76+ -- The same binary can behave as the client or the server,
77+ -- depending on the command line arguments
68 case cmd of
78 case cmd of
69 "server" -> spawnOnVM backend vm port ($(mkClosure 'pingServer) ())
79 "server" -> spawnOnVM backend vm port ($(mkClosure 'pingServer) ())
70 "client" -> callOnVM backend vm port $
80 "client" -> callOnVM backend vm port $