summaryrefslogtreecommitdiffstats
path: root/adaptors/resource-assignment/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'adaptors/resource-assignment/provider/src')
-rw-r--r--adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java4
-rw-r--r--adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java10
-rw-r--r--adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java2
-rw-r--r--adaptors/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java36
4 files changed, 50 insertions, 2 deletions
diff --git a/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java b/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
index 10f3e02b7..d41465949 100644
--- a/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
+++ b/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
@@ -457,6 +457,10 @@ public class ResourceAllocator implements SvcLogicResource {
rr.rangeForceNewNumbers = Boolean.parseBoolean(rangeForceNewNumbersStr);
String rangeNextInSequenceStr = getParam(ctx, "range-next-in-sequence", false, "false");
rr.rangeNextInSequence = Boolean.parseBoolean(rangeNextInSequenceStr);
+ String rangeRequestedCountStr = getParam(ctx, "range-requested-count", false, "1");
+ rr.rangeRequestedCount = Integer.parseInt(rangeRequestedCountStr);
+ String rangeSequentialStr = getParam(ctx, "range-sequential", false, "false");
+ rr.rangeSequential = Boolean.parseBoolean(rangeSequentialStr);
String replaceStr = getParam(ctx, "replace", false, "true");
rr.replace = Boolean.parseBoolean(replaceStr);
rr.applicationId = getParam(ctx, "application-id", false, "SDNC");
diff --git a/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java b/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java
index d15b1508f..3b4ac3b1d 100644
--- a/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java
+++ b/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java
@@ -134,8 +134,11 @@ public class DbAllocationRule implements AllocationRule {
ar.assetId = resourceTarget.resourceTargetType + "::" + resourceTarget.resourceTargetId;
ar.requestedNumbers = StrUtil.listInt(resourceRequest.rangeRequestedNumbers,
"Invalid value for requested-numbers");
- if (ar.requestedNumbers != null) {
+ if (ar.requestedNumbers != null && !ar.requestedNumbers.isEmpty()) {
ar.requestedCount = ar.requestedNumbers.size();
+ } else {
+ ar.requestedCount = resourceRequest.rangeRequestedCount;
+ ar.sequential = resourceRequest.rangeSequential;
}
ar.excludeNumbers = StrUtil.listInt(resourceRequest.rangeExcludeNumbers, "Invalid value for exclude-numbers");
ar.reverseOrder = resourceRequest.rangeReverseOrder;
@@ -212,8 +215,11 @@ public class DbAllocationRule implements AllocationRule {
ar.assetId = resourceTarget.resourceTargetType + "::" + resourceTarget.resourceTargetId;
ar.requestedNumbers = StrUtil.listInt(resourceRequest.rangeRequestedNumbers,
"Invalid value for requested-numbers");
- if (ar.requestedNumbers != null) {
+ if (ar.requestedNumbers != null && !ar.requestedNumbers.isEmpty()) {
ar.requestedCount = ar.requestedNumbers.size();
+ } else {
+ ar.requestedCount = resourceRequest.rangeRequestedCount;
+ ar.sequential = resourceRequest.rangeSequential;
}
ar.excludeNumbers = StrUtil.listInt(resourceRequest.rangeExcludeNumbers, "Invalid value for exclude-numbers");
ar.reverseOrder = resourceRequest.rangeReverseOrder;
diff --git a/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java b/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
index 2ebad4c89..3b2264259 100644
--- a/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
+++ b/adaptors/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
@@ -36,6 +36,8 @@ public class ResourceRequest {
public int rangeMaxOverride;
public boolean rangeForceNewNumbers;
public boolean rangeNextInSequence;
+ public int rangeRequestedCount;
+ public boolean rangeSequential;
public boolean replace;
public String requestType;
public String serviceModel;
diff --git a/adaptors/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java b/adaptors/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
index dbf0c4aac..1548791d3 100644
--- a/adaptors/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
+++ b/adaptors/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
@@ -961,4 +961,40 @@ public class TestReserve {
Assert.assertTrue(st == QueryStatus.SUCCESS);
Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "1002"));
}
+
+ @Test
+ public void test015() throws Exception {
+ String t = "015";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test allocating >1 numbers using range-requested-count parameter");
+
+ String entityId = "reserve" + t;
+ String targetId = "port-id-1";
+ String resourceName = "vlan-id-filter";
+
+ String assetId = "Site::" + targetId;
+
+ dataSetup.cleanup();
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL");
+ ctx.setAttribute("ra-input.endpoint-position", "VPE-Core2");
+ ctx.setAttribute("ra-input.check-only", "false");
+
+ ctx.setAttribute("ra-input.resource-name", resourceName);
+ ctx.setAttribute("ra-input.range-requested-count", "2");
+ ctx.setAttribute("ra-input.range-sequential", "true");
+
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", entityId + "_test");
+ ctx.setAttribute("ra-input.reservation-entity-version", "1");
+
+ ctx.setAttribute("ra-input.reservation-target-id", targetId);
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+ Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, "SI::" + entityId + "_test::VPE-Core2::1", "1002,1003"));
+ }
}