2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.controlloop.actor.appc;
23 import java.util.List;
24 import java.util.concurrent.CompletableFuture;
25 import org.onap.aai.domain.yang.GenericVnf;
26 import org.onap.policy.aai.AaiConstants;
27 import org.onap.policy.aai.AaiCqResponse;
28 import org.onap.policy.appc.Request;
29 import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
30 import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
31 import org.onap.policy.controlloop.actorserviceprovider.parameters.BidirectionalTopicConfig;
32 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 public class ModifyConfigOperation extends AppcOperation {
37 private static final Logger logger = LoggerFactory.getLogger(ModifyConfigOperation.class);
39 public static final String NAME = "ModifyConfig";
41 private static final List<String> PROPERTY_NAMES = List.of(OperationProperties.AAI_RESOURCE_VNF);
44 * Constructs the object.
46 * @param params operation parameters
47 * @param config configuration for this operation
49 public ModifyConfigOperation(ControlLoopOperationParams params, BidirectionalTopicConfig config) {
50 super(params, config, PROPERTY_NAMES);
54 * Ensures that A&AI customer query has been performed, and then runs the guard query.
57 @SuppressWarnings("unchecked")
58 protected CompletableFuture<OperationOutcome> startPreprocessorAsync() {
59 if (params.isPreprocessed()) {
63 ControlLoopOperationParams cqParams = params.toBuilder().actor(AaiConstants.ACTOR_NAME)
64 .operation(AaiCqResponse.OPERATION).payload(null).retry(null).timeoutSec(null).build();
66 // run Custom Query and Guard, in parallel
67 return allOf(() -> params.getContext().obtain(AaiCqResponse.CONTEXT_KEY, cqParams), this::startGuardAsync);
71 protected Request makeRequest(int attempt) {
72 AaiCqResponse cq = params.getContext().getProperty(AaiCqResponse.CONTEXT_KEY);
74 GenericVnf genvnf = cq.getGenericVnfByModelInvariantId(params.getTarget().getResourceID());
76 logger.info("{}: target entity could not be found for {}", getFullName(), params.getRequestId());
77 throw new IllegalArgumentException("target vnf-id could not be found");
80 return makeRequest(attempt, genvnf.getVnfId());