@@ -2,17 +2,17 @@
2module Network.Azure.ServiceManagement
2module Network.Azure.ServiceManagement
3 ( -- * Data types
3 ( -- * Data types
4 HostedService(..)
4 HostedService(..)
5− , Role(..)
5+ , CloudService(..)
7 , VirtualMachine(..)
6 , VirtualMachine(..)
8 -- * Pure functions
8 -- * Pure functions
9− , vmSshEndpoints
9+ , cloudServiceSshEndpoints
10 -- * Setup
10 -- * Setup
11 , AzureSetup(..)
11 , AzureSetup(..)
12 , azureSetup
12 , azureSetup
13 -- * High-level API
13 -- * High-level API
14 , hostedServices
14 , hostedServices
15− , virtualMachines
15+ , cloudServices
18import Prelude hiding (id, (.))
18import Prelude hiding (id, (.))
@@ -56,13 +56,17 @@ import Text.XML.HXT.XPath (getXPathTrees)
56data HostedService = HostedService {
56data HostedService = HostedService {
57 hostedServiceName :: String
57 hostedServiceName :: String
60−instance Show HostedService where
61+data CloudService = CloudService {
61− show = hostedServiceName
62+ cloudServiceName :: String
63+ , cloudServiceVMs :: [VirtualMachine]
63−data Role = Role {
67+data VirtualMachine = VirtualMachine {
64− roleName :: String
68+ vmName :: String
65− , roleInputEndpoints :: [Endpoint]
69+ , vmInputEndpoints :: [Endpoint]
67 deriving Show
71 deriving Show
@@ -73,20 +77,14 @@ data Endpoint = Endpoint {
74 deriving Show
78 deriving Show
76−data VirtualMachine = VirtualMachine {
77− vmService :: HostedService
82--------------------------------------------------------------------------------
80--------------------------------------------------------------------------------
83-- Pure operations --
81-- Pure operations --
84--------------------------------------------------------------------------------
82--------------------------------------------------------------------------------
86−vmSshEndpoints :: VirtualMachine -> [Endpoint]
84+cloudServiceSshEndpoints :: CloudService -> [Endpoint]
87−vmSshEndpoints vm =
85+cloudServiceSshEndpoints cs =
89− | ep <- concatMap roleInputEndpoints (vmRoles vm)
87+ | ep <- concatMap vmInputEndpoints (cloudServiceVMs cs)
90 , endpointName ep == "SSH"
88 , endpointName ep == "SSH"
@@ -122,8 +120,8 @@ azureSetup sid certPath pkeyPath = do
122--------------------------------------------------------------------------------
120--------------------------------------------------------------------------------
124-- | Get a list of virtual machines
122-- | Get a list of virtual machines
125−virtualMachines :: AzureSetup -> IO [VirtualMachine]
123+cloudServices :: AzureSetup -> IO [CloudService]
126−virtualMachines setup = azureExecute setup $ \exec -> do
124+cloudServices setup = azureExecute setup $ \exec -> do
127 services <- exec hostedServicesRequest
125 services <- exec hostedServicesRequest
128 forM services $ \service -> do
126 forM services $ \service -> do
129 roles <- exec AzureRequest {
127 roles <- exec AzureRequest {
@@ -134,9 +132,9 @@ virtualMachines setup = azureExecute setup $ \exec -> do
134 role <- getXPathTrees "//Role[@type='PersistentVMRole']" -< xml
132 role <- getXPathTrees "//Role[@type='PersistentVMRole']" -< xml
135 name <- getText . getXPathTrees "/Role/RoleName/text()" -< role
133 name <- getText . getXPathTrees "/Role/RoleName/text()" -< role
136 endpoints <- listA (parseEndpoint . getXPathTrees "//InputEndpoint") -< role
134 endpoints <- listA (parseEndpoint . getXPathTrees "//InputEndpoint") -< role
137− id -< Role name endpoints
135+ id -< VirtualMachine name endpoints
139− return $ VirtualMachine service roles
137+ return $ CloudService (hostedServiceName service) roles
141-- | Get list of available hosted services
139-- | Get list of available hosted services
142hostedServices :: AzureSetup -> IO [HostedService]
140hostedServices :: AzureSetup -> IO [HostedService]