diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-18 21:10:44 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-18 21:10:44 -0400 |
| commit | c8a3653775892bd361091885c63113b6ca36ed5a (patch) | |
| tree | 672624a10fc528b9e04ac2ab73db14ccad22e899 /Propellor/Attr.hs | |
| parent | 8e22065deff41c3e476763ebd939a63856e6d54b (diff) | |
genZone is working! complete DNS zone file generation from propellor config
Diffstat (limited to 'Propellor/Attr.hs')
| -rw-r--r-- | Propellor/Attr.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Propellor/Attr.hs b/Propellor/Attr.hs index f3e2e2e5..37ed1bad 100644 --- a/Propellor/Attr.hs +++ b/Propellor/Attr.hs @@ -74,11 +74,19 @@ hostProperties (Host ps _) = ps hostMap :: [Host] -> M.Map HostName Host hostMap l = M.fromList $ zip (map (_hostname . hostAttr) l) l +hostAttrMap :: [Host] -> M.Map HostName Attr +hostAttrMap l = M.fromList $ zip (map _hostname attrs) attrs + where + attrs = map hostAttr l + findHost :: [Host] -> HostName -> Maybe Host findHost l hn = M.lookup hn (hostMap l) -getAddresses :: HostName -> [Host] -> [IPAddr] -getAddresses hn hosts = case hostAttr <$> findHost hosts hn of +getAddresses :: Attr -> [IPAddr] +getAddresses = mapMaybe getIPAddr . S.toList . _dns + +hostAddresses :: HostName -> [Host] -> [IPAddr] +hostAddresses hn hosts = case hostAttr <$> findHost hosts hn of Nothing -> [] Just attr -> mapMaybe getIPAddr $ S.toList $ _dns attr |
