Statistics
| Branch: | Tag: | Revision:

root / src / Ganeti / Query / Network.hs @ ae960018

History | View | Annotate | Download (3.2 kB)

1
{-| Implementation of the Ganeti Query2 node group queries.
2

    
3
 -}
4

    
5
{-
6

    
7
Copyright (C) 2012 Google Inc.
8

    
9
This program is free software; you can redistribute it and/or modify
10
it under the terms of the GNU General Public License as published by
11
the Free Software Foundation; either version 2 of the License, or
12
(at your option) any later version.
13

    
14
This program is distributed in the hope that it will be useful, but
15
WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
General Public License for more details.
18

    
19
You should have received a copy of the GNU General Public License
20
along with this program; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
02110-1301, USA.
23

    
24
-}
25

    
26
module Ganeti.Query.Network
27
  ( NetworkRuntime(..)
28
  , networkFieldsMap
29
  ) where
30

    
31
import qualified Data.Map as Map
32

    
33
import Ganeti.Config
34
import Ganeti.Network
35
import Ganeti.Objects
36
import Ganeti.Query.Language
37
import Ganeti.Query.Common
38
import Ganeti.Query.Types
39

    
40
data NetworkRuntime = NetworkRuntime
41

    
42
networkFields :: FieldList Network NetworkRuntime
43
networkFields =
44
  [ (FieldDefinition "name" "Name" QFTText "Network name",
45
     FieldSimple (rsNormal . networkName), QffNormal)
46
  , (FieldDefinition "network" "Subnet" QFTText "IPv4 subnet",
47
     FieldSimple (rsNormal . networkNetwork), QffNormal)
48
  , (FieldDefinition "gateway" "Gateway" QFTOther "IPv4 gateway",
49
     FieldSimple (rsMaybeUnavail . networkGateway), QffNormal)
50
  , (FieldDefinition "network6" "IPv6Subnet" QFTOther "IPv6 subnet",
51
     FieldSimple (rsMaybeUnavail . networkNetwork6), QffNormal)
52
  , (FieldDefinition "gateway6" "IPv6Gateway" QFTOther "IPv6 gateway",
53
     FieldSimple (rsMaybeUnavail . networkGateway6), QffNormal)
54
  , (FieldDefinition "mac_prefix" "MacPrefix" QFTOther "MAC address prefix",
55
     FieldSimple (rsMaybeUnavail . networkMacPrefix), QffNormal)
56
  , (FieldDefinition "network_type" "NetworkType" QFTOther "Network type",
57
     FieldSimple (rsMaybeUnavail . networkNetworkType), QffNormal)
58
  , (FieldDefinition "free_count" "FreeCount" QFTOther "Number of free IPs",
59
     FieldSimple (rsMaybeNoData . fmap getFreeCount . createAddressPool),
60
     QffNormal)
61
  , (FieldDefinition "map" "Map" QFTText "Map of the network's reserved IPs",
62
     FieldSimple (rsMaybeNoData . fmap getMap . createAddressPool),
63
     QffNormal)
64
  , (FieldDefinition "reserved_count" "ReservedCount" QFTOther
65
       "Number of reserved IPs",
66
     FieldSimple (rsMaybeNoData . fmap getReservedCount . createAddressPool),
67
     QffNormal)
68
  , (FieldDefinition "group_list" "GroupList" QFTOther "List of node groups",
69
     FieldConfig (\cfg -> rsNormal . getGroupConnections cfg . networkUuid),
70
     QffNormal)
71
  , (FieldDefinition "group_cnt" "GroupCount" QFTOther "Number of node groups",
72
     FieldConfig (\cfg -> rsNormal . length . getGroupConnections cfg
73
       . networkUuid), QffNormal)
74
  ] ++
75
  uuidFields "Network" ++
76
  serialFields "Network" ++
77
  tagsFields
78

    
79
-- | The group fields map.
80
networkFieldsMap :: FieldMap Network NetworkRuntime
81
networkFieldsMap =
82
  Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) networkFields
83

    
84
-- TODO: the following fields are not implemented yet: external_reservations,
85
-- inst_cnt, inst_list