@@ -1,17 +1,23 @@
1{-# LANGUAGE Arrows #-}
1{-# LANGUAGE Arrows #-}
2module Network.Azure.ServiceManagement
2module Network.Azure.ServiceManagement
3 ( -- * Data types
3 ( -- * Data types
5− , CloudService(..)
4+ CloudService
6− , VirtualMachine(..)
7+ , VirtualMachine
7− , Endpoint(..)
11+ , Endpoint
8 -- * Pure functions
15 -- * Pure functions
9 , vmSshEndpoint
16 , vmSshEndpoint
10 -- * Setup
17 -- * Setup
11 , AzureSetup(..)
18 , AzureSetup(..)
12 , azureSetup
19 , azureSetup
13 -- * High-level API
20 -- * High-level API
15 , cloudServices
21 , cloudServices
@@ -62,11 +68,7 @@ import Text.XML.HXT.Core
62 , IOSArrow
68 , IOSArrow
63 , ArrowXml
69 , ArrowXml
65−-- , writeDocumentToString
69−-- import Control.Arrow.ArrowIO (arrIO)
70import Text.XML.HXT.XPath (getXPathTrees)
72import Text.XML.HXT.XPath (getXPathTrees)
72--------------------------------------------------------------------------------
74--------------------------------------------------------------------------------
@@ -77,20 +79,39 @@ data HostedService = HostedService {
77 hostedServiceName :: String
79 hostedServiceName :: String
82+-- | A cloud service is a bunch of virtual machines that are part of the same
83+-- network (i.e., can talk to each other directly using standard TCP
80data CloudService = CloudService {
85data CloudService = CloudService {
86+ -- | Name of the service.
81 cloudServiceName :: String
87 cloudServiceName :: String
88+ -- | Virtual machines that are part of this cloud service.
82 , cloudServiceVMs :: [VirtualMachine]
89 , cloudServiceVMs :: [VirtualMachine]
85data VirtualMachine = VirtualMachine {
93data VirtualMachine = VirtualMachine {
94+ -- | Name of the virtual machine.
86 vmName :: String
95 vmName :: String
96+ -- | The /internal/ IP address of the virtual machine (that is, the
97+ -- IP address on the Cloud Service). For the globally accessible IP
98+ -- address see 'vmInputEndpoints'.
87 , vmIpAddress :: String
99 , vmIpAddress :: String
100+ -- | Globally accessible endpoints to the virtual machine
88 , vmInputEndpoints :: [Endpoint]
101 , vmInputEndpoints :: [Endpoint]
104+-- | Globally accessible endpoint for a virtual machine
91data Endpoint = Endpoint {
105data Endpoint = Endpoint {
106+ -- | Name of the endpoint (typical example: @SSH@)
92 endpointName :: String
107 endpointName :: String
108+ -- | Port number (typical examples are 22 or high numbered ports such as 53749)
93 , endpointPort :: String
109 , endpointPort :: String
110+ -- | Virtual IP address (that is, globally accessible IP address).
112+ -- This corresponds to the IP address associated with the Cloud Service
113+ -- (i.e., that would be returned by a DNS lookup for @name.cloudapp.net@,
114+ -- where @name@ is the name of the Cloud Service).
94 , endpointVip :: String
115 , endpointVip :: String
@@ -148,6 +169,7 @@ hang2 d1 = hang d1 2
148-- Pure operations --
169-- Pure operations --
149--------------------------------------------------------------------------------
170--------------------------------------------------------------------------------
172+-- | Find the endpoint with name @SSH@.
151vmSshEndpoint :: VirtualMachine -> Maybe Endpoint
173vmSshEndpoint :: VirtualMachine -> Maybe Endpoint
152vmSshEndpoint vm = listToMaybe
174vmSshEndpoint vm = listToMaybe
@@ -160,11 +182,21 @@ vmSshEndpoint vm = listToMaybe
160--------------------------------------------------------------------------------
182--------------------------------------------------------------------------------
162-- | Azure setup
184-- | Azure setup
186+-- The documentation of "distributed-process-azure" explains in detail how
187+-- to obtain the SSL client certificate and the private key for your Azure
190+-- See also 'azureSetup'.
163data AzureSetup = AzureSetup
191data AzureSetup = AzureSetup
192+ { -- | Azure subscription ID
164− { subscriptionId :: String
193+ subscriptionId :: String
194+ -- | SSL client certificate
165− , certificate :: X509
195+ , certificate :: X509
196+ -- | RSA private key
166− , privateKey :: PrivateKey
197+ , privateKey :: PrivateKey
198+ -- | Base URL (generally <https://management.core.windows.net>)
167− , baseUrl :: String
199+ , baseUrl :: String
170-- TODO: it's dubious to be transferring private keys, but we transfer them
202-- TODO: it's dubious to be transferring private keys, but we transfer them
@@ -221,7 +253,7 @@ azureSetup sid certPath pkeyPath = do
221-- High-level API --
253-- High-level API --
222--------------------------------------------------------------------------------
254--------------------------------------------------------------------------------
224−-- | Get a list of virtual machines
256+-- | Find available cloud services
225cloudServices :: AzureSetup -> IO [CloudService]
257cloudServices :: AzureSetup -> IO [CloudService]
226cloudServices setup = azureExecute setup $ \exec -> do
258cloudServices setup = azureExecute setup $ \exec -> do
227 services <- exec hostedServicesRequest
259 services <- exec hostedServicesRequest
@@ -240,10 +272,6 @@ cloudServices setup = azureExecute setup $ \exec -> do
241 return $ CloudService (hostedServiceName service) roles
273 return $ CloudService (hostedServiceName service) roles
243−-- | Get list of available hosted services
244−hostedServices :: AzureSetup -> IO [HostedService]
245−hostedServices setup = azureExecute setup (\exec -> exec hostedServicesRequest)
247hostedServicesRequest :: AzureRequest HostedService
275hostedServicesRequest :: AzureRequest HostedService
248hostedServicesRequest = AzureRequest
276hostedServicesRequest = AzureRequest
249 { relativeUrl = "/services/hostedservices"
277 { relativeUrl = "/services/hostedservices"