use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.networkmaps.NetworkMapKey in project netvirt by opendaylight.
the class NeutronSubnetChangeListener method createSubnetToNetworkMapping.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void createSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
try {
InstanceIdentifier<NetworkMap> networkMapIdentifier = NeutronvpnUtils.buildNetworkMapIdentifier(networkId);
Optional<NetworkMap> optionalNetworkMap = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier);
NetworkMapBuilder nwMapBuilder = null;
if (optionalNetworkMap.isPresent()) {
nwMapBuilder = new NetworkMapBuilder(optionalNetworkMap.get());
} else {
nwMapBuilder = new NetworkMapBuilder().setKey(new NetworkMapKey(networkId)).setNetworkId(networkId);
LOG.debug("Adding a new network node in NetworkMaps DS for network {}", networkId.getValue());
}
List<Uuid> subnetIdList = nwMapBuilder.getSubnetIdList();
if (subnetIdList == null) {
subnetIdList = new ArrayList<>();
}
subnetIdList.add(subnetId);
nwMapBuilder.setSubnetIdList(subnetIdList);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, networkMapIdentifier, nwMapBuilder.build());
LOG.debug("Created subnet-network mapping for subnet {} network {}", subnetId.getValue(), networkId.getValue());
} catch (ReadFailedException | RuntimeException e) {
LOG.error("Create subnet-network mapping failed for subnet {} network {}", subnetId.getValue(), networkId.getValue());
}
}
Aggregations