1 {-| Module describing an NIC.
3 The NIC data type only holds data about a NIC, but does not provide any
10 Copyright (C) 2009, 2010, 2011, 2012, 2013 Google Inc.
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful, but
18 WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
29 module Ganeti.HTools.Nic
36 import qualified Ganeti.HTools.Container as Container
38 import qualified Ganeti.HTools.Types as T
40 -- * Type declarations
42 data Mode = Bridged | Routed | OpenVSwitch deriving (Show, Eq)
46 -- It holds the data for a NIC as it is provided via the IAllocator protocol
47 -- for an instance creation request. All data in those request is optional,
48 -- that's why all fields are Maybe's.
50 -- TODO: Another name might be more appropriate for this type, as for example
51 -- RequestedNic. But this type is used as a field in the Instance type, which
52 -- is not named RequestedInstance, so such a name would be weird. PartialNic
53 -- already exists in Objects, but doesn't fit the bill here, as it contains
54 -- a required field (mac). Objects and the types therein are subject to being
55 -- reworked, so until then this type is left as is.
57 { mac :: Maybe String -- ^ MAC address of the NIC
58 , ip :: Maybe String -- ^ IP address of the NIC
59 , mode :: Maybe Mode -- ^ the mode the NIC operates in
60 , link :: Maybe String -- ^ the link of the NIC
61 , bridge :: Maybe String -- ^ the bridge this NIC is connected to if
62 -- the mode is Bridged
63 , network :: Maybe T.NetworkID -- ^ network UUID if this NIC is connected
67 -- | A simple name for an instance map.
68 type List = Container.Container Nic
74 create :: Maybe String
81 create mac_init ip_init mode_init link_init bridge_init network_init =
86 , bridge = bridge_init
87 , network = network_init