def _add_arp_protection(self, machine, addresses, extra_port_dict=None): port_dict = {'fixed_ips': [{'ip_address': a} for a in addresses]} if extra_port_dict: port_dict.update(extra_port_dict) name = net_helpers.VethFixture.get_peer_name(machine.port.name) arp_protect.setup_arp_spoofing_protection(name, port_dict) self.addCleanup(arp_protect.delete_arp_spoofing_protection, [name])
def _do_test_setup_arp_spoofing(self, vif, port_details): with contextlib.nested( mock.patch.object( arp_protect, 'ebtables', return_value='\n'.join(self.EBTABLES_EMPTY_SAMPLE) ) ) as ebtables_fn: # noqa arp_protect.setup_arp_spoofing_protection(vif, port_details)
def treat_devices_added_updated(self, devices): try: devices_details_list = self.plugin_rpc.get_devices_details_list( self.context, devices, self.agent_id) except Exception as e: LOG.debug("Unable to get port details for " "%(devices)s: %(e)s", {'devices': devices, 'e': e}) # resync is needed return True for device_details in devices_details_list: device = device_details['device'] LOG.debug("Port %s added", device) if 'port_id' in device_details: LOG.info(_LI("Port %(device)s updated. Details: %(details)s"), {'device': device, 'details': device_details}) if self.prevent_arp_spoofing: port = self.br_mgr.get_tap_device_name( device_details['port_id']) arp_protect.setup_arp_spoofing_protection(port, device_details) if device_details['admin_state_up']: # create the networking for the port network_type = device_details.get('network_type') if network_type: segmentation_id = device_details.get('segmentation_id') else: # compatibility with pre-Havana RPC vlan_id encoding vlan_id = device_details.get('vlan_id') (network_type, segmentation_id) = lconst.interpret_vlan_id(vlan_id) if self.br_mgr.add_interface( device_details['network_id'], network_type, device_details['physical_network'], segmentation_id, device_details['port_id']): # update plugin about port status self.plugin_rpc.update_device_up(self.context, device, self.agent_id, cfg.CONF.host) else: self.plugin_rpc.update_device_down(self.context, device, self.agent_id, cfg.CONF.host) else: self.remove_port_binding(device_details['network_id'], device_details['port_id']) else: LOG.info(_LI("Device %s not defined on plugin"), device) return False