2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.sli.adaptors.ra.alloc;
24 import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationRule;
25 import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
26 import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
27 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
28 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
29 import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
30 import org.onap.ccsdk.sli.adaptors.util.vrf.VpnParam;
31 import org.onap.ccsdk.sli.adaptors.util.vrf.VrfUtil;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class ServingSiteAllocationRule implements AllocationRule {
37 private static final Logger log = LoggerFactory.getLogger(ServingSiteAllocationRule.class);
40 public AllocationRequest buildAllocationRequest(
41 String resourceUnionId,
43 String endPointPosition,
44 ServiceData serviceData,
45 EquipmentData equipmentData,
48 String vrfName = (String) serviceData.data.get("vrf-name");
52 log.info("vrfName: " + vrfName);
54 String v4ServingSiteStr = (String) serviceData.data.get("v4-serving-site");
55 String v6ServingSiteStr = (String) serviceData.data.get("v6-serving-site");
56 boolean v4ServingSite = v4ServingSiteStr != null &&
57 (v4ServingSiteStr.equalsIgnoreCase("Y") || v4ServingSiteStr.equalsIgnoreCase("true"));
58 boolean v6ServingSite = v6ServingSiteStr != null &&
59 (v6ServingSiteStr.equalsIgnoreCase("Y") || v6ServingSiteStr.equalsIgnoreCase("true"));
60 if (!v4ServingSite && !v6ServingSite)
63 VpnParam vpnp = VrfUtil.parseVrfInstanceName(vrfName);
65 LimitAllocationRequest ar = new LimitAllocationRequest();
66 ar.resourceSetId = resourceSetId;
67 ar.resourceUnionId = resourceUnionId;
68 ar.resourceName = "ServingSite";
69 ar.assetId = equipmentData.equipmentId + "-" + vpnp.vpnId;
70 ar.missingResourceAction = AllocationAction.Succeed_Allocate;
71 ar.expiredResourceAction = AllocationAction.Succeed_Allocate;