From 58e069092dc052c913600bfd27d17d12c278c25a Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Fri, 4 Jan 2013 20:07:37 +0000 Subject: Introduce support for 802.1qbg and 802.1qbh to Nova VIF model Define the nova network VIF model properties for supporting 802.1qbg / 802.1qbh networking in hypervisor drivers. Also wire up support to the libvirt driver for these new modes Blueprint: libvirt-vif-driver Change-Id: I91039790900170bfd698ea484d5f8a22445806ae Signed-off-by: Daniel P. Berrange --- nova/virt/libvirt/config.py | 3 ++- nova/virt/libvirt/designer.py | 32 ++++++++++++++++++++++++ nova/virt/libvirt/vif.py | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 1 deletion(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index ed5b21c79..d6ef3fca9 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -549,6 +549,7 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice): self.mac_addr = None self.script = None self.source_dev = None + self.source_mode = "private" self.vporttype = None self.vportparams = [] self.filtername = None @@ -571,7 +572,7 @@ class LibvirtConfigGuestInterface(LibvirtConfigGuestDevice): dev.append(etree.Element("script", path=self.script)) elif self.net_type == "direct": dev.append(etree.Element("source", dev=self.source_dev, - mode="private")) + mode=self.source_mode)) else: dev.append(etree.Element("source", bridge=self.source_dev)) diff --git a/nova/virt/libvirt/designer.py b/nova/virt/libvirt/designer.py index b832db4fa..176eeef4c 100644 --- a/nova/virt/libvirt/designer.py +++ b/nova/virt/libvirt/designer.py @@ -70,6 +70,38 @@ def set_vif_host_backend_ovs_config(conf, brname, interfaceid, tapname=None): conf.script = "" +def set_vif_host_backend_802qbg_config(conf, devname, managerid, + typeid, typeidversion, + instanceid, tapname=None): + """Populate a LibvirtConfigGuestInterface instance + with host backend details for an 802.1qbg device""" + + conf.net_type = "direct" + conf.source_dev = devname + conf.source_mode = "vepa" + conf.vporttype = "802.1Qbg" + conf.add_vport_param("managerid", managerid) + conf.add_vport_param("typeid", typeid) + conf.add_vport_param("typeidversion", typeidversion) + conf.add_vport_param("instanceid", instanceid) + if tapname: + conf.target_dev = tapname + + +def set_vif_host_backend_802qbh_config(conf, devname, profileid, + tapname=None): + """Populate a LibvirtConfigGuestInterface instance + with host backend details for an 802.1qbh device""" + + conf.net_type = "direct" + conf.source_dev = devname + conf.source_mode = "vepa" + conf.vporttype = "802.1Qbh" + conf.add_vport_param("profileid", profileid) + if tapname: + conf.target_dev = tapname + + def set_vif_host_backend_filter_config(conf, name, primary_addr, dhcp_server=None, diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index 4a56e3fb6..0990f29b1 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -196,6 +196,35 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): return self.get_config_ovs_ethernet(instance, network, mapping) + def get_config_802qbg(self, instance, network, mapping): + conf = super(LibvirtGenericVIFDriver, + self).get_config(instance, + network, + mapping) + + params = mapping["qbg_params"] + designer.set_vif_host_backend_802qbg_config( + conf, network["interface"], + params['managerid'], + params['typeid'], + params['typeidversion'], + params['instanceid']) + + return conf + + def get_config_802qbh(self, instance, network, mapping): + conf = super(LibvirtGenericVIFDriver, + self).get_config(instance, + network, + mapping) + + params = mapping["qbh_params"] + designer.set_vif_host_backend_802qbh_config( + conf, network["interface"], + params['profileid']) + + return conf + def get_config(self, instance, network, mapping): vif_type = mapping.get('vif_type') @@ -212,6 +241,10 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): return self.get_config_bridge(instance, network, mapping) elif vif_type == network_model.VIF_TYPE_OVS: return self.get_config_ovs(instance, network, mapping) + elif vif_type == network_model.VIF_TYPE_802_QBG: + return self.get_config_802qbg(instance, network, mapping) + elif vif_type == network_model.VIF_TYPE_802_QBH: + return self.get_config_802qbh(instance, network, mapping) else: raise exception.NovaException( _("Unexpected vif_type=%s") % vif_type) @@ -294,6 +327,14 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): else: self.plug_ovs_ethernet(instance, vif) + def plug_802qbg(self, instance, vif): + super(LibvirtGenericVIFDriver, + self).plug(instance, vif) + + def plug_802qbh(self, instance, vif): + super(LibvirtGenericVIFDriver, + self).plug(instance, vif) + def plug(self, instance, vif): network, mapping = vif vif_type = mapping.get('vif_type') @@ -311,6 +352,10 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): self.plug_bridge(instance, vif) elif vif_type == network_model.VIF_TYPE_OVS: self.plug_ovs(instance, vif) + elif vif_type == network_model.VIF_TYPE_802_QBG: + self.plug_802qbg(instance, vif) + elif vif_type == network_model.VIF_TYPE_802_QBH: + self.plug_802qbh(instance, vif) else: raise exception.NovaException( _("Unexpected vif_type=%s") % vif_type) @@ -369,6 +414,14 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): else: self.unplug_ovs_ethernet(instance, vif) + def unplug_802qbg(self, instance, vif): + super(LibvirtGenericVIFDriver, + self).unplug(instance, vif) + + def unplug_802qbh(self, instance, vif): + super(LibvirtGenericVIFDriver, + self).unplug(instance, vif) + def unplug(self, instance, vif): network, mapping = vif vif_type = mapping.get('vif_type') @@ -386,6 +439,10 @@ class LibvirtGenericVIFDriver(LibvirtBaseVIFDriver): self.unplug_bridge(instance, vif) elif vif_type == network_model.VIF_TYPE_OVS: self.unplug_ovs(instance, vif) + elif vif_type == network_model.VIF_TYPE_802_QBG: + self.unplug_802qbg(instance, vif) + elif vif_type == network_model.VIF_TYPE_802_QBH: + self.unplug_802qbh(instance, vif) else: raise exception.NovaException( _("Unexpected vif_type=%s") % vif_type) -- cgit