use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class DhcpInterfaceAddJob method call.
@Override
public List<ListenableFuture<Void>> call() {
String interfaceName = interfaceAdd.getName();
LOG.trace("Received add DCN for interface {}, dpid {}", interfaceName, dpnId);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface = interfaceManager.getInterfaceInfoFromConfigDataStore(interfaceName);
if (iface != null) {
IfTunnel tunnelInterface = iface.getAugmentation(IfTunnel.class);
if (tunnelInterface != null && !tunnelInterface.isInternal()) {
IpAddress tunnelIp = tunnelInterface.getTunnelDestination();
List<BigInteger> dpns = DhcpServiceUtils.getListOfDpns(dataBroker);
if (dpns.contains(dpnId)) {
return dhcpExternalTunnelManager.handleTunnelStateUp(tunnelIp, dpnId);
}
return Collections.emptyList();
}
}
if (!dpnId.equals(DhcpMConstants.INVALID_DPID)) {
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.debug("DHCP is not enabled for port {}", port.getName());
return Collections.emptyList();
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
// Support for VM migration use cases.
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx)));
LOG.info("DhcpInterfaceEventListener add isEnableDhcp:{}", subnet.isEnableDhcp());
futures.addAll(installDhcpEntries(interfaceAdd.getName(), dpnId));
LOG.trace("Checking ElanDpnInterface {} for dpn {} ", interfaceName, dpnId);
String subnetId = subnet.getUuid().getValue();
java.util.Optional<SubnetToDhcpPort> subnetToDhcp = DhcpServiceUtils.getSubnetDhcpPortData(dataBroker, subnetId);
if (!subnetToDhcp.isPresent()) {
return Collections.emptyList();
}
LOG.trace("Installing the Arp responder for interface {} with DHCP MAC {} & IP {}.", interfaceName, subnetToDhcp.get().getPortMacaddress(), subnetToDhcp.get().getPortFixedip());
ArpReponderInputBuilder builder = new ArpReponderInputBuilder();
builder.setDpId(dpnId).setInterfaceName(interfaceName).setSpa(subnetToDhcp.get().getPortFixedip()).setSha(subnetToDhcp.get().getPortMacaddress()).setLportTag(interfaceAdd.getIfIndex());
builder.setInstructions(ArpResponderUtil.getInterfaceInstructions(interfaceManager, interfaceName, subnetToDhcp.get().getPortFixedip(), subnetToDhcp.get().getPortMacaddress()));
elanService.addArpResponderFlow(builder.buildForInstallFlow());
return futures;
}
return Collections.emptyList();
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class CoeUtils method getAttachedInterfaceAndMac.
public static Pair<String, String> getAttachedInterfaceAndMac(OvsdbTerminationPointAugmentation ovsdbTp) {
String interfaceName = null;
String macAddress = null;
if (ovsdbTp != null) {
List<InterfaceExternalIds> ifaceExtIds = ovsdbTp.getInterfaceExternalIds();
if (ifaceExtIds != null) {
Iterator var2 = ifaceExtIds.iterator();
while (var2.hasNext()) {
if (interfaceName != null && macAddress != null) {
break;
}
InterfaceExternalIds entry = (InterfaceExternalIds) var2.next();
if (entry.getExternalIdKey().equals("iface-id")) {
interfaceName = entry.getExternalIdValue();
continue;
}
if (entry.getExternalIdKey().equals("attached-mac")) {
macAddress = entry.getExternalIdValue();
continue;
}
}
}
}
return Pair.of(interfaceName, macAddress);
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class ElanMacTableGet method doExecute.
@Override
protected Object doExecute() {
LOG.debug("Executing elan mac table get command for {}", elanName);
Collection<MacEntry> macTables = elanProvider.getElanMacTable(elanName);
if (!macTables.isEmpty()) {
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy:HH:mm:ss");
session.getConsole().println(getMacTableHeaderOutput());
session.getConsole().println(elanName);
for (MacEntry mac : macTables) {
boolean isStatic = mac.isIsStaticAddress();
session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", mac.getInterface(), mac.getMacAddress().getValue(), ""));
session.getConsole().println(String.format(ElanCLIUtils.MAC_TABLE_CLI_FORMAT, "", isStatic, "", isStatic ? "-" : formatter.format(new Date(mac.getControllerLearnedForwardingEntryTimestamp().longValue()))));
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class NeutronvpnUtils method createVpnPortFixedIpToPort.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void createVpnPortFixedIpToPort(String vpnName, String fixedIp, String portName, String macAddress, boolean isSubnetIp, WriteTransaction writeConfigTxn) {
InstanceIdentifier<VpnPortipToPort> id = NeutronvpnUtils.buildVpnPortipToPortIdentifier(vpnName, fixedIp);
VpnPortipToPortBuilder builder = new VpnPortipToPortBuilder().setKey(new VpnPortipToPortKey(fixedIp, vpnName)).setVpnName(vpnName).setPortFixedip(fixedIp).setPortName(portName).setMacAddress(macAddress).setSubnetIp(isSubnetIp);
try {
if (writeConfigTxn != null) {
writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, id, builder.build());
} else {
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, id, builder.build());
}
LOG.trace("Neutron port with fixedIp: {}, vpn {}, interface {}, mac {}, isSubnetIp {} added to " + "VpnPortipToPort DS", fixedIp, vpnName, portName, macAddress, isSubnetIp);
} catch (Exception e) {
LOG.error("Failure while creating VPNPortFixedIpToPort map for vpn {} - fixedIP {}", vpnName, fixedIp, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class NeutronPortChangeListener method setExternalGwMac.
private void setExternalGwMac(Port routerGwPort, Uuid routerId) {
// During full-sync networking-odl syncs routers before ports. As such,
// the MAC of the router's gw port is not available to be set when the
// router is written. We catch that here.
InstanceIdentifier<Routers> routersId = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
Optional<Routers> optionalRouter = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routersId);
if (!optionalRouter.isPresent()) {
return;
}
Routers extRouters = optionalRouter.get();
if (extRouters.getExtGwMacAddress() != null) {
return;
}
RoutersBuilder builder = new RoutersBuilder(extRouters);
builder.setExtGwMacAddress(routerGwPort.getMacAddress().getValue());
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersId, builder.build());
}
Aggregations