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 removeExternalNetworkFromVpn.
private boolean removeExternalNetworkFromVpn(Network extNet) {
Uuid extNetId = extNet.getUuid();
InstanceIdentifier<Networks> extNetsId = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
try {
Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, extNetsId);
NetworksBuilder builder = null;
if (optionalNets.isPresent()) {
builder = new NetworksBuilder(optionalNets.get());
} else {
LOG.error("removeExternalNetworkFromVpn: Provider Network {} is not present in the ConfigDS", extNetId.getValue());
return false;
}
builder.setVpnid(null);
Networks networks = builder.build();
LOG.info("removeExternalNetworkFromVpn: Withdraw VPN Id from Provider Network {} node", extNetId.getValue());
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, extNetsId, networks);
return true;
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
LOG.error("removeExternalNetworkFromVpn: Failed to withdraw VPN Id from Provider Network node {}: ", extNetId.getValue(), ex);
}
return false;
}
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 NeutronvpnNatManager method addExternalNetworkToRouter.
private void addExternalNetworkToRouter(Router update) {
Uuid routerId = update.getUuid();
Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
Map<ExternalFixedIpsKey, ExternalFixedIps> keyExternalFixedIpsMap = update.getExternalGatewayInfo().nonnullExternalFixedIps();
try {
Network input = neutronvpnUtils.getNeutronNetwork(extNetId);
ProviderTypes providerNwType = NeutronvpnUtils.getProviderNetworkType(input);
if (providerNwType == null) {
LOG.error("Unable to get Network Provider Type for network {}", input.getUuid().getValue());
return;
}
// Add this router to the ExtRouters list
addExternalRouter(update);
// Update External Subnets for this router
updateExternalSubnetsForRouter(routerId, extNetId, new ArrayList<ExternalFixedIps>(keyExternalFixedIpsMap.values()));
// Create and add Networks object for this External Network to the ExternalNetworks list
InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
if (!optionalNets.isPresent()) {
LOG.error("External Network {} not present in the NVPN datamodel", extNetId.getValue());
return;
}
NetworksBuilder builder = new NetworksBuilder(optionalNets.get());
List<Uuid> rtrList = (builder.getRouterIds() != null && !builder.getRouterIds().isEmpty()) ? new ArrayList<>(builder.getRouterIds()) : new ArrayList<>();
rtrList.add(routerId);
builder.setRouterIds(rtrList);
if (NeutronvpnUtils.isFlatOrVlanNetwork(input)) {
builder.setVpnid(extNetId);
}
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Updating externalnetworks {}", networkss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
LOG.trace("Updated externalnetworks successfully to CONFIG Datastore");
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
LOG.error("Creation of externalnetworks failed for {}", extNetId.getValue(), ex);
}
}
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 NeutronvpnNatManager method removeExternalNetwork.
public void removeExternalNetwork(Network net) {
Uuid extNetId = net.getUuid();
// Create and add Networks object for this External Network to the ExternalNetworks list
InstanceIdentifier<Networks> netsIdentifier = InstanceIdentifier.builder(ExternalNetworks.class).child(Networks.class, new NetworksKey(extNetId)).build();
try {
Optional<Networks> optionalNets = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
LOG.trace("Removing Networks node {}", extNetId.getValue());
if (!optionalNets.isPresent()) {
LOG.error("External Network {} not available in the datastore", extNetId.getValue());
return;
}
// Delete Networks object from the ExternalNetworks list
LOG.trace("Deleting External Network {}", extNetId.getValue());
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
LOG.trace("Deleted External Network {} successfully from CONFIG Datastore", extNetId.getValue());
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
LOG.error("Deletion of External Network {} failed", extNetId.getValue(), ex);
}
}
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 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.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.networkscontainer.NetworksKey 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