Revision 5cfa6c37

b/doc/hooks.rst
224 224

  
225 225
:directory: network-add
226 226
:env. vars: NETWORK_NAME, NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
227
            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
227
            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
228 228
:pre-execution: master node
229 229
:post-execution: master node
230 230

  
......
247 247
:env. vars: GROUP_NAME, NETWORK_NAME,
248 248
            GROUP_NETWORK_MODE, GROUP_NETWORK_LINK,
249 249
            NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
250
            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
250
            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
251 251
:pre-execution: nodegroup nodes
252 252
:post-execution: nodegroup nodes
253 253

  
......
261 261
:env. vars: GROUP_NAME, NETWORK_NAME,
262 262
            GROUP_NETWORK_MODE, GROUP_NETWORK_LINK,
263 263
            NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
264
            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
264
            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
265 265
:pre-execution: nodegroup nodes
266 266
:post-execution: nodegroup nodes
267 267

  
......
273 273

  
274 274
:directory: network-modify
275 275
:env. vars: NETWORK_NAME, NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
276
            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
276
            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
277 277
:pre-execution: master node
278 278
:post-execution: master node
279 279

  
......
290 290
INSTANCE_NICn_NETWORK_UUID, INSTANCE_NICn_NETWORK_SUBNET,
291 291
INSTANCE_NICn_NETWORK_GATEWAY, INSTANCE_NICn_NETWORK_SUBNET6,
292 292
INSTANCE_NICn_NETWORK_GATEWAY6, INSTANCE_NICn_NETWORK_MAC_PREFIX,
293
INSTANCE_NICn_NETWORK_TYPE, INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE,
294
INSTANCE_DISKn_MODE.
293
INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE, INSTANCE_DISKn_MODE.
295 294

  
296 295
The INSTANCE_NICn_* and INSTANCE_DISKn_* variables represent the
297 296
properties of the *n* -th NIC and disk, and are zero-indexed.
b/doc/rapi.rst
698 698
        'name': 'nat',
699 699
        'network': '10.0.0.0/28',
700 700
        'network6': None,
701
        'network_type': 'private',
702 701
        'reserved_count': 3,
703 702
        'tags': ['nfdhcpd'],
704 703
b/lib/cli.py
117 117
  "NET_OPT",
118 118
  "NETWORK_OPT",
119 119
  "NETWORK6_OPT",
120
  "NETWORK_TYPE_OPT",
121 120
  "NEW_CLUSTER_CERT_OPT",
122 121
  "NEW_CLUSTER_DOMAIN_SECRET_OPT",
123 122
  "NEW_CONFD_HMAC_KEY_OPT",
......
1527 1526
                                     help="Comma-delimited list of"
1528 1527
                                     " reserved IPs to remove")
1529 1528

  
1530
NETWORK_TYPE_OPT = cli_option("--network-type",
1531
                              action="store", default=None, dest="network_type",
1532
                              help="Network type: private, public, None")
1533

  
1534 1529
NETWORK6_OPT = cli_option("--network6",
1535 1530
                          action="store", default=None, dest="network6",
1536 1531
                          help="IP network in CIDR notation")
b/lib/client/gnt_network.py
36 36

  
37 37
#: default list of fields for L{ListNetworks}
38 38
_LIST_DEF_FIELDS = ["name", "network", "gateway",
39
                    "network_type", "mac_prefix", "group_list", "tags"]
39
                    "mac_prefix", "group_list", "tags"]
40 40

  
41 41

  
42 42
def _HandleReservedIPs(ips):
......
77 77
                            gateway6=opts.gateway6,
78 78
                            network6=opts.network6,
79 79
                            mac_prefix=opts.mac_prefix,
80
                            network_type=opts.network_type,
81 80
                            add_reserved_ips=reserved_ips,
82 81
                            conflicts_check=opts.conflicts_check,
83 82
                            tags=tags)
......
202 201
  cl = GetClient()
