@Deprecated @Override protected String createFlowName() { StringBuilder sb = new StringBuilder(); sb.append(OFRendererConstants.INTENT_L2_FLOW_NAME); sb.append(endPointGroups.get(OFRendererConstants.SRC_END_POINT_GROUP_INDEX)); sb.append(endPointGroups.get(OFRendererConstants.DST_END_POINT_GROUP_INDEX)); sb.append(intent.getId().getValue()); return sb.toString(); }
@Override protected Object doExecute() throws Exception { List<Intent> listIntents = provider.listIntents(isConfigurationData); if (listIntents.size() > 0) { StringBuilder sb = new StringBuilder(); Integer counter = 1; for (Intent intent : listIntents) { sb.append(String.format("#%d - id: %s\n", counter, intent.getId().getValue())); counter++; } return sb.toString(); } else { return String.format("No intents found. Check the logs for more details."); } } }
/** * * @param intentKey * @return the user that created this intent */ private static UserId getUserId(IntentKey intentKey) { // for this release, assume userId to be the same as the NIC intent ID return new UserId(intentKey.getId().getValue()); }
/** * To set the redirect intent data * @param intent :intent */ private void addIntentToCache(Intent intent) { RedirectNodeData redirectNodeData; String intentId = intent.getId().getValue(); if (redirectNodeCache.get(intentId) == null) { redirectNodeData = new RedirectNodeData(); redirectNodeData.setIntent(intent); redirectNodeCache.put(intentId, redirectNodeData); } else { redirectNodeData = redirectNodeCache.get(intentId); redirectNodeData.setIntent(intent); } }
/** * @param buffer * the beginning string typed by the user * @param cursor * the position of the cursor * @param candidates * the list of completions proposed to the user */ @Override public int complete(String buffer, int cursor, List<String> candidates) { String query = (buffer == null) ? ".*" : buffer; if (!query.contains("*")) { query = query.concat(".*"); } StringsCompleter delegate = new StringsCompleter(); for (Intent intent : provider.listIntents(true)) { String id = intent.getId().getValue(); if (id.matches(query)) { candidates.add(id); delegate.getStrings().add(id); } } return delegate.complete(buffer, cursor, candidates); } }
sb.append(String.format("Intent Id: <%s>\n", intent.getId().getValue())); sb.append(String.format("Subjects: \n")); for (Subjects subjects : intent.getSubjects()) {
IntentKey lclIntentKey = lclIntent.getKey(); Uuid uuid = lclIntentKey.getId(); LOG.trace(" Intent Deleted :{} ", uuid.getValue()); String encodeUUID = vtnRendererUtility.encodeUUID(uuid.getValue()); vtnIntentParser.delFlowCondFilter(encodeUUID); if (!vtnRendererUtility.deleteIntent(lclIntent)) { LOG.error("Intent data's are not deleted from operational data store", uuid.getValue()); return; LOG.trace("Intent data's are successfully deleted from operational data store", uuid.getValue());
private void pushPortFlows(final ClassificationConstraint portConstraint, final NodeId nodeId, final FlowAction flowAction) { String portObject = ""; try { portObject = portConstraint.getClassificationConstraint().getClassifier(); } catch (NullPointerException npe) { throw new InvalidParameterException(CONSTRAINTS_NOT_FOUND_EXCEPTION + npe.getMessage()); } Gson gson = new Gson(); final NeutronSecurityRule securityRule = gson.fromJson(portObject, NeutronSecurityRule.class); final PortFlow portFlow = IntentFlowUtils.extractPortFlow(securityRule, endPointGroups); final Set<MatchBuilder> matchBuilders = portFlow.createPortRangeMatchBuilder(); for(MatchBuilder matchBuilder : matchBuilders) { final FlowBuilder flowBuilder = createFlowBuilder(matchBuilder); final Instructions builtInstructions = createOutputInstructions(OutputPortValues.NORMAL); flowBuilder.setInstructions(builtInstructions); flowName = portFlow.getFlowName(intent.getId().getValue()); writeDataTransaction(nodeId, flowBuilder, flowAction); } }
/** * This method parse the intent and calls the VTN renderer * */ private void intentParser(Intent intent) { if (!IntentUtils.verifyIntent(intent)) { return; } // Retrieve the Intent ID. String intentID = intent.getId().getValue(); // Retrieve the end points. final List<String> endPointGroups = IntentUtils.extractEndPointGroup(intent); String endPointSrc = endPointGroups.get(INDEX_OF_SRC_END_POINT_GROUP); String endPointDst = endPointGroups.get(INDEX_OF_DST_END_POINT_GROUP); // Get the type of the action. String actionType = getAction(intent); // get the encode UUID value String encodeUUID = vtnRendererUtility.encodeUUID(intentID); Status intentStatus = Status.CompletedError; // Convert the intent to VTN configuration. if (vtnIntentParser.containsIntentID(encodeUUID)) { intentStatus = vtnIntentParser.updateRendering(endPointSrc, endPointDst, actionType, intentID, encodeUUID, intent); } else { intentStatus = vtnIntentParser.rendering(endPointSrc, endPointDst, actionType, encodeUUID, intent); } LOG.trace("intent status: intentID={}, intentStatus={}", intentID, intentStatus); vtnRendererUtility.addIntent(intent, intentStatus); }
/** * Redirect flow construction and deletion entry * @param intent : intent * @param flowAction :Add flow action */ public void redirectFlowConstruction(Intent intent, FlowAction flowAction) { if (intent == null || flowAction == null) { LOG.error("intent and action cannot be null"); return; } this.flowAction = flowAction; if (flowAction.equals(FlowAction.ADD_FLOW)) { addSfcNodeInfoToCache(intent); addIntentToCache(intent); } else if (flowAction.equals(FlowAction.REMOVE_FLOW)) { InstanceIdentifier<NetworkTopology> path = InstanceIdentifier.builder(NetworkTopology.class).build(); NetworkTopology networkTopology = mdsal.read(LogicalDatastoreType.OPERATIONAL, path); for (Topology topology : networkTopology.getTopology()) { for (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network .topology.rev131021.network.topology.topology.Node node : topology.getNode()) { removeRedirectFlow(new NodeId(node.getNodeId().getValue()), intent); LOG.info("Remove Redirect flow from switch: {}", node.getNodeId().getValue()); } } LOG.trace("Removed redirect intent data from cache {}", intent.getId().getValue()); redirectNodeCache.remove(intent.getId().getValue()); } }
/** * To set the ingress and egress data to redirect cache * @param intent :intent */ private void addSfcNodeInfoToCache(Intent intent) { String intentId = intent.getId().getValue(); RedirectNodeData redirectNodeData = redirectNodeCache.get(intentId); if (redirectNodeData == null) { addIntentToCache(intent); redirectNodeData = redirectNodeCache.get(intentId); } Redirect actionContainer = (Redirect) intent.getActions().get(0).getAction(); org.opendaylight.yang.gen.v1.urn.opendaylight.intent.rev150122.intent.actions.action.redirect.Redirect redirectForService = actionContainer.getRedirect(); String serviceName = redirectForService.getServiceName(); String[] redirectSfcDataList = readRedirectSfcData(serviceName); redirectNodeData.setIngressNodeId(redirectSfcDataList[0]); redirectNodeData.setEgressNodeId(redirectSfcDataList[1]); deleteArpFlow(new NodeId(extractTopologyNodeId(redirectSfcDataList[0]).getValue())); deleteArpFlow(new NodeId(extractTopologyNodeId(redirectSfcDataList[1]).getValue())); }