Search in sources :

Example 1 with Pair

use of org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair in project onos by opennetworkinglab.

the class PolatisFlowRuleProgrammable method editConnection.

private boolean editConnection(FlowRule rule, String mode) {
    CrossConnects crossConnects = PolatisOpticalUtility.fromFlowRule(this, rule);
    final StringBuilder cfg = new StringBuilder(xmlOpen(KEY_CONNS_XMLNS));
    List<Pair> pairs = crossConnects.pair();
    final String keyPairCompat = parseKeyPairCompat(this);
    final String keyPairMode = String.format("%s operation=\"%s\"", keyPairCompat, mode);
    pairs.forEach(p -> {
        cfg.append(xmlOpen(keyPairMode)).append(xmlOpen(KEY_SRC)).append(p.ingress()).append(xmlClose(KEY_SRC)).append(xmlOpen(KEY_DST)).append(p.egress()).append(xmlClose(KEY_DST)).append(xmlClose(keyPairCompat));
    });
    cfg.append(xmlClose(KEY_CONNS));
    return netconfEditConfig(handler(), null, cfg.toString());
}
Also used : CrossConnects(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.CrossConnects) Pair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair)

Example 2 with Pair

use of org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair in project onos by opennetworkinglab.

the class PolatisOpticalUtility method toFlowRule.

/**
 * Finds the FlowRule from flow rule store by the given cross connect information.
 * Returns an extra flow to remove the flow by ONOS if not found.
 * @param behaviour the parent driver handler
 * @param cfg cross connect information
 * @return the flow rule
 */
public static FlowRule toFlowRule(HandlerBehaviour behaviour, CrossConnects cfg) {
    // Note: do we need to handle more than one pair? In any case, this
    // looks strange.
    Pair p = cfg.pair().get(0);
    long i = p.ingress().uint32();
    long o = p.egress().uint32();
    PortNumber iPortNumber = PortNumber.portNumber(i);
    PortNumber oPortNumber = PortNumber.portNumber(o);
    return toFlowRule(behaviour, iPortNumber, oPortNumber);
}
Also used : PortNumber(org.onosproject.net.PortNumber) Pair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair) DefaultPair(org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.DefaultPair)

Example 3 with Pair

use of org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair in project onos by opennetworkinglab.

the class DcsBasedTapiConnectivityRpc method createConnectivityService.

/**
 * Service interface of createConnectivityService.
 *
 * @param inputVar input of service interface createConnectivityService
 * @return output of service interface createConnectivityService
 */
