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 java.util.ArrayList;
25 import java.util.HashSet;
28 import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationRule;
29 import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
30 import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
31 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
32 import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
33 import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
34 import org.onap.ccsdk.sli.adaptors.rm.data.MultiResourceAllocationRequest;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
38 public class VrfAllocationRule implements AllocationRule {
40 private static final Logger log = LoggerFactory.getLogger(VrfAllocationRule.class);
43 public AllocationRequest buildAllocationRequest(
44 String resourceUnionId,
46 String endPointPosition,
47 ServiceData serviceData,
48 EquipmentData equipmentData,
51 String vrfName = (String) serviceData.data.get("vrf-name");
55 log.info("vrfName: " + vrfName);
57 Set<String> resourceShareGroupList = new HashSet<>();
58 resourceShareGroupList.add(vrfName);
60 LimitAllocationRequest ar = new LimitAllocationRequest();
61 ar.resourceSetId = resourceSetId;
62 ar.resourceUnionId = resourceUnionId;
63 ar.resourceShareGroupList = resourceShareGroupList;
64 ar.resourceName = "VRF";
65 ar.assetId = equipmentData.equipmentId;
66 ar.missingResourceAction = AllocationAction.Succeed_Allocate;
67 ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
70 ar.checkLimit = 999999999;
74 String v4MulticastStr = (String) serviceData.data.get("v4-multicast");
75 String v6MulticastStr = (String) serviceData.data.get("v6-multicast");
76 boolean v4Multicast = v4MulticastStr != null &&
77 (v4MulticastStr.equalsIgnoreCase("Y") || v4MulticastStr.equalsIgnoreCase("true"));
78 boolean v6Multicast = v6MulticastStr != null &&
79 (v6MulticastStr.equalsIgnoreCase("Y") || v6MulticastStr.equalsIgnoreCase("true"));
80 if (v4Multicast || v6Multicast) {
81 LimitAllocationRequest ar2 = new LimitAllocationRequest();
82 ar2.resourceSetId = resourceSetId;
83 ar2.resourceUnionId = resourceUnionId;
84 ar2.resourceShareGroupList = resourceShareGroupList;
85 ar2.resourceName = "MVRF";
86 ar2.assetId = equipmentData.equipmentId;
87 ar2.missingResourceAction = AllocationAction.Succeed_Allocate;
88 ar2.expiredResourceAction = AllocationAction.Succeed_Allocate;
91 ar2.checkLimit = 999999999;
93 ar2.allocateCount = 1;
95 MultiResourceAllocationRequest mar = new MultiResourceAllocationRequest();
96 mar.resourceSetId = resourceSetId;
97 mar.resourceUnionId = resourceUnionId;
98 mar.resourceShareGroupList = resourceShareGroupList;
99 mar.assetId = equipmentData.equipmentId;
100 mar.missingResourceAction = AllocationAction.Succeed_Allocate;
101 mar.expiredResourceAction = AllocationAction.Succeed_Allocate;
102 mar.allocationRequestList = new ArrayList<>();
103 mar.allocationRequestList.add(ar);
104 mar.allocationRequestList.add(ar2);