203 202
  result = cl.QueryNetworks(fields=["name", "network", "gateway",
204 203
                                    "network6", "gateway6",
205
                                    "mac_prefix", "network_type",
204
                                    "mac_prefix",
206 205
                                    "free_count", "reserved_count",
207 206
                                    "map", "group_list", "inst_list",
208 207
                                    "external_reservations",
......
210 209
                            names=args, use_locking=False)
211 210

  
212 211
  for (name, network, gateway, network6, gateway6,
213
       mac_prefix, network_type, free_count, reserved_count,
212
       mac_prefix, free_count, reserved_count,
214 213
       mapping, group_list, instances, ext_res, serial, uuid) in result:
215 214
    size = free_count + reserved_count
216 215
    ToStdout("Network name: %s", name)
......
221 220
    ToStdout("  IPv6 Subnet: %s", network6)
222 221
    ToStdout("  IPv6 Gateway: %s", gateway6)
223 222
    ToStdout("  Mac Prefix: %s", mac_prefix)
224
    ToStdout("  Type: %s", network_type)
225 223
    ToStdout("  Size: %d", size)
226 224
    ToStdout("  Free: %d (%.2f%%)", free_count,
227 225
             100 * float(free_count) / float(size))
......
277 275
    "add_reserved_ips": _HandleReservedIPs(opts.add_reserved_ips),
278 276
    "remove_reserved_ips": _HandleReservedIPs(opts.remove_reserved_ips),
279 277
    "mac_prefix": opts.mac_prefix,
280
    "network_type": opts.network_type,
281 278
    "gateway6": opts.gateway6,
282 279
    "network6": opts.network6,
283 280
  }
......
312 309
  "add": (
313 310
    AddNetwork, ARGS_ONE_NETWORK,
314 311
    [DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_OPT,
315
     MAC_PREFIX_OPT, NETWORK_TYPE_OPT, NETWORK6_OPT, GATEWAY6_OPT,
312
     MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT,
316 313
     NOCONFLICTSCHECK_OPT, TAG_ADD_OPT, PRIORITY_OPT, SUBMIT_OPT],
317 314
    "<network_name>", "Add a new IP network to the cluster"),
318 315
  "list": (
......
331 328
  "modify": (
332 329
    SetNetworkParams, ARGS_ONE_NETWORK,
333 330
    [DRY_RUN_OPT, SUBMIT_OPT, ADD_RESERVED_IPS_OPT, REMOVE_RESERVED_IPS_OPT,
334
     GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK_TYPE_OPT, NETWORK6_OPT, GATEWAY6_OPT,
331
     GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT,
335 332
     PRIORITY_OPT],
336 333
    "<network_name>", "Alters the parameters of a network"),
337 334
  "connect": (
b/lib/cmdlib.py
1399 1399

  
1400 1400

  
1401 1401
def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6,
1402
                         network_type, mac_prefix, tags):
1402
                         mac_prefix, tags):
1403 1403
  """Builds network related env variables for hooks
1404 1404

  
1405 1405
  This builds the hook environment from individual variables.
......
1414 1414
  @param network6: the ipv6 subnet
1415 1415
  @type gateway6: string
1416 1416
  @param gateway6: the ipv6 gateway
1417
  @type network_type: string
1418
  @param network_type: the type of the network
1419 1417
  @type mac_prefix: string
1420 1418
  @param mac_prefix: the mac_prefix
1421 1419
  @type tags: list
......
1435 1433
    env["NETWORK_GATEWAY6"] = gateway6
1436 1434
  if mac_prefix:
1437 1435
    env["NETWORK_MAC_PREFIX"] = mac_prefix
1438
  if network_type:
1439
    env["NETWORK_TYPE"] = network_type
1440 1436
  if tags:
1441 1437
    env["NETWORK_TAGS"] = " ".join(tags)
1442 1438

  
......
16232 16228
      "network6": self.op.network6,
16233 16229
      "gateway6": self.op.gateway6,
16234 16230
      "mac_prefix": self.op.mac_prefix,
16235
      "network_type": self.op.network_type,
16236 16231
      "tags": self.op.tags,
16237 16232
      }
16238 16233
    return _BuildNetworkHookEnv(**args) # pylint: disable=W0142
......
16247 16242
                           network6=self.op.network6,
16248 16243
                           gateway6=self.op.gateway6,
16249 16244
                           mac_prefix=self.op.mac_prefix,
16250
                           network_type=self.op.network_type,
16251 16245
                           uuid=self.network_uuid,
16252 16246
                           family=constants.IP4_VERSION)
16253 16247
    # Initialize the associated address pool
......
16389 16383
    """
16390 16384
    self.network = self.cfg.GetNetwork(self.network_uuid)
16391 16385
    self.gateway = self.network.gateway
16392
    self.network_type = self.network.network_type
16393 16386
    self.mac_prefix = self.network.mac_prefix
16394 16387
    self.network6 = self.network.network6
16395 16388
    self.gateway6 = self.network.gateway6
