/** * Return a string configured in the given URI. * * @param uri An {@link Uri} instance. * @return A string configured in the given URI. * Note that {@code null} is returned if {@code uri} is * {@code null}. */ public static String getValue(Uri uri) { return (uri == null) ? null : uri.getValue(); }
/** * Determine whether the given two URIs are identical or not. * * <p> * Note that this method compares only strings configured in the given * URIs. The type of classes are never compared. * * </p> * * @param u1 The first instance to be compared. * @param u2 The second instance to be compared. * @return {@code true} only if {@code vh1} and {@code vh2} are identical. */ public static boolean equalsUri(Uri u1, Uri u2) { if (u1 == null) { return (u2 == null); } else if (u2 == null) { return false; } return Objects.equals(u1.getValue(), u2.getValue()); }
@XmlElement(name = "namespace") public String getNamespace() { return schema.getNamespace().getValue().toString(); }
private void processOutputAction(OutputActionCase action, FlowTableLookUpResult result) { Uri nodeConnector = action.getOutputAction().getOutputNodeConnector(); if (nodeConnector.getValue().matches("\\d+")) { result.outputNodeConnectors.add(nodeConnector); } else if (nodeConnector.getValue().matches("CONTROLLER")) { result.sendToController = true; } }
public char[] getValue() { if (_value == null) { if (_enumeration != null) { _value = _enumeration.toString().toCharArray(); } else if (_uri != null) { _value = _uri.getValue().toString().toCharArray(); } } return _value == null ? null : _value.clone(); }
@Override protected void setRestUriList(DataObject dataObject) { ServiceFunctionGroup obj = (ServiceFunctionGroup) dataObject; if (obj.getRestUri() != null) { String restUri = obj.getRestUri().getValue() + SFG_REST_URI + obj.getName(); this.restUriList = new ArrayList<>(); this.restUriList.add(restUri); LOG.info("SFG will be send to REST URI {}", restUri); } else { this.restUriList = null; } } }
/** * {@inheritDoc} */ @Override public String getDescription(Action act) throws RpcException { OutputActionCase ac = cast(OutputActionCase.class, act); OutputAction action = ac.getOutputAction(); String port = null; Integer len = null; if (action != null) { len = action.getMaxLength(); Uri uri = action.getOutputNodeConnector(); if (uri != null) { port = uri.getValue(); } } return new StringBuilder("OUTPUT(port="). append(port).append(", len=").append(len).append(')').toString(); }
/** * Return the egress switch port specified by the given action. * * @param action An {@link OutputActionCase} instance. * @return A MD-SAL node connector identifier which specifies the output * switch port. {@code null} if not found. */ private static String getOutputPort(OutputActionCase action) { OutputAction output = action.getOutputAction(); if (output != null) { Uri uri = output.getOutputNodeConnector(); if (uri != null) { return uri.getValue(); } } return null; }
@Override protected void setRestUriList(DataObject dataObject) { ServiceFunction obj = (ServiceFunction) dataObject; if (obj.getRestUri() != null) { SfName sfName = obj.getName(); if (sfName != null) { String restUri = obj.getRestUri().getValue() + SF_REST_URI + sfName.getValue(); this.restUriList = new ArrayList<>(); this.restUriList.add(restUri); LOG.info("SF will be send to REST URI {}", restUri); } } else { this.restUriList = null; } } }
@Override protected void setRestUriList(DataObject dataObject) { ServiceFunctionForwarder obj = (ServiceFunctionForwarder) dataObject; if (obj.getRestUri() != null) { SffName sffName = obj.getName(); if (sffName != null) { String restUri = obj.getRestUri().getValue() + SFF_REST_URI + sffName.getValue(); this.restUriList = new ArrayList<>(); this.restUriList.add(restUri); LOG.info("SFF will be send to REST URI {}", restUri); } } else { this.restUriList = null; } }
private ArrayList<String> getRestUriListFromSclServiceForwarderList( List<SclServiceFunctionForwarder> sclServiceForwarderList, String aclName, java.lang.Class<? extends AclBase> aclType) { // rest uri list should be created from Classifier SFFs. Classifier will be taken from ACL ArrayList<String> sffRestUriList = new ArrayList<>(); if (sclServiceForwarderList != null && aclName != null && aclType != null ) { for (SclServiceFunctionForwarder sclServiceForwarder : sclServiceForwarderList) { SffName sffName = new SffName(sclServiceForwarder.getName()); ServiceFunctionForwarder serviceForwarder = SfcProviderServiceForwarderAPI.readServiceFunctionForwarder(sffName); if (serviceForwarder != null && serviceForwarder.getRestUri() != null && !serviceForwarder.getRestUri().getValue().isEmpty()) { String restUri = serviceForwarder.getRestUri().getValue() + ACL_REST_URI + aclName; sffRestUriList.add(restUri); LOG.info("ACL will be send to REST URI {}", restUri); } } } return sffRestUriList.isEmpty() ? null : sffRestUriList; } }
/** * Determine whether the given action list contains only one output action * that transmits packets to the given port or not. * * @param actions An action list. * @param pid The target port identifier. * @return {@code true} if the given action list contains only one output * action that specifies the given port. * Otherwise {@code false}. */ public static boolean isOutput(List<Action> actions, String pid) { boolean result = false; if (actions != null && actions.size() == 1) { Action act = actions.get(0); org.opendaylight.yang.gen.v1.urn.opendaylight.action.types. rev131112.action.Action a = act.getAction(); if (a instanceof OutputActionCase) { OutputActionCase outCase = (OutputActionCase)a; OutputAction out = outCase.getOutputAction(); if (out != null) { Uri uri = out.getOutputNodeConnector(); result = (uri != null && pid.equals(uri.getValue())); } } } return result; }
public static Map<UUID, Controller> createOvsdbController(OvsdbBridgeAugmentation omn,DatabaseSchema dbSchema) { List<ControllerEntry> controllerEntries = omn.getControllerEntry(); Map<UUID,Controller> controllerMap = new HashMap<>(); if (controllerEntries != null && !controllerEntries.isEmpty()) { for (ControllerEntry controllerEntry : controllerEntries) { String controllerNamedUuid = "Controller_" + getRandomUuid(); Controller controller = TyperUtils.getTypedRowWrapper(dbSchema, Controller.class); controller.setTarget(controllerEntry.getTarget().getValue()); controllerMap.put(new UUID(controllerNamedUuid), controller); } } return controllerMap; }
private void pushChildren(LinkNode node, FlowTableMatcher.FlowTableLookUpResult result) { for (int i = 0; i < result.outputNodeConnectors.size(); i++) { String srcTpId = NameConverter.buildNodeConnectorId( node.dstNodeId(), result.outputNodeConnectors.get(i).getValue()); Link link = linkService.getLinkBySourceTpId(srcTpId); if (link != null) { LinkNode childNode = createLinkNode(link, result.meterId); node.addChild(childNode); if (!visitedInPort.containsKey(childNode.dstTpId())) { pathStack.add(childNode); } } } }
@Override protected void setRestUriList(DataObject dataObject) { RenderedServicePath obj = (RenderedServicePath) dataObject; List<RenderedServicePathHop> hopList = obj.getRenderedServicePathHop(); this.restUriList = new ArrayList<>(); if (hopList != null) { for (RenderedServicePathHop hop : hopList) { ServiceFunctionForwarder sff = SfcProviderServiceForwarderAPI .readServiceFunctionForwarder(hop.getServiceFunctionForwarder()); if (sff != null && sff.getRestUri() != null) { RspName rspName = obj.getName(); if (rspName != null) { String restUri = sff.getRestUri().getValue() + RSP_REST_URI + rspName.getValue(); this.restUriList.add(restUri); LOG.info("RSP will be send to REST URI {}", restUri); } } } } if (this.restUriList != null && this.restUriList.isEmpty()) { this.restUriList = null; } } }
@Override protected void setRestUriList(DataObject dataObject) { ServiceFunctionState obj = (ServiceFunctionState) dataObject; this.restUriList = new ArrayList<>(); if (SfcProviderServiceFunctionAPI.readServiceFunction(obj.getName())!=null) { ServiceFunction serviceFunction = SfcProviderServiceFunctionAPI.readServiceFunction(obj.getName()); if (serviceFunction.getRestUri() != null) { SfName sfName = obj.getName(); if (sfName != null) { String restUri = serviceFunction.getRestUri().getValue() + SFSTATE_REST_URI + sfName.getValue(); this.restUriList.add(restUri); LOG.info("Service Function state will be sent to REST URI {}", restUri); } } else { this.restUriList = null; } } else { this.restUriList = null; } }
private String getQueueUuid(OvsdbQueueRef queueRef, OvsdbNodeAugmentation operNode) { QueuesKey queueKey = queueRef.getValue().firstKeyOf(Queues.class); if (operNode.getQueues() != null && !operNode.getQueues().isEmpty()) { for (Queues queue : operNode.getQueues()) { if (queue.getQueueId().equals(queueKey.getQueueId())) { return queue.getQueueUuid().getValue(); } } } return SouthboundConstants.QUEUE_NAMED_UUID_PREFIX + TransactUtils.bytesToHexString(queueKey.getQueueId().getValue().getBytes()); }
@SuppressWarnings("unchecked") private String getQosId(Qos qos) { if (qos.getExternalIdsColumn() != null && qos.getExternalIdsColumn().getData() != null) { if (qos.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) { InstanceIdentifier<QosEntries> qosIid = (InstanceIdentifier<QosEntries>) SouthboundUtil.deserializeInstanceIdentifier( qos.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY)); if (qosIid != null) { QosEntriesKey qosEntriesKey = qosIid.firstKeyOf(QosEntries.class); if (qosEntriesKey != null) { return qosEntriesKey.getQosId().getValue(); } } } else if (qos.getExternalIdsColumn().getData().containsKey(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY)) { return qos.getExternalIdsColumn().getData().get(SouthboundConstants.QOS_ID_EXTERNAL_ID_KEY); } } return SouthboundConstants.QOS_URI_PREFIX + "://" + qos.getUuid().toString(); }
@SuppressWarnings("unchecked") private String getQueueId(Queue queue) { if (queue.getExternalIdsColumn() != null && queue.getExternalIdsColumn().getData() != null) { if (queue.getExternalIdsColumn().getData().containsKey(SouthboundConstants.IID_EXTERNAL_ID_KEY)) { InstanceIdentifier<Queues> queueIid = (InstanceIdentifier<Queues>) SouthboundUtil.deserializeInstanceIdentifier( queue.getExternalIdsColumn().getData().get(SouthboundConstants.IID_EXTERNAL_ID_KEY)); if (queueIid != null) { QueuesKey queuesKey = queueIid.firstKeyOf(Queues.class); if (queuesKey != null) { return queuesKey.getQueueId().getValue(); } } } else if (queue.getExternalIdsColumn().getData() .containsKey(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY)) { return queue.getExternalIdsColumn().getData().get(SouthboundConstants.QUEUE_ID_EXTERNAL_ID_KEY); } } return SouthboundConstants.QUEUE_URI_PREFIX + "://" + queue.getUuid().toString(); }
@Nonnull @Override public Optional<Action> process(@Nonnull final OutputActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) { final OutputAction outputAction = source.getOutputAction(); final OutputActionBuilder outputBuilder = new OutputActionBuilder(); if (outputAction.getMaxLength() != null) { outputBuilder.setMaxLength(outputAction.getMaxLength()); } else { outputBuilder.setMaxLength(0); } final OpenflowVersion version = OpenflowVersion.get(data.getVersion()); final String nodeConnectorId = outputAction.getOutputNodeConnector().getValue(); final Long portNumber = InventoryDataServiceUtil.portNumberfromNodeConnectorId(version, nodeConnectorId); if (OpenflowPortsUtil.checkPortValidity(version, portNumber)) { outputBuilder.setPort(new PortNumber(portNumber)); } else { LOG.error("Invalid Port specified {} for Output Action for OF version: {}", portNumber, version); } return Optional.of(new ActionBuilder() .setActionChoice(new OutputActionCaseBuilder() .setOutputAction(outputBuilder.build()) .build()) .build()); } }