Remove network_type slot (Issue 363)
authorDimitris Aragiorgis <dimara@grnet.gr>
Mon, 11 Feb 2013 12:42:34 +0000 (14:42 +0200)
committerGuido Trotter <ultrotter@google.com>
Mon, 11 Feb 2013 15:31:13 +0000 (16:31 +0100)
This slot was not used by Ganeti so the same info can be
provided via tags. In order not to break configuration data
we add a FromDict() method in Network config object that
removes the deprecated network_type (if found) and then invoke
the parent's method (which does the validation).

Signed-off-by: Dimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: Guido Trotter <ultrotter@google.com>

22 files changed:
doc/hooks.rst
doc/rapi.rst
lib/cli.py
lib/client/gnt_network.py
lib/cmdlib.py
lib/constants.py
lib/hypervisor/hv_kvm.py
lib/objects.py
lib/opcodes.py
lib/query.py
lib/rapi/client.py
lib/rapi/rlib2.py
man/ganeti-os-interface.rst
man/gnt-network.rst
src/Ganeti/Objects.hs
src/Ganeti/OpCodes.hs
src/Ganeti/OpParams.hs
src/Ganeti/Types.hs
test/hs/Test/Ganeti/Network.hs
test/hs/Test/Ganeti/Objects.hs
test/hs/Test/Ganeti/OpCodes.hs
test/hs/Test/Ganeti/Types.hs

index a9f073e..3f27953 100644 (file)
@@ -224,7 +224,7 @@ Adds a network to the cluster.
 
 :directory: network-add
 :env. vars: NETWORK_NAME, NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
-            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
+            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
 :pre-execution: master node
 :post-execution: master node
 
@@ -247,7 +247,7 @@ Connects a network to a nodegroup.
 :env. vars: GROUP_NAME, NETWORK_NAME,
             GROUP_NETWORK_MODE, GROUP_NETWORK_LINK,
             NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
-            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
+            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
 :pre-execution: nodegroup nodes
 :post-execution: nodegroup nodes
 
@@ -261,7 +261,7 @@ Disconnects a network from a nodegroup.
 :env. vars: GROUP_NAME, NETWORK_NAME,
             GROUP_NETWORK_MODE, GROUP_NETWORK_LINK,
             NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
-            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
+            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
 :pre-execution: nodegroup nodes
 :post-execution: nodegroup nodes
 
@@ -273,7 +273,7 @@ Modifies a network.
 
 :directory: network-modify
 :env. vars: NETWORK_NAME, NETWORK_SUBNET, NETWORK_GATEWAY, NETWORK_SUBNET6,
-            NETWORK_GATEWAY6, NETWORK_TYPE, NETWORK_MAC_PREFIX, NETWORK_TAGS
+            NETWORK_GATEWAY6, NETWORK_MAC_PREFIX, NETWORK_TAGS
 :pre-execution: master node
 :post-execution: master node
 
@@ -290,8 +290,7 @@ INSTANCE_NICn_NETWORK, INSTANCE_NICn_NETWORK_FAMILY,
 INSTANCE_NICn_NETWORK_UUID, INSTANCE_NICn_NETWORK_SUBNET,
 INSTANCE_NICn_NETWORK_GATEWAY, INSTANCE_NICn_NETWORK_SUBNET6,
 INSTANCE_NICn_NETWORK_GATEWAY6, INSTANCE_NICn_NETWORK_MAC_PREFIX,
-INSTANCE_NICn_NETWORK_TYPE, INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE,
-INSTANCE_DISKn_MODE.
+INSTANCE_DISK_COUNT, INSTANCE_DISKn_SIZE, INSTANCE_DISKn_MODE.
 
 The INSTANCE_NICn_* and INSTANCE_DISKn_* variables represent the
 properties of the *n* -th NIC and disk, and are zero-indexed.
index f70f8ca..11c64c1 100644 (file)
@@ -698,7 +698,6 @@ Example::
         'name': 'nat',
         'network': '10.0.0.0/28',
         'network6': None,
-        'network_type': 'private',
         'reserved_count': 3,
         'tags': ['nfdhcpd'],
         …
