Commit 5cfa6c37 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Guido Trotter
Browse files

Remove network_type slot (Issue 363)



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: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 3697def0
......@@ -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.
......
......@@ -698,7 +698,6 @@ Example::
'name': 'nat',
'network': '10.0.0.0/28',
'network6': None,
'network_type': 'private',
'reserved_count': 3,
'tags': ['nfdhcpd'],
......
......@@ -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")
......
......@@ -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": (
......
......@@ -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)
......
......@@ -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,
......
......@@ -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:
......
......@@ -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.
......
......@@ -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"),
......
......@@ -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"),
}
......
......@@ -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,
}
......
......@@ -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",
......
......@@ -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.
......
......@@ -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*}
......
......@@ -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 $
......
......@@ -501,7 +501,6 @@ $(genOpCode "OpCode"
])
, ("OpNetworkAdd",
[ pNetworkName
, pNetworkType
, pNetworkAddress4
, pNetworkGateway4
, pNetworkAddress6
......@@ -517,7 +516,6 @@ $(genOpCode "OpCode"
])
, ("OpNetworkSetParams",
[ pNetworkName
, pNetworkType
, pNetworkGateway4
, pNetworkAddress6
, pNetworkGateway6
......
......@@ -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 =
......
......@@ -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)
......
......@@ -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
......
......@@ -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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment