use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class NatUtil method checkForRoutersWithSameExtNetAndNaptSwitch.
public static boolean checkForRoutersWithSameExtNetAndNaptSwitch(DataBroker broker, Uuid networkId, String routerName, BigInteger dpnId) {
InstanceIdentifier<Networks> id = buildNetworkIdentifier(networkId);
Optional<Networks> networkData = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id);
if (networkData != null && networkData.isPresent()) {
List<Uuid> routerUuidList = networkData.get().getRouterIds();
if (routerUuidList != null && !routerUuidList.isEmpty()) {
for (Uuid routerUuid : routerUuidList) {
String sharedRouterName = routerUuid.getValue();
if (!routerName.equals(sharedRouterName)) {
BigInteger swtichDpnId = NatUtil.getPrimaryNaptfromRouterName(broker, sharedRouterName);
if (swtichDpnId == null) {
continue;
} else if (swtichDpnId.equals(dpnId)) {
LOG.debug("checkForRoutersWithSameExtNetAndNaptSwitch: external-network {} is " + "associated with other active router {} on NAPT switch {}", networkId, sharedRouterName, swtichDpnId);
return true;
}
}
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class FloatingIPListener method getVpnId.
private long getVpnId(Uuid extNwId, Uuid floatingIpExternalId) {
Uuid subnetId = NatUtil.getFloatingIpPortSubnetIdFromFloatingIpId(dataBroker, floatingIpExternalId);
if (subnetId != null) {
long vpnId = NatUtil.getVpnId(dataBroker, subnetId.getValue());
if (vpnId != NatConstants.INVALID_ID) {
LOG.debug("getVpnId : Got vpnId {} for floatingIpExternalId {}", vpnId, floatingIpExternalId);
return vpnId;
}
}
InstanceIdentifier<Networks> nwId = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNwId)).build();
Optional<Networks> nw = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, nwId);
if (!nw.isPresent()) {
LOG.error("getVpnId : Unable to read external network for {}", extNwId);
return NatConstants.INVALID_ID;
}
Uuid vpnUuid = nw.get().getVpnid();
if (vpnUuid == null) {
LOG.error("getVpnId : Unable to read vpn from External network: {}", extNwId);
return NatConstants.INVALID_ID;
}
// Get the id using the VPN UUID (also vpn instance name)
return NatUtil.getVpnId(dataBroker, vpnUuid.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class ExternalNetworksChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Networks> identifier, Networks networks) {
if (identifier == null || networks == null || networks.getRouterIds().isEmpty()) {
LOG.warn("remove : returning without processing since networks/identifier is null: " + "identifier: {}, networks: {}", identifier, networks);
return;
}
for (Uuid routerId : networks.getRouterIds()) {
String routerName = routerId.toString();
InstanceIdentifier<RouterToNaptSwitch> routerToNaptSwitchInstanceIdentifier = NatUtil.buildNaptSwitchIdentifier(routerName);
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.OPERATIONAL, routerToNaptSwitchInstanceIdentifier);
LOG.debug("remove : successful deletion of data in napt-switches container");
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class NaptSwitchHA method getRouterIdsForExtNetwork.
@Nonnull
private List<String> getRouterIdsForExtNetwork(Uuid extNetworkId) {
List<String> routerUuidsAsString = new ArrayList<>();
InstanceIdentifier<Networks> extNetwork = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetworkId)).build();
Optional<Networks> extNetworkData = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, extNetwork);
if (extNetworkData.isPresent()) {
List<Uuid> routerUuids = extNetworkData.get().getRouterIds();
if (routerUuids != null) {
for (Uuid routerUuid : routerUuids) {
routerUuidsAsString.add(routerUuid.getValue());
}
}
}
return routerUuidsAsString;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks in project netvirt by opendaylight.
the class BgpManagerTestImpl method addPrefix.
public void addPrefix(String rd, String macAddress, String pfx, List<String> nhList, VrfEntry.EncapType encapType, long lbl, long l3vni, long l2vni, String gatewayMac) throws TransactionCommitFailedException {
for (String nh : nhList) {
Ipv4Address nexthop = nh != null ? new Ipv4Address(nh) : null;
Long label = lbl;
InstanceIdentifier<Networks> iid = InstanceIdentifier.builder(Bgp.class).child(Networks.class, new NetworksKey(pfx, rd)).build();
NetworksBuilder networksBuilder = new NetworksBuilder().setRd(rd).setPrefixLen(pfx).setNexthop(nexthop).setLabel(label).setEthtag(0L);
buildVpnEncapSpecificInfo(networksBuilder, encapType, label, l3vni, l2vni, macAddress, gatewayMac);
singleTxdataBroker.syncWrite(LogicalDatastoreType.CONFIGURATION, iid, networksBuilder.build());
}
}
Aggregations