use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey in project netvirt by opendaylight.
the class ElanServiceTest method readBgpNetworkFromDS.
public Networks readBgpNetworkFromDS(String prefix) throws ReadFailedException {
InstanceIdentifier<Networks> iid = InstanceIdentifier.create(Bgp.class).child(NetworksContainer.class).child(Networks.class, new NetworksKey(prefix, RD));
awaitForData(LogicalDatastoreType.CONFIGURATION, iid);
return singleTxdataBroker.syncRead(CONFIGURATION, iid);
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey in project netvirt by opendaylight.
the class FloatingIPListener method getVpnUuid.
private Uuid getVpnUuid(Uuid extNwId, Uuid floatingIpExternalId) {
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 null;
}
ProviderTypes providerType = nw.get().getProviderNetworkType();
if (providerType == ProviderTypes.FLAT || providerType == ProviderTypes.VLAN) {
Uuid subnetId = NatUtil.getFloatingIpPortSubnetIdFromFloatingIpId(dataBroker, floatingIpExternalId);
if (subnetId != null) {
return subnetId;
}
}
Uuid vpnUuid = nw.get().getVpnid();
if (vpnUuid == null) {
LOG.error("getVpnId : Unable to read vpn from External network: {}", extNwId);
return null;
}
return vpnUuid;
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey 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.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey in project netvirt by opendaylight.
the class NeutronvpnManager method addExternalNetworkToVpn.
private boolean addExternalNetworkToVpn(Network extNet, Uuid vpnId) {
Uuid extNetId = extNet.getUuid();
InstanceIdentifier<Networks> extNetIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
try {
Optional<Networks> optionalExtNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, extNetIdentifier);
if (!optionalExtNets.isPresent()) {
LOG.error("addExternalNetworkToVpn: Provider Network {} is not present in ConfigDS", extNetId.getValue());
return false;
}
NetworksBuilder builder = new NetworksBuilder(optionalExtNets.get());
builder.setVpnid(vpnId);
Networks networks = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("addExternalNetworkToVpn: Set VPN Id {} for Provider Network {}", vpnId.getValue(), extNetId.getValue());
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, extNetIdentifier, networks);
return true;
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
LOG.error("addExternalNetworkToVpn: Failed to set VPN Id {} to Provider Network {}: ", vpnId.getValue(), extNetId.getValue(), ex);
}
return false;
}
Aggregations