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 ...");
35 String serviceNmame = input.getServiceName();
36 SdncRequestHeader sdncRequestHeader = input.getSdncRequestHeader();
37 ConnectionType conType = input.getConnectionType();
38 ComplianceCheckResult serviceHandlerCheckResult = ServicehandlerComplianceCheck.check(
39 serviceNmame, sdncRequestHeader, conType, rpcActions, true, true);
40 if (serviceHandlerCheckResult.hasPassed()) {
41 LOG.debug("Service request compliant !");
43 return OperationResult.failed(serviceHandlerCheckResult.getMessage());
46 * If compliant, service-request parameters are verified in order to
47 * check if there is no missing parameter that prevents calculating
48 * a path and implement a service.
50 LOG.debug("checking Tx/Rx Info for AEnd ...");
51 ComplianceCheckResult txrxCheckAEnd = ServicehandlerTxRxCheck.check(input.getServiceAEnd(),
52 ServiceEndpointType.SERVICEAEND);
53 if (txrxCheckAEnd.hasPassed()) {
54 LOG.debug("Tx/Rx Info for AEnd checked !");
56 return OperationResult.failed(txrxCheckAEnd.getMessage());
59 LOG.debug("checking Tx/Rx Info for ZEnd ...");
60 ComplianceCheckResult txrxCheckZEnd = ServicehandlerTxRxCheck.check(input.getServiceZEnd(),
61 ServiceEndpointType.SERVICEZEND);
62 if (txrxCheckZEnd.hasPassed()) {
63 LOG.debug("Tx/Rx Info for ZEnd checked");
65 * If OK, common-id is verified in order to see if there is
66 * no routing policy provided. If yes, the routing
67 * constraints of the policy are recovered and coherency
68 * with hard/soft constraints provided in the input of the
72 return OperationResult.failed(txrxCheckZEnd.getMessage());
75 if (input.getCommonId() != null) {
76 LOG.debug("Common-id specified");
77 // Check coherency with hard/soft constraints
78 if (CheckCoherencyHardSoft.check(input.getHardConstraints(), input.getSoftConstraints())) {
79 LOG.debug("hard/soft constraints coherent !");
81 return OperationResult.failed("hard/soft constraints are not coherent !");
84 LOG.warn("Common-id not specified !");
86 } catch (NullPointerException e) {
87 LOG.error("one of input parameter is null ",e);
88 return OperationResult.failed("one of input parameter is null.");
90 return OperationResult.ok("Validation successful.");
93 private ServiceCreateValidation() {