diff --git a/etc/os-net-config/samples/bridge_vlan.json b/etc/os-net-config/samples/bridge_vlan.json index 1e351e05..244c89ab 100644 --- a/etc/os-net-config/samples/bridge_vlan.json +++ b/etc/os-net-config/samples/bridge_vlan.json @@ -2,20 +2,24 @@ { "type": "ovs_bridge", "name": "br-ctlplane", + "use_dhcp": "true", "members": [ + { + "type": "interface", + "name": "em1" + }, { "type": "vlan", - "device": "em1", "vlan_id": 16, "addresses": [{ "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" + }] } ] } diff --git a/etc/os-net-config/samples/bridge_vlan.yaml b/etc/os-net-config/samples/bridge_vlan.yaml index 9f25e090..a17d61e6 100644 --- a/etc/os-net-config/samples/bridge_vlan.yaml +++ b/etc/os-net-config/samples/bridge_vlan.yaml @@ -2,15 +2,18 @@ network_config: - type: ovs_bridge name: br-ctlplane + use_dhcp: true members: + - + type: interface + name: em1 - type: vlan - device: em1 vlan_id: 16 addresses: - 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 diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py index c40a4b01..944893e5 100644 --- a/os_net_config/impl_eni.py +++ b/os_net_config/impl_eni.py @@ -89,8 +89,9 @@ class ENINetConfig(os_net_config.NetConfig): for i in interface.members: data += " %s" % i.name data += "\n" - for i in interface.members: - data += " pre-up ip addr flush dev %s\n" % i.name + for mem in interface.members: + if isinstance(mem, objects.Interface): + data += " pre-up ip addr flush dev %s\n" % mem.name if interface.primary_interface_name: mac = utils.interface_mac(interface.primary_interface_name) data += (" ovs_extra set bridge %s " diff --git a/os_net_config/impl_ifcfg.py b/os_net_config/impl_ifcfg.py index f6030540..ab6bf4d6 100644 --- a/os_net_config/impl_ifcfg.py +++ b/os_net_config/impl_ifcfg.py @@ -61,7 +61,8 @@ class IfcfgNetConfig(os_net_config.NetConfig): data += "HOTPLUG=no\n" if isinstance(base_opt, objects.Vlan): 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: data += "DEVICETYPE=ovs\n" if base_opt.bridge_name: diff --git a/os_net_config/objects.py b/os_net_config/objects.py index b73122c3..12b1c990 100644 --- a/os_net_config/objects.py +++ b/os_net_config/objects.py @@ -205,7 +205,8 @@ class Vlan(_BaseOpts): @staticmethod 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') opts = _BaseOpts.base_opts_from_json(json) return Vlan(device, vlan_id, *opts)