2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.requesthandler.impl;
27 import com.att.eelf.i18n.EELFResourceManager;
28 import org.onap.appc.domainmodel.lcm.RuntimeContext;
29 import org.onap.appc.domainmodel.lcm.VNFContext;
30 import org.onap.appc.domainmodel.lcm.VNFOperation;
31 import org.onap.appc.i18n.Msg;
32 import org.onap.appc.logging.LoggingConstants;
33 import org.onap.appc.logging.LoggingUtils;
34 import org.onap.appc.requesthandler.exceptions.*;
36 import java.util.HashSet;
39 public class VMRequestValidatorImpl extends AbstractRequestValidatorImpl {
42 public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, InvalidInputException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException, DuplicateRequestException {
43 if(!lcmStateManager.isLCMOperationEnabled()) {
44 LoggingUtils.logErrorMessage(
45 LoggingConstants.TargetNames.REQUEST_VALIDATOR,
46 EELFResourceManager.format(Msg.LCM_OPERATIONS_DISABLED),
47 this.getClass().getCanonicalName());
48 throw new LCMOperationsDisabledException("APPC LCM operations have been administratively disabled");
52 super.validateInput(runtimeContext.getRequestContext());
53 String vnfId = runtimeContext.getRequestContext().getActionIdentifiers().getVnfId();
55 VNFContext vnfContext = queryAAI(vnfId);
56 runtimeContext.setVnfContext(vnfContext);
58 VNFOperation operation = runtimeContext.getRequestContext().getAction();
59 if(supportedVMLevelAction().contains(operation)) {
60 queryWFM(vnfContext, runtimeContext.getRequestContext());
63 throw new LCMOperationsDisabledException("Action "+ operation.name() + " is not supported on VM level");
67 public Set<VNFOperation> supportedVMLevelAction(){
68 Set<VNFOperation> vnfOperations = new HashSet<>();
69 vnfOperations.add(VNFOperation.Start);
70 vnfOperations.add(VNFOperation.Stop);
71 vnfOperations.add(VNFOperation.Restart);
72 vnfOperations.add(VNFOperation.Rebuild);
73 vnfOperations.add(VNFOperation.Terminate);
74 vnfOperations.add(VNFOperation.Migrate);
75 vnfOperations.add(VNFOperation.Evacuate);
76 vnfOperations.add(VNFOperation.Snapshot);