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);
}
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);
}
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);
}
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");
}
}
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));
}
Aggregations