use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.vrfscontainer.VrfsBuilder in project netvirt by opendaylight.
the class BgpConfigurationManager method addVrf.
// TODO: add LayerType as arg - supports command
public void addVrf(String rd, List<String> irts, List<String> erts, AddressFamily addressFamily) {
Vrfs vrf = bgpUtil.getVrfFromRd(rd);
List<AddressFamiliesVrf> adfList = new ArrayList<>(1);
if (vrf != null) {
adfList = new ArrayList<AddressFamiliesVrf>(vrf.nonnullAddressFamiliesVrf().values());
}
AddressFamiliesVrfBuilder adfBuilder = new AddressFamiliesVrfBuilder();
if (addressFamily.equals(AddressFamily.IPV4)) {
adfBuilder.setAfi((long) af_afi.AFI_IP.getValue());
adfBuilder.setSafi((long) af_safi.SAFI_MPLS_VPN.getValue());
} else if (addressFamily.equals(AddressFamily.IPV6)) {
adfBuilder.setAfi((long) af_afi.AFI_IPV6.getValue());
adfBuilder.setSafi((long) af_safi.SAFI_MPLS_VPN.getValue());
} else if (addressFamily.equals(AddressFamily.L2VPN)) {
adfBuilder.setAfi((long) af_afi.AFI_IP.getValue());
adfBuilder.setSafi((long) af_safi.SAFI_EVPN.getValue());
}
AddressFamiliesVrf adf = adfBuilder.build();
adfList.add(adf);
InstanceIdentifier.InstanceIdentifierBuilder<Vrfs> iib = InstanceIdentifier.builder(Bgp.class).child(VrfsContainer.class).child(Vrfs.class, new VrfsKey(rd));
InstanceIdentifier<Vrfs> iid = iib.build();
Vrfs dto = new VrfsBuilder().setRd(rd).setImportRts(irts).setExportRts(erts).setAddressFamiliesVrf(adfList).build();
List<AddressFamiliesVrf> listAdFamilies = mapNewAdFamily.get(rd);
if (listAdFamilies != null) {
listAdFamilies.add(adf);
} else {
mapNewAdFamily.put(rd, adfList);
}
try {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, iid, dto);
} catch (TransactionCommitFailedException e) {
LOG.error("Error adding VRF to datastore", e);
throw new RuntimeException(e);
}
// enable multipath by default in all VRFs
setMultipaths(rd, BgpConstants.BGP_DEFAULT_MULTIPATH);
}
Aggregations