index 55060de..c82de33 100644 (file)
@@ -117,7 +117,6 @@ __all__ = [
   "NET_OPT",
   "NETWORK_OPT",
   "NETWORK6_OPT",
-  "NETWORK_TYPE_OPT",
   "NEW_CLUSTER_CERT_OPT",
   "NEW_CLUSTER_DOMAIN_SECRET_OPT",
   "NEW_CONFD_HMAC_KEY_OPT",
@@ -1527,10 +1526,6 @@ REMOVE_RESERVED_IPS_OPT = cli_option("--remove-reserved-ips",
                                      help="Comma-delimited list of"
                                      " reserved IPs to remove")
 
-NETWORK_TYPE_OPT = cli_option("--network-type",
-                              action="store", default=None, dest="network_type",
-                              help="Network type: private, public, None")
-
 NETWORK6_OPT = cli_option("--network6",
                           action="store", default=None, dest="network6",
                           help="IP network in CIDR notation")
index 7210ab3..2407f39 100644 (file)
@@ -36,7 +36,7 @@ from ganeti import errors
 
 #: default list of fields for L{ListNetworks}
 _LIST_DEF_FIELDS = ["name", "network", "gateway",
-                    "network_type", "mac_prefix", "group_list", "tags"]
+                    "mac_prefix", "group_list", "tags"]
 
 
 def _HandleReservedIPs(ips):
@@ -77,7 +77,6 @@ def AddNetwork(opts, args):
                             gateway6=opts.gateway6,
                             network6=opts.network6,
                             mac_prefix=opts.mac_prefix,
-                            network_type=opts.network_type,
                             add_reserved_ips=reserved_ips,
                             conflicts_check=opts.conflicts_check,
                             tags=tags)
@@ -202,7 +201,7 @@ def ShowNetworkConfig(_, args):
   cl = GetClient()
   result = cl.QueryNetworks(fields=["name", "network", "gateway",
                                     "network6", "gateway6",
-                                    "mac_prefix", "network_type",
+                                    "mac_prefix",
                                     "free_count", "reserved_count",
                                     "map", "group_list", "inst_list",
                                     "external_reservations",
@@ -210,7 +209,7 @@ def ShowNetworkConfig(_, args):
                             names=args, use_locking=False)
 
   for (name, network, gateway, network6, gateway6,
-       mac_prefix, network_type, free_count, reserved_count,
+       mac_prefix, free_count, reserved_count,
        mapping, group_list, instances, ext_res, serial, uuid) in result:
     size = free_count + reserved_count
     ToStdout("Network name: %s", name)
@@ -221,7 +220,6 @@ def ShowNetworkConfig(_, args):
     ToStdout("  IPv6 Subnet: %s", network6)
     ToStdout("  IPv6 Gateway: %s", gateway6)
     ToStdout("  Mac Prefix: %s", mac_prefix)
-    ToStdout("  Type: %s", network_type)
     ToStdout("  Size: %d", size)
     ToStdout("  Free: %d (%.2f%%)", free_count,
              100 * float(free_count) / float(size))
@@ -277,7 +275,6 @@ def SetNetworkParams(opts, args):
     "add_reserved_ips": _HandleReservedIPs(opts.add_reserved_ips),
     "remove_reserved_ips": _HandleReservedIPs(opts.remove_reserved_ips),
     "mac_prefix": opts.mac_prefix,
-    "network_type": opts.network_type,
     "gateway6": opts.gateway6,
     "network6": opts.network6,
   }
