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());
}
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);
}
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);
}
}
Aggregations