......
16407 16400
                                     " reserved" % self.gateway,
16408 16401
                                     errors.ECODE_STATE)
16409 16402

  
16410
    if self.op.network_type:
16411
      if self.op.network_type == constants.VALUE_NONE:
16412
        self.network_type = None
16413
      else:
16414
        self.network_type = self.op.network_type
16415

  
16416 16403
    if self.op.mac_prefix:
16417 16404
      if self.op.mac_prefix == constants.VALUE_NONE:
16418 16405
        self.mac_prefix = None
......
16443 16430
      "network6": self.network6,
16444 16431
      "gateway6": self.gateway6,
16445 16432
      "mac_prefix": self.mac_prefix,
16446
      "network_type": self.network_type,
16447 16433
      "tags": self.tags,
16448 16434
      }
16449 16435
    return _BuildNetworkHookEnv(**args) # pylint: disable=W0142
......
16503 16489
    if self.op.gateway6:
16504 16490
      self.network.gateway6 = self.gateway6
16505 16491

  
16506
    if self.op.network_type:
16507
      self.network.network_type = self.network_type
16508

  
16509 16492
    self.pool.Validate()
16510 16493

  
16511 16494
    self.cfg.Update(self.network, feedback_fn)
b/lib/constants.py
1213 1213
RESERVE_ACTION = "reserve"
1214 1214
RELEASE_ACTION = "release"
1215 1215

  
1216
# An extra description of the network.
1217
# Can be used by hooks/kvm-vif-bridge to apply different rules
1218
NETWORK_TYPE_PRIVATE = "private"
1219
NETWORK_TYPE_PUBLIC = "public"
1220

  
1221
NETWORK_VALID_TYPES = compat.UniqueFrozenset([
1222
  NETWORK_TYPE_PRIVATE,
1223
  NETWORK_TYPE_PUBLIC,
1224
  ])
1225

  
1226 1216
NICS_PARAMETER_TYPES = {
1227 1217
  NIC_MODE: VTYPE_STRING,
1228 1218
  NIC_LINK: VTYPE_STRING,
b/lib/hypervisor/hv_kvm.py
149 149

  
150 150

  
151 151
def _BuildNetworkEnv(name, network, gateway, network6, gateway6,
152
                     network_type, mac_prefix, tags, env):
152
                     mac_prefix, tags, env):
153 153
  """Build environment variables concerning a Network.
154 154

  
155 155
  """
......
165 165
    env["NETWORK_GATEWAY6"] = gateway6
166 166
  if mac_prefix:
167 167
    env["NETWORK_MAC_PREFIX"] = mac_prefix
168
  if network_type:
169
    env["NETWORK_TYPE"] = network_type
170 168
  if tags:
171 169
    env["NETWORK_TAGS"] = " ".join(tags)
172 170

  
......
857 855
    if nic.network:
858 856
      n = objects.Network.FromDict(nic.netinfo)
859 857
      _BuildNetworkEnv(nic.network, n.network, n.gateway,
860
                       n.network6, n.gateway6, n.network_type,
858
                       n.network6, n.gateway6,
861 859
                       n.mac_prefix, n.tags, env)
862 860

  
863 861
    if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
