use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project netvirt by opendaylight.
the class NeutronvpnManager method dissociateNetworksFromVpn.
/**
* Parses and disassociates networks list from given VPN.
*
* @param vpnId Uuid of given VPN.
* @param networkList List list of network Ids (Uuid), which will be disassociated.
* @return list of formatted strings with detailed error messages.
*/
@NonNull
protected List<String> dissociateNetworksFromVpn(@NonNull Uuid vpnId, @NonNull List<Uuid> networkList) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
ConcurrentMap<Uuid, Network> extNwMap = new ConcurrentHashMap<>();
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
if (networkList.isEmpty()) {
LOG.error("dissociateNetworksFromVpn: Failed as networks list is empty");
failedNwList.add(String.format("Failed to disassociate networks from VPN %s as networks list is empty", vpnId.getValue()));
return failedNwList;
}
for (Uuid nw : networkList) {
List<Uuid> networkSubnets = neutronvpnUtils.getSubnetIdsFromNetworkId(nw);
if (networkSubnets == null) {
passedNwList.add(nw);
continue;
}
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
LOG.error("dissociateNetworksFromVpn: Network {} not found in ConfigDS", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not found in ConfigDS", nw.getValue()));
continue;
}
Uuid networkVpnId = neutronvpnUtils.getVpnForNetwork(nw);
if (networkVpnId == null) {
LOG.error("dissociateNetworksFromVpn: Network {} is not associated to any VPN", nw.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as is not associated to any VPN", nw.getValue()));
continue;
}
if (!vpnId.equals(networkVpnId)) {
LOG.error("dissociateNetworksFromVpn: Network {} is associated to another VPN {} instead of given {}", nw.getValue(), networkVpnId.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to disassociate network %s as it is associated to another " + "vpn %s instead of given %s", nw.getValue(), networkVpnId.getValue(), vpnId.getValue()));
continue;
}
/* Handle disassociation of external network(s) from Internet BGP-VPN use case outside of the
* networkList iteration
*/
if (neutronvpnUtils.getIsExternal(network)) {
extNwMap.put(nw, network);
// Handle external-Nw to BGPVPN Disassociation and still ext-router is being set with external-Nw
List<Uuid> routerList = neutronvpnUtils.getRouterIdsForExtNetwork(nw);
if (!routerList.isEmpty()) {
for (Uuid routerId : routerList) {
// If v6 subnet was already added to router means it requires IPv6 AddrFamily in VpnInstance
if (neutronvpnUtils.isV6SubnetPartOfRouter(routerId)) {
ipVersion = ipVersion.addVersion(IpVersionChoice.IPV6);
LOG.debug("dissociateNetworksFromVpn: External network {} is still associated with " + "router(router-gw) {} and V6 subnet is part of that router. Hence Set IPv6 " + "address family type in Internet VPN Instance {}", network, routerId, vpnId);
break;
}
}
}
}
for (Uuid subnet : networkSubnets) {
Subnetmap subnetmap = neutronvpnUtils.getSubnetmap(subnet);
if (subnetmap == null) {
failedNwList.add(String.format("subnetmap %s not found for network %s", subnet.getValue(), nw.getValue()));
LOG.error("dissociateNetworksFromVpn: Subnetmap for subnet {} not found when " + "dissociating network {} from VPN {}", subnet.getValue(), nw.getValue(), vpnId.getValue());
continue;
}
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
if (!NeutronvpnUtils.getIsExternal(network)) {
LOG.debug("dissociateNetworksFromVpn: Withdraw subnet {} from VPN {}", subnet.getValue(), vpnId.getValue());
removeSubnetFromVpn(vpnId, subnetmap, null);
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
vpnManager.removeRouteTargetsToSubnetAssociation(routeTargets, subnetmap.getSubnetIp(), vpnId.getValue());
passedNwList.add(nw);
}
}
if (ipVersion != IpVersionChoice.UNDEFINED) {
LOG.debug("dissociateNetworksFromVpn: Updating vpnInstance with ip address family {}" + " for VPN {}", ipVersion, vpnId);
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
}
}
// Handle disassociation of external network(s) from Internet BGP-VPN Instance use case
if (!extNwMap.isEmpty() || extNwMap != null) {
for (Network extNw : extNwMap.values()) {
if (disassociateExtNetworkFromVpn(vpnId, extNw)) {
passedNwList.add(extNw.getUuid());
} else {
LOG.error("dissociateNetworksFromVpn: Failed to withdraw External Provider Network {} from VPN {}", extNw, vpnId.getValue());
failedNwList.add(String.format("Failed to withdraw External Provider Network %s from VPN %s", extNw, vpnId.getValue()));
continue;
}
}
}
clearFromVpnMaps(vpnId, null, new ArrayList<>(passedNwList));
LOG.info("dissociateNetworksFromVpn: Network(s) {} disassociated from L3VPN {} successfully", passedNwList, vpnId.getValue());
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project netvirt by opendaylight.
the class NeutronvpnManager method associateNetworksToVpn.
/**
* Parses and associates networks list with given VPN.
*
* @param vpnId Uuid of given VPN.
* @param networkList List list of network Ids (Uuid), which will be associated.
* @return list of formatted strings with detailed error messages.
*/
@NonNull
protected List<String> associateNetworksToVpn(@NonNull Uuid vpnId, @NonNull List<Uuid> networkList) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
ConcurrentMap<Uuid, Network> extNwMap = new ConcurrentHashMap<>();
boolean isExternalNetwork = false;
if (networkList.isEmpty()) {
LOG.error("associateNetworksToVpn: Failed as given networks list is empty, VPN Id: {}", vpnId.getValue());
failedNwList.add(String.format("Failed to associate networks with VPN %s as given networks list is empty", vpnId.getValue()));
return failedNwList;
}
VpnInstance vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
if (vpnInstance == null) {
LOG.error("associateNetworksToVpn: Can not find vpnInstance for VPN {} in ConfigDS", vpnId.getValue());
failedNwList.add(String.format("Failed to associate network: can not found vpnInstance for VPN %s " + "in ConfigDS", vpnId.getValue()));
return failedNwList;
}
try {
if (isVpnOfTypeL2(vpnInstance) && neutronEvpnUtils.isVpnAssociatedWithNetwork(vpnInstance)) {
LOG.error("associateNetworksToVpn: EVPN {} supports only one network to be associated with", vpnId.getValue());
failedNwList.add(String.format("Failed to associate network: EVPN %s supports only one network to be " + "associated with", vpnId.getValue()));
return failedNwList;
}
Set<VpnTarget> routeTargets = vpnManager.getRtListForVpn(vpnId.getValue());
boolean isIpFamilyUpdated = false;
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (Uuid nw : networkList) {
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
LOG.error("associateNetworksToVpn: Network {} not found in ConfigDS", nw.getValue());
failedNwList.add(String.format("Failed to associate network: network %s not found in ConfigDS", nw.getValue()));
continue;
}
NetworkProviderExtension providerExtension = network.augmentation(NetworkProviderExtension.class);
if (providerExtension.getSegments() != null && providerExtension.getSegments().size() > 1) {
LOG.error("associateNetworksToVpn: MultiSegmented network {} not supported in BGPVPN {}", nw.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to associate multisegmented network %s with BGPVPN %s", nw.getValue(), vpnId.getValue()));
continue;
}
Uuid networkVpnId = neutronvpnUtils.getVpnForNetwork(nw);
if (networkVpnId != null) {
LOG.error("associateNetworksToVpn: Network {} already associated with another VPN {}", nw.getValue(), networkVpnId.getValue());
failedNwList.add(String.format("Failed to associate network %s as it is already associated to " + "another VPN %s", nw.getValue(), networkVpnId.getValue()));
continue;
}
/* Handle association of external network(s) to Internet BGP-VPN use case outside of the
* networkList iteration
*/
if (neutronvpnUtils.getIsExternal(network)) {
extNwMap.put(nw, network);
isExternalNetwork = true;
// Check whether router-gw is set with external network before external network to BGPVPN association
List<Uuid> routerList = neutronvpnUtils.getRouterIdsForExtNetwork(nw);
if (!routerList.isEmpty()) {
for (Uuid routerId : routerList) {
// If v6 subnet was already added to router means it requires IPv6 AddrFamily in VpnInstance
if (neutronvpnUtils.isV6SubnetPartOfRouter(routerId)) {
ipVersion = ipVersion.addVersion(IpVersionChoice.IPV6);
LOG.debug("associateNetworksToVpn: External network {} is already associated with " + "router(router-gw) {} and V6 subnet is part of that router. Hence Set IPv6 " + "address family type in Internet VPN Instance {}", network, routerId, vpnId);
break;
}
}
}
}
List<Subnetmap> subnetmapList = neutronvpnUtils.getSubnetmapListFromNetworkId(nw);
if (subnetmapList == null || subnetmapList.isEmpty()) {
passedNwList.add(nw);
continue;
}
if (vpnManager.checkForOverlappingSubnets(nw, subnetmapList, vpnId, routeTargets, failedNwList)) {
continue;
}
for (Subnetmap subnetmap : subnetmapList) {
IpVersionChoice ipVers = NeutronvpnUtils.getIpVersionFromString(subnetmap.getSubnetIp());
if (!ipVersion.isIpVersionChosen(ipVers)) {
ipVersion = ipVersion.addVersion(ipVers);
}
}
// Update vpnInstance for IP address family
if (ipVersion != IpVersionChoice.UNDEFINED && !isIpFamilyUpdated) {
LOG.debug("associateNetworksToVpn: Updating vpnInstance with ip address family {}" + " for VPN {} ", ipVersion, vpnId);
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, true);
isIpFamilyUpdated = true;
}
for (Subnetmap subnetmap : subnetmapList) {
Uuid subnetId = subnetmap.getId();
Uuid subnetVpnId = neutronvpnUtils.getVpnForSubnet(subnetId);
if (subnetVpnId != null) {
LOG.error("associateNetworksToVpn: Failed to associate subnet {} with VPN {}" + " as it is already associated", subnetId.getValue(), subnetVpnId.getValue());
failedNwList.add(String.format("Failed to associate subnet %s with VPN %s" + " as it is already associated", subnetId.getValue(), vpnId.getValue()));
continue;
}
if (!NeutronvpnUtils.getIsExternal(network)) {
LOG.debug("associateNetworksToVpn: Add subnet {} to VPN {}", subnetId.getValue(), vpnId.getValue());
addSubnetToVpn(vpnId, subnetId, null);
vpnManager.updateRouteTargetsToSubnetAssociation(routeTargets, subnetmap.getSubnetIp(), vpnId.getValue());
passedNwList.add(nw);
}
}
passedNwList.add(nw);
// Handle association of external network(s) to Internet BGP-VPN Instance use case
if (!extNwMap.isEmpty() || extNwMap != null) {
for (Network extNw : extNwMap.values()) {
if (!associateExtNetworkToVpn(vpnId, extNw, vpnInstance.getBgpvpnType())) {
LOG.error("associateNetworksToVpn: Failed to associate Provider External Network {} with " + "VPN {}", extNw, vpnId.getValue());
failedNwList.add(String.format("Failed to associate Provider External Network %s with " + "VPN %s", extNw, vpnId.getValue()));
continue;
}
}
}
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("associateNetworksToVpn: Failed to associate VPN {} with networks {}: ", vpnId.getValue(), networkList, e);
failedNwList.add(String.format("Failed to associate VPN %s with networks %s: %s", vpnId.getValue(), networkList, e));
}
// VpnMap update for ext-nw is already done in associateExtNetworkToVpn() method.
if (!isExternalNetwork) {
updateVpnMaps(vpnId, null, null, null, new ArrayList<>(passedNwList));
}
LOG.info("Network(s) {} associated to L3VPN {} successfully", passedNwList, vpnId.getValue());
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project openflowplugin by opendaylight.
the class Activator method createMessages.
private static List<Message> createMessages(NodeRef nodeRef) {
List<Message> messages = new ArrayList<>();
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddGroupCaseBuilder().setAddGroupCaseData(new AddGroupCaseDataBuilder(createGroup(1L)).build()).build()).build());
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddFlowCaseBuilder().setAddFlowCaseData(new AddFlowCaseDataBuilder(createFlow("42", 1L, 1, (short) 1)).build()).build()).build());
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddFlowCaseBuilder().setAddFlowCaseData(new AddFlowCaseDataBuilder(createFlow("43", 1L, 2, (short) 2)).build()).build()).build());
LOG.debug("createMessages() passing {}", messages);
return messages;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project lispflowmapping by opendaylight.
the class LispSouthboundRPC method createGetStatsOutput.
private static GetStatsOutput createGetStatsOutput(ConcurrentLispSouthboundStats stats) {
long[] rxStats = stats.getRx();
long[] txStats = stats.getTx();
ControlMessageStatsBuilder cmsb = new ControlMessageStatsBuilder();
cmsb.setRxUnknown(stats.getRxUnknown());
cmsb.setTxErrors(stats.getTxErrors());
List<ControlMessage> messages = new ArrayList<ControlMessage>();
for (int i = 0; i <= ConcurrentLispSouthboundStats.MAX_LISP_TYPES; i++) {
if (MessageType.forValue(i) == null) {
continue;
}
ControlMessageBuilder cmb = new ControlMessageBuilder();
cmb.setMsgType(MessageType.forValue(i));
cmb.setRxCount(rxStats[i]);
cmb.setTxCount(txStats[i]);
messages.add(cmb.build());
}
cmsb.setControlMessage(messages);
MapRegisterCacheStatsBuilder mrcsb = new MapRegisterCacheStatsBuilder();
mrcsb.setHits(stats.getCacheHits());
mrcsb.setMisses(stats.getCacheMisses());
return new GetStatsOutputBuilder().setControlMessageStats(cmsb.build()).setMapRegisterCacheStats(mrcsb.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.Messages in project bgpcep by opendaylight.
the class PCCMockCommon method checkResyncSession.
static void checkResyncSession(final Optional<Integer> startAtNumberLsp, final int expectedNumberOfLsp, final int expectedTotalMessages, final BigInteger startingDBVersion, final BigInteger expectedDBVersion, final TestingSessionListener pceSessionListener) throws Exception {
assertNotNull(pceSessionListener.getSession());
assertTrue(pceSessionListener.isUp());
final List<Message> messages;
checkReceivedMessages(pceSessionListener, expectedTotalMessages);
if (startAtNumberLsp.isPresent()) {
messages = pceSessionListener.messages().subList(startAtNumberLsp.get(), startAtNumberLsp.get() + expectedNumberOfLsp);
} else {
messages = pceSessionListener.messages();
}
checkEquals(() -> checkSequequenceDBVersionSync(pceSessionListener, expectedDBVersion));
assertEquals(expectedNumberOfLsp, messages.size());
final PCEPSession session = pceSessionListener.getSession();
checkSession(session, DEAD_TIMER, KEEP_ALIVE);
assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
final BigInteger pceDBVersion = session.getLocalTlvs().getAugmentation(Tlvs3.class).getLspDbVersion().getLspDbVersionValue();
assertEquals(startingDBVersion, pceDBVersion);
}
Aggregations