use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class AlivenessMonitorUtils method startArpMonitoring.
public static void startArpMonitoring(MacEntry macEntry, Long arpMonitorProfileId, AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker, INeutronVpnManager neutronVpnService, IInterfaceManager interfaceManager) {
if (interfaceManager.isExternalInterface(macEntry.getInterfaceName())) {
LOG.debug("ARP monitoring is currently not supported through external interfaces," + "skipping ARP monitoring from interface {} for IP {} (last known MAC {})", macEntry.getInterfaceName(), macEntry.getIpAddress().getHostAddress(), macEntry.getMacAddress());
return;
}
Optional<IpAddress> gatewayIpOptional = VpnUtil.getGatewayIpAddressFromInterface(macEntry.getInterfaceName(), neutronVpnService);
if (!gatewayIpOptional.isPresent()) {
LOG.error("Error while retrieving GatewayIp for interface{}", macEntry.getInterfaceName());
return;
}
final IpAddress gatewayIp = gatewayIpOptional.get();
Optional<String> gatewayMacOptional = VpnUtil.getGWMacAddressFromInterface(macEntry, gatewayIp, dataBroker);
if (!gatewayMacOptional.isPresent()) {
LOG.error("Error while retrieving GatewayMac for interface{}", macEntry.getInterfaceName());
return;
}
final PhysAddress gatewayMac = new PhysAddress(gatewayMacOptional.get());
if (arpMonitorProfileId == null || arpMonitorProfileId.equals(0L)) {
Optional<Long> profileIdOptional = allocateProfile(alivenessMonitorService, ArpConstants.FAILURE_THRESHOLD, ArpConstants.ARP_CACHE_TIMEOUT_MILLIS, ArpConstants.MONITORING_WINDOW, EtherTypes.Arp);
if (!profileIdOptional.isPresent()) {
LOG.error("Error while allocating Profile Id for alivenessMonitorService");
return;
}
arpMonitorProfileId = profileIdOptional.get();
}
IpAddress targetIp = new IpAddress(new Ipv4Address(macEntry.getIpAddress().getHostAddress()));
MonitorStartInput arpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder().setSource(new SourceBuilder().setEndpointType(getSourceEndPointType(macEntry.getInterfaceName(), gatewayIp, gatewayMac)).build()).setDestination(new DestinationBuilder().setEndpointType(getEndPointIpAddress(targetIp)).build()).setMode(MonitoringMode.OneOne).setProfileId(arpMonitorProfileId).build()).build();
try {
Future<RpcResult<MonitorStartOutput>> result = alivenessMonitorService.monitorStart(arpMonitorInput);
RpcResult<MonitorStartOutput> rpcResult = result.get();
long monitorId;
if (rpcResult.isSuccessful()) {
monitorId = rpcResult.getResult().getMonitorId();
createOrUpdateInterfaceMonitorIdMap(monitorId, macEntry);
LOG.trace("Started ARP monitoring with id {}", monitorId);
} else {
LOG.warn("RPC Call to start monitoring returned with Errors {}", rpcResult.getErrors());
}
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when starting monitoring", e);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class ElanL2GatewayUtils method removeRemoteUcastMacsFromExternalDevice.
/**
* Removes the given MAC Addresses from the specified External Device.
*
* @param deviceNodeId
* the device node id
* @param macAddresses
* the mac addresses
* @return the listenable future
*/
private ListenableFuture<Void> removeRemoteUcastMacsFromExternalDevice(String deviceNodeId, String logicalSwitchName, List<PhysAddress> macAddresses) {
NodeId nodeId = new NodeId(deviceNodeId);
// TODO (eperefr)
List<MacAddress> lstMac = macAddresses.stream().filter(Objects::nonNull).map(physAddress -> new MacAddress(physAddress.getValue())).collect(Collectors.toList());
return HwvtepUtils.deleteRemoteUcastMacs(broker, nodeId, logicalSwitchName, lstMac);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress in project netvirt by opendaylight.
the class ElanL2GatewayUtils method installL2GwUcastMacInElan.
public void installL2GwUcastMacInElan(final ElanInstance elan, final L2GatewayDevice extL2GwDevice, final String macToBeAdded, final LocalUcastMacs localUcastMacs, String interfaceName) {
final String extDeviceNodeId = extL2GwDevice.getHwvtepNodeId();
final String elanInstanceName = elan.getElanInstanceName();
final Collection<DpnInterfaces> elanDpns = getElanDpns(elanInstanceName);
ConcurrentMap<String, L2GatewayDevice> elanL2GwDevices = ElanL2GwCacheUtils.getInvolvedL2GwDevices(elanInstanceName);
// DMAC table
if (elanDpns.size() > 0 || elanL2GwDevices.values().size() > 0) {
String jobKey = elanInstanceName + ":" + macToBeAdded;
IpAddress extL2GwDeviceTepIp = extL2GwDevice.getTunnelIp();
List<PhysAddress> macList = Lists.newArrayList(new PhysAddress(macToBeAdded));
elanClusterUtils.runOnlyInOwnerNode(jobKey, "install l2gw macs in dmac table", () -> {
if (doesLocalUcastMacExistsInCache(extL2GwDevice, localUcastMacs)) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
for (DpnInterfaces elanDpn : elanDpns) {
futures.addAll(elanDmacUtils.installDmacFlowsToExternalRemoteMacInBatch(elanDpn.getDpId(), extDeviceNodeId, elan.getElanTag(), ElanUtils.getVxlanSegmentationId(elan), macToBeAdded, elanInstanceName, interfaceName));
}
for (L2GatewayDevice otherDevice : elanL2GwDevices.values()) {
if (!otherDevice.getHwvtepNodeId().equals(extDeviceNodeId) && !areMLAGDevices(extL2GwDevice, otherDevice)) {
final String hwvtepId = otherDevice.getHwvtepNodeId();
final String logicalSwitchName = elanInstanceName;
futures.add(HwvtepUtils.installUcastMacs(broker, hwvtepId, macList, logicalSwitchName, extL2GwDeviceTepIp));
}
}
return futures;
} else {
LOG.trace("Skipping install of dmac flows for mac {} as it is not found in cache", macToBeAdded);
}
return Collections.emptyList();
});
}
}
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 InterfacemgrProvider method getInterfaceInfoFromOperationalDataStore.
@Override
public InterfaceInfo getInterfaceInfoFromOperationalDataStore(String interfaceName, InterfaceInfo.InterfaceType interfaceType) {
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = interfaceManagerCommonUtils.getInterfaceState(interfaceName);
if (ifState == null) {
LOG.debug("Interface {} is not present", interfaceName);
return null;
}
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
if (ncId != null) {
interfaceInfo.setDpId(IfmUtil.getDpnFromNodeConnectorId(ncId));
interfaceInfo.setPortNo(Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId)));
}
interfaceInfo.setAdminState(ifState.getAdminStatus() == AdminStatus.Up ? InterfaceAdminState.ENABLED : InterfaceAdminState.DISABLED);
interfaceInfo.setInterfaceName(interfaceName);
Integer lportTag = ifState.getIfIndex();
interfaceInfo.setInterfaceTag(lportTag);
interfaceInfo.setInterfaceType(interfaceType);
interfaceInfo.setGroupId(IfmUtil.getGroupId(lportTag, interfaceType));
interfaceInfo.setOpState(InterfaceInfo.InterfaceOpState.fromModel(ifState.getOperStatus()));
PhysAddress phyAddress = ifState.getPhysAddress();
if (phyAddress != null) {
interfaceInfo.setMacAddress(ifState.getPhysAddress().getValue());
}
return interfaceInfo;
}
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 InterfaceManagerCommonUtils method addStateEntry.
public void addStateEntry(String interfaceName, WriteTransaction interfaceOperShardTransaction, List<ListenableFuture<Void>> futures, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
// allocate lport tag and create interface-if-index map.
// This is done even if interface-state is not present, so that there is
// no throttling
// on id allocation even when multiple southbound port_up events come in
// one shot
Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
if (ifState == null) {
LOG.debug("could not retrieve interface state corresponding to {}, processing will be resumed when " + "interface-state is available", interfaceName);
return;
}
LOG.debug("adding interface state for {}", interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus = ifState.getOperStatus();
PhysAddress physAddress = ifState.getPhysAddress();
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus = ifState.getAdminStatus();
NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo = getInterfaceFromConfigDS(interfaceKey);
if (interfaceInfo != null && !interfaceInfo.isEnabled()) {
operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
}
List<String> childLowerLayerIfList = new ArrayList<>();
childLowerLayerIfList.add(0, nodeConnectorId.getValue());
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
ifaceBuilder.setIfIndex(ifIndex).setType(Other.class);
Class<? extends InterfaceType> interfaceType = null;
if (interfaceInfo != null) {
interfaceType = interfaceInfo.getType();
ifaceBuilder.setType(interfaceType);
}
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
interfaceOperShardTransaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
// install ingress flow
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
if (interfaceInfo != null && interfaceInfo.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
FlowBasedServicesUtils.installLportIngressFlow(dpId, portNo, interfaceInfo, futures, txRunner, ifIndex);
futures.add(FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceInfo, Long.toString(portNo), interfaceName, ifIndex));
}
// Update the DpnToInterfaceList OpDS
createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
}
Aggregations