b/lib/objects.py
2034 2034
  __slots__ = [
2035 2035
    "name",
2036 2036
    "serial_no",
2037
    "network_type",
2038 2037
    "mac_prefix",
2039 2038
    "family",
2040 2039
    "network",
......
2069 2068
      result["%sNETWORK_GATEWAY6" % prefix] = self.gateway6
2070 2069
    if self.mac_prefix:
2071 2070
      result["%sNETWORK_MAC_PREFIX" % prefix] = self.mac_prefix
2072
    if self.network_type:
2073
      result["%sNETWORK_TYPE" % prefix] = self.network_type
2074 2071

  
2075 2072
    return result
2076 2073

  
2074
  @classmethod
2075
  def FromDict(cls, val):
2076
    """Custom function for networks.
2077

  
2078
    Remove deprecated network_type. Still this info can be passed via tags.
2079

  
2080
    """
2081
    if "network_type" in val:
2082
      del val["network_type"]
2083
    obj = super(Network, cls).FromDict(val)
2084
    return obj
2085

  
2077 2086

  
2078 2087
class SerializableConfigParser(ConfigParser.SafeConfigParser):
2079 2088
  """Simple wrapper over ConfigParse that allows serialization.
b/lib/opcodes.py
361 361
_PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType,
362 362
                 "Storage type")
363 363

  
364
_CheckNetworkType = ht.TElemOf(constants.NETWORK_VALID_TYPES)
365

  
366 364

  
367 365
@ht.WithDesc("IPv4 network")
368 366
def _CheckCIDRNetNotation(value):
......
2065 2063
  OP_DSC_FIELD = "network_name"
2066 2064
  OP_PARAMS = [
2067 2065
    _PNetworkName,
2068
    ("network_type", None, ht.TMaybe(_CheckNetworkType), "Network type"),
2069 2066
    ("network", ht.NoDefault, _TIpNetwork4, "IPv4 subnet"),
2070 2067
    ("gateway", None, ht.TMaybe(_TIpAddress4), "IPv4 gateway"),
2071 2068
    ("network6", None, ht.TMaybe(_TIpNetwork6), "IPv6 subnet"),
......
2099 2096
  OP_DSC_FIELD = "network_name"
2100 2097
  OP_PARAMS = [
2101 2098
    _PNetworkName,
2102
    ("network_type", None, ht.TMaybeValueNone(_CheckNetworkType),
2103
     "Network type"),
2104 2099
    ("gateway", None, ht.TMaybeValueNone(_TIpAddress4), "IPv4 gateway"),
2105 2100
    ("network6", None, ht.TMaybeValueNone(_TIpNetwork6), "IPv6 subnet"),
2106 2101
    ("gateway6", None, ht.TMaybeValueNone(_TIpAddress6), "IPv6 gateway"),
b/lib/query.py
2531 2531
  "network6": ("IPv6Subnet", QFT_OTHER, 0, "IPv6 subnet"),
2532 2532
  "gateway6": ("IPv6Gateway", QFT_OTHER, 0, "IPv6 gateway"),
2533 2533
  "mac_prefix": ("MacPrefix", QFT_OTHER, 0, "MAC address prefix"),
2534
  "network_type": ("NetworkType", QFT_OTHER, 0, "Network type"),
2535 2534
  "serial_no": ("SerialNo", QFT_NUMBER, 0, _SERIAL_NO_DOC % "Network"),
2536 2535
  "uuid": ("UUID", QFT_TEXT, 0, "Network UUID"),
2537 2536
  }
b/lib/rapi/client.py
1768 1768
                             None, None)
1769 1769

  
1770 1770
  def CreateNetwork(self, network_name, network, gateway=None, network6=None,
1771
                    gateway6=None, mac_prefix=None, network_type=None,
1771
                    gateway6=None, mac_prefix=None,
1772 1772
                    add_reserved_ips=None, tags=None, dry_run=False):
1773 1773
    """Creates a new network.
1774 1774

  
......
1797 1797
      "gateway6": gateway6,
1798 1798
      "network6": network6,
1799 1799
      "mac_prefix": mac_prefix,
1800
      "network_type": network_type,
1801 1800
      "add_reserved_ips": add_reserved_ips,
1802 1801
      "tags": tags,
1803 1802
      }
