use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class AclServiceUtils method getFlowForAllowedAddresses.
public static Map<String, List<MatchInfoBase>> getFlowForAllowedAddresses(List<AllowedAddressPairs> syncAllowedAddresses, Map<String, List<MatchInfoBase>> flowMatchesMap, boolean isSourceIpMacMatch) {
if (flowMatchesMap == null) {
return null;
}
Map<String, List<MatchInfoBase>> updatedFlowMatchesMap = new HashMap<>();
MatchInfoBase ipv4Match = MatchEthernetType.IPV4;
MatchInfoBase ipv6Match = MatchEthernetType.IPV6;
for (Entry<String, List<MatchInfoBase>> entry : flowMatchesMap.entrySet()) {
String flowName = entry.getKey();
List<MatchInfoBase> flows = entry.getValue();
// iterate over allow address pair and update match type
for (AllowedAddressPairs aap : syncAllowedAddresses) {
List<MatchInfoBase> matchInfoBaseList;
String flowId;
if (flows.contains(ipv4Match) && isIPv4Address(aap) && isNotIpv4AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv4_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
} else if (flows.contains(ipv6Match) && !isIPv4Address(aap) && isNotIpv6AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv6_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
}
}
}
return updatedFlowMatchesMap;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method addEbgpMultihop.
public void addEbgpMultihop(String nbrIp, int hops) {
Ipv4Address nbrAddr = new Ipv4Address(nbrIp);
InstanceIdentifier.InstanceIdentifierBuilder<EbgpMultihop> iib = InstanceIdentifier.builder(Bgp.class).child(Neighbors.class, new NeighborsKey(nbrAddr)).child(EbgpMultihop.class);
InstanceIdentifier<EbgpMultihop> iid = iib.build();
EbgpMultihop dto = new EbgpMultihopBuilder().setPeerIp(nbrAddr).setNhops((long) hops).build();
update(iid, dto);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method startConfig.
public void startConfig(String bgpHost, int thriftPort) {
InstanceIdentifier.InstanceIdentifierBuilder<ConfigServer> iib = InstanceIdentifier.builder(Bgp.class).child(ConfigServer.class);
InstanceIdentifier<ConfigServer> iid = iib.build();
Ipv4Address ipAddr = new Ipv4Address(bgpHost);
ConfigServer dto = new ConfigServerBuilder().setHost(ipAddr).setPort((long) thriftPort).build();
update(iid, dto);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method delVrf.
public boolean delVrf(String rd, AddressFamily addressFamily) {
if (addressFamily == null) {
LOG.error("delVrf: vrf {}, addressFamily invalid", rd);
return false;
}
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());
}
Vrfs vrfOriginal = bgpUtil.getVrfFromRd(rd);
if (vrfOriginal == null) {
LOG.error("delVrf: no vrf with existing rd {}. step aborted", rd);
return false;
}
InstanceIdentifier.InstanceIdentifierBuilder<Vrfs> iib = InstanceIdentifier.builder(Bgp.class).child(Vrfs.class, new VrfsKey(rd));
InstanceIdentifier<Vrfs> iid = iib.build();
@SuppressWarnings("static-access") InstanceIdentifier<Bgp> iid6 = iid.builder(Bgp.class).build().child(Multipath.class, new MultipathKey(adfBuilder.getAfi(), adfBuilder.getSafi())).create(Bgp.class);
InstanceIdentifierBuilder<Vrfs> iib3 = iid6.child(Vrfs.class, new VrfsKey(rd)).builder();
InstanceIdentifier<Vrfs> iidFinal = iib3.build();
// ** update or delete the vrfs with the rest of AddressFamilies already present in the last list
AddressFamiliesVrf adfToDel = adfBuilder.build();
List<AddressFamiliesVrf> adfListOriginal = vrfOriginal.getAddressFamiliesVrf() == null ? new ArrayList<>() : vrfOriginal.getAddressFamiliesVrf();
List<AddressFamiliesVrf> adfListToRemoveFromOriginal = new ArrayList<>();
adfListOriginal.forEach(adf -> {
if (adf.equals(adfToDel)) {
adfListToRemoveFromOriginal.add(adfToDel);
return;
}
});
for (AddressFamiliesVrf adfToRemove : adfListToRemoveFromOriginal) {
adfListOriginal.remove(adfToRemove);
try {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, iid, vrfOriginal);
} catch (TransactionCommitFailedException e) {
LOG.error("delVrf: Error updating VRF to datastore", e);
throw new RuntimeException(e);
}
}
if (adfListOriginal.isEmpty()) {
delete(iidFinal);
return true;
}
// not all is removed
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update in project netvirt by opendaylight.
the class BgpConfigurationManager method setMultipathStatus.
public void setMultipathStatus(af_afi afi, af_safi safi, boolean enable) {
long lafi = afi.getValue();
long lsafi = safi.getValue();
InstanceIdentifier.InstanceIdentifierBuilder<Multipath> iib = InstanceIdentifier.builder(Bgp.class).child(Multipath.class, new MultipathKey(Long.valueOf(afi.getValue()), Long.valueOf(safi.getValue())));
Multipath dto = new MultipathBuilder().setAfi(lafi).setSafi(lsafi).setMultipathEnabled(enable).build();
update(iib.build(), dto);
}
Aggregations