def _test_is_firewall_required(self, port_filter, driver, expect): vif = model.VIF(id="dc065497-3c8d-4f44-8fb4-e1d33c16a536", type=model.VIF_TYPE_BRIDGE, address="22:52:25:62:e2:aa", network=model.Network( id="b82c1929-051e-481d-8110-4669916c7915", label="Demo Net", subnets=[]), details={ model.VIF_DETAILS_PORT_FILTER: port_filter, }) self.flags(firewall_driver=driver) self.assertEqual(expect, os_vif_util._is_firewall_required(vif))
def _test_is_firewall_required(self, port_filter, driver, expect): vif = model.VIF( id="dc065497-3c8d-4f44-8fb4-e1d33c16a536", type=model.VIF_TYPE_BRIDGE, address="22:52:25:62:e2:aa", network=model.Network( id="b82c1929-051e-481d-8110-4669916c7915", label="Demo Net", subnets=[]), details={ model.VIF_DETAILS_PORT_FILTER: port_filter, } ) self.flags(firewall_driver=driver) self.assertEqual(expect, os_vif_util._is_firewall_required(vif))
def _nova_to_osvif_vif_vhostuser(vif): if vif['details'].get(model.VIF_DETAILS_VHOSTUSER_FP_PLUG, False): if vif['details'].get(model.VIF_DETAILS_VHOSTUSER_OVS_PLUG, False): profile = objects.vif.VIFPortProfileFPOpenVSwitch( interface_id=vif.get('ovs_interfaceid') or vif['id'], datapath_type=vif['details'].get( model.VIF_DETAILS_OVS_DATAPATH_TYPE)) if os_vif_util._is_firewall_required( vif) or vif.is_hybrid_plug_enabled(): profile.bridge_name = os_vif_util._get_hybrid_bridge_name(vif) profile.hybrid_plug = True else: profile.hybrid_plug = False if vif["network"]["bridge"] is not None: profile.bridge_name = vif["network"]["bridge"] else: profile = objects.vif.VIFPortProfileFPBridge() if vif["network"]["bridge"] is not None: profile.bridge_name = vif["network"]["bridge"] obj = os_vif_util._get_vif_instance( vif, objects.vif.VIFVHostUser, plugin="vhostuser_fp", vif_name=os_vif_util.get_vif_name(vif), port_profile=profile) os_vif_util._set_vhostuser_settings(vif, obj) return obj elif vif['details'].get(model.VIF_DETAILS_VHOSTUSER_OVS_PLUG, False): profile = objects.vif.VIFPortProfileOpenVSwitch( interface_id=vif.get('ovs_interfaceid') or vif['id'], datapath_type=vif['details'].get( model.VIF_DETAILS_OVS_DATAPATH_TYPE)) vif_name = ('vhu' + vif['id'])[:model.NIC_NAME_LEN] obj = os_vif_util._get_vif_instance(vif, objects.vif.VIFVHostUser, port_profile=profile, plugin="ovs", vif_name=vif_name) if vif["network"]["bridge"] is not None: obj.bridge_name = vif["network"]["bridge"] os_vif_util._set_vhostuser_settings(vif, obj) return obj elif vif['details'].get(model.VIF_DETAILS_VHOSTUSER_VROUTER_PLUG, False): obj = os_vif_util._get_vif_instance( vif, objects.vif.VIFVHostUser, plugin="contrail_vrouter", vif_name=os_vif_util._get_vif_name(vif)) os_vif_util._set_vhostuser_settings(vif, obj) return obj #added for kaloom kvs elif vif['details'].get(VIF_DETAILS_VHOSTUSER_KVS_PLUG, False): profile = objects.vif.VIFPortProfileOpenVSwitch( interface_id=vif.get('ovs_interfaceid') or vif['id'], datapath_type='') vif_name = ('vhu' + vif['id'])[:model.NIC_NAME_LEN] obj = os_vif_util._get_vif_instance(vif, objects.vif.VIFVHostUser, port_profile=profile, plugin="kvs_kaloom", vif_name=vif_name) if vif["network"]["bridge"] is not None: obj.bridge_name = vif["network"]["bridge"] os_vif_util._set_vhostuser_settings(vif, obj) return obj else: raise NotImplementedError()