use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.
the class WeightedCentralizedSwitchScheduler method deleteFromDpnMaps.
private void deleteFromDpnMaps(String routerName, List<Uuid> deletedSubnetIds, BigInteger primarySwitchId) {
if (deletedSubnetIds == null || deletedSubnetIds.isEmpty()) {
LOG.debug("deleteFromDpnMaps no subnets associated with {}", routerName);
return;
}
WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
String primaryRd = NatUtil.getPrimaryRd(dataBroker, routerName);
for (Uuid subnetUuid : deletedSubnetIds) {
String routerPort = subnetIdToRouterPortMap.remove(subnetUuid.getValue());
if (routerPort == null) {
LOG.error("The router port was not found for {}", subnetUuid.getValue());
continue;
}
vpnFootprintService.updateVpnToDpnMapping(primarySwitchId, routerName, primaryRd, routerPort, null, false);
NatUtil.removeFromNeutronRouterDpnsMap(dataBroker, routerName, primarySwitchId, writeOperTxn);
NatUtil.removeFromDpnRoutersMap(dataBroker, routerName, routerName, interfaceManager, writeOperTxn);
}
writeOperTxn.submit();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.
the class WeightedCentralizedSwitchScheduler method updateCentralizedSwitch.
@Override
public boolean updateCentralizedSwitch(Routers oldRouter, Routers newRouter) {
String routerName = newRouter.getRouterName();
List<Uuid> addedSubnetIds = getUpdatedSubnetIds(newRouter.getSubnetIds(), oldRouter.getSubnetIds());
List<Uuid> deletedSubnetIds = getUpdatedSubnetIds(oldRouter.getSubnetIds(), newRouter.getSubnetIds());
BigInteger primarySwitchId = NatUtil.getPrimaryNaptfromRouterName(dataBroker, newRouter.getRouterName());
addToDpnMaps(routerName, addedSubnetIds, primarySwitchId);
deleteFromDpnMaps(routerName, deletedSubnetIds, primarySwitchId);
return true;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.
the class WeightedCentralizedSwitchScheduler method getUpdatedSubnetIds.
public static List<Uuid> getUpdatedSubnetIds(List<Uuid> updatedSubnetIds, List<Uuid> currentSubnetIds) {
if (updatedSubnetIds == null) {
return null;
}
List<Uuid> newSubnetIds = new ArrayList<>(updatedSubnetIds);
if (currentSubnetIds == null) {
return newSubnetIds;
}
List<Uuid> origSubnetIds = new ArrayList<>(currentSubnetIds);
for (Iterator<Uuid> iterator = newSubnetIds.iterator(); iterator.hasNext(); ) {
Uuid updatedSubnetId = iterator.next();
for (Uuid currentSubnetId : origSubnetIds) {
if (updatedSubnetId.getValue().equals(currentSubnetId.getValue())) {
iterator.remove();
break;
}
}
}
return newSubnetIds;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.
the class AbstractSnatService method installSnatCommonEntriesForNonNaptSwitch.
protected void installSnatCommonEntriesForNonNaptSwitch(Routers routers, BigInteger primarySwitchId, BigInteger dpnId, int addOrRemove) {
String routerName = routers.getRouterName();
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
List<ExternalIps> externalIps = routers.getExternalIps();
if (externalIps.isEmpty()) {
LOG.error("AbstractSnatService: installSnatCommonEntriesForNaptSwitch no externalIP present" + " for routerId {}", routerId);
return;
}
String externalIp = externalIps.get(0).getIpAddress();
Uuid externalSubnetId = externalIps.get(0).getSubnetId();
long extSubnetId = NatConstants.INVALID_ID;
if (addOrRemove == NwConstants.ADD_FLOW) {
extSubnetId = NatUtil.getExternalSubnetVpnId(dataBroker, externalSubnetId);
}
installDefaultFibRouteForSNAT(dpnId, routerId, addOrRemove);
installSnatMissEntry(dpnId, routerId, routerName, primarySwitchId, externalIp, extSubnetId, addOrRemove);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid in project netvirt by opendaylight.
the class NeutronUtils method writePortStatus.
private static boolean writePortStatus(String uuid, String portStatus, DataBroker dataBroker, boolean create) {
Uuid uuidObj = new Uuid(uuid);
PortBuilder portBuilder = new PortBuilder();
portBuilder.setUuid(uuidObj);
portBuilder.setStatus(portStatus);
InstanceIdentifier iid = InstanceIdentifier.create(Neutron.class).child(Ports.class).child(Port.class, new PortKey(uuidObj));
SingleTransactionDataBroker tx = new SingleTransactionDataBroker(dataBroker);
try {
if (create) {
tx.syncWrite(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
} else {
tx.syncUpdate(LogicalDatastoreType.OPERATIONAL, iid, portBuilder.build());
}
} catch (TransactionCommitFailedException e) {
LOG.error("writePortStatus: failed neutron port status write. isCreate: {}", create, e);
return false;
}
return true;
}
Aggregations