2 * Copyright © 2017 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.servicehandler.validation;
11 import org.opendaylight.transportpce.common.OperationResult;
12 import org.opendaylight.transportpce.servicehandler.ServiceEndpointType;
13 import org.opendaylight.transportpce.servicehandler.ServiceInput;
14 import org.opendaylight.transportpce.servicehandler.validation.checks.CheckCoherencyHardSoft;
15 import org.opendaylight.transportpce.servicehandler.validation.checks.ComplianceCheckResult;
16 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerComplianceCheck;
17 import org.opendaylight.transportpce.servicehandler.validation.checks.ServicehandlerTxRxCheck;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.ConnectionType;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.RpcActions;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev211210.sdnc.request.header.SdncRequestHeader;
21 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory;
24 public final class ServiceCreateValidation {
25 private static final Logger LOG = LoggerFactory.getLogger(ServiceCreateValidation.class);
27 public static OperationResult validateServiceCreateRequest(ServiceInput input, RpcActions rpcActions) {
29 * Upon receipt of service
30 * -create RPC, service header and sdnc
31 * -request header compliancy are verified.
33 LOG.debug("checking Service Compliance ...");
34 String serviceNmame = input.getServiceName();
35 SdncRequestHeader sdncRequestHeader = input.getSdncRequestHeader();
36 ConnectionType conType = input.getConnectionType();
37 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
38 serviceNmame, sdncRequestHeader, conType, rpcActions, true, true);
39 if (serviceHandlerCheckResult.hasPassed()) {
40 LOG.debug("Service request compliant !");
42 return OperationResult.failed(serviceHandlerCheckResult.getMessage());
45 * If compliant, service-request parameters are verified in order to
46 * check if there is no missing parameter that prevents calculating
47 * a path and implement a service.
49 LOG.debug("checking Tx/Rx Info for AEnd ...");
50 ComplianceCheckResult txrxCheckAEnd = ServicehandlerTxRxCheck.check(input.getServiceAEnd(),
51 ServiceEndpointType.SERVICEAEND);
52 if (txrxCheckAEnd.hasPassed()) {
53 LOG.debug("Tx/Rx Info for AEnd checked !");
55 return OperationResult.failed(txrxCheckAEnd.getMessage());
58 LOG.debug("checking Tx/Rx Info for ZEnd ...");
59 ComplianceCheckResult txrxCheckZEnd = ServicehandlerTxRxCheck.check(input.getServiceZEnd(),
60 ServiceEndpointType.SERVICEZEND);
61 if (txrxCheckZEnd.hasPassed()) {
62 LOG.debug("Tx/Rx Info for ZEnd checked");
64 * If OK, common-id is verified in order to see if there is
65 * no routing policy provided. If yes, the routing
66 * constraints of the policy are recovered and coherency
67 * with hard/soft constraints provided in the input of the
71 return OperationResult.failed(txrxCheckZEnd.getMessage());
74 if (input.getCommonId() != null) {
75 LOG.debug("Common-id specified");
76 // Check coherency with hard/soft constraints
77 if (CheckCoherencyHardSoft.check(input.getHardConstraints(), input.getSoftConstraints())) {
78 LOG.debug("hard/soft constraints coherent !");
80 return OperationResult.failed("hard/soft constraints are not coherent !");
83 LOG.warn("Common-id not specified !");
85 return OperationResult.ok("Validation successful.");
88 private ServiceCreateValidation() {