use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.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 networks 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> networks) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
if (networks.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;
}
for (Uuid nw : networks) {
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.getAugmentation(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;
}
if (neutronvpnUtils.getIsExternal(network)) {
if (associateExtNetworkToVpn(vpnId, network)) {
passedNwList.add(nw);
continue;
} else {
LOG.error("associateNetworksToVpn: Failed to associate Provider Network {} with VPN {}", nw.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to associate Provider Network %s with VPN %s", nw.getValue(), vpnId.getValue()));
continue;
}
}
List<Uuid> networkSubnets = neutronvpnUtils.getSubnetIdsFromNetworkId(nw);
if (networkSubnets == null) {
passedNwList.add(nw);
continue;
}
for (Uuid subnet : networkSubnets) {
Uuid subnetVpnId = neutronvpnUtils.getVpnForSubnet(subnet);
if (subnetVpnId != null) {
LOG.error("associateNetworksToVpn: Failed to associate subnet {} with VPN {} as it is already " + "associated", subnet.getValue(), subnetVpnId.getValue());
failedNwList.add(String.format("Failed to associate subnet %s with VPN %s as it is already " + "associated", subnet.getValue(), vpnId.getValue()));
continue;
}
Subnetmap sm = neutronvpnUtils.getSubnetmap(subnet);
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToAdd(sm, vpnId)) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), NeutronvpnUtils.getIpVersionFromString(sm.getSubnetIp()), true);
}
LOG.debug("associateNetworksToVpn: Add subnet {} to VPN {}", subnet.getValue(), vpnId.getValue());
addSubnetToVpn(vpnId, subnet, null);
passedNwList.add(nw);
}
}
} catch (ReadFailedException e) {
LOG.error("associateNetworksToVpn: Failed to associate VPN {} with networks {}: ", vpnId.getValue(), networks, e);
failedNwList.add(String.format("Failed to associate VPN %s with networks %s: %s", vpnId.getValue(), networks, e));
}
LOG.info("associateNetworksToVpn: update VPN {} with networks list: {}", vpnId.getValue(), passedNwList.toString());
updateVpnMaps(vpnId, null, null, null, new ArrayList<Uuid>(passedNwList));
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.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 networks 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> networks) {
List<String> failedNwList = new ArrayList<>();
HashSet<Uuid> passedNwList = new HashSet<>();
if (networks.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 : networks) {
Network network = neutronvpnUtils.getNeutronNetwork(nw);
if (network == null) {
LOG.error("dissociateNetworksFromVpn: Network {} not found in ConfigDS");
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;
}
if (neutronvpnUtils.getIsExternal(network)) {
if (disassociateExtNetworkFromVpn(vpnId, network)) {
passedNwList.add(nw);
continue;
} else {
LOG.error("dissociateNetworksFromVpn: Failed to withdraw Provider Network {} from VPN {}", nw.getValue(), vpnId.getValue());
failedNwList.add(String.format("Failed to withdraw Provider Network %s from VPN %s", nw.getValue(), vpnId.getValue()));
continue;
}
}
List<Uuid> networkSubnets = neutronvpnUtils.getSubnetIdsFromNetworkId(nw);
if (networkSubnets == null) {
passedNwList.add(nw);
continue;
}
for (Uuid subnet : networkSubnets) {
Subnetmap sm = neutronvpnUtils.getSubnetmap(subnet);
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sm, vpnId)) {
IpVersionChoice ipVersionsToRemove = IpVersionChoice.UNDEFINED;
IpVersionChoice ipVersion = neutronvpnUtils.getIpVersionFromString(sm.getSubnetIp());
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersionsToRemove.addVersion(ipVersion), false);
}
LOG.debug("dissociateNetworksFromVpn: Withdraw subnet {} from VPN {}", subnet.getValue(), vpnId.getValue());
removeSubnetFromVpn(vpnId, subnet, null);
passedNwList.add(nw);
}
}
LOG.info("dissociateNetworksFromVpn: Withdraw networks list {} from VPN {}", networks.toString(), vpnId.getValue());
clearFromVpnMaps(vpnId, null, new ArrayList<Uuid>(passedNwList));
return failedNwList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.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.pcep.stats.rev171113.pcep.session.state.Messages in project bgpcep by opendaylight.
the class BGPSessionImpl method handleMessage.
/**
* Handles incoming message based on their type.
*
* @param msg incoming message
*/
synchronized void handleMessage(final Notification msg) {
if (this.state == State.IDLE) {
return;
}
try {
// Update last reception time
this.lastMessageReceivedAt = System.nanoTime();
if (msg instanceof Open) {
// Open messages should not be present here
this.terminate(new BGPDocumentedException(null, BGPError.FSM_ERROR));
} else if (msg instanceof Notify) {
final Notify notify = (Notify) msg;
// Notifications are handled internally
LOG.info("Session closed because Notification message received: {} / {}, data={}", notify.getErrorCode(), notify.getErrorSubcode(), notify.getData() != null ? ByteBufUtil.hexDump(notify.getData()) : null);
notifyTerminationReasonAndCloseWithoutMessage(notify.getErrorCode(), notify.getErrorSubcode());
} else if (msg instanceof Keepalive) {
// Keepalives are handled internally
LOG.trace("Received KeepAlive message.");
this.kaCounter++;
if (this.kaCounter >= 2) {
this.sync.kaReceived();
}
} else if (msg instanceof RouteRefresh) {
this.listener.onMessage(this, msg);
} else if (msg instanceof Update) {
this.listener.onMessage(this, msg);
this.sync.updReceived((Update) msg);
} else {
LOG.warn("Ignoring unhandled message: {}.", msg.getClass());
}
this.sessionState.messageReceived(msg);
} catch (final BGPDocumentedException e) {
this.terminate(e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages in project bgpcep by opendaylight.
the class PcepStateUtils method showMessages.
private static void showMessages(final ShellTable table, final Messages messages) {
if (messages == null) {
return;
}
addHeader(table, "Messages");
table.addRow().addContent("Last Sent Msg Timestamp", messages.getLastSentMsgTimestamp());
table.addRow().addContent("Received Msg Count", messages.getReceivedMsgCount());
table.addRow().addContent("Sent Msg Count", messages.getSentMsgCount());
table.addRow().addContent("Unknown Msg Received", messages.getUnknownMsgReceived());
final StatefulMessagesStatsAug statefulMessages = messages.getAugmentation(StatefulMessagesStatsAug.class);
if (statefulMessages == null) {
return;
}
addHeader(table, " Stateful Messages");
table.addRow().addContent("Last Received RptMsg Timestamp", statefulMessages.getLastReceivedRptMsgTimestamp());
table.addRow().addContent("Received RptMsg", statefulMessages.getReceivedRptMsgCount());
table.addRow().addContent("Sent Init Msg", statefulMessages.getSentInitMsgCount());
table.addRow().addContent("Sent Upd Msg", statefulMessages.getSentUpdMsgCount());
}
Aggregations