b/lib/rapi/rlib2.py
94 94

  
95 95
NET_FIELDS = ["name", "network", "gateway",
96 96
              "network6", "gateway6",
97
              "mac_prefix", "network_type",
97
              "mac_prefix",
98 98
              "free_count", "reserved_count",
99 99
              "map", "group_list", "inst_list",
100 100
              "external_reservations", "tags",
b/man/ganeti-os-interface.rst
144 144
NIC_%d_NETWORK_MAC_PREFIX
145 145
    (Optional) If a NIC network is specified, the network's mac prefix.
146 146

  
147
NIC_%d_NETWORK_TYPE
148
    (Optional) If a NIC network is specified, the network's type.
149

  
150 147
NIC_%d_NETWORK_TAGS
151 148
    (Optional) If a NIC network is specified, the network's tags, space
152 149
    separated.
b/man/gnt-network.rst
32 32
| [--network6=*NETWORK6*]
33 33
| [--gateway6=*GATEWAY6*]
34 34
| [--mac-prefix=*MACPREFIX*]
35
| [--network-type=*NETWORKTYPE*]
36 35
| [--submit]
37 36
| {*network*}
38 37

  
......
46 45
The ``--gateway`` option allows you to specify the default gateway for
47 46
this network.
48 47

  
49
The ``--network-type`` can be none, private or public.
50

  
51 48
IPv6 semantics can be assigned to the network via the ``--network6`` and
52 49
``--gateway6`` options. IP pool is meaningless for IPV6 so those two
53 50
values can be used for EUI64 generation from a NIC's MAC address.
......
71 68
| [--network6=*NETWORK6*]
72 69
| [--gateway6=*GATEWAY6*]
73 70
| [--mac-prefix=*MACPREFIX*]
74
| [--network-type=*NETWORKTYPE*]
75 71
| [--submit]
76 72
| {*network*}
77 73

  
b/src/Ganeti/Objects.hs
173 173
$(buildObject "Network" "network" $
174 174
  [ simpleField "name"             [t| NonEmptyString |]
175 175
  , optionalField $
176
    simpleField "network_type"     [t| NetworkType |]
177
  , optionalField $
178 176
    simpleField "mac_prefix"       [t| String |]
179 177
  , optionalField $
180 178
    simpleField "family"           [t| Int |]
b/src/Ganeti/OpCodes.hs
501 501
     ])
502 502
  , ("OpNetworkAdd",
503 503
     [ pNetworkName
504
     , pNetworkType
505 504
     , pNetworkAddress4
506 505
     , pNetworkGateway4
507 506
     , pNetworkAddress6
......
517 516
     ])
518 517
  , ("OpNetworkSetParams",
519 518
     [ pNetworkName
520
     , pNetworkType
521 519
     , pNetworkGateway4
522 520
     , pNetworkAddress6
523 521
     , pNetworkGateway6
b/src/Ganeti/OpParams.hs
222 222
  , pTestDummyFail
223 223
  , pTestDummySubmitJobs
224 224
  , pNetworkName
225
  , pNetworkType
226 225
  , pNetworkAddress4
227 226
  , pNetworkGateway4
228 227
  , pNetworkAddress6
......
1358 1357
pNetworkName :: Field
1359 1358
pNetworkName = simpleField "network_name" [t| NonEmptyString |]
1360 1359

  
1361
-- | Network type field.
1362
pNetworkType :: Field
1363
pNetworkType = optionalField $ simpleField "network_type" [t| NetworkType |]
1364

  
1365 1360
-- | Network address (IPv4 subnet). FIXME: no real type for this.
1366 1361
pNetworkAddress4 :: Field
1367 1362
pNetworkAddress4 =
b/src/Ganeti/Types.hs
70 70
  , IAllocatorTestDir(..)
71 71
  , IAllocatorMode(..)
72 72
  , iAllocatorModeToRaw
73
  , NetworkType(..)
74
  , networkTypeToRaw
75 73
  , NICMode(..)
76 74
  , nICModeToRaw
77 75
  , JobStatus(..)
......
359 357
  ])
360 358
$(THH.makeJSONInstance ''IAllocatorMode)
361 359

  
362
-- | Network type.
363
$(THH.declareSADT "NetworkType"
364
  [ ("PrivateNetwork", 'C.networkTypePrivate)
365
  , ("PublicNetwork",  'C.networkTypePublic)
366
  ])
367
$(THH.makeJSONInstance ''NetworkType)
368

  
369 360
-- | Netork mode.
370 361
$(THH.declareSADT "NICMode"
371 362
  [ ("NMBridged", 'C.nicModeBridged)
b/test/hs/Test/Ganeti/Network.hs
4 4
module Test.Ganeti.Network
5 5
  ( testNetwork
6 6
  , genBitStringMaxLen
7
  , genNetworkType
8 7
  ) where
9 8

  
10 9
import Test.QuickCheck
......
14 13

  
15 14
import Test.Ganeti.Objects
16 15
  ( genBitStringMaxLen
17
  , genNetworkType
18 16
  , genValidNetwork )
19 17
import Test.Ganeti.TestHelper
20 18
import Test.Ganeti.TestCommon
b/test/hs/Test/Ganeti/Objects.hs
31 31
  , Node(..)
32 32
  , genEmptyCluster
33 33
  , genValidNetwork
34
  , genNetworkType
35 34
  , genBitStringMaxLen
36 35
  ) where
37 36

  
......
45 44
import qualified Data.Set as Set
46 45
import qualified Text.JSON as J
47 46

  
48
import Test.Ganeti.Query.Language (genJSValue)
49 47
import Test.Ganeti.TestHelper
50 48
import Test.Ganeti.TestCommon
51 49
import Test.Ganeti.Types ()
......
169 167
  -- generate netmask for the IPv4 network
170 168
  netmask <- choose (24::Int, 30)
171 169
  name <- genName >>= mkNonEmpty
172
  network_type <- genMaybe genNetworkType
173 170
  mac_prefix <- genMaybe genName
174
  net_family <- arbitrary
175 171
  net <- genIp4NetWithNetmask netmask
176 172
  net6 <- genMaybe genIp6Net
177 173
  gateway <- genMaybe genIp4AddrStr
178 174
  gateway6 <- genMaybe genIp6Addr
179
  size <- genMaybe genJSValue
180 175
  res <- liftM Just (genBitString $ netmask2NumHosts netmask)
181 176
  ext_res <- liftM Just (genBitString $ netmask2NumHosts netmask)
182
  let n = Network name network_type mac_prefix net_family net net6 gateway
183
          gateway6 size res ext_res 0 Set.empty
177
  let n = Network name mac_prefix net net6 gateway
178
          gateway6 res ext_res 0 Set.empty
184 179
  return n
185 180

  
186
-- | Generates an arbitrary network type.
187
genNetworkType :: Gen NetworkType
188
genNetworkType = elements [ PrivateNetwork, PublicNetwork ]
189

  
190 181
-- | Generate an arbitrary string consisting of '0' and '1' of the given length.
191 182
genBitString :: Int -> Gen String
192 183
genBitString len = vectorOf len (elements "01")
b/test/hs/Test/Ganeti/OpCodes.hs
318 318
        OpCodes.OpTestDummy <$> pure J.JSNull <*> pure J.JSNull <*>
319 319
          pure J.JSNull <*> pure J.JSNull
320 320
      "OP_NETWORK_ADD" ->
321
        OpCodes.OpNetworkAdd <$> genNameNE <*> arbitrary <*> genIp4Net <*>
321
        OpCodes.OpNetworkAdd <$> genNameNE <*> genIp4Net <*>
322 322
          genMaybe genIp4Addr <*> pure Nothing <*> pure Nothing <*>
323 323
          genMaybe genMacPrefix <*> genMaybe (listOf genIp4Addr) <*>
324 324
          arbitrary <*> (genTags >>= mapM mkNonEmpty)
325 325
      "OP_NETWORK_REMOVE" ->
326 326
        OpCodes.OpNetworkRemove <$> genNameNE <*> arbitrary
327 327
      "OP_NETWORK_SET_PARAMS" ->
328
        OpCodes.OpNetworkSetParams <$> genNameNE <*> arbitrary <*>
328
        OpCodes.OpNetworkSetParams <$> genNameNE <*>
329 329
          genMaybe genIp4Addr <*> pure Nothing <*> pure Nothing <*>
330 330
          genMaybe genMacPrefix <*> genMaybe (listOf genIp4Addr) <*>
331 331
          genMaybe (listOf genIp4Addr)
b/test/hs/Test/Ganeti/Types.hs
112 112

  
113 113
$(genArbitrary ''IAllocatorMode)
114 114

  
115
$(genArbitrary ''NetworkType)
116

  
117 115
$(genArbitrary ''NICMode)
118 116

  
119 117
$(genArbitrary ''JobStatus)
......
287 285
      all_hs_codes = sort $ map Types.iAllocatorModeToRaw [minBound..maxBound]
288 286
  assertEqual "for IAllocatorMode equivalence" all_py_codes all_hs_codes
289 287

  
290
-- | Test 'NetworkType' serialisation.
291
prop_NetworkType_serialisation :: NetworkType -> Property
292
prop_NetworkType_serialisation = testSerialisation
293

  
294
-- | Tests equivalence with Python, based on Constants.hs code.
295
case_NetworkType_pyequiv :: Assertion
296
case_NetworkType_pyequiv = do
297
  let all_py_codes = sort C.networkValidTypes
298
      all_hs_codes = sort $ map Types.networkTypeToRaw [minBound..maxBound]
299
  assertEqual "for NetworkType equivalence" all_py_codes all_hs_codes
300

  
301 288
-- | Test 'NICMode' serialisation.
302 289
prop_NICMode_serialisation :: NICMode -> Property
303 290
prop_NICMode_serialisation = testSerialisation
......
417 404
  , 'prop_IAllocatorTestDir_serialisation
418 405
  , 'prop_IAllocatorMode_serialisation
419 406
  , 'case_IAllocatorMode_pyequiv
420
  , 'prop_NetworkType_serialisation
421
  , 'case_NetworkType_pyequiv
422 407
  , 'prop_NICMode_serialisation
423 408
  , 'prop_OpStatus_serialization
424 409
  , 'prop_JobStatus_serialization

Also available in: Unified diff