@@ -1,3 +1,58 @@
1−module Control.Distributed.Process.Backend.Azure where
1+module Control.Distributed.Process.Backend.Azure
5+ , defaultAzureParameters
7+ -- * Re-exports from Azure Service Management
11+import System.Environment (getEnv)
12+import System.FilePath ((</>))
3import Network.Azure.ServiceManagement
13import Network.Azure.ServiceManagement
20+data Backend = Backend {
21+ findVMs :: IO [VirtualMachine]
24+data AzureParameters = AzureParameters {
25+ azureSubscriptionId :: String
26+ , azureAuthCertificate :: FilePath
27+ , azureAuthPrivateKey :: FilePath
28+ , azureSshPublicKey :: FilePath
29+ , azureSshPrivateKey :: FilePath
30+ , azureSshKnownHosts :: FilePath
33+-- | Create default azure parameters
34+defaultAzureParameters :: String -- ^ Azure subscription ID
35+ -> FilePath -- ^ Path to X509 certificate
36+ -> FilePath -- ^ Path to private key
37+ -> IO AzureParameters
38+defaultAzureParameters sid x509 pkey = do
39+ home <- getEnv "HOME"
40+ return AzureParameters
41+ { azureSubscriptionId = sid
42+ , azureAuthCertificate = x509
43+ , azureAuthPrivateKey = pkey
44+ , azureSshPublicKey = home </> ".ssh" </> "id_rsa.pub"
45+ , azureSshPrivateKey = home </> ".ssh" </> "id_rsa"
46+ , azureSshKnownHosts = home </> ".ssh" </> "known_hosts"
49+-- | Initialize the backend
50+initializeBackend :: AzureParameters -> IO Backend
51+initializeBackend params = do
52+ setup <- azureSetup (azureSubscriptionId params)
53+ (azureAuthCertificate params)
54+ (azureAuthPrivateKey params)
56+ findVMs = virtualMachines setup