A vlan on an OVS bridge doesn't require a device
Updates the object model so that a VLAN on top of a bridge (an OVS int port) doesn't require a physical device to be set in the object model.
This commit is contained in:
parent
db8deb0a06
commit
3b5e878987
@ -2,20 +2,24 @@
|
|||||||
{
|
{
|
||||||
"type": "ovs_bridge",
|
"type": "ovs_bridge",
|
||||||
"name": "br-ctlplane",
|
"name": "br-ctlplane",
|
||||||
|
"use_dhcp": "true",
|
||||||
"members": [
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "interface",
|
||||||
|
"name": "em1"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "vlan",
|
"type": "vlan",
|
||||||
"device": "em1",
|
|
||||||
"vlan_id": 16,
|
"vlan_id": 16,
|
||||||
"addresses": [{
|
"addresses": [{
|
||||||
"ip_netmask": "192.0.2.1/24"
|
"ip_netmask": "192.0.2.1/24"
|
||||||
}],
|
|
||||||
"routes": [{
|
|
||||||
"next_hop": "192.0.2.1",
|
|
||||||
"ip_netmask": "192.0.2.1/24"
|
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"routes": [{
|
||||||
|
"next_hop": "192.0.2.1",
|
||||||
|
"ip_netmask": "192.0.2.1/24"
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,18 @@ network_config:
|
|||||||
-
|
-
|
||||||
type: ovs_bridge
|
type: ovs_bridge
|
||||||
name: br-ctlplane
|
name: br-ctlplane
|
||||||
|
use_dhcp: true
|
||||||
members:
|
members:
|
||||||
|
-
|
||||||
|
type: interface
|
||||||
|
name: em1
|
||||||
-
|
-
|
||||||
type: vlan
|
type: vlan
|
||||||
device: em1
|
|
||||||
vlan_id: 16
|
vlan_id: 16
|
||||||
addresses:
|
addresses:
|
||||||
-
|
-
|
||||||
ip_netmask: 192.0.2.1/24
|
ip_netmask: 192.0.2.1/24
|
||||||
routes:
|
routes:
|
||||||
-
|
-
|
||||||
next_hop: 192.0.2.1
|
next_hop: 192.0.2.1
|
||||||
ip_netmask: 192.0.2.1/24
|
ip_netmask: 192.0.2.1/24
|
||||||
|
@ -89,8 +89,9 @@ class ENINetConfig(os_net_config.NetConfig):
|
|||||||
for i in interface.members:
|
for i in interface.members:
|
||||||
data += " %s" % i.name
|
data += " %s" % i.name
|
||||||
data += "\n"
|
data += "\n"
|
||||||
for i in interface.members:
|
for mem in interface.members:
|
||||||
data += " pre-up ip addr flush dev %s\n" % i.name
|
if isinstance(mem, objects.Interface):
|
||||||
|
data += " pre-up ip addr flush dev %s\n" % mem.name
|
||||||
if interface.primary_interface_name:
|
if interface.primary_interface_name:
|
||||||
mac = utils.interface_mac(interface.primary_interface_name)
|
mac = utils.interface_mac(interface.primary_interface_name)
|
||||||
data += (" ovs_extra set bridge %s "
|
data += (" ovs_extra set bridge %s "
|
||||||
|
@ -61,7 +61,8 @@ class IfcfgNetConfig(os_net_config.NetConfig):
|
|||||||
data += "HOTPLUG=no\n"
|
data += "HOTPLUG=no\n"
|
||||||
if isinstance(base_opt, objects.Vlan):
|
if isinstance(base_opt, objects.Vlan):
|
||||||
data += "VLAN=yes\n"
|
data += "VLAN=yes\n"
|
||||||
data += "PHYSDEV=%s\n" % base_opt.device
|
if base_opt.device:
|
||||||
|
data += "PHYSDEV=%s\n" % base_opt.device
|
||||||
if base_opt.ovs_port:
|
if base_opt.ovs_port:
|
||||||
data += "DEVICETYPE=ovs\n"
|
data += "DEVICETYPE=ovs\n"
|
||||||
if base_opt.bridge_name:
|
if base_opt.bridge_name:
|
||||||
|
@ -205,7 +205,8 @@ class Vlan(_BaseOpts):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_json(json):
|
def from_json(json):
|
||||||
device = _get_required_field(json, 'device', 'Vlan')
|
# A vlan on an OVS bridge won't require a device (OVS Int Port)
|
||||||
|
device = json.get('device')
|
||||||
vlan_id = _get_required_field(json, 'vlan_id', 'Vlan')
|
vlan_id = _get_required_field(json, 'vlan_id', 'Vlan')
|
||||||
opts = _BaseOpts.base_opts_from_json(json)
|
opts = _BaseOpts.base_opts_from_json(json)
|
||||||
return Vlan(device, vlan_id, *opts)
|
return Vlan(device, vlan_id, *opts)
|
||||||
|
Loading…
Reference in New Issue
Block a user