Search in sources :

Example 6 with NodeConnectorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method remove.

@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface del) {
    if (!L2vlan.class.equals(del.getType()) && !Tunnel.class.equals(del.getType())) {
        return;
    }
    List<String> ofportIds = del.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    String interfaceName = del.getName();
    Port port = dhcpPortCache.get(interfaceName);
    if (NeutronConstants.IS_DHCP_PORT.test(port)) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    DhcpInterfaceRemoveJob job = new DhcpInterfaceRemoveJob(dhcpManager, dhcpExternalTunnelManager, dataBroker, del, dpnId, interfaceManager, elanService, port);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
    dhcpPortCache.remove(interfaceName);
}
Also used : Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceRemoveJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceRemoveJob)

Example 7 with NodeConnectorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method update.

@Override
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(update.getType()) && !Tunnel.class.equals(update.getType())) {
        return;
    }
    if ((original.getOperStatus().getIntValue() ^ update.getOperStatus().getIntValue()) == 0) {
        LOG.trace("Interface operstatus {} is same", update.getOperStatus());
        return;
    }
    if (original.getOperStatus().equals(OperStatus.Unknown) || update.getOperStatus().equals(OperStatus.Unknown)) {
        LOG.trace("New/old interface state is unknown not handling");
        return;
    }
    List<String> ofportIds = update.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    String interfaceName = update.getName();
    DhcpInterfaceUpdateJob job = new DhcpInterfaceUpdateJob(dhcpExternalTunnelManager, dataBroker, interfaceName, dpnId, update.getOperStatus(), interfaceManager);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceUpdateJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceUpdateJob)

Example 8 with NodeConnectorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.

the class DhcpInterfaceEventListener method add.

@Override
protected void add(InstanceIdentifier<Interface> identifier, Interface add) {
    // We're only interested in Vlan and Tunnel ports
    if (!L2vlan.class.equals(add.getType()) && !Tunnel.class.equals(add.getType())) {
        return;
    }
    String interfaceName = add.getName();
    LOG.trace("DhcpInterfaceAddJob to be created for interface {}", interfaceName);
    List<String> ofportIds = add.getLowerLayerIf();
    if (ofportIds == null || ofportIds.isEmpty()) {
        return;
    }
    Port port = dhcpManager.getNeutronPort(interfaceName);
    if (NeutronConstants.IS_DHCP_PORT.test(port)) {
        return;
    }
    dhcpPortCache.put(interfaceName, port);
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
    BigInteger dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
    DhcpInterfaceAddJob job = new DhcpInterfaceAddJob(dhcpManager, dhcpExternalTunnelManager, dataBroker, add, dpnId, interfaceManager, elanService);
    jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), job, DhcpMConstants.RETRY_COUNT);
}
Also used : Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) BigInteger(java.math.BigInteger) DhcpInterfaceAddJob(org.opendaylight.netvirt.dhcpservice.jobs.DhcpInterfaceAddJob)

Example 9 with NodeConnectorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.

the class DhcpSubnetListener method installNeutronPortEntries.

private void installNeutronPortEntries(List<Uuid> portList) {
    LOG.trace("DhcpSubnetListener installNeutronPortEntries : portList: {}", portList);
    for (Uuid portIntf : portList) {
        NodeConnectorId nodeConnectorId = getNodeConnectorIdForPortIntf(portIntf);
        BigInteger dpId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
        String interfaceName = portIntf.getValue();
        Port port = dhcpManager.getNeutronPort(interfaceName);
        String vmMacAddress = port.getMacAddress().getValue();
        // check whether any changes have happened
        LOG.trace("DhcpSubnetListener installNeutronPortEntries dpId: {} vmMacAddress : {}", dpId, vmMacAddress);
        // Bind the dhcp service when enabled
        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)), LOG, "Error writing to the datastore");
        // install the entries
        ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> dhcpManager.installDhcpEntries(dpId, vmMacAddress, tx)), LOG, "Error writing to the datastore");
    }
}
Also used : SubnetmapKey(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapKey) InterfacesState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState) LoggerFactory(org.slf4j.LoggerFactory) Singleton(javax.inject.Singleton) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) SubnetmapBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.SubnetmapBuilder) Neutron(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron) Inject(javax.inject.Inject) AsyncClusteredDataTreeChangeListenerBase(org.opendaylight.genius.datastoreutils.AsyncClusteredDataTreeChangeListenerBase) PreDestroy(javax.annotation.PreDestroy) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) Optional(com.google.common.base.Optional) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Subnetmap(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.subnetmaps.Subnetmap) ManagedNewTransactionRunnerImpl(org.opendaylight.genius.infra.ManagedNewTransactionRunnerImpl) BigInteger(java.math.BigInteger) NwConstants(org.opendaylight.genius.mdsalutil.NwConstants) MDSALUtil(org.opendaylight.genius.mdsalutil.MDSALUtil) DhcpserviceConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dhcpservice.config.rev150710.DhcpserviceConfig) Logger(org.slf4j.Logger) Subnet(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet) ManagedNewTransactionRunner(org.opendaylight.genius.infra.ManagedNewTransactionRunner) Subnetmaps(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.Subnetmaps) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.Subnets) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) Objects(java.util.Objects) ExecutionException(java.util.concurrent.ExecutionException) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) List(java.util.List) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) PostConstruct(javax.annotation.PostConstruct) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) Port(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port) BigInteger(java.math.BigInteger)

Example 10 with NodeConnectorId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project netvirt by opendaylight.

the class QosNeutronUtils method getDpIdFromInterface.

private static BigInteger getDpIdFromInterface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
    String lowerLayerIf = ifState.getLowerLayerIf().get(0);
    NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
    return BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(nodeConnectorId));
}
Also used : NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)

Aggregations

NodeConnectorId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId)86 BigInteger (java.math.BigInteger)31 NodeConnectorKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)19 NodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector)17 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)16 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)15 FlowCapableNodeConnector (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector)12 Test (org.junit.Test)11 Nodes (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes)11 ArrayList (java.util.ArrayList)10 Collections (java.util.Collections)10 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)9 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)9 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)8 NodeConnectorStatisticsAndPortNumberMap (org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.node.connector.statistics.and.port.number.map.NodeConnectorStatisticsAndPortNumberMap)8 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)7 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)7 List (java.util.List)6 ExecutionException (java.util.concurrent.ExecutionException)6 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)5