use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class IfMgr method addHostIntf.
public void addHostIntf(Uuid portId, Uuid snetId, Uuid networkId, IpAddress fixedIp, String macAddress, String deviceOwner) {
LOG.debug("addHostIntf portId {}, snetId {}, networkId {}, ip {}, mac {}", portId, snetId, networkId, fixedIp, macAddress);
// Save the interface ipv6 address in its fully expanded format
Ipv6Address addr = new Ipv6Address(InetAddresses.forString(fixedIp.getIpv6Address().getValue()).getHostAddress());
fixedIp = new IpAddress(addr);
VirtualPort intf = VirtualPort.builder().intfUUID(portId).networkID(networkId).macAddress(macAddress).routerIntfFlag(false).deviceOwner(deviceOwner).build();
intf.setSubnetInfo(snetId, fixedIp);
VirtualPort prevIntf = vintfs.putIfAbsent(portId, intf);
if (prevIntf == null) {
Long elanTag = getNetworkElanTag(networkId);
// Do service binding for the port and set the serviceBindingStatus to true.
ipv6ServiceUtils.bindIpv6Service(portId.getValue(), elanTag, NwConstants.IPV6_TABLE);
intf.setServiceBindingStatus(true);
/* Update the intf dpnId/ofPort from the Operational Store */
updateInterfaceDpidOfPortInfo(portId);
} else {
intf = prevIntf;
intf.setSubnetInfo(snetId, fixedIp);
}
VirtualSubnet snet = getSubnet(snetId);
if (snet != null) {
intf.setSubnet(snetId, snet);
} else {
addUnprocessed(unprocessedSubnetIntfs, snetId, intf);
}
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class VpnUtil method createLearntVpnVipToPort.
protected static void createLearntVpnVipToPort(DataBroker broker, String vpnName, String fixedIp, String portName, String macAddress) {
synchronized ((vpnName + fixedIp).intern()) {
InstanceIdentifier<LearntVpnVipToPort> id = buildLearntVpnVipToPortIdentifier(vpnName, fixedIp);
LearntVpnVipToPortBuilder builder = new LearntVpnVipToPortBuilder().setKey(new LearntVpnVipToPortKey(fixedIp, vpnName)).setVpnName(vpnName).setPortFixedip(fixedIp).setPortName(portName).setMacAddress(macAddress.toLowerCase(Locale.getDefault())).setCreationTime(new SimpleDateFormat("MM/dd/yyyy h:mm:ss a").format(new Date()));
MDSALUtil.syncWrite(broker, LogicalDatastoreType.OPERATIONAL, id, builder.build());
LOG.debug("createLearntVpnVipToPort: ARP learned for fixedIp: {}, vpn {}, interface {}, mac {}," + " added to VpnPortipToPort DS", fixedIp, vpnName, portName, 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 DhcpNeutronPortListener method update.
@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
LOG.trace("Port changed to {}", update);
// With Ipv6 changes we can get ipv4 subnets later. The below check is to support such scenario.
if (original.getFixedIps().size() < update.getFixedIps().size()) {
final String interfaceName = update.getUuid().getValue();
List<FixedIps> updatedFixedIps = update.getFixedIps();
// Need to check only the newly added fixed ip.
updatedFixedIps.removeAll(original.getFixedIps());
Subnet subnet = dhcpManager.getNeutronSubnet(updatedFixedIps);
if (null == subnet || !subnet.isEnableDhcp()) {
LOG.trace("Subnet is null/not ipv4 or not enabled {}", subnet);
return;
}
// Binding the DHCP service for an existing port because of subnet change.
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
})), DhcpMConstants.RETRY_COUNT);
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(interfaceName), () -> {
BigInteger dpnId = interfaceManager.getDpnForInterface(interfaceName);
if (dpnId == null || dpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.trace("Unable to install the DHCP flow since dpn is not available");
return Collections.emptyList();
}
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(tx -> dhcpManager.installDhcpEntries(dpnId, DhcpServiceUtils.getAndUpdateVmMacAddress(tx, interfaceName, dhcpManager), tx)));
}, DhcpMConstants.RETRY_COUNT);
}
if (!isVnicTypeDirectOrMacVtap(update)) {
LOG.trace("Port updated is normal {}", update.getUuid());
if (isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original Port was direct/macvtap {} so removing flows and cache entry if any", update.getUuid());
removePort(original);
}
return;
}
if (!isVnicTypeDirectOrMacVtap(original)) {
LOG.trace("Original port was normal and updated is direct. Calling addPort()");
addPort(update);
return;
}
String macOriginal = getMacAddress(original);
String macUpdated = getMacAddress(update);
String segmentationIdOriginal = DhcpServiceUtils.getSegmentationId(original.getNetworkId(), broker);
String segmentationIdUpdated = DhcpServiceUtils.getSegmentationId(update.getNetworkId(), broker);
if (macOriginal != null && !macOriginal.equalsIgnoreCase(macUpdated) && segmentationIdOriginal != null && !segmentationIdOriginal.equalsIgnoreCase(segmentationIdUpdated)) {
LOG.trace("Mac/segment id has changed");
dhcpExternalTunnelManager.removeVniMacToPortCache(new BigInteger(segmentationIdOriginal), macOriginal);
dhcpExternalTunnelManager.updateVniMacToPortCache(new BigInteger(segmentationIdUpdated), macUpdated, update);
}
}
use of org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.Mac in project netvirt by opendaylight.
the class DhcpServiceUtils method createSubnetDhcpPortData.
@SuppressWarnings("checkstyle:IllegalCatch")
protected static void createSubnetDhcpPortData(Port port, BiConsumer<InstanceIdentifier<SubnetToDhcpPort>, SubnetToDhcpPort> consumer) {
java.util.Optional<String> ip4Address = getIpV4Address(port);
java.util.Optional<String> subnetId = getNeutronSubnetId(port);
if (!(ip4Address.isPresent() && subnetId.isPresent())) {
return;
}
LOG.trace("Adding SubnetPortData entry for subnet {}", subnetId.get());
InstanceIdentifier<SubnetToDhcpPort> identifier = buildSubnetToDhcpPort(subnetId.get());
SubnetToDhcpPort subnetToDhcpPort = getSubnetToDhcpPort(port, subnetId.get(), ip4Address.get());
try {
LOG.trace("Adding to SubnetToDhcpPort subnet {} mac {}.", subnetId.get(), port.getMacAddress().getValue());
consumer.accept(identifier, subnetToDhcpPort);
} catch (Exception e) {
LOG.error("Failure while creating SubnetToDhcpPort map for network {}.", port.getNetworkId(), 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 DhcpAllocationPoolManager method getIpAllocation.
public IpAddress getIpAllocation(String networkId, AllocationPool pool, String macAddress) {
String poolIdKey = getPoolKeyIdByAllocationPool(networkId, pool);
long allocatedIpLong = createIdAllocation(poolIdKey, macAddress);
LOG.debug("allocated id {} for mac {}, from pool {}", allocatedIpLong, macAddress, poolIdKey);
IpAddress allocatedIpAddress = allocatedIpLong != 0 ? DhcpServiceUtils.convertLongToIp(allocatedIpLong) : null;
return allocatedIpAddress;
}
Aggregations