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 AlivenessProtocolHandlerARP method startMonitoringTask.
@Override
public void startMonitoringTask(MonitoringInfo monitorInfo) {
if (arpService == null) {
LOG.debug("ARP Service not available to send the packet");
return;
}
EndpointType source = monitorInfo.getSource().getEndpointType();
final String sourceInterface = Preconditions.checkNotNull(getInterfaceName(source), "Source interface is required to send ARP Packet for monitoring");
final String srcIp = Preconditions.checkNotNull(getIpAddress(source), "Source Ip address is required to send ARP Packet for monitoring");
final Optional<PhysAddress> srcMacAddressOptional = getMacAddress(source);
if (srcMacAddressOptional.isPresent()) {
PhysAddress srcMacAddress = srcMacAddressOptional.get();
EndpointType target = monitorInfo.getDestination().getEndpointType();
final String targetIp = Preconditions.checkNotNull(getIpAddress(target), "Target Ip address is required to send ARP Packet for monitoring");
if (LOG.isTraceEnabled()) {
LOG.trace("sendArpRequest interface {}, senderIPAddress {}, targetAddress {}", sourceInterface, srcIp, targetIp);
}
InterfaceAddressBuilder interfaceAddressBuilder = new InterfaceAddressBuilder().setInterface(sourceInterface).setIpAddress(IpAddressBuilder.getDefaultInstance(srcIp));
if (srcMacAddress != null) {
interfaceAddressBuilder.setMacaddress(srcMacAddress);
}
List<InterfaceAddress> addresses = Collections.singletonList(interfaceAddressBuilder.build());
SendArpRequestInput input = new SendArpRequestInputBuilder().setInterfaceAddress(addresses).setIpaddress(IpAddressBuilder.getDefaultInstance(targetIp)).build();
Future<RpcResult<Void>> future = arpService.sendArpRequest(input);
final String msgFormat = String.format("Send ARP Request on interface %s to destination %s", sourceInterface, targetIp);
Futures.addCallback(JdkFutureAdapters.listenInPoolThread(future), new FutureCallback<RpcResult<Void>>() {
@Override
public void onFailure(Throwable error) {
LOG.error("Error - {}", msgFormat, error);
}
@Override
public void onSuccess(RpcResult<Void> result) {
if (result != null && !result.isSuccessful()) {
LOG.warn("Rpc call to {} failed {}", msgFormat, getErrorText(result.getErrors()));
} else {
LOG.debug("Successful RPC Result - {}", msgFormat);
}
}
});
}
}
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 HwvtepUtils method installUcastMacs.
/**
* Installs a list of Mac Addresses as remote Ucast address in an external
* device using the hwvtep-southbound.
*
* @param deviceNodeId
* NodeId if the ExternalDevice where the macs must be installed
* in.
* @param macAddresses
* List of Mac addresses to be installed in the external device.
* @param logicalSwitchName
* the logical switch name
* @param remoteVtepIp
* VTEP's IP in this OVS used for the tunnel with external
* device.
*/
public static ListenableFuture<Void> installUcastMacs(DataBroker broker, String deviceNodeId, List<PhysAddress> macAddresses, String logicalSwitchName, IpAddress remoteVtepIp) {
NodeId nodeId = new NodeId(deviceNodeId);
HwvtepPhysicalLocatorAugmentation phyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(String.valueOf(remoteVtepIp.getValue()));
List<RemoteUcastMacs> macs = new ArrayList<>();
for (PhysAddress mac : macAddresses) {
// TODO: Query ARP cache to get IP address corresponding to
// the MAC
// IpAddress ipAddress = null;
macs.add(HwvtepSouthboundUtils.createRemoteUcastMac(nodeId, mac.getValue().toLowerCase(Locale.getDefault()), /*ipAddress*/
null, logicalSwitchName, phyLocatorAug));
}
return HwvtepUtils.addRemoteUcastMacs(broker, nodeId, macs);
}
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 getInterfaceInfo.
@Override
public InterfaceInfo getInterfaceInfo(String 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;
}
Interface intf = interfaceManagerCommonUtils.getInterfaceFromConfigDS(new InterfaceKey(interfaceName));
if (intf == null) {
LOG.error("Interface {} doesn't exist in config datastore", interfaceName);
return null;
}
NodeConnectorId ncId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(intf.getName(), interfaceManagerCommonUtils);
InterfaceInfo.InterfaceType interfaceType = IfmUtil.getInterfaceType(intf);
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
BigInteger dpId = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_DPID;
Integer portNo = org.opendaylight.genius.interfacemanager.globals.IfmConstants.INVALID_PORT_NO;
if (ncId != null) {
dpId = IfmUtil.getDpnFromNodeConnectorId(ncId);
portNo = Integer.parseInt(IfmUtil.getPortNoFromNodeConnectorId(ncId));
}
if (interfaceType == InterfaceInfo.InterfaceType.VLAN_INTERFACE) {
interfaceInfo = IfmUtil.getVlanInterfaceInfo(intf, dpId);
} else if (interfaceType == InterfaceInfo.InterfaceType.UNKNOWN_INTERFACE) {
LOG.error("Type of Interface {} is unknown", interfaceName);
return null;
}
interfaceInfo.setDpId(dpId);
interfaceInfo.setPortNo(portNo);
interfaceInfo.setAdminState(intf.isEnabled() ? 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 InterfacemgrProvider method populateInterfaceInfo.
public InterfaceInfo populateInterfaceInfo(String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
InterfaceInfo interfaceInfo = new InterfaceInfo(interfaceName);
NodeConnectorId ncId = IfmUtil.getNodeConnectorIdFromInterface(ifState);
if (ncId != null) {
if (Tunnel.class.equals(ifState.getType())) {
interfaceInfo.setPortName(interfaceName);
} else {
Interface iface = interfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceName);
if (iface != null) {
ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
interfaceInfo.setPortName(parentRefs.getParentInterface());
}
}
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();
if (lportTag != null) {
interfaceInfo.setInterfaceTag(lportTag);
}
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 org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface addStateEntry(Interface interfaceInfo, String interfaceName, WriteTransaction transaction, PhysAddress physAddress, OperStatus operStatus, AdminStatus adminStatus, NodeConnectorId nodeConnectorId) {
LOG.debug("adding interface state for {}", interfaceName);
InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setType(Other.class).setIfIndex(IfmConstants.DEFAULT_IFINDEX);
Integer ifIndex;
Class<? extends InterfaceType> interfaceType = null;
if (interfaceInfo != null) {
if (!interfaceInfo.isEnabled()) {
operStatus = OperStatus.Down;
}
interfaceType = interfaceInfo.getType();
ifaceBuilder.setType(interfaceType);
// retrieve if-index only for northbound configured interfaces
ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
ifaceBuilder.setIfIndex(ifIndex);
interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
}
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
List<String> childLowerLayerIfList = new ArrayList<>();
if (nodeConnectorId != null) {
childLowerLayerIfList.add(0, nodeConnectorId.getValue());
} else {
// logical tunnel group doesn't have OF port
ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
if (parentRefs != null) {
BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
String lowref = MDSALUtil.NODE_PREFIX + MDSALUtil.SEPARATOR + dpId + MDSALUtil.SEPARATOR + 0;
childLowerLayerIfList.add(0, lowref);
}
}
ifaceBuilder.setAdminStatus(adminStatus).setOperStatus(operStatus).setLowerLayerIf(childLowerLayerIfList);
if (physAddress != null) {
ifaceBuilder.setPhysAddress(physAddress);
}
ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = ifaceBuilder.build();
boolean isTunnelInterface = InterfaceManagerCommonUtils.isTunnelInterface(interfaceInfo);
boolean isOfTunnelInterface = InterfaceManagerCommonUtils.isOfTunnelInterface(interfaceInfo);
if (isTunnelInterface && !isOfTunnelInterface) {
batchingUtils.write(ifStateId, ifState, BatchingUtils.EntityType.DEFAULT_OPERATIONAL);
} else {
transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifState, true);
}
if (nodeConnectorId != null) {
BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
// Update the DpnToInterfaceList OpDS
createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
}
return ifState;
}
Aggregations