Search in sources :

Example 11 with PhysAddress

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.

the class OvsInterfaceStateAddHelper method addState.

public List<ListenableFuture<Void>> addState(String interfaceName, Interface parentInterface) {
    if (parentInterface.getLowerLayerIf() == null || parentInterface.getLowerLayerIf().isEmpty()) {
        LOG.trace("Cannot obtain lower layer if, not proceeding with Interface State addition for interface: {}", interfaceName);
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(parentInterface.getLowerLayerIf().get(0));
    PhysAddress physAddress = parentInterface.getPhysAddress();
    long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
    return addState(nodeConnectorId, interfaceName, portNo, physAddress);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 12 with PhysAddress

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.

the class OvsInterfaceStateUpdateHelper method updateState.

public List<ListenableFuture<Void>> updateState(String interfaceName, FlowCapableNodeConnector flowCapableNodeConnectorNew, FlowCapableNodeConnector flowCapableNodeConnectorOld) {
    LOG.debug("Updating interface state information for interface: {}", interfaceName);
    Interface.OperStatus operStatusNew = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorNew);
    MacAddress macAddressNew = flowCapableNodeConnectorNew.getHardwareAddress();
    Interface.OperStatus operStatusOld = InterfaceManagerCommonUtils.getOpState(flowCapableNodeConnectorOld);
    MacAddress macAddressOld = flowCapableNodeConnectorOld.getHardwareAddress();
    boolean opstateModified = !operStatusNew.equals(operStatusOld);
    boolean hardwareAddressModified = !macAddressNew.equals(macAddressOld);
    if (!opstateModified && !hardwareAddressModified) {
        LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
        return Collections.emptyList();
    }
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
    // For monitoring enabled tunnels, skip opstate update
    if (isTunnelInterface(iface) && !modifyTunnelOpState(iface, opstateModified)) {
        LOG.debug("skip interface-state updation for monitoring enabled tunnel interface {}", interfaceName);
        opstateModified = false;
    }
    if (!opstateModified && !hardwareAddressModified) {
        LOG.debug("If State entry for port: {} Not Modified.", interfaceName);
        return Collections.emptyList();
    }
    InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
    if (hardwareAddressModified) {
        LOG.debug("Hw-Address Modified for Port: {}", interfaceName);
        PhysAddress physAddress = new PhysAddress(macAddressNew.getValue());
        ifaceBuilder.setPhysAddress(physAddress);
    }
    if (opstateModified) {
        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            // modify the attributes in interface operational DS
            handleInterfaceStateUpdates(iface, tx, ifaceBuilder, true, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
            // start/stop monitoring based on opState
            if (isTunnelInterface(iface)) {
                handleTunnelMonitoringUpdates(iface.getAugmentation(IfTunnel.class), iface.getName(), operStatusNew);
            }
        }));
    } else {
        return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
            // modify the attributes in interface operational DS
            handleInterfaceStateUpdates(iface, tx, ifaceBuilder, false, interfaceName, flowCapableNodeConnectorNew.getName(), operStatusNew);
        }));
    }
}
Also used : IfmUtil(org.opendaylight.genius.interfacemanager.IfmUtil) AlivenessMonitorUtils(org.opendaylight.genius.interfacemanager.commons.AlivenessMonitorUtils) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) FlowCapableNodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector) Logger(org.slf4j.Logger) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) LoggerFactory(org.slf4j.LoggerFactory) InterfaceManagerCommonUtils(org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils) Singleton(javax.inject.Singleton) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Inject(javax.inject.Inject) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Collections(java.util.Collections) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceKey) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 13 with PhysAddress

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.

the class ArpUtilImpl method checkAndFireMacChangedNotification.