@Override
public RpcOutput createConnectivityService(RpcInput inputVar) {
    try {
        TapiCreateConnectivityInputHandler input = new TapiCreateConnectivityInputHandler();
        input.setRpcInput(inputVar);
        log.info("input SIPs: {}", input.getSips());
        // check SIP validation
        if (!disjoint(getUsedSips(), input.getSips())) {
            log.error("SIPS {} are already used, please use a different pair", input.getSips());
            return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
        }
        log.debug("check SIP validation : OK");
        List<TapiNepRef> nepRefs = input.getSips().stream().map(sipId -> resolver.getNepRef(sipId)).collect(Collectors.toList());
        // setup connections
        TapiNepPair neps = TapiNepPair.create(nepRefs.get(0), nepRefs.get(1));
        // Allocate a connectivity Service
        TapiConnectivityServiceHandler connectivityServiceHandler = TapiConnectivityServiceHandler.create();
        // This connectivity service will be supported over a single end-to-end connection
        // Allocate a manager for that connection
        DcsBasedTapiConnectionManager connectionManager = DcsBasedTapiConnectionManager.create();
        TapiConnectionHandler connectionHandler = connectionManager.createConnection(neps);
        // Add the supporting connection uuid to the service
        connectivityServiceHandler.addConnection(connectionHandler.getModelObject().uuid());
        neps.stream().map(nepRef -> TapiSepHandler.create().setSip(nepRef.getSipId())).forEach(sepBuilder -> {
            connectivityServiceHandler.addSep(sepBuilder.getModelObject());
        });
        // build
        connectionManager.apply();
        connectivityServiceHandler.add();
        // output
        TapiCreateConnectivityOutputHandler output = TapiCreateConnectivityOutputHandler.create().addService(connectivityServiceHandler.getModelObject());
        return new RpcOutput(RpcOutput.Status.RPC_SUCCESS, output.getDataNode());
    } catch (Throwable e) {
        log.error("Error:", e);
        return new RpcOutput(RpcOutput.Status.RPC_FAILURE, null);
    }
}
Also used : TapiConnectivityService(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.TapiConnectivityService) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler) LoggerFactory(org.slf4j.LoggerFactory) Collections.disjoint(java.util.Collections.disjoint) TapiCreateConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityInputHandler) ArrayList(java.util.ArrayList) TapiDeleteConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler) TapiSepHandler(org.onosproject.odtn.utils.tapi.TapiSepHandler) TapiConnectionHandler(org.onosproject.odtn.utils.tapi.TapiConnectionHandler) DynamicConfigService(org.onosproject.config.DynamicConfigService) TapiNepPair(org.onosproject.odtn.utils.tapi.TapiNepPair) DefaultServiceDirectory.getService(org.onlab.osgi.DefaultServiceDirectory.getService) RpcInput(org.onosproject.yang.model.RpcInput) Logger(org.slf4j.Logger) TapiCreateConnectivityOutputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityOutputHandler) TapiResolver(org.onosproject.odtn.TapiResolver) ModelConverter(org.onosproject.yang.model.ModelConverter) TapiObjectHandler(org.onosproject.odtn.utils.tapi.TapiObjectHandler) DefaultConnectivityService(org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connectivitycontext.DefaultConnectivityService) Collectors(java.util.stream.Collectors) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiGetConnectivityListOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityListOutputHandler) Uuid(org.onosproject.yang.gen.v1.tapicommon.rev20181210.tapicommon.Uuid) TapiGetConnectivityDetailsOutputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsOutputHandler) TapiGetConnectivityDetailsInputHandler(org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler) List(java.util.List) TapiContextHandler(org.onosproject.odtn.utils.tapi.TapiContextHandler) TapiConnectionHandler(org.onosproject.odtn.utils.tapi.TapiConnectionHandler) TapiNepRef(org.onosproject.odtn.utils.tapi.TapiNepRef) TapiNepPair(org.onosproject.odtn.utils.tapi.TapiNepPair) RpcOutput(org.onosproject.yang.model.RpcOutput) TapiCreateConnectivityInputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityInputHandler) TapiConnectivityServiceHandler(org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler) TapiCreateConnectivityOutputHandler(org.onosproject.odtn.utils.tapi.TapiCreateConnectivityOutputHandler)

Aggregations

Pair (org.onosproject.yang.gen.v1.opticalswitch.rev20180322.opticalswitch.crossconnects.Pair)2 ArrayList (java.util.ArrayList)1 Collections.disjoint (java.util.Collections.disjoint)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DefaultServiceDirectory.getService (org.onlab.osgi.DefaultServiceDirectory.getService)1 DynamicConfigService (org.onosproject.config.DynamicConfigService)1 PortNumber (org.onosproject.net.PortNumber)1 TapiResolver (org.onosproject.odtn.TapiResolver)1 TapiConnectionHandler (org.onosproject.odtn.utils.tapi.TapiConnectionHandler)1 TapiConnectivityServiceHandler (org.onosproject.odtn.utils.tapi.TapiConnectivityServiceHandler)1 TapiContextHandler (org.onosproject.odtn.utils.tapi.TapiContextHandler)1 TapiCreateConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiCreateConnectivityInputHandler)1 TapiCreateConnectivityOutputHandler (org.onosproject.odtn.utils.tapi.TapiCreateConnectivityOutputHandler)1 TapiDeleteConnectivityInputHandler (org.onosproject.odtn.utils.tapi.TapiDeleteConnectivityInputHandler)1 TapiGetConnectivityDetailsInputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsInputHandler)1 TapiGetConnectivityDetailsOutputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityDetailsOutputHandler)1 TapiGetConnectivityListOutputHandler (org.onosproject.odtn.utils.tapi.TapiGetConnectivityListOutputHandler)1 TapiNepPair (org.onosproject.odtn.utils.tapi.TapiNepPair)1 TapiNepRef (org.onosproject.odtn.utils.tapi.TapiNepRef)1