use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class DhcpSubnetListener method update.
@Override
protected void update(InstanceIdentifier<Subnet> identifier, Subnet original, Subnet update) {
LOG.trace("DhcpSubnetListener Update : Original dhcpstatus: {}, Updated dhcpstatus {}", original.isEnableDhcp(), update.isEnableDhcp());
if (!Objects.equals(original.isEnableDhcp(), update.isEnableDhcp())) {
// write api to get port list
SubnetmapBuilder subnetmapBuilder = getSubnetMapBuilder(dataBroker, update.getUuid());
List<Uuid> portList = subnetmapBuilder.getPortList();
List<Uuid> directPortList = subnetmapBuilder.getDirectPortList();
if (update.isEnableDhcp()) {
if (null != portList) {
// Install Entries for neutron ports
installNeutronPortEntries(portList);
}
if (null != directPortList) {
// install Entries for direct ports
installDirectPortEntries(directPortList);
}
} else {
if (null != portList) {
// UnInstall Entries for neutron ports
uninstallNeutronPortEntries(portList);
}
if (null != directPortList) {
// Uninstall Entries for direct ports
uninstallDirectPortEntries(directPortList);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class DhcpAllocationPoolManager method getAllocationPoolByNetwork.
public AllocationPool getAllocationPoolByNetwork(String networkId) throws ReadFailedException {
InstanceIdentifier<Network> network = InstanceIdentifier.builder(DhcpAllocationPool.class).child(Network.class, new NetworkKey(networkId)).build();
Optional<Network> optionalNetworkConfData = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, network);
if (!optionalNetworkConfData.isPresent()) {
LOG.info("No network configuration data for network {}", networkId);
return null;
}
Network networkConfData = optionalNetworkConfData.get();
List<AllocationPool> allocationPoolList = networkConfData.getAllocationPool();
// as we have no info about a specific subnet
if (allocationPoolList != null && !allocationPoolList.isEmpty()) {
return allocationPoolList.get(0);
} else {
LOG.warn("No allocation pools for network {}", networkId);
return null;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class DhcpExternalTunnelManager method getSubnetDhcpPortData.
public java.util.Optional<SubnetToDhcpPort> getSubnetDhcpPortData(String elanInstanceName) {
java.util.Optional<SubnetToDhcpPort> optSubnetDhcp = java.util.Optional.empty();
Uuid nwUuid = new Uuid(elanInstanceName);
List<Uuid> subnets = DhcpServiceUtils.getSubnetIdsFromNetworkId(broker, nwUuid);
for (Uuid subnet : subnets) {
if (DhcpServiceUtils.isIpv4Subnet(broker, subnet)) {
optSubnetDhcp = DhcpServiceUtils.getSubnetDhcpPortData(broker, subnet.getValue());
return optSubnetDhcp;
}
}
return optSubnetDhcp;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class DhcpInterfaceConfigListener method add.
@Override
protected void add(InstanceIdentifier<Interface> identifier, Interface add) {
jobCoordinator.enqueueJob(DhcpServiceUtils.getJobKey(add.getName()), () -> {
String interfaceName = add.getName();
IfL2vlan vlanInterface = add.getAugmentation(IfL2vlan.class);
if (vlanInterface == null) {
return Collections.emptyList();
}
Port port = dhcpManager.getNeutronPort(interfaceName);
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null != subnet && subnet.isEnableDhcp()) {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> {
LOG.debug("Binding DHCP service for interface {}", interfaceName);
DhcpServiceUtils.bindDhcpService(interfaceName, NwConstants.DHCP_TABLE, tx);
}));
}
return Collections.emptyList();
}, DhcpMConstants.RETRY_COUNT);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.subnets.rev150712.subnets.attributes.subnets.Subnet in project netvirt by opendaylight.
the class DhcpUCastMacListener method add.
@Override
protected void add(InstanceIdentifier<LocalUcastMacs> identifier, LocalUcastMacs add) {
NodeId torNodeId = identifier.firstKeyOf(Node.class).getNodeId();
InstanceIdentifier<LogicalSwitches> logicalSwitchRef = (InstanceIdentifier<LogicalSwitches>) add.getLogicalSwitchRef().getValue();
Optional<LogicalSwitches> logicalSwitchOptional = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, logicalSwitchRef);
if (!logicalSwitchOptional.isPresent()) {
LOG.error("Logical Switch ref doesn't have data {}", logicalSwitchRef);
return;
}
LogicalSwitches logicalSwitch = logicalSwitchOptional.get();
String elanInstanceName = logicalSwitch.getHwvtepNodeName().getValue();
String macAddress = add.getMacEntryKey().getValue();
BigInteger vni = new BigInteger(logicalSwitch.getTunnelKey());
Port port = dhcpExternalTunnelManager.readVniMacToPortCache(vni, macAddress);
if (port == null) {
LOG.trace("No neutron port created for macAddress {}, tunnelKey {}", macAddress, vni);
return;
}
L2GatewayDevice device = ElanL2GwCacheUtils.getL2GatewayDeviceFromCache(elanInstanceName, torNodeId.getValue());
if (device == null) {
LOG.error("Logical Switch Device with name {} is not present in L2GWCONN cache", elanInstanceName);
return;
}
IpAddress tunnelIp = device.getTunnelIp();
Subnet subnet = dhcpManager.getNeutronSubnet(port);
if (null != subnet && !subnet.isEnableDhcp()) {
dhcpExternalTunnelManager.updateExistingVMTunnelIPCache(tunnelIp, elanInstanceName, macAddress);
LOG.warn("DhcpUCastMacListener add: flag for the subnetId {} is False so Table 18 entries are not added", subnet.getUuid());
return;
}
BigInteger designatedDpnId = dhcpExternalTunnelManager.readDesignatedSwitchesForExternalTunnel(tunnelIp, elanInstanceName);
if (designatedDpnId == null || designatedDpnId.equals(DhcpMConstants.INVALID_DPID)) {
LOG.trace("Unable to install flows for macAddress {}. TunnelIp {}, elanInstanceName {}, designatedDpn {} ", macAddress, tunnelIp, elanInstanceName, designatedDpnId);
dhcpExternalTunnelManager.updateLocalCache(tunnelIp, elanInstanceName, macAddress);
return;
}
dhcpExternalTunnelManager.installDhcpFlowsForVms(tunnelIp, elanInstanceName, DhcpServiceUtils.getListOfDpns(broker), designatedDpnId, macAddress);
}
Aggregations