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.sdnc;
23 import java.util.UUID;
24 import org.apache.commons.lang3.StringUtils;
25 import org.onap.policy.controlloop.VirtualControlLoopEvent;
26 import org.onap.policy.sdnc.SdncHealNetworkInfo;
27 import org.onap.policy.sdnc.SdncHealRequest;
28 import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
29 import org.onap.policy.sdnc.SdncHealRequestInfo;
30 import org.onap.policy.sdnc.SdncHealServiceInfo;
31 import org.onap.policy.sdnc.SdncRequest;
33 public class RerouteOperator extends SdncOperator {
34 public static final String NAME = "Reroute";
37 * Constructs the object.
39 * @param actorName name of the actor with which this operator is associated
41 public RerouteOperator(String actorName) {
42 super(actorName, NAME);
46 protected SdncRequest constructRequest(VirtualControlLoopEvent onset) {
47 String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
48 if (StringUtils.isBlank(serviceInstance)) {
49 throw new IllegalArgumentException("missing enrichment data, service-instance-id");
51 SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo();
52 serviceInfo.setServiceInstanceId(serviceInstance);
54 String networkId = onset.getAai().get("network-information.network-id");
55 if (StringUtils.isBlank(networkId)) {
56 throw new IllegalArgumentException("missing enrichment data, network-id");
58 SdncHealNetworkInfo networkInfo = new SdncHealNetworkInfo();
59 networkInfo.setNetworkId(networkId);
61 SdncHealRequestInfo requestInfo = new SdncHealRequestInfo();
62 requestInfo.setRequestAction("ReoptimizeSOTNInstance");
64 SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
65 headerInfo.setSvcAction("reoptimize");
66 headerInfo.setSvcRequestId(UUID.randomUUID().toString());
68 SdncRequest request = new SdncRequest();
69 request.setNsInstanceId(serviceInstance);
70 request.setRequestId(onset.getRequestId());
71 request.setUrl("/GENERIC-RESOURCE-API:network-topology-operation");
73 SdncHealRequest healRequest = new SdncHealRequest();
74 healRequest.setRequestHeaderInfo(headerInfo);
75 healRequest.setNetworkInfo(networkInfo);
76 healRequest.setRequestInfo(requestInfo);
77 healRequest.setServiceInfo(serviceInfo);
78 request.setHealRequest(healRequest);