use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron 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.opendaylight.neutron.rev150712.Neutron in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Subnet> identifier, Subnet input) {
LOG.trace("Removing subnet : key: {}, value={}", identifier, input);
Uuid networkId = input.getNetworkId();
Uuid subnetId = input.getUuid();
Network network = neutronvpnUtils.getNeutronNetwork(networkId);
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a subnet remove() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
return;
}
handleNeutronSubnetDeleted(subnetId, networkId);
externalSubnetHandler.handleExternalSubnetRemoved(network, subnetId);
neutronvpnUtils.removeFromSubnetCache(input);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method add.
@Override
protected void add(InstanceIdentifier<Subnet> identifier, Subnet input) {
LOG.trace("Adding Subnet : key: {}, value={}", identifier, input);
Uuid networkId = input.getNetworkId();
Uuid subnetId = input.getUuid();
Network network = neutronvpnUtils.getNeutronNetwork(networkId);
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.warn("neutron vpn received a subnet add() for a network without a provider extension augmentation " + "or with an unsupported network type for the subnet {} which is part of network {}", subnetId.getValue(), network);
return;
}
neutronvpnUtils.addToSubnetCache(input);
handleNeutronSubnetCreated(input, network);
externalSubnetHandler.handleExternalSubnetAdded(network, subnetId, null);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method deleteSubPortInterface.
private void deleteSubPortInterface(SubPorts subPort) {
String portName = subPort.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (iface == null) {
LOG.warn("Interface not present for SubPort {}", subPort);
return futures;
}
/*
* We'll reset interface back to way it was? Can IFM handle parentRef delete?
*/
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
// Reset augmentations
interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
interfaceBuilder.addAugmentation(IfL2vlan.class, ifL2vlan);
iface = interfaceBuilder.build();
/*
* There is no means to do an update to remove elements from a node.
* Our solution is to get existing iface, remove parentRef and VlanId,
* and do a put to replace existing entry. This works out better as put
* has better performance than merge.
* Only drawback is any in-flight changes might be lost, but that is a corner case
* and this being subport delete path, don't expect any significant changes to
* corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
*/
WriteTransaction txn = dataBroker.newWriteOnlyTransaction();
txn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, iface);
LOG.trace("Resetting trunk member interface {}", iface);
futures.add(txn.submit());
return futures;
});
}
Aggregations