diff --git a/doc/hooks.rst b/doc/hooks.rst index a9f073e2fba33629d05c7ebcb8f2d34357e7f425..3f27953e94ea48f2e407135ddc2b52bfa716b249 100644 --- a/doc/hooks.rst +++ b/doc/hooks.rst @@ -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. diff --git a/doc/rapi.rst b/doc/rapi.rst index f70f8ca1acb1ba4ae8ee2b15eea5da1fa0928fde..11c64c15ae087cb322587d78e08ca37a1f7f7710 100644 --- a/doc/rapi.rst +++ b/doc/rapi.rst @@ -698,7 +698,6 @@ Example:: 'name': 'nat', 'network': '10.0.0.0/28', 'network6': None, - 'network_type': 'private', 'reserved_count': 3, 'tags': ['nfdhcpd'], β¦ diff --git a/lib/cli.py b/lib/cli.py index 55060dec8a1295c490153e3b2e0ec05db7881b53..c82de3355660f2fafcfb6fb16db638f5672694c7 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -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") diff --git a/lib/client/gnt_network.py b/lib/client/gnt_network.py index 7210ab30c578a95f9629608e491580b73b0f80ae..2407f392f725c8185734fb15efd3f610563eba48 100644 --- a/lib/client/gnt_network.py +++ b/lib/client/gnt_network.py @@ -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": ( diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 1bccf4a39ec9bfe88e8d751aeb8225fa7387b84d..870402c73c2d27e470ce9acc7fe854736bde3db0 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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) diff --git a/lib/constants.py b/lib/constants.py index 3a5634f3223a20d40f12f56e7eb6d16380b3176c..80bd5d4bdf16995050c28d9827a13625f61c1f9b 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -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, diff --git a/lib/hypervisor/hv_kvm.py b/lib/hypervisor/hv_kvm.py index 26aacfdfadd31aa3f6858fbe438cafd932648d0f..2fe5b434ead62636e6261ad86dc4a5ba9471c169 100644 --- a/lib/hypervisor/hv_kvm.py +++ b/lib/hypervisor/hv_kvm.py @@ -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: diff --git a/lib/objects.py b/lib/objects.py index f51c0ec7a4badd7d3749234974b6f05d6d8d796b..bd4326c4394601303f3732bce621de826e893344 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -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. diff --git a/lib/opcodes.py b/lib/opcodes.py index 2c88363b1a997eb1e1ee857d23c320f4ef53a43f..f30ec4104302a5cb415dac1d30c9c08b1899231c 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -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"), diff --git a/lib/query.py b/lib/query.py index dc07159fb150e69a16697d143f09ebc500f86b78..ef52d0899cd4a5593faa961cc177109c6f8a7b0b 100644 --- a/lib/query.py +++ b/lib/query.py @@ -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"), } diff --git a/lib/rapi/client.py b/lib/rapi/client.py index 452fa95c85e8e96be2cca1ff44db1f2d445f155f..cf7971132300264afe96f5216e0e392626211580 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -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, } diff --git a/lib/rapi/rlib2.py b/lib/rapi/rlib2.py index d7489139d74a86552a021df128daeba794270e10..3a28a8472d4111b4f69534337d3074c250557d9a 100644 --- a/lib/rapi/rlib2.py +++ b/lib/rapi/rlib2.py @@ -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", diff --git a/man/ganeti-os-interface.rst b/man/ganeti-os-interface.rst index cd7c763fc53709c699e050359c211a458a6370fb..ed5872fdfa9652103bb15d5470772f8db1ea2fdb 100644 --- a/man/ganeti-os-interface.rst +++ b/man/ganeti-os-interface.rst @@ -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. diff --git a/man/gnt-network.rst b/man/gnt-network.rst index 3e4a551f26fe3b37c4032be43c6d61674fd095a5..69848cde32a279e9a94b2dba154e8719f4fd203d 100644 --- a/man/gnt-network.rst +++ b/man/gnt-network.rst @@ -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*} diff --git a/src/Ganeti/Objects.hs b/src/Ganeti/Objects.hs index b0fd163d4d086e8e64e84cf86fca8c299979ccdf..d3f13dfb9b96ede6d2d1beb387597620fb4d883a 100644 --- a/src/Ganeti/Objects.hs +++ b/src/Ganeti/Objects.hs @@ -172,8 +172,6 @@ roleDescription NRMaster = "master" -- haven't been exhaustively deduced from the python code yet. $(buildObject "Network" "network" $ [ simpleField "name" [t| NonEmptyString |] - , optionalField $ - simpleField "network_type" [t| NetworkType |] , optionalField $ simpleField "mac_prefix" [t| String |] , optionalField $ diff --git a/src/Ganeti/OpCodes.hs b/src/Ganeti/OpCodes.hs index ec9a34f861dcfce17994105b0da65138c41fb2c4..7e931b805f6a83f46aa7992b053270d07d1a61f5 100644 --- a/src/Ganeti/OpCodes.hs +++ b/src/Ganeti/OpCodes.hs @@ -501,7 +501,6 @@ $(genOpCode "OpCode" ]) , ("OpNetworkAdd", [ pNetworkName - , pNetworkType , pNetworkAddress4 , pNetworkGateway4 , pNetworkAddress6 @@ -517,7 +516,6 @@ $(genOpCode "OpCode" ]) , ("OpNetworkSetParams", [ pNetworkName - , pNetworkType , pNetworkGateway4 , pNetworkAddress6 , pNetworkGateway6 diff --git a/src/Ganeti/OpParams.hs b/src/Ganeti/OpParams.hs index b247f00501f193374976a7012c64f97953c79020..8e91b8f7dae53994d091b906a6a1530922c01f65 100644 --- a/src/Ganeti/OpParams.hs +++ b/src/Ganeti/OpParams.hs @@ -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 = diff --git a/src/Ganeti/Types.hs b/src/Ganeti/Types.hs index ae692f6b8a99650d06418dbd8672bcef238f2259..e6c9378e1682dbec62343c1e375a1c5d0c9e0ff7 100644 --- a/src/Ganeti/Types.hs +++ b/src/Ganeti/Types.hs @@ -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) diff --git a/test/hs/Test/Ganeti/Network.hs b/test/hs/Test/Ganeti/Network.hs index 4867830c95d90433483e542ccabcee2d08444a15..57793ca3f972435493336e3dc0fe0ce7a70662a7 100644 --- a/test/hs/Test/Ganeti/Network.hs +++ b/test/hs/Test/Ganeti/Network.hs @@ -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 diff --git a/test/hs/Test/Ganeti/Objects.hs b/test/hs/Test/Ganeti/Objects.hs index a4fa648c87b456d051388b8374e21b1c6395cdd5..65d7659d9262f616eacadc32a6597fb9cd0aa96b 100644 --- a/test/hs/Test/Ganeti/Objects.hs +++ b/test/hs/Test/Ganeti/Objects.hs @@ -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") diff --git a/test/hs/Test/Ganeti/OpCodes.hs b/test/hs/Test/Ganeti/OpCodes.hs index 5092ffd2baf16cd93deb5cf39e489e4bffbfc551..caad2591b5cfa61ce4e390816d442a7996350332 100644 --- a/test/hs/Test/Ganeti/OpCodes.hs +++ b/test/hs/Test/Ganeti/OpCodes.hs @@ -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) diff --git a/test/hs/Test/Ganeti/Types.hs b/test/hs/Test/Ganeti/Types.hs index 7526e01efcb9a85fcfd8c78d12da75b761a3384d..6f84782cac602a30078963032f5392db3a2ec83c 100644 --- a/test/hs/Test/Ganeti/Types.hs +++ b/test/hs/Test/Ganeti/Types.hs @@ -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