summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsp694w <sp694w@att.com>2018-08-06 06:49:54 -0400
committersp694w <sp694w@att.com>2018-08-06 14:07:55 -0400
commit10188fc727feaa425aac9b5652ed69d691129be9 (patch)
tree38fcd0c3bee623a122664bfdf1ba49744a62be30
parent5d0c8984dc39d465ef6c3ed776213010849d34a5 (diff)
RA: Add capability for Policy driven VlanTags
Change-Id: I5486a4989006c80b8a77ff2eb64fceed068c0c16 Issue-ID: CCSDK-438 Signed-off-by: Saurav Paira <sp694w@att.com>
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java99
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java67
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java7
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDaoImpl.java10
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java2
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java197
6 files changed, 284 insertions, 98 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
index 0e4b9252..385dae75 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java
@@ -47,7 +47,8 @@ public class ResourceAllocator implements SvcLogicResource {
private static final Logger log = LoggerFactory.getLogger(ResourceAllocator.class);
- private static final String[] INPUT_PREFIX = {"ra-input.", "tmp.resource-allocator."};
+ private static final String[] INPUT_PREFIX = { "ra-input.", "tmp.resource-allocator." };
+ private static final String START_RELEASE_LC = "Starting release for: {}";
private ResourceManager resourceManager;
private EndPointAllocator endPointAllocator;
@@ -98,16 +99,16 @@ public class ResourceAllocator implements SvcLogicResource {
String orderBy, SvcLogicContext ctx) throws SvcLogicException {
String resourceEntityId = getParam(ctx,
- new String[] {"service-instance-id", "reservation-entity-id", "resource-entity-id"}, false, null);
- String resourceEntityType =
- getParam(ctx, new String[] {"reservation-entity-type", "resource-entity-type"}, false, null);
- String resourceEntityVersion =
- getParam(ctx, new String[] {"reservation-entity-version", "resource-entity-version"}, false, "1");
-
- String resourceTargetId =
- getParam(ctx, new String[] {"reservation-target-id", "resource-target-id"}, false, null);
- String resourceTargetType =
- getParam(ctx, new String[] {"reservation-target-type", "resource-target-type"}, false, null);
+ new String[] { "service-instance-id", "reservation-entity-id", "resource-entity-id" }, false, null);
+ String resourceEntityType = getParam(ctx, new String[] { "reservation-entity-type", "resource-entity-type" },
+ false, null);
+ String resourceEntityVersion = getParam(ctx,
+ new String[] { "reservation-entity-version", "resource-entity-version" }, false, "1");
+
+ String resourceTargetId = getParam(ctx, new String[] { "reservation-target-id", "resource-target-id" }, false,
+ null);
+ String resourceTargetType = getParam(ctx, new String[] { "reservation-target-type", "resource-target-type" },
+ false, null);
String resourceName = getParam(ctx, "resource-name", false, null);
if (resourceEntityId != null && resourceEntityType != null) {
@@ -130,8 +131,8 @@ public class ResourceAllocator implements SvcLogicResource {
sd.resourceEntityId, sd.resourceEntityVersion);
setResourceDataInResponse(rdlist, rsList);
} else if (rt.resourceTargetId != null && rt.resourceTargetType != null && rr.resourceName != null) {
- ResourceData rd =
- endPointAllocator.getResource(rt.resourceTargetType, rt.resourceTargetId, rr.resourceName);
+ ResourceData rd = endPointAllocator.getResource(rt.resourceTargetType, rt.resourceTargetId,
+ rr.resourceName);
setResourceDataInResponse(Collections.singletonList(rd), rsList);
}
@@ -179,19 +180,24 @@ public class ResourceAllocator implements SvcLogicResource {
@Override
public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException {
String resourceEntityId = getParam(ctx,
- new String[] {"service-instance-id", "reservation-entity-id", "resource-entity-id"}, true, null);
- String resourceEntityType =
- getParam(ctx, new String[] {"reservation-entity-type", "resource-entity-type"}, true, null);
- String resourceEntityVersion =
- getParam(ctx, new String[] {"reservation-entity-version", "resource-entity-version"}, false, null);
+ new String[] { "service-instance-id", "reservation-entity-id", "resource-entity-id" }, true, null);
+ String resourceEntityType = getParam(ctx, new String[] { "reservation-entity-type", "resource-entity-type" },
+ true, null);
+ String resourceEntityVersion = getParam(ctx,
+ new String[] { "reservation-entity-version", "resource-entity-version" }, false, null);
+
+ String endPointPosition = getParam(ctx, "endpoint-position", false, null);
ResourceEntity sd = new ResourceEntity();
sd.resourceEntityId = resourceEntityId;
sd.resourceEntityType = resourceEntityType;
sd.resourceEntityVersion = resourceEntityVersion;
+ ResourceRequest rr = new ResourceRequest();
+ rr.endPointPosition = endPointPosition;
+
try {
- this.release(sd);
+ this.release(sd, rr);
} catch (Exception e) {
throw new SvcLogicException(e.getMessage());
}
@@ -202,12 +208,12 @@ public class ResourceAllocator implements SvcLogicResource {
if (sd.resourceEntityVersion != null) {
String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + sd.resourceEntityVersion;
- log.info("Starting release for: " + resourceSet);
+ log.info(START_RELEASE_LC, resourceSet);
resourceManager.releaseResourceSet(resourceSet);
} else {
String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId;
- log.info("Starting release for: " + resourceUnion);
+ log.info(START_RELEASE_LC, resourceUnion);
resourceManager.releaseResourceUnion(resourceUnion);
}
@@ -216,6 +222,39 @@ public class ResourceAllocator implements SvcLogicResource {
}
+ public AllocationStatus release(ResourceEntity sd, ResourceRequest rr) throws Exception {
+
+ if (sd != null && sd.resourceEntityVersion != null) {
+ if (rr != null && rr.endPointPosition != null && !rr.endPointPosition.isEmpty()) {
+ String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + rr.endPointPosition
+ + "::" + sd.resourceEntityVersion;
+ log.info(START_RELEASE_LC, resourceSet);
+ resourceManager.releaseResourceSet(resourceSet);
+
+ } else {
+ String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::"
+ + sd.resourceEntityVersion;
+ log.info(START_RELEASE_LC, resourceSet);
+ resourceManager.releaseResourceSet(resourceSet);
+ }
+
+ } else if (sd != null && (sd.resourceEntityVersion == null || sd.resourceEntityVersion.isEmpty())) {
+ if (rr != null && rr.endPointPosition != null && !rr.endPointPosition.isEmpty()) {
+ String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + rr.endPointPosition;
+ log.info(START_RELEASE_LC, resourceUnion);
+ resourceManager.releaseResourceUnion(resourceUnion);
+
+ } else {
+ String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId;
+ log.info(START_RELEASE_LC, resourceUnion);
+ resourceManager.releaseResourceUnion(resourceUnion);
+ }
+ }
+
+ return AllocationStatus.Success;
+
+ }
+
private QueryStatus allocateResources(SvcLogicContext ctx, boolean checkOnly, String prefix)
throws SvcLogicException {
String serviceModel = getParam(ctx, "service-model", true, null);
@@ -321,20 +360,20 @@ public class ResourceAllocator implements SvcLogicResource {
private ResourceEntity getResourceEntityData(SvcLogicContext ctx) throws SvcLogicException {
ResourceEntity sd = new ResourceEntity();
sd.resourceEntityId = getParam(ctx,
- new String[] {"service-instance-id", "reservation-entity-id", "resource-entity-id"}, true, null);
- sd.resourceEntityType =
- getParam(ctx, new String[] {"reservation-entity-type", "resource-entity-type"}, true, null);
- sd.resourceEntityVersion =
- getParam(ctx, new String[] {"reservation-entity-version", "resource-entity-version"}, false, "1");
+ new String[] { "service-instance-id", "reservation-entity-id", "resource-entity-id" }, true, null);
+ sd.resourceEntityType = getParam(ctx, new String[] { "reservation-entity-type", "resource-entity-type" }, true,
+ null);
+ sd.resourceEntityVersion = getParam(ctx,
+ new String[] { "reservation-entity-version", "resource-entity-version" }, false, "1");
sd.data = getDataParam(ctx, "reservation-entity-data", "resource-entity-data", "service-data");
return sd;
}
private ResourceTarget getResourceTargetData(SvcLogicContext ctx) throws SvcLogicException {
ResourceTarget sd = new ResourceTarget();
- sd.resourceTargetId = getParam(ctx, new String[] {"reservation-target-id", "resource-target-id"}, true, null);
- sd.resourceTargetType =
- getParam(ctx, new String[] {"reservation-target-type", "resource-target-type"}, true, null);
+ sd.resourceTargetId = getParam(ctx, new String[] { "reservation-target-id", "resource-target-id" }, true, null);
+ sd.resourceTargetType = getParam(ctx, new String[] { "reservation-target-type", "resource-target-type" }, true,
+ null);
sd.data = getDataParam(ctx, "reservation-target-data", "resource-target-data", "equipment-data");
return sd;
}
@@ -443,4 +482,4 @@ public class ResourceAllocator implements SvcLogicResource {
public void setSpeedUtil(SpeedUtil speedUtil) {
this.speedUtil = speedUtil;
}
-}
+} \ No newline at end of file
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java
index b13ef80e..12c02c85 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java
@@ -38,6 +38,7 @@ import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
import org.onap.ccsdk.sli.adaptors.rm.data.MultiResourceAllocationRequest;
import org.onap.ccsdk.sli.adaptors.rm.data.Range;
import org.onap.ccsdk.sli.adaptors.rm.data.RangeAllocationRequest;
+import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
import org.onap.ccsdk.sli.adaptors.util.expr.ExpressionEvaluator;
import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
import org.slf4j.Logger;
@@ -92,6 +93,13 @@ public class DbAllocationRule implements AllocationRule {
arlist.add(ar1);
}
+ if ((rangeRuleList == null || rangeRuleList.isEmpty())
+ && ResourceType.Range.equals(resourceRequest.resourceType)) {
+ AllocationRequest ar1 = buildAllocationRequest(resourceEntity, resourceTarget, resourceRequest, checkOnly,
+ change);
+ arlist.add(ar1);
+ }
+
if (arlist.isEmpty()) {
return null;
}
@@ -106,6 +114,59 @@ public class DbAllocationRule implements AllocationRule {
return ar;
}
+ private AllocationRequest buildAllocationRequest(ResourceEntity resourceEntity, ResourceTarget resourceTarget,
+ ResourceRequest resourceRequest, boolean checkOnly, boolean change) {
+
+ RangeAllocationRequest ar = new RangeAllocationRequest();
+ ar.applicationId = resourceRequest.applicationId;
+ if (resourceRequest.endPointPosition != null) {
+ ar.resourceUnionId = resourceEntity.resourceEntityType + "::" + resourceEntity.resourceEntityId + "::"
+ + resourceRequest.endPointPosition;
+ ar.endPointPosition = resourceRequest.endPointPosition;
+ } else {
+ ar.resourceUnionId = resourceEntity.resourceEntityType + "::" + resourceEntity.resourceEntityId;
+ }
+ ar.resourceSetId = ar.resourceUnionId + "::" + resourceEntity.resourceEntityVersion;
+ ar.resourceName = resourceRequest.resourceName;
+ if (resourceRequest.resourceShareGroup != null) {
+ ar.resourceShareGroupList = Collections.singleton(resourceRequest.resourceShareGroup);
+ }
+ ar.assetId = resourceTarget.resourceTargetType + "::" + resourceTarget.resourceTargetId;
+ ar.requestedNumbers = StrUtil.listInt(resourceRequest.rangeRequestedNumbers,
+ "Invalid value for requested-numbers");
+ if (ar.requestedNumbers != null) {
+ ar.requestedCount = ar.requestedNumbers.size();
+ }
+ ar.excludeNumbers = StrUtil.listInt(resourceRequest.rangeExcludeNumbers, "Invalid value for exclude-numbers");
+ ar.reverseOrder = resourceRequest.rangeReverseOrder;
+ ar.missingResourceAction = AllocationAction.Succeed_Allocate;
+ ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
+ ar.replace = resourceRequest.replace;
+ ar.check = true;
+ ar.allocate = !checkOnly;
+ ar.rangeList = resourceRequest.rangeOverrideList;
+ if (ar.rangeList == null || ar.rangeList.isEmpty()) {
+ if (resourceRequest.rangeMinOverride >= 0
+ && resourceRequest.rangeMaxOverride >= resourceRequest.rangeMinOverride) {
+ ar.rangeList = new ArrayList<>();
+ Range range = new Range();
+ range.min = resourceRequest.rangeMinOverride;
+ range.max = resourceRequest.rangeMaxOverride;
+ ar.rangeList.add(range);
+ }
+ } else {
+ if (resourceRequest.rangeMinOverride >= 0) {
+ ar.rangeList.get(0).min = resourceRequest.rangeMinOverride;
+ }
+ if (resourceRequest.rangeMaxOverride >= 0) {
+ ar.rangeList.get(ar.rangeList.size() - 1).max = resourceRequest.rangeMaxOverride;
+ }
+ }
+ ar.forceNewNumbers = resourceRequest.rangeForceNewNumbers;
+ StrUtil.info(log, ar);
+ return ar;
+ }
+
private AllocationRequest buildAllocationRequest(ResourceRule resourceRule, ResourceEntity resourceEntity,
ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change) {
StrUtil.info(log, resourceRule);
@@ -163,7 +224,8 @@ public class DbAllocationRule implements AllocationRule {
ar.allocate = !checkOnly;
ar.rangeList = rangeRule.rangeList;
if (ar.rangeList == null || ar.rangeList.isEmpty()) {
- if (resourceRequest.rangeMinOverride >= 0 && resourceRequest.rangeMaxOverride >= resourceRequest.rangeMinOverride) {
+ if (resourceRequest.rangeMinOverride >= 0
+ && resourceRequest.rangeMaxOverride >= resourceRequest.rangeMinOverride) {
ar.rangeList = new ArrayList<>();
Range range = new Range();
range.min = resourceRequest.rangeMinOverride;
@@ -177,6 +239,7 @@ public class DbAllocationRule implements AllocationRule {
if (resourceRequest.rangeMaxOverride >= 0) {
ar.rangeList.get(ar.rangeList.size() - 1).max = resourceRequest.rangeMaxOverride;
}
+
}
ar.forceNewNumbers = resourceRequest.rangeForceNewNumbers;
return ar;
@@ -189,4 +252,4 @@ public class DbAllocationRule implements AllocationRule {
public void setRangeRuleDao(RangeRuleDao rangeRuleDao) {
this.rangeRuleDao = rangeRuleDao;
}
-}
+} \ No newline at end of file
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
index a52ce385..36a13797 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
@@ -21,6 +21,11 @@
package org.onap.ccsdk.sli.adaptors.ra.comp;
+import java.util.List;
+
+import org.onap.ccsdk.sli.adaptors.rm.data.Range;
+import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
+
public class ResourceRequest {
public String resourceName;
@@ -37,4 +42,6 @@ public class ResourceRequest {
public boolean checkOnly;
public String applicationId;
public String endPointPosition;
+ public ResourceType resourceType;
+ public List<Range> rangeOverrideList;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDaoImpl.java
index 4599314a..b021620b 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDaoImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDaoImpl.java
@@ -40,8 +40,8 @@ public class RangeRuleDaoImpl implements RangeRuleDao {
@Override
public List<RangeRule> getRangeRules(String serviceModel, String equipLevel) {
- List<RangeRule> rangeRuleList =
- jdbcTemplate.query(GET_SQL, new Object[] {serviceModel, equipLevel}, (RowMapper<RangeRule>) (rs, rowNum) -> {
+ return jdbcTemplate.query(GET_SQL, new Object[] { serviceModel, equipLevel },
+ (RowMapper<RangeRule>) (rs, rowNum) -> {
RangeRule rl = new RangeRule();
rl.id = rs.getLong("range_rule_id");
rl.rangeName = rs.getString("range_name");
@@ -71,17 +71,17 @@ public class RangeRuleDaoImpl implements RangeRuleDao {
}
}
if (nn.length > 2) {
- log.warn("Invalid value found in DB for range: " + rangeStr);
+ log.warn("Invalid value found in DB for range: {}", rangeStr);
}
rl.rangeList.add(range);
}
return rl;
});
- return rangeRuleList;
+
}
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
-}
+} \ No newline at end of file
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java
index fdc8a2b1..2e378f1a 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java
@@ -56,7 +56,7 @@ public class RangeUtil {
if (req.rangeList != null && !req.rangeList.isEmpty()) {
boolean good = false;
for (Range range : req.rangeList) {
- if (num < range.min || num > range.min) {
+ if (num < range.min || num > range.max) {
continue;
}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
index cdd95dcd..168bdd72 100644
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java
@@ -1,6 +1,7 @@
package jtest.org.onap.ccsdk.sli.adaptors.ra;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -15,6 +16,8 @@ import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse;
import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
+import org.onap.ccsdk.sli.adaptors.rm.data.Range;
+import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
@@ -27,7 +30,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:test-context.xml"})
+@ContextConfiguration(locations = { "classpath:test-context.xml" })
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class TestReserve {
@@ -35,11 +38,10 @@ public class TestReserve {
private JdbcTemplate jdbcTemplate;
- private static final String[] RESOURCE_COLUMNS = {"asset_id", "resource_name", "resource_type", "lt_used"};
-
- private static final String[] ALLOCATION_ITEM_COLUMNS = {"resource_id", "application_id", "resource_set_id",
- "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time"};
+ private static final String[] RESOURCE_COLUMNS = { "asset_id", "resource_name", "resource_type", "lt_used" };
+ private static final String[] ALLOCATION_ITEM_COLUMNS = { "resource_id", "application_id", "resource_set_id",
+ "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time" };
@Autowired
public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
@@ -50,7 +52,8 @@ public class TestReserve {
private ResourceAllocator resourceAllocator;
/*
- * @Autowired(required = true) private ResourceAllocatorApi resourceAllocatorApi;
+ * @Autowired(required = true) private ResourceAllocatorApi
+ * resourceAllocatorApi;
*/
@Autowired(required = true)
@@ -67,9 +70,8 @@ public class TestReserve {
dataSetup.cleanup();
TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
- TestTable allocationItem =
- new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
-
+ TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
+ ALLOCATION_ITEM_COLUMNS);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.service-model", "ADIG");
@@ -86,7 +88,6 @@ public class TestReserve {
ctx.setAttribute("ra-input.reservation-target-data.max-vpe-bandwidth-mbps", "5000");
-
QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -106,7 +107,6 @@ public class TestReserve {
ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
ctx.setAttribute("ra-input.reservation-target-type", "Port");
-
st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -123,7 +123,6 @@ public class TestReserve {
ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
ctx.setAttribute("ra-input.reservation-target-type", "AffinityLink");
-
st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -131,18 +130,15 @@ public class TestReserve {
resource.print();
allocationItem.print();
-
/* Query Using ReservationEntityId using ServiceLogicContext */
ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.service-model", "ADIG");
ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
ctx.setAttribute("ra-input.reservation-entity-type", "SI");
-
st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
-
/* Query Using ReservationTargetId using ServiceLogicContext */
ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.service-model", "ADIG");
@@ -159,7 +155,6 @@ public class TestReserve {
sd.resourceEntityId = "ICOREPVCID-123456";
sd.resourceEntityType = "SI";
-
ResourceRequest rr = new ResourceRequest();
rr.serviceModel = "ADIG";
rr.resourceName = "cust-vlan-id";
@@ -179,12 +174,10 @@ public class TestReserve {
AllocationStatus status = resourceAllocator.release(sd);
Assert.assertTrue(status == AllocationStatus.Success);
-
log.info("======================== Query Using ResourceEntity==============================");
rsList = new ArrayList<>();
resourceAllocator.query(sd, null, null, rsList);
-
rsList.forEach(r -> {
StrUtil.info(log, r);
});
@@ -241,7 +234,6 @@ public class TestReserve {
}
-
@Test
public void test003() throws Exception {
String t = "003";
@@ -256,7 +248,6 @@ public class TestReserve {
rt.resourceTargetId = "MDTWNJ21A5";
rt.resourceTargetType = "Site";
-
ResourceRequest rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL";
rr.resourceName = "VPE-Cust";
@@ -281,8 +272,6 @@ public class TestReserve {
}
-
-
@Test
public void test004() throws Exception {
String t = "004";
@@ -313,8 +302,6 @@ public class TestReserve {
rr.resourceName = "VPE-Core2";
rrs.add(rr);
-
-
List<ResourceResponse> rsList = new ArrayList<>();
// resourceAllocator.reserve(sd, rt, rrs, rsList);
@@ -332,7 +319,6 @@ public class TestReserve {
}
-
@Test
public void test005() throws Exception {
String t = "005";
@@ -344,9 +330,8 @@ public class TestReserve {
dataSetup.cleanup();
TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
- TestTable allocationItem =
- new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
-
+ TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
+ ALLOCATION_ITEM_COLUMNS);
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
@@ -359,7 +344,6 @@ public class TestReserve {
ctx.setAttribute("ra-input.resource-name", "cust-vlan-id");
-
QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -378,7 +362,6 @@ public class TestReserve {
ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
-
st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -398,7 +381,6 @@ public class TestReserve {
ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
ctx.setAttribute("ra-input.replace", "false");
-
st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -406,18 +388,15 @@ public class TestReserve {
resource.print();
allocationItem.print();
-
/* Query Using ReservationEntityId using ServiceLogicContext */
ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
-
st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
-
/* Query Using ReservationTargetId using ServiceLogicContext */
ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
@@ -434,7 +413,6 @@ public class TestReserve {
sd.resourceEntityId = "gblond2003me6";
sd.resourceEntityType = "VPE-Core1";
-
ResourceRequest rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL-1";
rr.resourceName = "vlan-id-inner";
@@ -450,13 +428,17 @@ public class TestReserve {
});
/*
- * log.info("======================== release Using ResourceEntity==============================");
- * rsList = new ArrayList<ResourceResponse>(); AllocationStatus status =
- * resourceAllocator.release(sd); Assert.assertTrue(status == AllocationStatus.Success);
+ * log.
+ * info("======================== release Using ResourceEntity=============================="
+ * ); rsList = new ArrayList<ResourceResponse>(); AllocationStatus status =
+ * resourceAllocator.release(sd); Assert.assertTrue(status ==
+ * AllocationStatus.Success);
*
*
- * log.info("======================== Query Using ResourceEntity==============================");
- * rsList = new ArrayList<ResourceResponse>(); resourceAllocator.query(sd, null, null, rsList);
+ * log.
+ * info("======================== Query Using ResourceEntity=============================="
+ * ); rsList = new ArrayList<ResourceResponse>(); resourceAllocator.query(sd,
+ * null, null, rsList);
*
*
* rsList.forEach(r -> { StrUtil.info(log, r); });
@@ -464,8 +446,6 @@ public class TestReserve {
}
-
-
@Test
public void test006() throws Exception {
String t = "006";
@@ -480,12 +460,10 @@ public class TestReserve {
rt.resourceTargetId = "MDTWNJ21A5";
rt.resourceTargetType = "Site";
-
ResourceRequest rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL-1";
rr.resourceName = "cust-vlan-id";
-
List<ResourceResponse> rsList = new ArrayList<>();
resourceAllocator.reserve(sd, rt, rr, rsList);
@@ -512,9 +490,8 @@ public class TestReserve {
dataSetup.cleanup();
TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
- TestTable allocationItem =
- new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
-
+ TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
+ ALLOCATION_ITEM_COLUMNS);
ResourceEntity sd = new ResourceEntity();
sd.resourceEntityId = "gblond2003me6";
@@ -525,7 +502,6 @@ public class TestReserve {
rt.resourceTargetId = "MDTWNJ21A5";
rt.resourceTargetType = "Site";
-
ResourceRequest rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL";
// rr.resourceName = "vlan-id-outer";
@@ -533,7 +509,6 @@ public class TestReserve {
rr.rangeMaxOverride = -1;
rr.rangeMinOverride = -1;
-
List<ResourceResponse> rsList = new ArrayList<>();
resourceAllocator.reserve(sd, rt, rr, rsList);
@@ -547,7 +522,6 @@ public class TestReserve {
rt.resourceTargetId = "MDTWNJ21A5";
rt.resourceTargetType = "Site";
-
rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL";
// rr.resourceName = "vlan-id-filter";
@@ -555,11 +529,9 @@ public class TestReserve {
rr.rangeMaxOverride = -1;
rr.rangeMinOverride = -1;
-
rsList = new ArrayList<>();
resourceAllocator.reserve(sd, rt, rr, rsList);
-
// VPE-Core2
sd = new ResourceEntity();
sd.resourceEntityId = "gblond2003me6";
@@ -570,7 +542,6 @@ public class TestReserve {
rt.resourceTargetId = "MDTWNJ21A5";
rt.resourceTargetType = "Site";
-
rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL";
// rr.resourceName = "vlan-id-filter";
@@ -578,11 +549,9 @@ public class TestReserve {
rr.rangeMaxOverride = -1;
rr.rangeMinOverride = -1;
-
rsList = new ArrayList<>();
resourceAllocator.reserve(sd, rt, rr, rsList);
-
// VPE-Core3
sd = new ResourceEntity();
sd.resourceEntityId = "gblond2003me6";
@@ -593,7 +562,6 @@ public class TestReserve {
rt.resourceTargetId = "MDTWNJ21A5";
rt.resourceTargetType = "Site";
-
rr = new ResourceRequest();
rr.serviceModel = "MY-SERV-MODEL";
// rr.resourceName = "vlan-id-filter";
@@ -601,7 +569,6 @@ public class TestReserve {
rr.rangeMaxOverride = -1;
rr.rangeMinOverride = -1;
-
rsList = new ArrayList<>();
resourceAllocator.reserve(sd, rt, rr, rsList);
@@ -620,13 +587,10 @@ public class TestReserve {
StrUtil.info(log, r);
});
-
-
SvcLogicContext ctx = new SvcLogicContext();
ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
ctx.setAttribute("ra-input.reservation-entity-type", "VPE");
-
QueryStatus st = resourceAllocator.release("NetworkCapacity", "gblond2003me6", ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
@@ -711,4 +675,117 @@ public class TestReserve {
Assert.assertTrue(dataSetup.checkRangeItem(resourceName, assetId, resourceSet1, "201"));
Assert.assertFalse(dataSetup.checkRangeItem(resourceName, assetId, resourceSet2, "201"));
}
+
+ @Test
+ public void test0010_vlantag_with_resourcemodel() throws Exception {
+
+ String t = "0010";
+ log.info("============== reserve " + t + " ================================");
+
+ dataSetup.cleanup();
+
+ TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
+ TestTable allocationItem = new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id",
+ ALLOCATION_ITEM_COLUMNS);
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+ sd.resourceEntityVersion = "1";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+ ResourceRequest rr = new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL_3456";
+ rr.resourceName = "vlan-id-outer";
+ rr.endPointPosition = "VPE-Core1";
+ rr.rangeMaxOverride = 3901;
+ rr.rangeMinOverride = 3900;
+ rr.resourceType = ResourceType.Range;
+
+ List<ResourceResponse> rsList = new ArrayList<>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ resource.print();
+ allocationItem.print();
+
+ Range range = new Range();
+ range.min = 3900;
+ range.max = 3901;
+
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+ rr = new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL_3456";
+ rr.resourceName = "vlan-id-outer";
+ rr.endPointPosition = "VPE-Core2";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+ rr.rangeOverrideList = Arrays.asList(range);
+ rr.resourceType = ResourceType.Range;
+
+ rsList = new ArrayList<>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ resource.print();
+ allocationItem.print();
+
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+ Range range1 = new Range();
+ range1.min = 3900;
+ range1.max = 3901;
+
+ Range range2 = new Range();
+ range2.min = 3904;
+ range2.max = 3905;
+
+ rr = new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL_3456";
+ rr.resourceName = "vlan-id-outer";
+ rr.endPointPosition = "VPE-Core3";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+ rr.rangeOverrideList = new ArrayList<>();
+ rr.rangeOverrideList.add(range1);
+ rr.rangeOverrideList.add(range2);
+ rr.resourceType = ResourceType.Range;
+
+ rsList = new ArrayList<>();
+ AllocationStatus status = resourceAllocator.reserve(sd, rt, rr, rsList);
+ Assert.assertTrue(status == AllocationStatus.Success);
+
+ resource.print();
+ allocationItem.print();
+
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+ sd.resourceEntityVersion = "1";
+
+ rr = new ResourceRequest();
+ rr.endPointPosition = "VPE-Core2";
+ status = resourceAllocator.release(sd, rr);
+ Assert.assertTrue(status == AllocationStatus.Success);
+
+ resource.print();
+ allocationItem.print();
+
+ }
}