Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (2.6 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.Objects
35
import Ganeti.Query.Language
36
import Ganeti.Query.Common
37
import Ganeti.Query.Types
38

    
39
data NetworkRuntime = NetworkRuntime
40

    
41
networkFields :: FieldList Network NetworkRuntime
42
networkFields =
43
  [ (FieldDefinition "name" "Name" QFTText "Network name",
44
     FieldSimple (rsNormal . networkName), QffNormal)
45
  , (FieldDefinition "network" "Subnet" QFTText "IPv4 subnet",
46
     FieldSimple (rsNormal . networkNetwork), QffNormal)
47
  , (FieldDefinition "gateway" "Gateway" QFTOther "IPv4 gateway",
48
     FieldSimple (rsMaybeUnavail . networkGateway), QffNormal)
49
  , (FieldDefinition "network6" "IPv6Subnet" QFTOther "IPv6 subnet",
50
     FieldSimple (rsMaybeUnavail . networkNetwork6), QffNormal)
51
  , (FieldDefinition "gateway6" "IPv6Gateway" QFTOther "IPv6 gateway",
52
     FieldSimple (rsMaybeUnavail . networkGateway6), QffNormal)
53
  , (FieldDefinition "mac_prefix" "MacPrefix" QFTOther "MAC address prefix",
54
     FieldSimple (rsMaybeUnavail . networkMacPrefix), QffNormal)
55
  , (FieldDefinition "network_type" "NetworkType" QFTOther "Network type",
56
     FieldSimple (rsMaybeUnavail . networkNetworkType), QffNormal)
57
  , (FieldDefinition "group_list" "GroupList" QFTOther "List of node groups",
58
     FieldConfig (\cfg -> rsNormal . getGroupConnections cfg . networkUuid),
59
       QffNormal)
60
  ] ++
61
  uuidFields "Network" ++
62
  serialFields "Network" ++
63
  tagsFields
64

    
65
-- | The group fields map.
66
networkFieldsMap :: FieldMap Network NetworkRuntime
67
networkFieldsMap =
68
  Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) networkFields
69

    
70
-- TODO: the following fields are not implemented yet: external_reservations,
71
-- free_count, group_cnt, inst_cnt, inst_list, map, reserved_count, serial_no,
72
-- tags, uuid