@@ -2,17 +2,17 @@
22module Network.Azure.ServiceManagement
33 ( -- * Data types
44 HostedService(..)
5− , Role(..)
6− , Endpoint(..)
5+ , CloudService(..)
76 , VirtualMachine(..)
7+ , Endpoint(..)
88 -- * Pure functions
9− , vmSshEndpoints
9+ , cloudServiceSshEndpoints
1010 -- * Setup
1111 , AzureSetup(..)
1212 , azureSetup
1313 -- * High-level API
1414 , hostedServices
15− , virtualMachines
15+ , cloudServices
1616 ) where
1717
1818import Prelude hiding (id, (.))
@@ -56,13 +56,17 @@ import Text.XML.HXT.XPath (getXPathTrees)
5656data HostedService = HostedService {
5757 hostedServiceName :: String
5858 }
59+ deriving Show
5960
60−instance Show HostedService where
61− show = hostedServiceName
61+data CloudService = CloudService {
62+ cloudServiceName :: String
63+ , cloudServiceVMs :: [VirtualMachine]
64+ }
65+ deriving Show
6266
63−data Role = Role {
64− roleName :: String
65− , roleInputEndpoints :: [Endpoint]
67+data VirtualMachine = VirtualMachine {
68+ vmName :: String
69+ , vmInputEndpoints :: [Endpoint]
6670 }
6771 deriving Show
6872
@@ -73,20 +77,14 @@ data Endpoint = Endpoint {
7377 }
7478 deriving Show
7579
76−data VirtualMachine = VirtualMachine {
77− vmService :: HostedService
78− , vmRoles :: [Role]
79− }
80− deriving Show
81−
8280--------------------------------------------------------------------------------
8381-- Pure operations --
8482--------------------------------------------------------------------------------
8583
86−vmSshEndpoints :: VirtualMachine -> [Endpoint]
87−vmSshEndpoints vm =
84+cloudServiceSshEndpoints :: CloudService -> [Endpoint]
85+cloudServiceSshEndpoints cs =
8886 [ ep
89− | ep <- concatMap roleInputEndpoints (vmRoles vm)
87+ | ep <- concatMap vmInputEndpoints (cloudServiceVMs cs)
9088 , endpointName ep == "SSH"
9189 ]
9290
@@ -122,8 +120,8 @@ azureSetup sid certPath pkeyPath = do
122120--------------------------------------------------------------------------------
123121
124122-- | Get a list of virtual machines
125−virtualMachines :: AzureSetup -> IO [VirtualMachine]
126−virtualMachines setup = azureExecute setup $ \exec -> do
123+cloudServices :: AzureSetup -> IO [CloudService]
124+cloudServices setup = azureExecute setup $ \exec -> do
127125 services <- exec hostedServicesRequest
128126 forM services $ \service -> do
129127 roles <- exec AzureRequest {
@@ -134,9 +132,9 @@ virtualMachines setup = azureExecute setup $ \exec -> do
134132 role <- getXPathTrees "//Role[@type='PersistentVMRole']" -< xml
135133 name <- getText . getXPathTrees "/Role/RoleName/text()" -< role
136134 endpoints <- listA (parseEndpoint . getXPathTrees "//InputEndpoint") -< role
137− id -< Role name endpoints
135+ id -< VirtualMachine name endpoints
138136 }
139− return $ VirtualMachine service roles
137+ return $ CloudService (hostedServiceName service) roles
140138
141139-- | Get list of available hosted services
142140hostedServices :: AzureSetup -> IO [HostedService]