diff --git a/api-daemon/pvcapid/flaskapi.py b/api-daemon/pvcapid/flaskapi.py index e428d0e7..e84c77ba 100755 --- a/api-daemon/pvcapid/flaskapi.py +++ b/api-daemon/pvcapid/flaskapi.py @@ -2109,6 +2109,9 @@ class API_Network_Root(Resource): enum: - managed - bridged + mtu: + type: integer + description: The MTU of the network, if set; empty otherwise domain: type: string description: The DNS domain of the network ("managed" networks only) @@ -2169,6 +2172,7 @@ class API_Network_Root(Resource): {'name': 'vni', 'required': True}, {'name': 'description', 'required': True}, {'name': 'nettype', 'choices': ('managed', 'bridged'), 'helptext': 'A valid nettype must be specified', 'required': True}, + {'name': 'mtu'}, {'name': 'domain'}, {'name': 'name_servers'}, {'name': 'ip4_network'}, @@ -2205,6 +2209,10 @@ class API_Network_Root(Resource): enum: - managed - bridged + - in: query + name: mtu + type: integer + description: The MTU of the network; defaults to the underlying interface MTU if not set - in: query name: domain type: string @@ -2261,6 +2269,7 @@ class API_Network_Root(Resource): reqargs.get('vni', None), reqargs.get('description', None), reqargs.get('nettype', None), + reqargs.get('mtu', ''), reqargs.get('domain', None), name_servers, reqargs.get('ip4_network', None), @@ -2301,6 +2310,7 @@ class API_Network_Element(Resource): @RequestParser([ {'name': 'description', 'required': True}, {'name': 'nettype', 'choices': ('managed', 'bridged'), 'helptext': 'A valid nettype must be specified', 'required': True}, + {'name': 'mtu'}, {'name': 'domain'}, {'name': 'name_servers'}, {'name': 'ip4_network'}, @@ -2332,6 +2342,10 @@ class API_Network_Element(Resource): enum: - managed - bridged + - in: query + name: mtu + type: integer + description: The MTU of the network; defaults to the underlying interface MTU if not set - in: query name: domain type: string @@ -2388,6 +2402,7 @@ class API_Network_Element(Resource): reqargs.get('vni', None), reqargs.get('description', None), reqargs.get('nettype', None), + reqargs.get('mtu', ''), reqargs.get('domain', None), name_servers, reqargs.get('ip4_network', None), @@ -2401,6 +2416,7 @@ class API_Network_Element(Resource): @RequestParser([ {'name': 'description'}, + {'name': 'mtu'}, {'name': 'domain'}, {'name': 'name_servers'}, {'name': 'ip4_network'}, @@ -2424,6 +2440,10 @@ class API_Network_Element(Resource): name: description type: string description: The description of the network + - in: query + name: mtu + type: integer + description: The MTU of the network - in: query name: domain type: string @@ -2484,6 +2504,7 @@ class API_Network_Element(Resource): return api_helper.net_modify( vni, reqargs.get('description', None), + reqargs.get('mtu', None), reqargs.get('domain', None), name_servers, reqargs.get('ip4_network', None), diff --git a/api-daemon/pvcapid/helper.py b/api-daemon/pvcapid/helper.py index 6e6ee970..2dac3253 100755 --- a/api-daemon/pvcapid/helper.py +++ b/api-daemon/pvcapid/helper.py @@ -927,7 +927,7 @@ def net_list(zkhandler, limit=None, is_fuzzy=True): @ZKConnection(config) -def net_add(zkhandler, vni, description, nettype, domain, name_servers, +def net_add(zkhandler, vni, description, nettype, mtu, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end): """ @@ -935,7 +935,7 @@ def net_add(zkhandler, vni, description, nettype, domain, name_servers, """ if dhcp4_flag: dhcp4_flag = bool(strtobool(dhcp4_flag)) - retflag, retdata = pvc_network.add_network(zkhandler, vni, description, nettype, domain, name_servers, + retflag, retdata = pvc_network.add_network(zkhandler, vni, description, nettype, mtu, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end) @@ -951,7 +951,7 @@ def net_add(zkhandler, vni, description, nettype, domain, name_servers, @ZKConnection(config) -def net_modify(zkhandler, vni, description, domain, name_servers, +def net_modify(zkhandler, vni, description, mtu, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end): @@ -960,7 +960,7 @@ def net_modify(zkhandler, vni, description, domain, name_servers, """ if dhcp4_flag is not None: dhcp4_flag = bool(strtobool(dhcp4_flag)) - retflag, retdata = pvc_network.modify_network(zkhandler, vni, description, domain, name_servers, + retflag, retdata = pvc_network.modify_network(zkhandler, vni, description, mtu, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end) diff --git a/daemon-common/network.py b/daemon-common/network.py index 3e034cf8..4d91d5a6 100644 --- a/daemon-common/network.py +++ b/daemon-common/network.py @@ -135,6 +135,7 @@ def getNetworkACLs(zkhandler, vni, _direction): def getNetworkInformation(zkhandler, vni): description = zkhandler.read(('network', vni)) nettype = zkhandler.read(('network.type', vni)) + mtu = zkhandler.read(('network.mtu', vni)) domain = zkhandler.read(('network.domain', vni)) name_servers = zkhandler.read(('network.nameservers', vni)) ip6_network = zkhandler.read(('network.ip6.network', vni)) @@ -151,6 +152,7 @@ def getNetworkInformation(zkhandler, vni): 'vni': int(vni), 'description': description, 'type': nettype, + 'mtu': mtu, 'domain': domain, 'name_servers': name_servers.split(','), 'ip6': { @@ -235,7 +237,7 @@ def isValidIP(ipaddr): # # Direct functions # -def add_network(zkhandler, vni, description, nettype, +def add_network(zkhandler, vni, description, nettype, mtu, domain, name_servers, ip4_network, ip4_gateway, ip6_network, ip6_gateway, dhcp4_flag, dhcp4_start, dhcp4_end): # Ensure start and end DHCP ranges are set if the flag is set @@ -267,6 +269,7 @@ def add_network(zkhandler, vni, description, nettype, result = zkhandler.write([ (('network', vni), description), (('network.type', vni), nettype), + (('network.mtu', vni), mtu), (('network.domain', vni), domain), (('network.nameservers', vni), name_servers), (('network.ip6.network', vni), ip6_network), @@ -290,13 +293,15 @@ def add_network(zkhandler, vni, description, nettype, return False, 'ERROR: Failed to add network.' -def modify_network(zkhandler, vni, description=None, domain=None, name_servers=None, +def modify_network(zkhandler, vni, description=None, mtu=None, domain=None, name_servers=None, ip4_network=None, ip4_gateway=None, ip6_network=None, ip6_gateway=None, dhcp4_flag=None, dhcp4_start=None, dhcp4_end=None): # Add the modified parameters to Zookeeper update_data = list() if description is not None: update_data.append((('network', vni), description)) + if mtu is not None: + update_data.append((('mtu', vni), mtu)) if domain is not None: update_data.append((('network.domain', vni), domain)) if name_servers is not None: diff --git a/docs/manuals/swagger.json b/docs/manuals/swagger.json index 33792a67..9cc23b24 100644 --- a/docs/manuals/swagger.json +++ b/docs/manuals/swagger.json @@ -364,6 +364,10 @@ }, "type": "object" }, + "mtu": { + "description": "The MTU of the network, if set; empty otherwise", + "type": "integer" + }, "name_servers": { "description": "The configured DNS nameservers of the network for NS records (\"managed\" networks only)", "items": { @@ -1765,6 +1769,12 @@ "required": true, "type": "string" }, + { + "description": "The MTU of the network; defaults to the underlying interface MTU if not set", + "in": "query", + "name": "mtu", + "type": "integer" + }, { "description": "The DNS domain of the network (\"managed\" networks only)", "in": "query", @@ -1910,6 +1920,12 @@ "required": true, "type": "string" }, + { + "description": "The MTU of the network; defaults to the underlying interface MTU if not set", + "in": "query", + "name": "mtu", + "type": "integer" + }, { "description": "The DNS domain of the network (\"managed\" networks only)", "in": "query", @@ -1993,6 +2009,12 @@ "name": "description", "type": "string" }, + { + "description": "The MTU of the network", + "in": "query", + "name": "mtu", + "type": "integer" + }, { "description": "The DNS domain of the network (\"managed\" networks only)", "in": "query",