@@ -312,7 +309,7 @@ commands = {
   "add": (
     AddNetwork, ARGS_ONE_NETWORK,
     [DRY_RUN_OPT, NETWORK_OPT, GATEWAY_OPT, ADD_RESERVED_IPS_OPT,
-     MAC_PREFIX_OPT, NETWORK_TYPE_OPT, NETWORK6_OPT, GATEWAY6_OPT,
+     MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT,
      NOCONFLICTSCHECK_OPT, TAG_ADD_OPT, PRIORITY_OPT, SUBMIT_OPT],
     "<network_name>", "Add a new IP network to the cluster"),
   "list": (
@@ -331,7 +328,7 @@ commands = {
   "modify": (
     SetNetworkParams, ARGS_ONE_NETWORK,
     [DRY_RUN_OPT, SUBMIT_OPT, ADD_RESERVED_IPS_OPT, REMOVE_RESERVED_IPS_OPT,
-     GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK_TYPE_OPT, NETWORK6_OPT, GATEWAY6_OPT,
+     GATEWAY_OPT, MAC_PREFIX_OPT, NETWORK6_OPT, GATEWAY6_OPT,
      PRIORITY_OPT],
     "<network_name>", "Alters the parameters of a network"),
   "connect": (
index 1bccf4a..870402c 100644 (file)
@@ -1399,7 +1399,7 @@ def _ExpandInstanceName(cfg, name):
 
 
 def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6,
-                         network_type, mac_prefix, tags):
+                         mac_prefix, tags):
   """Builds network related env variables for hooks
 
   This builds the hook environment from individual variables.
@@ -1414,8 +1414,6 @@ def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6,
   @param network6: the ipv6 subnet
   @type gateway6: string
   @param gateway6: the ipv6 gateway
-  @type network_type: string
-  @param network_type: the type of the network
   @type mac_prefix: string
   @param mac_prefix: the mac_prefix
   @type tags: list
@@ -1435,8 +1433,6 @@ def _BuildNetworkHookEnv(name, subnet, gateway, network6, gateway6,
     env["NETWORK_GATEWAY6"] = gateway6
   if mac_prefix:
     env["NETWORK_MAC_PREFIX"] = mac_prefix
-  if network_type:
-    env["NETWORK_TYPE"] = network_type
   if tags:
     env["NETWORK_TAGS"] = " ".join(tags)
 
@@ -16232,7 +16228,6 @@ class LUNetworkAdd(LogicalUnit):
       "network6": self.op.network6,
       "gateway6": self.op.gateway6,
       "mac_prefix": self.op.mac_prefix,
-      "network_type": self.op.network_type,
       "tags": self.op.tags,
       }
     return _BuildNetworkHookEnv(**args) # pylint: disable=W0142
@@ -16247,7 +16242,6 @@ class LUNetworkAdd(LogicalUnit):
                            network6=self.op.network6,
                            gateway6=self.op.gateway6,
                            mac_prefix=self.op.mac_prefix,
-                           network_type=self.op.network_type,
                            uuid=self.network_uuid,
                            family=constants.IP4_VERSION)
     # Initialize the associated address pool
@@ -16389,7 +16383,6 @@ class LUNetworkSetParams(LogicalUnit):
     """
     self.network = self.cfg.GetNetwork(self.network_uuid)
     self.gateway = self.network.gateway
-    self.network_type = self.network.network_type
     self.mac_prefix = self.network.mac_prefix
     self.network6 = self.network.network6
     self.gateway6 = self.network.gateway6
@@ -16407,12 +16400,6 @@ class LUNetworkSetParams(LogicalUnit):
                                      " reserved" % self.gateway,
                                      errors.ECODE_STATE)
 
-    if self.op.network_type:
-      if self.op.network_type == constants.VALUE_NONE:
-        self.network_type = None
-      else:
-        self.network_type = self.op.network_type
-
     if self.op.mac_prefix:
       if self.op.mac_prefix == constants.VALUE_NONE:
         self.mac_prefix = None
@@ -16443,7 +16430,6 @@ class LUNetworkSetParams(LogicalUnit):
       "network6": self.network6,
       "gateway6": self.gateway6,
       "mac_prefix": self.mac_prefix,
-      "network_type": self.network_type,
       "tags": self.tags,
       }
     return _BuildNetworkHookEnv(**args) # pylint: disable=W0142
@@ -16503,9 +16489,6 @@ class LUNetworkSetParams(LogicalUnit):
     if self.op.gateway6:
       self.network.gateway6 = self.gateway6
 
-    if self.op.network_type:
-      self.network.network_type = self.network_type
-
     self.pool.Validate()
 
     self.cfg.Update(self.network, feedback_fn)
index 3a5634f..80bd5d4 100644 (file)
@@ -1213,16 +1213,6 @@ NIC_VALID_MODES = compat.UniqueFrozenset([
 RESERVE_ACTION = "reserve"
 RELEASE_ACTION = "release"
 
-# An extra description of the network.
-# Can be used by hooks/kvm-vif-bridge to apply different rules
-NETWORK_TYPE_PRIVATE = "private"
-NETWORK_TYPE_PUBLIC = "public"
-
-NETWORK_VALID_TYPES = compat.UniqueFrozenset([
-  NETWORK_TYPE_PRIVATE,
-  NETWORK_TYPE_PUBLIC,
-  ])
-
 NICS_PARAMETER_TYPES = {
   NIC_MODE: VTYPE_STRING,
   NIC_LINK: VTYPE_STRING,
index 26aacfd..2fe5b43 100644 (file)
@@ -149,7 +149,7 @@ def _OpenTap(vnet_hdr=True):
 
 
 def _BuildNetworkEnv(name, network, gateway, network6, gateway6,
-                     network_type, mac_prefix, tags, env):
+                     mac_prefix, tags, env):
   """Build environment variables concerning a Network.
 
   """
@@ -165,8 +165,6 @@ def _BuildNetworkEnv(name, network, gateway, network6, gateway6,
     env["NETWORK_GATEWAY6"] = gateway6
   if mac_prefix:
     env["NETWORK_MAC_PREFIX"] = mac_prefix
-  if network_type:
-    env["NETWORK_TYPE"] = network_type
   if tags:
     env["NETWORK_TAGS"] = " ".join(tags)
 
@@ -857,7 +855,7 @@ class KVMHypervisor(hv_base.BaseHypervisor):
     if nic.network:
       n = objects.Network.FromDict(nic.netinfo)
       _BuildNetworkEnv(nic.network, n.network, n.gateway,
-                       n.network6, n.gateway6, n.network_type,
+                       n.network6, n.gateway6,
                        n.mac_prefix, n.tags, env)
 
     if nic.nicparams[constants.NIC_MODE] == constants.NIC_MODE_BRIDGED:
index f51c0ec..bd4326c 100644 (file)
@@ -2034,7 +2034,6 @@ class Network(TaggableObject):
   __slots__ = [
     "name",
     "serial_no",
-    "network_type",
     "mac_prefix",
     "family",
     "network",
@@ -2069,11 +2068,21 @@ class Network(TaggableObject):
       result["%sNETWORK_GATEWAY6" % prefix] = self.gateway6
     if self.mac_prefix:
       result["%sNETWORK_MAC_PREFIX" % prefix] = self.mac_prefix
-    if self.network_type:
-      result["%sNETWORK_TYPE" % prefix] = self.network_type
 
     return result
 
+  @classmethod
+  def FromDict(cls, val):
+    """Custom function for networks.
+
+    Remove deprecated network_type. Still this info can be passed via tags.
+
+    """
+    if "network_type" in val:
+      del val["network_type"]
+    obj = super(Network, cls).FromDict(val)
+    return obj
+
 
 class SerializableConfigParser(ConfigParser.SafeConfigParser):
   """Simple wrapper over ConfigParse that allows serialization.
index 2c88363..f30ec41 100644 (file)
@@ -361,8 +361,6 @@ def _CheckStorageType(storage_type):
 _PStorageType = ("storage_type", ht.NoDefault, _CheckStorageType,
                  "Storage type")
 
-_CheckNetworkType = ht.TElemOf(constants.NETWORK_VALID_TYPES)
-
 
 @ht.WithDesc("IPv4 network")
 def _CheckCIDRNetNotation(value):
@@ -2065,7 +2063,6 @@ class OpNetworkAdd(OpCode):
   OP_DSC_FIELD = "network_name"
   OP_PARAMS = [
     _PNetworkName,
-    ("network_type", None, ht.TMaybe(_CheckNetworkType), "Network type"),
     ("network", ht.NoDefault, _TIpNetwork4, "IPv4 subnet"),
     ("gateway", None, ht.TMaybe(_TIpAddress4), "IPv4 gateway"),
     ("network6", None, ht.TMaybe(_TIpNetwork6), "IPv6 subnet"),
@@ -2099,8 +2096,6 @@ class OpNetworkSetParams(OpCode):
   OP_DSC_FIELD = "network_name"
   OP_PARAMS = [
     _PNetworkName,
-    ("network_type", None, ht.TMaybeValueNone(_CheckNetworkType),
-     "Network type"),
     ("gateway", None, ht.TMaybeValueNone(_TIpAddress4), "IPv4 gateway"),
     ("network6", None, ht.TMaybeValueNone(_TIpNetwork6), "IPv6 subnet"),
     ("gateway6", None, ht.TMaybeValueNone(_TIpAddress6), "IPv6 gateway"),
index dc07159..ef52d08 100644 (file)
@@ -2531,7 +2531,6 @@ _NETWORK_SIMPLE_FIELDS = {
   "network6": ("IPv6Subnet", QFT_OTHER, 0, "IPv6 subnet"),
   "gateway6": ("IPv6Gateway", QFT_OTHER, 0, "IPv6 gateway"),
   "mac_prefix": ("MacPrefix", QFT_OTHER, 0, "MAC address prefix"),
-  "network_type": ("NetworkType", QFT_OTHER, 0, "Network type"),
   "serial_no": ("SerialNo", QFT_NUMBER, 0, _SERIAL_NO_DOC % "Network"),
   "uuid": ("UUID", QFT_TEXT, 0, "Network UUID"),
   }
index 452fa95..cf79711 100644 (file)
@@ -1768,7 +1768,7 @@ class GanetiRapiClient(object): # pylint: disable=R0904
                              None, None)
 
   def CreateNetwork(self, network_name, network, gateway=None, network6=None,
-                    gateway6=None, mac_prefix=None, network_type=None,
+                    gateway6=None, mac_prefix=None,
                     add_reserved_ips=None, tags=None, dry_run=False):
     """Creates a new network.
 
@@ -1797,7 +1797,6 @@ class GanetiRapiClient(object): # pylint: disable=R0904
       "gateway6": gateway6,
       "network6": network6,
       "mac_prefix": mac_prefix,
-      "network_type": network_type,
       "add_reserved_ips": add_reserved_ips,
       "tags": tags,
       }
index d748913..3a28a84 100644 (file)
@@ -94,7 +94,7 @@ N_FIELDS = ["name", "offline", "master_candidate", "drained",
 
 NET_FIELDS = ["name", "network", "gateway",
               "network6", "gateway6",
-              "mac_prefix", "network_type",
+              "mac_prefix",
               "free_count", "reserved_count",
               "map", "group_list", "inst_list",
               "external_reservations", "tags",
index cd7c763..ed5872f 100644 (file)
@@ -144,9 +144,6 @@ NIC_%d_NETWORK_GATEWAY6
 NIC_%d_NETWORK_MAC_PREFIX
     (Optional) If a NIC network is specified, the network's mac prefix.
 
-NIC_%d_NETWORK_TYPE
-    (Optional) If a NIC network is specified, the network's type.
-
 NIC_%d_NETWORK_TAGS
     (Optional) If a NIC network is specified, the network's tags, space
     separated.
index 3e4a551..69848cd 100644 (file)
@@ -32,7 +32,6 @@ ADD
 | [--network6=*NETWORK6*]
 | [--gateway6=*GATEWAY6*]
 | [--mac-prefix=*MACPREFIX*]
-| [--network-type=*NETWORKTYPE*]
 | [--submit]
 | {*network*}
 
@@ -46,8 +45,6 @@ notation.
 The ``--gateway`` option allows you to specify the default gateway for
 this network.
 
-The ``--network-type`` can be none, private or public.
-
 IPv6 semantics can be assigned to the network via the ``--network6`` and
 ``--gateway6`` options. IP pool is meaningless for IPV6 so those two
 values can be used for EUI64 generation from a NIC's MAC address.
@@ -71,7 +68,6 @@ MODIFY
 | [--network6=*NETWORK6*]
 | [--gateway6=*GATEWAY6*]
 | [--mac-prefix=*MACPREFIX*]
-| [--network-type=*NETWORKTYPE*]
 | [--submit]
 | {*network*}
 
index b0fd163..d3f13df 100644 (file)
@@ -173,8 +173,6 @@ roleDescription NRMaster    = "master"
 $(buildObject "Network" "network" $
   [ simpleField "name"             [t| NonEmptyString |]
   , optionalField $
-    simpleField "network_type"     [t| NetworkType |]
-  , optionalField $
     simpleField "mac_prefix"       [t| String |]
   , optionalField $
     simpleField "family"           [t| Int |]
index ec9a34f..7e931b8 100644 (file)
@@ -501,7 +501,6 @@ $(genOpCode "OpCode"
      ])
   , ("OpNetworkAdd",
      [ pNetworkName
-     , pNetworkType
      , pNetworkAddress4
      , pNetworkGateway4
      , pNetworkAddress6
@@ -517,7 +516,6 @@ $(genOpCode "OpCode"
      ])
   , ("OpNetworkSetParams",
      [ pNetworkName
-     , pNetworkType
      , pNetworkGateway4
      , pNetworkAddress6
      , pNetworkGateway6
index b247f00..8e91b8f 100644 (file)
@@ -222,7 +222,6 @@ module Ganeti.OpParams
   , pTestDummyFail
   , pTestDummySubmitJobs
   , pNetworkName
-  , pNetworkType
   , pNetworkAddress4
   , pNetworkGateway4
   , pNetworkAddress6
@@ -1358,10 +1357,6 @@ pTestDummySubmitJobs =
 pNetworkName :: Field
 pNetworkName = simpleField "network_name" [t| NonEmptyString |]
 
--- | Network type field.
-pNetworkType :: Field
-pNetworkType = optionalField $ simpleField "network_type" [t| NetworkType |]
-
 -- | Network address (IPv4 subnet). FIXME: no real type for this.
 pNetworkAddress4 :: Field
 pNetworkAddress4 =
index ae692f6..e6c9378 100644 (file)
@@ -70,8 +70,6 @@ module Ganeti.Types
   , IAllocatorTestDir(..)
   , IAllocatorMode(..)
   , iAllocatorModeToRaw
-  , NetworkType(..)
-  , networkTypeToRaw
   , NICMode(..)
   , nICModeToRaw
   , JobStatus(..)
@@ -359,13 +357,6 @@ $(THH.declareSADT "IAllocatorMode"
   ])
 $(THH.makeJSONInstance ''IAllocatorMode)
 
--- | Network type.
-$(THH.declareSADT "NetworkType"
-  [ ("PrivateNetwork", 'C.networkTypePrivate)
-  , ("PublicNetwork",  'C.networkTypePublic)
-  ])
-$(THH.makeJSONInstance ''NetworkType)
-
 -- | Netork mode.
 $(THH.declareSADT "NICMode"
   [ ("NMBridged", 'C.nicModeBridged)
index 4867830..57793ca 100644 (file)
@@ -4,7 +4,6 @@
 module Test.Ganeti.Network
   ( testNetwork
   , genBitStringMaxLen
-  , genNetworkType
   ) where
 
 import Test.QuickCheck
@@ -14,7 +13,6 @@ import Ganeti.Objects as Objects
 
 import Test.Ganeti.Objects
   ( genBitStringMaxLen
-  , genNetworkType
   , genValidNetwork )
 import Test.Ganeti.TestHelper
 import Test.Ganeti.TestCommon
index a4fa648..65d7659 100644 (file)
@@ -31,7 +31,6 @@ module Test.Ganeti.Objects
   , Node(..)
   , genEmptyCluster
   , genValidNetwork
-  , genNetworkType
   , genBitStringMaxLen
   ) where
 
@@ -45,7 +44,6 @@ import qualified Data.Map as Map
 import qualified Data.Set as Set
 import qualified Text.JSON as J
 
-import Test.Ganeti.Query.Language (genJSValue)
 import Test.Ganeti.TestHelper
 import Test.Ganeti.TestCommon
 import Test.Ganeti.Types ()
@@ -169,24 +167,17 @@ genValidNetwork = do
   -- generate netmask for the IPv4 network
   netmask <- choose (24::Int, 30)
   name <- genName >>= mkNonEmpty
-  network_type <- genMaybe genNetworkType
   mac_prefix <- genMaybe genName
-  net_family <- arbitrary
   net <- genIp4NetWithNetmask netmask
   net6 <- genMaybe genIp6Net
   gateway <- genMaybe genIp4AddrStr
   gateway6 <- genMaybe genIp6Addr
-  size <- genMaybe genJSValue
   res <- liftM Just (genBitString $ netmask2NumHosts netmask)
   ext_res <- liftM Just (genBitString $ netmask2NumHosts netmask)
-  let n = Network name network_type mac_prefix net_family net net6 gateway
-          gateway6 size res ext_res 0 Set.empty
+  let n = Network name mac_prefix net net6 gateway
+          gateway6 res ext_res 0 Set.empty
   return n
 
--- | Generates an arbitrary network type.
-genNetworkType :: Gen NetworkType
-genNetworkType = elements [ PrivateNetwork, PublicNetwork ]
-
 -- | Generate an arbitrary string consisting of '0' and '1' of the given length.
 genBitString :: Int -> Gen String
 genBitString len = vectorOf len (elements "01")
index 5092ffd..caad259 100644 (file)
@@ -318,14 +318,14 @@ instance Arbitrary OpCodes.OpCode where
         OpCodes.OpTestDummy <$> pure J.JSNull <*> pure J.JSNull <*>
           pure J.JSNull <*> pure J.JSNull
       "OP_NETWORK_ADD" ->
-        OpCodes.OpNetworkAdd <$> genNameNE <*> arbitrary <*> genIp4Net <*>
+        OpCodes.OpNetworkAdd <$> genNameNE <*> genIp4Net <*>
           genMaybe genIp4Addr <*> pure Nothing <*> pure Nothing <*>
           genMaybe genMacPrefix <*> genMaybe (listOf genIp4Addr) <*>
           arbitrary <*> (genTags >>= mapM mkNonEmpty)
       "OP_NETWORK_REMOVE" ->
         OpCodes.OpNetworkRemove <$> genNameNE <*> arbitrary
       "OP_NETWORK_SET_PARAMS" ->
-        OpCodes.OpNetworkSetParams <$> genNameNE <*> arbitrary <*>
+        OpCodes.OpNetworkSetParams <$> genNameNE <*>
           genMaybe genIp4Addr <*> pure Nothing <*> pure Nothing <*>
           genMaybe genMacPrefix <*> genMaybe (listOf genIp4Addr) <*>
           genMaybe (listOf genIp4Addr)
index 7526e01..6f84782 100644 (file)
@@ -112,8 +112,6 @@ $(genArbitrary ''IAllocatorTestDir)
 
 $(genArbitrary ''IAllocatorMode)
 
-$(genArbitrary ''NetworkType)
-
 $(genArbitrary ''NICMode)
 
 $(genArbitrary ''JobStatus)
@@ -287,17 +285,6 @@ case_IAllocatorMode_pyequiv = do
       all_hs_codes = sort $ map Types.iAllocatorModeToRaw [minBound..maxBound]
   assertEqual "for IAllocatorMode equivalence" all_py_codes all_hs_codes
 
--- | Test 'NetworkType' serialisation.
-prop_NetworkType_serialisation :: NetworkType -> Property
-prop_NetworkType_serialisation = testSerialisation
-
--- | Tests equivalence with Python, based on Constants.hs code.
-case_NetworkType_pyequiv :: Assertion
-case_NetworkType_pyequiv = do
-  let all_py_codes = sort C.networkValidTypes
-      all_hs_codes = sort $ map Types.networkTypeToRaw [minBound..maxBound]
-  assertEqual "for NetworkType equivalence" all_py_codes all_hs_codes
-
 -- | Test 'NICMode' serialisation.
 prop_NICMode_serialisation :: NICMode -> Property
 prop_NICMode_serialisation = testSerialisation
@@ -417,8 +404,6 @@ testSuite "Types"
   , 'prop_IAllocatorTestDir_serialisation
   , 'prop_IAllocatorMode_serialisation
   , 'case_IAllocatorMode_pyequiv
-  , 'prop_NetworkType_serialisation
-  , 'case_NetworkType_pyequiv
   , 'prop_NICMode_serialisation
   , 'prop_OpStatus_serialization
   , 'prop_JobStatus_serialization