private void checkAndFireMacChangedNotification(String interfaceName, InetAddress inetAddr, byte[] macAddressBytes) throws InterruptedException {
    IpAddress ip = new IpAddress(inetAddr.getHostAddress().toCharArray());
    String macAddress = NWUtil.toStringMacAddress(macAddressBytes);
    PhysAddress mac = new PhysAddress(macAddress);
    if (!macAddress.equals(macsDB.get(interfaceName + "-" + inetAddr.getHostAddress()))) {
        if (LOG.isTraceEnabled()) {
            LOG.trace("mac address changed for {}", inetAddr);
        }
        MacChangedBuilder builder = new MacChangedBuilder();
        builder.setInterface(interfaceName);
        builder.setIpaddress(ip);
        builder.setMacaddress(mac);
        notificationPublishService.putNotification(builder.build());
    }
}
Also used : MacChangedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.MacChangedBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 14 with PhysAddress

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.

the class ArpUtilImpl method fireArpReqRecvdNotification.

private void fireArpReqRecvdNotification(String interfaceName, InetAddress srcInetAddr, byte[] srcMac, InetAddress dstInetAddr, int tableId, BigInteger metadata) throws InterruptedException {
    arpReqRecvd.mark();
    String macAddress = NWUtil.toStringMacAddress(srcMac);
    ArpRequestReceivedBuilder builder = new ArpRequestReceivedBuilder();
    builder.setInterface(interfaceName);
    builder.setOfTableId((long) tableId);
    builder.setSrcIpaddress(new IpAddress(srcInetAddr.getHostAddress().toCharArray()));
    builder.setDstIpaddress(new IpAddress(dstInetAddr.getHostAddress().toCharArray()));
    builder.setSrcMac(new PhysAddress(macAddress));
    builder.setMetadata(metadata);
    ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(builder.build());
    if (offerNotification != null && offerNotification.equals(NotificationPublishService.REJECTED)) {
        arpReqRecvdNotificationRejected.mark();
    } else {
        arpReqRecvdNotification.mark();
    }
}
Also used : ArpRequestReceivedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.ArpRequestReceivedBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 15 with PhysAddress

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project genius by opendaylight.

the class ArpUtilTest method testGetMac.

@Test
public void testGetMac() throws Exception {
    final InterfaceAddress interfaceAddress = new InterfaceAddressBuilder().setInterface(INTERFACE_NAME).setIpAddress(new IpAddress(Ipv4Address.getDefaultInstance("192.168.0.1"))).setMacaddress(new PhysAddress("1F:1F:1F:1F:1F:1F")).build();
    final List<InterfaceAddress> itf = Arrays.asList(interfaceAddress);
    GetMacInput getMacInput = new GetMacInputBuilder().setIpaddress(new IpAddress(Ipv4Address.getDefaultInstance("192.168.0.2"))).setInterfaceAddress(itf).build();
    // request payload
    PacketReceived packetReceived = ArpUtilTestUtil.createPayload(0);
    Future<RpcResult<GetMacOutput>> output = odlArputilService.getMac(getMacInput);
    arpUtil.onPacketReceived(packetReceived);
    Assert.assertEquals("00:01:02:03:04:05", output.get().getResult().getMacaddress().getValue());
}
Also used : InterfaceAddressBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddressBuilder) InterfaceAddress(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.interfaces.InterfaceAddress) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetMacInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.GetMacInput) PacketReceived(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) GetMacInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.GetMacInputBuilder) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress) Test(org.junit.Test)

Aggregations

PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)38 ArrayList (java.util.ArrayList)17 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)17 BigInteger (java.math.BigInteger)15 InterfaceInfo (org.opendaylight.genius.interfacemanager.globals.InterfaceInfo)8 MacEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry)8 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)7 Collections (java.util.Collections)7 NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)7 StaticMacEntries (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntries)6 List (java.util.List)5 Inject (javax.inject.Inject)5 Singleton (javax.inject.Singleton)5 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)5 ManagedNewTransactionRunner (org.opendaylight.genius.infra.ManagedNewTransactionRunner)5 ManagedNewTransactionRunnerImpl (org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl)5 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)5 ElanInterfaceMac (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan._interface.forwarding.entries.ElanInterfaceMac)5 ElanInstance (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance)5 StaticMacEntriesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.elan._interface.StaticMacEntriesBuilder)5