aboutsummaryrefslogtreecommitdiffstats
path: root/resource-assignment
diff options
context:
space:
mode:
authorsb5356 <sb5356@att.com>2018-05-15 11:58:17 -0400
committerTimoney, Dan (dt5972) <dt5972@att.com>2018-06-06 15:26:06 -0400
commit7893d08db0ef3fd29d64c9be759325fa18cc21fa (patch)
tree6f4344818c4089df46c5f19a1ff480ab015ccea4 /resource-assignment
parent52a06cedb172a1a446ecfaaaa96bf500a58c8fb5 (diff)
[CCSDK-245] RA: Refactor RA to make it generic
Resource allocator is cleaned up and refactored so it does not contain any service specific logic. Issue-ID: CCSDK-245 Change-Id: Ib948eb813020fbe7dc779148e412de1e074b300b Signed-off-by: sb5356 <sb5356@att.com>
Diffstat (limited to 'resource-assignment')
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/comp/LockHelperImpl.java82
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDao.java13
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDaoImpl.java44
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReleaseRequestType.java45
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReserveRequestType.java43
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java1114
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/AffinityAllocationRule.java68
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/DbAllocationRule.java243
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/ServingSiteAllocationRule.java80
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/VrfAllocationRule.java111
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/AnyVrfPresentCheck.java74
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ExcludeVpeCheck.java57
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/HubWithRgCheck.java107
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/OneMVrfCheck.java100
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ProvStatusCheck.java49
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VlanSpeedCheck.java50
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VpeLockCheck.java111
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationRule.java17
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocationDefinition.java60
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocator.java20
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocatorImpl.java329
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EquipmentCheck.java35
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java (renamed from resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ServiceData.java)21
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceEntity.java (renamed from resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointData.java)17
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java (renamed from resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/PreferenceRule.java)25
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceResponse.java13
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceTarget.java (renamed from resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDao.java)15
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/comp/EquipmentReader.java32
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDaoImpl.java64
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDao.java32
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDaoImpl.java81
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDao.java30
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDaoImpl.java70
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentData.java31
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentLevel.java26
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/AffinityLinkPref.java85
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/EvcExistingVrfPref.java60
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/AicSiteReader.java49
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/UplinkCircuitReader.java54
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VnfReader.java49
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VpePortReader.java70
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilder.java42
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilderImpl.java172
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDao.java28
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDaoImpl.java85
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDao.java28
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDaoImpl.java86
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDao.java27
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDaoImpl.java57
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDao.java8
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDaoImpl.java40
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDao.java14
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDaoImpl.java35
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDao.java27
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDaoImpl.java48
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDao.java38
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDaoImpl.java110
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceResource.java32
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceStatus.java27
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java113
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java29
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/AllocationRequest.java6
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java6
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LabelUtil.java28
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LimitUtil.java93
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/RangeUtil.java83
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/ResourceUtil.java24
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/CachedDataSourceWrap.java46
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/expr/ExpressionEvaluator.java161
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/speed/SpeedUtil.java26
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VpnParam.java30
-rw-r--r--resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VrfUtil.java76
-rwxr-xr-xresource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment-blueprint.xml2
-rwxr-xr-xresource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment.xml17
-rw-r--r--resource-assignment/provider/src/main/resources/resource-allocator.properties26
-rw-r--r--resource-assignment/provider/src/main/resources/sql/001_resource_rule_ddl.sql32
-rw-r--r--resource-assignment/provider/src/main/resources/sql/002_max_port_speed_ddl.sql29
-rw-r--r--resource-assignment/provider/src/main/resources/sql/003_max_server_speed_ddl.sql28
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java224
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java405
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java59
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java85
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java430
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve.java1122
-rw-r--r--resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java77
-rw-r--r--resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestDb.java (renamed from resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestDb.java)0
-rw-r--r--resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java135
-rw-r--r--resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java84
-rw-r--r--resource-assignment/provider/src/test/resources/homing-req.json46
-rwxr-xr-xresource-assignment/provider/src/test/resources/param.txt44
-rw-r--r--resource-assignment/provider/src/test/resources/sql/data.sql66
-rw-r--r--resource-assignment/provider/src/test/resources/svc-topology-req.json195
-rw-r--r--resource-assignment/provider/src/test/resources/test-context.xml217
93 files changed, 2016 insertions, 6608 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/comp/LockHelperImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/comp/LockHelperImpl.java
index 4d9bb27d..3a8c730e 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/comp/LockHelperImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/comp/LockHelperImpl.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,12 +26,15 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
-
import org.onap.ccsdk.sli.adaptors.lock.dao.ResourceLockDao;
import org.onap.ccsdk.sli.adaptors.lock.data.ResourceLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class LockHelperImpl implements LockHelper {
+ private static final Logger log = LoggerFactory.getLogger(LockHelperImpl.class);
+
private ResourceLockDao resourceLockDao;
private int retryCount = 10;
private int lockWait = 5; // Seconds
@@ -51,10 +54,12 @@ public class LockHelperImpl implements LockHelper {
for (int i = 0; true; i++) {
try {
tryLock(resourceNameList, lockRequester, lockTimeout);
+ log.info("Resources locked: " + resourceNameList);
return;
} catch (ResourceLockedException e) {
- if (i > retryCount)
+ if (i > retryCount) {
throw e;
+ }
try {
Thread.sleep(lockWait * 1000);
} catch (InterruptedException ex) {
@@ -65,58 +70,64 @@ public class LockHelperImpl implements LockHelper {
@Override
public void unlock(Collection<String> lockNames, boolean force) {
- if (lockNames == null || lockNames.size() == 0)
+ if (lockNames == null || lockNames.size() == 0) {
return;
-
- resourceLockDao.lockTable();
+ }
try {
for (String name : lockNames) {
ResourceLock l = resourceLockDao.getByResourceName(name);
- if (l != null)
- if (force || l.lockCount == 1)
+ if (l != null) {
+ if (force || l.lockCount == 1) {
resourceLockDao.delete(l.id);
- else
+ } else {
resourceLockDao.decrementLockCount(l.id);
+ }
+ }
}
+
+ resourceLockDao.commit();
+
+ log.info("Resources unlocked: " + lockNames);
} finally {
- resourceLockDao.unlockTable();
+ resourceLockDao.rollback();
}
}
public void tryLock(Collection<String> resourceNameList, String lockRequester, int lockTimeout /* Seconds */) {
- if (resourceNameList == null || resourceNameList.size() == 0)
+ if (resourceNameList == null || resourceNameList.size() == 0) {
return;
+ }
lockRequester = generateLockRequester(lockRequester, 100);
- resourceLockDao.lockTable();
-
- try {
- // First check if all requested records are available to lock
+ // First check if all requested records are available to lock
- Date now = new Date();
+ Date now = new Date();
- List<ResourceLock> dbLockList = new ArrayList<ResourceLock>();
- List<String> insertLockNameList = new ArrayList<String>();
+ try {
+ List<ResourceLock> dbLockList = new ArrayList<>();
+ List<String> insertLockNameList = new ArrayList<>();
for (String name : resourceNameList) {
ResourceLock l = resourceLockDao.getByResourceName(name);
- boolean canLock =
- l == null || now.getTime() > l.expirationTime.getTime() || lockRequester != null &&
- lockRequester.equals(l.lockHolder) || l.lockCount <= 0;
- if (!canLock)
+ boolean canLock = l == null || now.getTime() > l.expirationTime.getTime() ||
+ lockRequester != null && lockRequester.equals(l.lockHolder) || l.lockCount <= 0;
+ if (!canLock) {
throw new ResourceLockedException(l.resourceName, l.lockHolder, lockRequester);
+ }
- if (l != null)
+ if (l != null) {
dbLockList.add(l);
- else
+ } else {
insertLockNameList.add(name);
+ }
}
// Update the lock info in DB
- for (ResourceLock l : dbLockList)
+ for (ResourceLock l : dbLockList) {
resourceLockDao.update(l.id, now, new Date(now.getTime() + lockTimeout * 1000), l.lockCount + 1);
+ }
// Insert records for those that are not yet there
for (String lockName : insertLockNameList) {
@@ -126,16 +137,26 @@ public class LockHelperImpl implements LockHelper {
l.lockTime = now;
l.expirationTime = new Date(now.getTime() + lockTimeout * 1000);
l.lockCount = 1;
- resourceLockDao.add(l);
+
+ try {
+ resourceLockDao.add(l);
+ } catch (Exception e) {
+ log.info("Failed to insert lock record: " + lockName);
+ throw new ResourceLockedException(l.resourceName, "unknown", lockRequester);
+ }
}
+
+ resourceLockDao.commit();
+
} finally {
- resourceLockDao.unlockTable();
+ resourceLockDao.rollback();
}
}
private static String generateLockRequester(String name, int maxLength) {
- if (name == null)
+ if (name == null) {
name = "";
+ }
int l1 = name.length();
String tname = Thread.currentThread().getName();
int l2 = tname.length();
@@ -146,8 +167,9 @@ public class LockHelperImpl implements LockHelper {
l1 = maxl1;
}
int maxl2 = maxLength - l1 - 1;
- if (l2 > maxl2)
+ if (l2 > maxl2) {
tname = tname.substring(0, 6) + "..." + tname.substring(l2 - maxl2 + 9);
+ }
}
return tname + '-' + name;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDao.java
index bcabb36d..f9d41135 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDao.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDao.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,15 +22,10 @@
package org.onap.ccsdk.sli.adaptors.lock.dao;
import java.util.Date;
-
import org.onap.ccsdk.sli.adaptors.lock.data.ResourceLock;
public interface ResourceLockDao {
- void lockTable();
-
- void unlockTable();
-
void add(ResourceLock l);
void update(long id, Date lockTime, Date expirationTime, int lockCount);
@@ -40,4 +35,8 @@ public interface ResourceLockDao {
void delete(long id);
void decrementLockCount(long id);
+
+ void commit();
+
+ void rollback();
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDaoImpl.java
index d68317fb..48541922 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDaoImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/lock/dao/ResourceLockDaoImpl.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,6 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Date;
import java.util.List;
-
import org.onap.ccsdk.sli.adaptors.lock.data.ResourceLock;
import org.onap.ccsdk.sli.adaptors.util.db.CachedDataSourceWrap;
import org.slf4j.Logger;
@@ -35,29 +34,10 @@ import org.springframework.jdbc.core.RowMapper;
public class ResourceLockDaoImpl implements ResourceLockDao {
+ @SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(ResourceLockDaoImpl.class);
private JdbcTemplate jdbcTemplate;
- private boolean testing = false;
-
- @Override
- public void lockTable() {
- if (!testing) {
- jdbcTemplate.update("LOCK TABLES RESOURCE_LOCK WRITE");
- log.info("Table RESOURCE_LOCK locked.");
- }
- }
-
- @Override
- public void unlockTable() {
- if (!testing) {
- jdbcTemplate.update("UNLOCK TABLES");
- log.info("Table RESOURCE_LOCK unlocked.");
-
- CachedDataSourceWrap ds = (CachedDataSourceWrap) jdbcTemplate.getDataSource();
- ds.releaseConnection();
- }
- }
@Override
public void add(ResourceLock l) {
@@ -109,7 +89,21 @@ public class ResourceLockDaoImpl implements ResourceLockDao {
this.jdbcTemplate = jdbcTemplate;
}
- public void setTesting(boolean testing) {
- this.testing = testing;
+ @Override
+ public void commit() {
+ if (jdbcTemplate.getDataSource() instanceof CachedDataSourceWrap) {
+ CachedDataSourceWrap ds = (CachedDataSourceWrap) jdbcTemplate.getDataSource();
+ ds.commit();
+ ds.releaseConnection();
+ }
+ }
+
+ @Override
+ public void rollback() {
+ if (jdbcTemplate.getDataSource() instanceof CachedDataSourceWrap) {
+ CachedDataSourceWrap ds = (CachedDataSourceWrap) jdbcTemplate.getDataSource();
+ ds.rollback();
+ ds.releaseConnection();
+ }
}
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReleaseRequestType.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReleaseRequestType.java
deleted file mode 100644
index d3df91c2..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReleaseRequestType.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra;
-
-public enum ReleaseRequestType {
- Cancel, Activate, Disconnect;
-
- public static ReleaseRequestType convert(Object o) {
- if (o == null)
- return null;
- String s = o.toString();
- s = s.trim();
- if (s.length() == 0)
- return null;
-
- if (s.equalsIgnoreCase("Cancel"))
- return Cancel;
- if (s.equalsIgnoreCase("Activate"))
- return Activate;
- if (s.equalsIgnoreCase("Disconnect"))
- return Disconnect;
-
- throw new IllegalArgumentException("Invalid request-type: " + s +
- ". Supported values are Cancel, Activate, Disconnect.");
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReserveRequestType.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReserveRequestType.java
deleted file mode 100644
index b46b7ded..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ReserveRequestType.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra;
-
-public enum ReserveRequestType {
- New, Change;
-
- public static ReserveRequestType convert(Object o) {
- if (o == null)
- return null;
- String s = o.toString();
- s = s.trim();
- if (s.length() == 0)
- return null;
-
- if (s.equalsIgnoreCase("New"))
- return New;
- if (s.equalsIgnoreCase("Change"))
- return Change;
-
- throw new IllegalArgumentException("Invalid request-type: " + s +
- ". Supported values are New, Change.");
- }
-}
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 8e7c63ce..426fd289 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
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,48 +21,25 @@
package org.onap.ccsdk.sli.adaptors.ra;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
+import java.util.Set;
import org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocator;
-import org.onap.ccsdk.sli.adaptors.ra.comp.EndPointData;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.dao.ServerDao;
-import org.onap.ccsdk.sli.adaptors.ra.equip.dao.VpePortDao;
-import org.onap.ccsdk.sli.adaptors.ra.equip.dao.VplspePortDao;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
-import org.onap.ccsdk.sli.adaptors.ra.rule.comp.AllocationRequestBuilder;
-import org.onap.ccsdk.sli.adaptors.ra.rule.dao.MaxPortSpeedDao;
-import org.onap.ccsdk.sli.adaptors.ra.rule.dao.MaxServerSpeedDao;
-import org.onap.ccsdk.sli.adaptors.ra.rule.dao.ParameterDao;
-import org.onap.ccsdk.sli.adaptors.ra.rule.data.ThresholdStatus;
-import org.onap.ccsdk.sli.adaptors.ra.service.dao.ServiceResourceDao;
-import org.onap.ccsdk.sli.adaptors.ra.service.data.ServiceResource;
-import org.onap.ccsdk.sli.adaptors.ra.service.data.ServiceStatus;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceData;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity;
+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.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationOutcome;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationOutcome;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitResource;
-import org.onap.ccsdk.sli.adaptors.rm.data.MultiResourceAllocationOutcome;
-import org.onap.ccsdk.sli.adaptors.rm.data.RangeAllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.RangeResource;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
import org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil;
import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,23 +47,15 @@ public class ResourceAllocator implements SvcLogicResource {
private static final Logger log = LoggerFactory.getLogger(ResourceAllocator.class);
- public ResourceAllocator() {
- log.info("ResourceAllocator created.");
- }
+ private static final String[] INPUT_PREFIX = {"ra-input.", "tmp.resource-allocator."};
- private ServerDao serverDao;
- private VpePortDao vpePortDao;
- private VplspePortDao vplspePortDao;
- private MaxPortSpeedDao maxPortSpeedDao;
- private MaxServerSpeedDao maxServerSpeedDao;
- private ServiceResourceDao serviceResourceDao;
- private ParameterDao parameterDao;
-
- private AllocationRequestBuilder allocationRequestBuilder;
private ResourceManager resourceManager;
+ private EndPointAllocator endPointAllocator;
private SpeedUtil speedUtil;
- private EndPointAllocator endPointAllocator;
+ public ResourceAllocator() {
+ log.info("ResourceAllocator created.");
+ }
@Override
public QueryStatus notify(String resource, String action, String key, SvcLogicContext ctx)
@@ -95,11 +64,7 @@ public class ResourceAllocator implements SvcLogicResource {
}
@Override
- public QueryStatus update(
- String resource,
- String key,
- Map<String, String> parms,
- String prefix,
+ public QueryStatus update(String resource, String key, Map<String, String> parms, String prefix,
SvcLogicContext ctx) throws SvcLogicException {
return QueryStatus.SUCCESS;
@@ -117,13 +82,7 @@ public class ResourceAllocator implements SvcLogicResource {
}
@Override
- public QueryStatus save(
- String arg0,
- boolean arg1,
- boolean arg2,
- String arg3,
- Map<String, String> arg4,
- String arg5,
+ public QueryStatus save(String arg0, boolean arg1, boolean arg2, String arg3, Map<String, String> arg4, String arg5,
SvcLogicContext arg6) throws SvcLogicException {
return QueryStatus.SUCCESS;
}
@@ -131,886 +90,355 @@ public class ResourceAllocator implements SvcLogicResource {
@Override
public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx)
throws SvcLogicException {
- String serviceModel = ctx.getAttribute("tmp.resource-allocator.service-model");
- if (serviceModel != null && serviceModel.trim().length() > 0)
- return allocateResources(serviceModel, ctx, true, prefix);
- return allocateResourcesL3SDN(ctx, true, prefix);
+ return allocateResources(ctx, true, prefix);
}
@Override
- public QueryStatus query(
- String resource,
- boolean localOnly,
- String select,
- String key,
- String prefix,
- String orderBy,
- SvcLogicContext ctx) throws SvcLogicException {
-
- prefix = prefix == null ? "" : prefix + '.';
-
- if (!"NetworkCapacity".equals(resource)) {
- log.info("resource: " + resource);
- log.info("key: " + key);
-
- Resource r = resourceManager.getResource(resource, key);
- if (r == null)
- return QueryStatus.NOT_FOUND;
-
- if (r instanceof LimitResource) {
- ctx.setAttribute(prefix + "used", String.valueOf(((LimitResource) r).used));
-
- log.info("Added context attr: " + prefix + "used: " + String.valueOf(((LimitResource) r).used));
- }
-
- return QueryStatus.SUCCESS;
+ public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix,
+ 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);
+ String resourceName = getParam(ctx, "resource-name", false, null);
+
+ if (resourceEntityId != null && resourceEntityType != null) {
+ List<ResourceData> rdlist = endPointAllocator.getResourcesForEntity(resourceEntityType, resourceEntityId,
+ resourceEntityVersion);
+ setResourceDataInContext(ctx, prefix, rdlist);
+ } else if (resourceTargetId != null && resourceTargetType != null && resourceName != null) {
+ ResourceData rd = endPointAllocator.getResource(resourceTargetType, resourceTargetId, resourceName);
+ setResourceDataInContext(ctx, prefix, Collections.singletonList(rd));
}
- log.info("key: " + key);
- log.info("prefix: " + prefix);
-
- if (key == null)
- return QueryStatus.SUCCESS;
-
- if (key.startsWith("'") && key.endsWith("'"))
- key = key.substring(1, key.length() - 1);
-
- String endPointPosition = "VPE-Cust";
+ return QueryStatus.SUCCESS;
+ }
- String resourceUnionId = key + '/' + endPointPosition;
- List<Resource> rlist = resourceManager.getResourceUnion(resourceUnionId);
+ public AllocationStatus query(ResourceEntity sd, ResourceTarget rt, ResourceRequest rr,
+ List<ResourceResponse> rsList) throws Exception {
+
+ if (sd.resourceEntityId != null && sd.resourceEntityType != null) {
+ List<ResourceData> rdlist = endPointAllocator.getResourcesForEntity(sd.resourceEntityType,
+ 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);
+ setResourceDataInResponse(Collections.singletonList(rd), rsList);
+ }
- log.info("Resources found for " + resourceUnionId + ": " + rlist.size());
+ return AllocationStatus.Success;
+ }
- String assetId = null;
- for (Resource r : rlist) {
- log.info("Resource: " + r.resourceKey.resourceName);
+ private void setResourceDataInContext(SvcLogicContext ctx, String prefix, List<ResourceData> rdlist) {
+ prefix = prefix == null ? "" : prefix + '.';
- if (r instanceof RangeResource) {
- RangeResource rr = (RangeResource) r;
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceUnionId.equals(resourceUnionId)) {
- RangeAllocationItem rai = (RangeAllocationItem) ai;
- ctx.setAttribute(prefix + r.resourceKey.resourceName, String.valueOf(rai.used.first()));
+ setAttr(ctx, prefix + "resource-list_length", String.valueOf(rdlist.size()));
- log.info("Added context attr: " + prefix + r.resourceKey.resourceName + ": " +
- String.valueOf(rr.used.first()));
+ for (int i = 0; i < rdlist.size(); i++) {
+ ResourceData rd = rdlist.get(i);
- assetId = r.resourceKey.assetId;
- String vpeName = assetId;
- int i1 = assetId.indexOf('/');
- if (i1 > 0)
- vpeName = assetId.substring(0, i1);
- ctx.setAttribute(prefix + "vpe-name", vpeName);
+ String pp = prefix + "resource-list[" + i + "].";
- log.info("Added context attr: " + prefix + "vpe-name: " + vpeName);
- }
- }
- }
+ setAttr(ctx, pp + "resource-name", rd.resourceName);
+ setAttr(ctx, pp + "endpoint-position", rd.endPointPosition);
+ setAttr(ctx, pp + "resource-target-type", rd.resourceTargetType);
+ setAttr(ctx, pp + "resource-target-id", rd.resourceTargetId);
+ // SDNGC-7687
+ setAttr(ctx, pp + "resource-target-value", rd.resourceTargetValue);
+ setAttr(ctx, pp + "status", rd.status);
- String affinityLink = "1";
- if (assetId != null) {
- for (Resource r : rlist) {
- if (r instanceof LimitResource) {
- LimitResource ll = (LimitResource) r;
- if (ll.resourceKey.assetId.startsWith(assetId + '-')) {
- int i1 = ll.resourceKey.assetId.lastIndexOf('-');
- affinityLink = ll.resourceKey.assetId.substring(i1 + 1);
- break;
- }
+ if (rd.data != null && !rd.data.isEmpty()) {
+ for (String kk : rd.data.keySet()) {
+ String value = String.valueOf(rd.data.get(kk));
+ setAttr(ctx, pp + kk, value);
}
}
}
-
- ctx.setAttribute(prefix + "affinity-link", affinityLink);
-
- log.info("Added context attr: " + prefix + "affinity-link: " + affinityLink);
-
- return QueryStatus.SUCCESS;
}
@Override
public QueryStatus reserve(String resource, String select, String key, String prefix, SvcLogicContext ctx)
throws SvcLogicException {
- String serviceModel = ctx.getAttribute("tmp.resource-allocator.service-model");
- if (serviceModel != null && serviceModel.trim().length() > 0)
- return allocateResources(serviceModel, ctx, false, prefix);
- return allocateResourcesL3SDN(ctx, false, prefix);
+ return allocateResources(ctx, false, prefix);
+ }
+
+ public AllocationStatus reserve(ResourceEntity sd, ResourceTarget rt, ResourceRequest rr,
+ List<ResourceResponse> rsList) throws Exception {
+ return allocateResources(sd, rt, rr, rsList);
}
@Override
public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException {
- String serviceInstanceId = ctx.getAttribute("tmp.resource-allocator.service-instance-id");
- if (serviceInstanceId == null)
- throw new SvcLogicException("tmp.resource-allocator.service-instance-id is required in ResourceAllocator");
-
- String requestTypeStr = ctx.getAttribute("tmp.resource-allocator.request-type");
- if (requestTypeStr == null)
- throw new SvcLogicException("tmp.resource-allocator.request-type is required in ResourceAllocator");
+ 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);
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = resourceEntityId;
+ sd.resourceEntityType = resourceEntityType;
+ sd.resourceEntityVersion = resourceEntityVersion;
- ReleaseRequestType requestType = null;
try {
- requestType = ReleaseRequestType.convert(requestTypeStr);
- } catch (IllegalArgumentException e) {
- throw new SvcLogicException("Invalid tmp.resource-allocator.request-type: " + requestTypeStr +
- ". Supported values are Cancel, Activate, Disconnect.");
- }
-
- log.info("Starting release: " + requestType + " for: " + serviceInstanceId);
-
- ServiceResource activeServiceResource =
- serviceResourceDao.getServiceResource(serviceInstanceId, ServiceStatus.Active);
- ServiceResource pendingServiceResource =
- serviceResourceDao.getServiceResource(serviceInstanceId, ServiceStatus.Pending);
-
- log.info("Active ServiceResource: ");
- StrUtil.info(log, activeServiceResource);
- log.info("Pending ServiceResource: ");
- StrUtil.info(log, pendingServiceResource);
-
- if (requestType == ReleaseRequestType.Cancel) {
- if (pendingServiceResource != null) {
- log.info("Releasing pending resources: " + pendingServiceResource.resourceSetId);
-
- resourceManager.releaseResourceSet(pendingServiceResource.resourceSetId);
- serviceResourceDao.deleteServiceResource(serviceInstanceId, ServiceStatus.Pending);
- } else {
- log.info("Pending record not found for service instance: " + serviceInstanceId + ". Nothing to do.");
- }
-
- } else if (requestType == ReleaseRequestType.Activate) {
- if (pendingServiceResource != null) {
- if (activeServiceResource != null) {
- log.info("Releasing active resources: " + activeServiceResource.resourceSetId);
-
- resourceManager.releaseResourceSet(activeServiceResource.resourceSetId);
- serviceResourceDao.deleteServiceResource(serviceInstanceId, ServiceStatus.Active);
- }
-
- log.info("Updating the status of the pending record to active.");
-
- serviceResourceDao.updateServiceStatus(serviceInstanceId, ServiceStatus.Pending, ServiceStatus.Active);
- } else {
- log.info("Pending record not found for service instance: " + serviceInstanceId + ". Nothing to do.");
- }
-
- } else if (requestType == ReleaseRequestType.Disconnect) {
- if (pendingServiceResource != null) {
- log.info("Releasing pending resources: " + pendingServiceResource.resourceSetId);
-
- resourceManager.releaseResourceSet(pendingServiceResource.resourceSetId);
- serviceResourceDao.deleteServiceResource(serviceInstanceId, ServiceStatus.Pending);
- }
- if (activeServiceResource != null) {
- log.info("Releasing active resources: " + activeServiceResource.resourceSetId);
-
- resourceManager.releaseResourceSet(activeServiceResource.resourceSetId);
- serviceResourceDao.deleteServiceResource(serviceInstanceId, ServiceStatus.Active);
- }
+ this.release(sd);
+ } catch (Exception e) {
+ throw new SvcLogicException(e.getMessage());
}
-
return QueryStatus.SUCCESS;
}
- private QueryStatus allocateResourcesL3SDN(SvcLogicContext ctx, boolean checkOnly, String prefix)
- throws SvcLogicException {
- prefix = prefix == null ? "" : prefix + '.';
+ public AllocationStatus release(ResourceEntity sd) throws Exception {
- String aicSiteId = getAicSiteId(ctx);
- Map<String, Object> service = getServiceData(ctx);
+ if (sd.resourceEntityVersion != null) {
+ String resourceSet = sd.resourceEntityType + "::" + sd.resourceEntityId + "::" + sd.resourceEntityVersion;
+ log.info("Starting release for: " + resourceSet);
- String requestTypeStr = ctx.getAttribute("tmp.resource-allocator.request-type");
- if (requestTypeStr == null)
- requestTypeStr = "New";
+ resourceManager.releaseResourceSet(resourceSet);
+ } else {
+ String resourceUnion = sd.resourceEntityType + "::" + sd.resourceEntityId;
+ log.info("Starting release for: " + resourceUnion);
- ReserveRequestType requestType = null;
- try {
- requestType = ReserveRequestType.convert(requestTypeStr);
- } catch (IllegalArgumentException e) {
- throw new SvcLogicException("Invalid tmp.resource-allocator.request-type: " + requestTypeStr +
- ". Supported values are New, Change.");
+ resourceManager.releaseResourceUnion(resourceUnion);
}
- String serviceInstanceId = String.valueOf(service.get("service-instance-id"));
-
- ServiceResource activeServiceResource =
- serviceResourceDao.getServiceResource(serviceInstanceId, ServiceStatus.Active);
- ServiceResource pendingServiceResource =
- serviceResourceDao.getServiceResource(serviceInstanceId, ServiceStatus.Pending);
-
- log.info("Active ServiceResource: ");
- StrUtil.info(log, activeServiceResource);
- log.info("Pending ServiceResource: ");
- StrUtil.info(log, pendingServiceResource);
+ return AllocationStatus.Success;
- ServiceResource sr = new ServiceResource();
- sr.serviceInstanceId = serviceInstanceId;
- sr.serviceStatus = ServiceStatus.Pending;
- sr.serviceChangeNumber = 1;
- if (pendingServiceResource != null)
- sr.serviceChangeNumber = pendingServiceResource.serviceChangeNumber + 1;
- else if (activeServiceResource != null)
- sr.serviceChangeNumber = activeServiceResource.serviceChangeNumber + 1;
- sr.resourceSetId = serviceInstanceId + "/" + sr.serviceChangeNumber;
- sr.resourceUnionId = serviceInstanceId;
-
- log.info("New ServiceResource: ");
- StrUtil.info(log, sr);
+ }
- List<Map<String, Object>> vpePortData = vpePortDao.getVpePortData(aicSiteId);
- List<Map<String, Object>> vplspePortData = vplspePortDao.getVplspePortData(aicSiteId);
- List<Map<String, Object>> serverData = serverDao.getServerData(aicSiteId);
+ private QueryStatus allocateResources(SvcLogicContext ctx, boolean checkOnly, String prefix)
+ throws SvcLogicException {
+ String serviceModel = getParam(ctx, "service-model", true, null);
+ String requestType = getParam(ctx, "request-type", false, "New");
- vpePortData = orderVpe(vpePortData);
+ ResourceEntity sd = getResourceEntityData(ctx);
+ ResourceTarget rt = getResourceTargetData(ctx);
+ ResourceRequest rr = getResourceRequest(ctx);
- long maxAvailableSpeedVpePort = 0;
- boolean vpePortFound = false;
+ log.info("Starting reserve: " + requestType + ", service-model: " + serviceModel);
+ StrUtil.info(log, sd);
+ StrUtil.info(log, rt);
+ StrUtil.info(log, rr);
- for (Map<String, Object> vpe : vpePortData) {
- String vpeId = String.valueOf(vpe.get("vpe-id"));
- String interfaceName = String.valueOf(vpe.get("physical-interface-name"));
- String portId = vpeId + "/" + interfaceName;
+ boolean change = requestType.equalsIgnoreCase("change");
- log.info("Checking VPE port: " + portId);
+ List<ResourceData> rlist = endPointAllocator.allocateResources(serviceModel, sd, rt, rr, checkOnly, change);
- String provStatus = String.valueOf(vpe.get("provisioning-status"));
- if (!"PROV".equals(provStatus)) {
- log.info("Skipping port " + portId + ": Provisioning status is not PROV.");
- continue;
- }
+ if (rlist != null && !rlist.isEmpty()) {
+ setResourceDataInContext(ctx, prefix, rlist);
- String imageFile = String.valueOf(vpe.get("image-file-name"));
- String endPointPosition = "VPE-Cust";
- long maxPortSpeed = maxPortSpeedDao.getMaxPortSpeed(imageFile, endPointPosition, interfaceName);
- vpe.put("max-port-speed", maxPortSpeed);
-
- EquipmentData ed = new EquipmentData();
- ed.data = vpe;
- ed.equipmentId = portId;
- ed.equipmentLevel = EquipmentLevel.Port;
-
- ServiceData sd = new ServiceData();
- sd.data = service;
- sd.serviceModel = "L3SDN";
- sd.endPointPosition = endPointPosition;
- sd.resourceUnionId = sr.resourceUnionId;
- sd.resourceSetId = sr.resourceSetId;
-
- StrUtil.info(log, ed);
- StrUtil.info(log, sd);
-
- AllocationRequest ar = allocationRequestBuilder.buildAllocationRequest(sd, ed, checkOnly,
- requestType == ReserveRequestType.Change);
- AllocationOutcome ao = resourceManager.allocateResources(ar);
-
- if (ao.status == AllocationStatus.Success) {
-
- // Assign affinity link
- if (!checkOnly) {
- List<String> affinityLinkIdList = new ArrayList<>();
- affinityLinkIdList.add("0");
- affinityLinkIdList.add("1");
- affinityLinkIdList.add("2");
- affinityLinkIdList.add("3");
-
- String preferedAffinityLinkId = "0";
- long lowestAssignedBw = Long.MAX_VALUE;
- for (String affinityLinkId : affinityLinkIdList) {
- long used = 0;
- String assetId = ed.equipmentId + "-" + affinityLinkId;
- Resource r = resourceManager.getResource("Bandwidth", assetId);
- if (r != null) {
- LimitResource ll = (LimitResource) r;
- used = ll.used;
- }
- if (used < lowestAssignedBw) {
- lowestAssignedBw = used;
- preferedAffinityLinkId = affinityLinkId;
- }
- log.info("Assigned bandwidth on affinity link: " + assetId + ": " + used);
- }
-
- log.info("Prefered affinity link for " + ed.equipmentId + ": " + preferedAffinityLinkId);
-
- ctx.setAttribute(prefix + "affinity-link", preferedAffinityLinkId);
-
- LimitAllocationRequest ar1 = new LimitAllocationRequest();
- ar1.resourceSetId = sd.resourceSetId;
- ar1.resourceUnionId = sd.resourceUnionId;
- ar1.resourceShareGroupList = null;
- ar1.resourceName = "Bandwidth";
- ar1.assetId = ed.equipmentId + "-" + preferedAffinityLinkId;
- ar1.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar1.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar1.replace = true;
- ar1.strict = false;
- ar1.checkLimit = Long.MAX_VALUE;
- ar1.checkCount = 0;
- ar1.allocateCount = (Long) sd.data.get("service-speed-kbps");
-
- resourceManager.allocateResources(ar1);
+ for (ResourceData rd : rlist) {
+ if (!rd.status.equals("Success")) {
+ log.info("Capacity not found for: " + sd.resourceEntityType + "::" + sd.resourceEntityId);
+ return QueryStatus.NOT_FOUND;
}
-
- ctx.setAttribute(prefix + "vpe-name", vpeId);
-
- vpePortFound = true;
- break;
- }
-
- if (ao instanceof LimitAllocationOutcome) {
- LimitAllocationOutcome lao = (LimitAllocationOutcome) ao;
- long available = lao.limit - lao.used;
- if (available > maxAvailableSpeedVpePort)
- maxAvailableSpeedVpePort = available;
}
}
+ return QueryStatus.SUCCESS;
+ }
- long maxAvailableSpeedVplspePort = 0;
- boolean vplspePortFound = false;
+ private AllocationStatus allocateResources(ResourceEntity sd, ResourceTarget rt, ResourceRequest rr,
+ List<ResourceResponse> rsList) throws Exception {
- for (Map<String, Object> vplspe : vplspePortData) {
- String vplspeId = String.valueOf(vplspe.get("vplspe-id"));
- String interfaceName = String.valueOf(vplspe.get("physical-interface-name"));
- String portId = vplspeId + "/" + interfaceName;
+ String serviceModel = rr.serviceModel;
+ String requestType = rr.requestType == null ? "New" : rr.requestType;
- log.info("Checking VPLSPE port: " + portId);
+ log.info("Starting reserve: " + requestType + ", service-model: " + serviceModel);
+ StrUtil.info(log, sd);
+ StrUtil.info(log, rt);
+ StrUtil.info(log, rr);
- String provStatus = String.valueOf(vplspe.get("provisioning-status"));
- if (!"PROV".equals(provStatus)) {
- log.info("Skipping port " + portId + ": Provisioning status is not PROV.");
- continue;
- }
+ boolean change = requestType.equalsIgnoreCase("change");
- long physicalSpeed = (Long) vplspe.get("physical-interface-speed");
- String physicalSpeedUnit = String.valueOf(vplspe.get("physical-interface-speed-unit"));
- long maxPortSpeed = speedUtil.convertToKbps(physicalSpeed, physicalSpeedUnit);
- vplspe.put("max-port-speed", maxPortSpeed);
-
- EquipmentData ed = new EquipmentData();
- ed.data = vplspe;
- ed.equipmentId = portId;
- ed.equipmentLevel = EquipmentLevel.Port;
-
- ServiceData sd = new ServiceData();
- sd.data = service;
- sd.serviceModel = "L3SDN";
- sd.endPointPosition = "IPAG-TOA";
- sd.resourceUnionId = sr.resourceUnionId;
- sd.resourceSetId = sr.resourceSetId;
-
- StrUtil.info(log, ed);
- StrUtil.info(log, sd);
-
- AllocationRequest ar = allocationRequestBuilder.buildAllocationRequest(sd, ed, checkOnly,
- requestType == ReserveRequestType.Change);
- AllocationOutcome ao = resourceManager.allocateResources(ar);
-
- if (ao.status == AllocationStatus.Success) {
- vplspePortFound = true;
- break;
- }
+ List<ResourceData> rlist = endPointAllocator.allocateResources(serviceModel, sd, rt, rr, rr.checkOnly, change);
- if (ao instanceof LimitAllocationOutcome) {
- LimitAllocationOutcome lao = (LimitAllocationOutcome) ao;
- long available = lao.limit - lao.used;
- if (available > maxAvailableSpeedVplspePort)
- maxAvailableSpeedVplspePort = available;
+ if (rlist != null && !rlist.isEmpty()) {
+ setResourceDataInResponse(rlist, rsList);
+
+ for (ResourceData rd : rlist) {
+ if (!rd.status.equals("Success")) {
+ log.info("Capacity not found for: " + sd.resourceEntityType + "::" + sd.resourceEntityId);
+ return AllocationStatus.ResourceNotFound;
+ }
}
}
- long maxAvailableSpeedServer = 0;
- boolean serverFound = false;
-
- for (Map<String, Object> server : serverData) {
- String serverId = String.valueOf(server.get("server-id"));
- String serverModel = String.valueOf(server.get("server-model"));
-
- log.info("Checking Server: " + serverId);
-
- String endPointPosition = "VCE-Cust";
-
- int serverCount = (Integer) server.get("server-count");
- if (serverCount == 0)
- serverCount = 1;
- String ratioString = parameterDao.getParameter("homing.pserver.sparing.ratio");
- if (ratioString == null || ratioString.length() == 0)
- ratioString = "1:1";
- int primaryServerCount = calculatePrimaryServerCount(serverCount, ratioString);
- server.put("number-primary-servers", primaryServerCount);
-
- int evcCount = getEvcCountOnServer(serverId);
- int evcCountPerServer = (evcCount + primaryServerCount - 1) / primaryServerCount;
- long maxServerSpeed = maxServerSpeedDao.getMaxServerSpeed(serverModel, evcCountPerServer);
- server.put("max-server-speed", maxServerSpeed);
- server.put("evc-count", evcCount);
- server.put("evc-count-per-server", evcCountPerServer);
-
- EquipmentData ed = new EquipmentData();
- ed.data = server;
- ed.equipmentId = serverId;
- ed.equipmentLevel = EquipmentLevel.Server;
-
- ServiceData sd = new ServiceData();
- sd.data = service;
- sd.serviceModel = "L3SDN";
- sd.endPointPosition = endPointPosition;
- sd.resourceUnionId = sr.resourceUnionId;
- sd.resourceSetId = sr.resourceSetId;
-
- StrUtil.info(log, ed);
- StrUtil.info(log, sd);
-
- AllocationRequest ar = allocationRequestBuilder.buildAllocationRequest(sd, ed, checkOnly,
- requestType == ReserveRequestType.Change);
- AllocationOutcome ao = resourceManager.allocateResources(ar);
-
- if (ao.status == AllocationStatus.Success) {
- serverFound = true;
-
- if (ao instanceof MultiResourceAllocationOutcome) {
- MultiResourceAllocationOutcome mrao = (MultiResourceAllocationOutcome) ao;
- for (AllocationOutcome ao1 : mrao.allocationOutcomeList) {
- if (ao1 instanceof LimitAllocationOutcome) {
- LimitAllocationOutcome lao = (LimitAllocationOutcome) ao1;
- if ("Bandwidth".equals(lao.request.resourceName)) {
- ThresholdStatus th = allocationRequestBuilder.getThresholdStatus(sd, ed, lao);
- setThresholdData(ctx, th, sd, ed);
- }
- }
+ return AllocationStatus.Success;
+ }
+
+ private void setResourceDataInResponse(List<ResourceData> rlist, List<ResourceResponse> rsList) {
+ for (ResourceData rd : emptyIfNull(rlist)) {
+ ResourceResponse res = new ResourceResponse();
+ res.resourceName = rd.resourceName;
+ res.endPointPosition = rd.endPointPosition;
+ res.resourceTargetId = rd.resourceTargetId;
+ res.resourceTargetType = rd.resourceTargetType;
+ res.status = rd.status;
+ if (rd.data != null && !rd.data.isEmpty()) {
+ for (String kk : rd.data.keySet()) {
+ if (kk.equalsIgnoreCase("allocated")) {
+ res.resourceAllocated = String.valueOf(rd.data.get(kk));
}
- }
- break;
- }
+ if (kk.equalsIgnoreCase("used")) {
+ res.resourceUsed = String.valueOf(rd.data.get(kk));
+ }
- if (ao instanceof MultiResourceAllocationOutcome) {
- MultiResourceAllocationOutcome mrao = (MultiResourceAllocationOutcome) ao;
- for (AllocationOutcome ao1 : mrao.allocationOutcomeList) {
- if (ao1 instanceof LimitAllocationOutcome) {
- LimitAllocationOutcome lao = (LimitAllocationOutcome) ao1;
- if (lao.status == AllocationStatus.Failure && "Bandwidth".equals(lao.request.resourceName)) {
- long available = lao.limit - lao.used;
- if (available > maxAvailableSpeedServer)
- maxAvailableSpeedServer = available;
- }
- if (lao.status == AllocationStatus.Failure && "Connection".equals(lao.request.resourceName)) {
- maxAvailableSpeedServer = 0;
- break;
- }
+ if (kk.equalsIgnoreCase("available")) {
+ res.resourceAvailable = String.valueOf(rd.data.get(kk));
+ }
- ThresholdStatus th = allocationRequestBuilder.getThresholdStatus(sd, ed, lao);
- setThresholdData(ctx, th, sd, ed);
+ if (kk.equalsIgnoreCase("limit")) {
+ res.resourceLimit = String.valueOf(rd.data.get(kk));
}
- }
- }
- }
- if (vpePortFound && vplspePortFound && serverFound) {
- if (!checkOnly) {
- if (pendingServiceResource == null) {
- log.info("Adding the pending service resource record to DB.");
- serviceResourceDao.addServiceResource(sr);
- } else {
- log.info("Releasing previously allocated resources for resource set id: " +
- pendingServiceResource.resourceSetId);
- resourceManager.releaseResourceSet(pendingServiceResource.resourceSetId);
-
- log.info("Updating the pending service resource record in DB with service change number: " +
- sr.serviceChangeNumber);
- serviceResourceDao.updateServiceResource(sr);
}
}
-
- return QueryStatus.SUCCESS;
+ rsList.add(res);
}
- log.info("Releasing allocated resources (if any) for resource set id: " + sr.resourceSetId);
- resourceManager.releaseResourceSet(sr.resourceSetId);
-
- long maxAvailableSpeed = Long.MAX_VALUE;
- if (!vpePortFound && maxAvailableSpeedVpePort < maxAvailableSpeed)
- maxAvailableSpeed = maxAvailableSpeedVpePort;
- if (!vplspePortFound && maxAvailableSpeedVplspePort < maxAvailableSpeed)
- maxAvailableSpeed = maxAvailableSpeedVplspePort;
- if (!serverFound && maxAvailableSpeedServer < maxAvailableSpeed)
- maxAvailableSpeed = maxAvailableSpeedServer;
-
- setOutputContext(ctx, maxAvailableSpeed, "kbps");
- return QueryStatus.NOT_FOUND;
}
- private List<Map<String, Object>> orderVpe(List<Map<String, Object>> vpePortData) {
- for (Map<String, Object> vpe : vpePortData) {
- String vpeId = String.valueOf(vpe.get("vpe-id"));
- String interfaceName = String.valueOf(vpe.get("physical-interface-name"));
- String portId = vpeId + "/" + interfaceName;
- Resource r = resourceManager.getResource("Bandwidth", portId);
- long used = 0;
- if (r != null) {
- LimitResource ll = (LimitResource) r;
- used = ll.used;
- }
- vpe.put("used-bandwidth", used);
-
- log.info("Used bandwidth on VPE: " + vpeId + ": " + used);
- }
-
- Collections.sort(vpePortData, new Comparator<Map<String, Object>>() {
-
- @Override
- public int compare(Map<String, Object> o1, Map<String, Object> o2) {
- long used1 = (Long) o1.get("used-bandwidth");
- long used2 = (Long) o2.get("used-bandwidth");
- if (used1 < used2)
- return -1;
- if (used1 > used2)
- return 1;
- return 0;
- }
- });
-
- return vpePortData;
+ public static <T> Iterable<T> emptyIfNull(Iterable<T> iterable) {
+ return iterable == null ? Collections.<T>emptyList() : iterable;
}
- private void setThresholdData(SvcLogicContext ctx, ThresholdStatus th, ServiceData sd, EquipmentData ed) {
- if (th == null)
- return;
-
- String pp = "tmp.resource-allocator-output.threshold-notification-list.threshold-hotification[0].";
- ctx.setAttribute("tmp.resource-allocator-output.threshold-notification-list.threshold-hotification_length",
- "1");
- ctx.setAttribute(pp + "message", th.resourceThreshold.message);
- ctx.setAttribute(pp + "resource-rule.service-model", th.resourceRule.serviceModel);
- ctx.setAttribute(pp + "resource-rule.endpoint-position", th.resourceRule.endPointPosition);
- ctx.setAttribute(pp + "resource-rule.resource-name", th.resourceRule.resourceName);
- ctx.setAttribute(pp + "resource-rule.equipment-level", th.resourceRule.equipmentLevel);
- ctx.setAttribute(pp + "resource-rule.soft-limit-expression", th.resourceRule.softLimitExpression);
- ctx.setAttribute(pp + "resource-rule.hard-limit-expression", th.resourceRule.hardLimitExpression);
- ctx.setAttribute(pp + "resource-state.used", String.valueOf(th.used));
- ctx.setAttribute(pp + "resource-state.limit-value", String.valueOf(th.limitValue));
- ctx.setAttribute(pp + "resource-state.threshold-value", String.valueOf(th.thresholdValue));
- ctx.setAttribute(pp + "resource-state.last-added", String.valueOf(th.lastAdded));
- ctx.setAttribute(pp + "equipment-data.equipment-id", ed.equipmentId);
- for (String edKey : ed.data.keySet())
- ctx.setAttribute(pp + "equipment-data." + edKey, String.valueOf(ed.data.get(edKey)));
+ private void setAttr(SvcLogicContext ctx, String name, String value) {
+ ctx.setAttribute(name, value);
+ log.info("Added context attr: " + name + ": " + value);
}
- private QueryStatus allocateResources(String serviceModel, SvcLogicContext ctx, boolean checkOnly, String prefix)
- throws SvcLogicException {
- prefix = prefix == null ? "" : prefix + '.';
-
- Map<String, Object> service = getServiceData(ctx);
- Map<String, Object> ec = getEquipConstraints(ctx);
-
- String requestTypeStr = ctx.getAttribute("tmp.resource-allocator.request-type");
- if (requestTypeStr == null)
- requestTypeStr = "New";
-
- ReserveRequestType requestType = null;
- try {
- requestType = ReserveRequestType.convert(requestTypeStr);
- } catch (IllegalArgumentException e) {
- throw new SvcLogicException("Invalid tmp.resource-allocator.request-type: " + requestTypeStr +
- ". Supported values are New, Change.");
- }
-
- String serviceInstanceId = String.valueOf(service.get("service-instance-id"));
-
- log.info("Starting reserve: " + requestType + ", service-instance-id: " + serviceInstanceId);
-
- ServiceResource activeServiceResource =
- serviceResourceDao.getServiceResource(serviceInstanceId, ServiceStatus.Active);
- ServiceResource pendingServiceResource =
- serviceResourceDao.getServiceResource(serviceInstanceId, ServiceStatus.Pending);
-
- log.info("Active ServiceResource: ");
- StrUtil.info(log, activeServiceResource);
- log.info("Pending ServiceResource: ");
- StrUtil.info(log, pendingServiceResource);
-
- int changeNumber = 1;
- if (pendingServiceResource != null)
- changeNumber = pendingServiceResource.serviceChangeNumber + 1;
- else if (activeServiceResource != null)
- changeNumber = activeServiceResource.serviceChangeNumber + 1;
-
- ServiceData sd = new ServiceData();
- sd.data = service;
- sd.serviceModel = serviceModel;
- sd.endPointPosition = (String) service.get("end-point-position");
- sd.resourceShareGroup = (String) service.get("resource-share-group");
- sd.resourceName = (String) service.get("resource-name");
- sd.serviceInstanceId = serviceInstanceId;
-
- StrUtil.info(log, sd);
-
- List<EndPointData> epList = endPointAllocator.allocateEndPoints(sd, ec, checkOnly,
- requestType == ReserveRequestType.Change, changeNumber);
-
- if (epList != null && !epList.isEmpty()) {
- if (!checkOnly) {
- EndPointData ep = epList.get(0);
-
- if (sd.resourceName == null) {
- ServiceResource sr = new ServiceResource();
- sr.serviceInstanceId = serviceInstanceId;
- sr.serviceStatus = ServiceStatus.Pending;
- sr.serviceChangeNumber = changeNumber;
- sr.resourceSetId = ep.resourceSetId;
- sr.resourceUnionId = ep.resourceUnionId;
-
- log.info("New ServiceResource: ");
- StrUtil.info(log, sr);
-
- if (pendingServiceResource == null) {
- log.info("Adding the pending service resource record to DB.");
- serviceResourceDao.addServiceResource(sr);
- } else {
- log.info("Releasing previously allocated resources for resource set id: " +
- pendingServiceResource.resourceSetId);
- resourceManager.releaseResourceSet(pendingServiceResource.resourceSetId);
-
- log.info("Updating the pending service resource record in DB with service change number: " +
- sr.serviceChangeNumber);
- serviceResourceDao.updateServiceResource(sr);
- }
- }
-
- for (EndPointData ep1 : epList)
- if (ep1.data != null && !ep1.data.isEmpty())
- for (String key : ep1.data.keySet()) {
- String value = String.valueOf(ep1.data.get(key));
- ctx.setAttribute(prefix + key, value);
-
- log.info("Added context attr: " + prefix + key + ": " + value);
- }
- }
-
- return QueryStatus.SUCCESS;
- }
-
- log.info("Capacity not found for EVC: " + serviceInstanceId);
-
- return QueryStatus.NOT_FOUND;
+ 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");
+ sd.data = getDataParam(ctx, "reservation-entity-data", "resource-entity-data", "service-data");
+ return sd;
}
- private int getEvcCountOnServer(String serverId) {
- LimitResource l = (LimitResource) resourceManager.getResource("Connection", serverId);
- if (l != null)
- return (int) l.used;
- return 0;
+ 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.data = getDataParam(ctx, "reservation-target-data", "resource-target-data", "equipment-data");
+ return sd;
}
- private String getAicSiteId(SvcLogicContext ctx) throws SvcLogicException {
- String aicSiteId = ctx.getAttribute("tmp.resource-allocator.aic-site-id");
- if (aicSiteId == null)
- throw new SvcLogicException("tmp.resource-allocator.aic-site-id is required in ResourceAllocator");
- return aicSiteId;
+ private ResourceRequest getResourceRequest(SvcLogicContext ctx) throws SvcLogicException {
+ ResourceRequest rr = new ResourceRequest();
+ rr.resourceName = getParam(ctx, "resource-name", false, null);
+ rr.resourceShareGroup = getParam(ctx, "resource-share-group", false, null);
+ rr.rangeRequestedNumbers = getParam(ctx, "range-requested-numbers", false, null);
+ rr.rangeExcludeNumbers = getParam(ctx, "range-exclude-numbers", false, null);
+ String rangeReverseOrderStr = getParam(ctx, "range-reverse-order", false, "false");
+ rr.rangeReverseOrder = Boolean.parseBoolean(rangeReverseOrderStr);
+ String rangeMinOverrideStr = getParam(ctx, "range-min-override", false, "-1");
+ rr.rangeMinOverride = Integer.parseInt(rangeMinOverrideStr);
+ String rangeMaxOverrideStr = getParam(ctx, "range-max-override", false, "-1");
+ rr.rangeMaxOverride = Integer.parseInt(rangeMaxOverrideStr);
+ String replaceStr = getParam(ctx, "replace", false, "true");
+ rr.replace = Boolean.parseBoolean(replaceStr);
+ rr.applicationId = getParam(ctx, "application-id", false, "SDNC");
+ rr.endPointPosition = getParam(ctx, "endpoint-position", false, null);
+ return rr;
}
- private Map<String, Object> getServiceData(SvcLogicContext ctx) throws SvcLogicException {
- Map<String, Object> sd = new HashMap<String, Object>();
-
- String endPointPosition = ctx.getAttribute("tmp.resource-allocator.end-point-position");
- if (endPointPosition != null && endPointPosition.trim().length() > 0)
- sd.put("end-point-position", endPointPosition.trim());
-
- String resourceName = ctx.getAttribute("tmp.resource-allocator.resource-name");
- if (resourceName != null && resourceName.trim().length() > 0)
- sd.put("resource-name", resourceName.trim());
-
- String resourceShareGroup = ctx.getAttribute("tmp.resource-allocator.resource-share-group");
- if (resourceShareGroup != null && resourceShareGroup.trim().length() > 0)
- sd.put("resource-share-group", resourceShareGroup.trim());
-
- String serviceInstanceId = ctx.getAttribute("tmp.resource-allocator.service-instance-id");
- if (serviceInstanceId == null)
- serviceInstanceId = "checkServiceInstance";
- sd.put("service-instance-id", serviceInstanceId);
-
- String speedStr = ctx.getAttribute("tmp.resource-allocator.speed");
- if (speedStr != null && speedStr.trim().length() > 0) {
- long speed = 0;
- try {
- speed = Long.parseLong(speedStr);
- } catch (NumberFormatException e) {
- throw new SvcLogicException("Invalid tmp.resource-allocator.speed. Must be a number.");
+ private String getParam(SvcLogicContext ctx, String name, boolean required, String def) throws SvcLogicException {
+ String v = null;
+ for (String p : INPUT_PREFIX) {
+ v = ctx.getAttribute(p + name);
+ if (v != null && v.trim().length() > 0) {
+ log.info("Param: " + name + ": " + v.trim());
+ return v.trim();
+ }
}
- String unit = ctx.getAttribute("tmp.resource-allocator.speed-unit");
- if (unit == null || unit.trim().length() == 0)
- throw new SvcLogicException("tmp.resource-allocator.speed-unit is required in ResourceAllocator");
- long serviceSpeedKbps = speedUtil.convertToKbps(speed, unit);
-
- sd.put("service-speed-kbps", serviceSpeedKbps);
+ if (required) {
+ throw new SvcLogicException("The following variable is required in DG context: " + name);
}
- String vpnId = ctx.getAttribute("tmp.resource-allocator.vpn-id");
- if (vpnId != null && vpnId.trim().length() > 0)
- sd.put("vpn-id", vpnId.trim());
-
- String vpnIdList = ctx.getAttribute("tmp.resource-allocator.vpn-id-list");
- if (vpnIdList != null && vpnIdList.trim().length() > 0)
- sd.put("vpn-id-list", vpnIdList.trim());
-
- String vrfName = ctx.getAttribute("tmp.resource-allocator.vrf-name");
- if (vrfName != null && vrfName.trim().length() > 0)
- sd.put("vrf-name", vrfName.trim());
-
- String vrfNameList = ctx.getAttribute("tmp.resource-allocator.vrf-name-list");
- if (vrfNameList != null && vrfNameList.trim().length() > 0)
- sd.put("vrf-name-list", vrfNameList.trim());
-
- String v4multicast = ctx.getAttribute("tmp.resource-allocator.v4-multicast");
- if (v4multicast != null && v4multicast.trim().length() > 0)
- sd.put("v4-multicast", v4multicast.trim());
-
- String v6multicast = ctx.getAttribute("tmp.resource-allocator.v6-multicast");
- if (v6multicast != null && v6multicast.trim().length() > 0)
- sd.put("v6-multicast", v6multicast.trim());
-
- String v4ServingSite = ctx.getAttribute("tmp.resource-allocator.v4-serving-site");
- if (v4ServingSite != null && v4ServingSite.trim().length() > 0)
- sd.put("v4-serving-site", v4ServingSite.trim());
-
- String v6ServingSite = ctx.getAttribute("tmp.resource-allocator.v6-serving-site");
- if (v6ServingSite != null && v6ServingSite.trim().length() > 0)
- sd.put("v6-serving-site", v6ServingSite.trim());
-
- return sd;
+ log.info("Param: " + name + " not supplied. Using default: " + def);
+ return def;
}
- private Map<String, Object> getEquipConstraints(SvcLogicContext ctx) throws SvcLogicException {
- Map<String, Object> mm = new HashMap<String, Object>();
-
- String vrfRequired = ctx.getAttribute("tmp.resource-allocator.vrf-required");
- if (vrfRequired != null && vrfRequired.trim().length() > 0)
- mm.put("vrf-required", vrfRequired.trim());
-
- String clli = ctx.getAttribute("tmp.resource-allocator.clli");
- if (clli == null || clli.trim().length() == 0)
- clli = ctx.getAttribute("tmp.resource-allocator.aic-site-id");
- if (clli != null) {
- mm.put("clli", clli.trim());
- mm.put("aic-site-id", clli.trim());
- }
-
- String vpeName = ctx.getAttribute("tmp.resource-allocator.vpe-name");
- if (vpeName != null && vpeName.trim().length() > 0)
- mm.put("vpe-name", vpeName.trim());
-
- String vnfName = ctx.getAttribute("tmp.resource-allocator.device-name");
- if (vnfName != null && vnfName.trim().length() > 0)
- mm.put("vnf-name", vnfName.trim());
-
- String excludeVpeList = ctx.getAttribute("tmp.resource-allocator.exclude-vpe-list");
- if (excludeVpeList != null && excludeVpeList.trim().length() > 0)
- mm.put("exclude-vpe-list", excludeVpeList.trim());
-
- String uplinkCircuitCountStr =
- ctx.getAttribute("tmp.resource-allocator.uplink-circuit-list.uplink-circuit_length");
- if (uplinkCircuitCountStr != null) {
- long uplinkCircuitCount = 0;
- try {
- uplinkCircuitCount = Long.parseLong(uplinkCircuitCountStr);
- } catch (NumberFormatException e) {
- throw new SvcLogicException(
- "Invalid tmp.resource-allocator.uplink-circuit-list.uplink-circuit_length. Must be a number.");
- }
- List<Map<String, Object>> uplinkCircuitList = new ArrayList<>();
- for (int i = 0; i < uplinkCircuitCount; i++) {
- String uplinkCircuitId = ctx.getAttribute(
- "tmp.resource-allocator.uplink-circuit-list.uplink-circuit[" + i + "].uplink-circuit-id");
- String uplinkCircuitBandwidthStr =
- ctx.getAttribute("tmp.resource-allocator.uplink-circuit-list.uplink-circuit[" + i +
- "].uplink-circuit-bandwidth");
- String uplinkCircuitBandwidthUnit =
- ctx.getAttribute("tmp.resource-allocator.uplink-circuit-list.uplink-circuit[" + i +
- "].uplink-circuit-bandwidth-unit");
-
- long uplinkCircuitBandwidth = 0;
- try {
- uplinkCircuitBandwidth = Long.parseLong(uplinkCircuitBandwidthStr);
- } catch (NumberFormatException e) {
- throw new SvcLogicException("Invalid tmp.resource-allocator.uplink-circuit-list.uplink-circuit[" +
- i + "].uplink-circuit-id. Must be a number.");
- }
-
- long uplinkCircuitBandwidthKbps =
- speedUtil.convertToKbps(uplinkCircuitBandwidth, uplinkCircuitBandwidthUnit);
-
- Map<String, Object> uplinkCircuit = new HashMap<String, Object>();
- uplinkCircuit.put("uplink-circuit-id", uplinkCircuitId);
- uplinkCircuit.put("uplink-circuit-bandwidth", uplinkCircuitBandwidthKbps);
- uplinkCircuitList.add(uplinkCircuit);
+ private String getParam(SvcLogicContext ctx, String[] names, boolean required, String def)
+ throws SvcLogicException {
+ String v = null;
+ for (String name : names) {
+ v = getParam(ctx, name, false, def);
+ if (v != null) {
+ return v;
}
- mm.put("uplink-circuit-list", uplinkCircuitList);
}
-
- return mm;
- }
-
- private void setOutputContext(SvcLogicContext ctx, long maxAvailableSpeed, String unit) {
- ctx.setAttribute("tmp.resource-allocator-output.max-available-speed", String.valueOf(maxAvailableSpeed));
- ctx.setAttribute("tmp.resource-allocator-output.speed-unit", unit);
- }
-
- private int calculatePrimaryServerCount(int serverCount, String ratioString) throws SvcLogicException {
- String[] ss = ratioString.split(":");
- if (ss.length != 2)
- throw new SvcLogicException("Invalid value for homing.pserver.sparing.ratio: " + ratioString);
-
- int n = 1, m = 1;
- try {
- n = Integer.parseInt(ss[0]);
- m = Integer.parseInt(ss[1]);
- } catch (Exception e) {
- throw new SvcLogicException("Invalid value for homing.pserver.sparing.ratio: " + ratioString);
+ if (required) {
+ throw new SvcLogicException(
+ "One of the following variable is required in DG context: " + Arrays.deepToString(names));
}
- return (serverCount - 1) * n / (n + m) + 1;
+ log.info("Param: " + names + " not supplied. Using default: " + def);
+ return def;
}
- public void setServerDao(ServerDao serverDao) {
- this.serverDao = serverDao;
- }
-
- public void setVpePortDao(VpePortDao vpePortDao) {
- this.vpePortDao = vpePortDao;
- }
-
- public void setVplspePortDao(VplspePortDao vplspePortDao) {
- this.vplspePortDao = vplspePortDao;
- }
-
- public void setMaxPortSpeedDao(MaxPortSpeedDao maxPortSpeedDao) {
- this.maxPortSpeedDao = maxPortSpeedDao;
- }
-
- public void setMaxServerSpeedDao(MaxServerSpeedDao maxServerSpeedDao) {
- this.maxServerSpeedDao = maxServerSpeedDao;
- }
-
- public void setAllocationRequestBuilder(AllocationRequestBuilder allocationRequestBuilder) {
- this.allocationRequestBuilder = allocationRequestBuilder;
+ private Map<String, String> getDataParam(SvcLogicContext ctx, String... names) {
+ Map<String, String> data = new HashMap<>();
+ Set<String> ctxNames = ctx.getAttributeKeySet();
+ for (String n : ctxNames) {
+ for (String p : INPUT_PREFIX) {
+ for (String name : names) {
+ String pp = p + name + '.';
+ if (n.startsWith(pp)) {
+ String nn = n.substring(pp.length());
+ String vv = ctx.getAttribute(n);
+ data.put(nn, vv);
+
+ log.info("Data param: " + nn + ": " + vv);
+
+ if (ctxNames.contains(n + "-unit")) {
+ try {
+ long v = Long.parseLong(vv);
+ String unit = ctx.getAttribute(n + "-unit");
+ long kbps = speedUtil.convertToKbps(v, unit);
+ long mbps = speedUtil.convertToMbps(v, unit);
+ data.put(nn + "-kbps", String.valueOf(kbps));
+ data.put(nn + "-mbps", String.valueOf(mbps));
+
+ log.info("Data param: " + nn + "-kbps: " + kbps);
+ log.info("Data param: " + nn + "-mbps: " + mbps);
+
+ } catch (Exception e) {
+ log.warn("Invalid number for " + n + ": " + vv);
+ }
+ }
+ }
+ }
+ }
+ }
+ return data;
}
public void setResourceManager(ResourceManager resourceManager) {
this.resourceManager = resourceManager;
}
- public void setSpeedUtil(SpeedUtil speedUtil) {
- this.speedUtil = speedUtil;
- }
-
- public void setServiceResourceDao(ServiceResourceDao serviceResourceDao) {
- this.serviceResourceDao = serviceResourceDao;
- }
-
public void setEndPointAllocator(EndPointAllocator endPointAllocator) {
this.endPointAllocator = endPointAllocator;
}
- public void setParameterDao(ParameterDao parameterDao) {
- this.parameterDao = parameterDao;
+ public void setSpeedUtil(SpeedUtil speedUtil) {
+ this.speedUtil = speedUtil;
}
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/AffinityAllocationRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/AffinityAllocationRule.java
deleted file mode 100644
index 0da7acb7..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/AffinityAllocationRule.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.alloc;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationRule;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AffinityAllocationRule implements AllocationRule {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(AffinityAllocationRule.class);
-
- @Override
- public AllocationRequest buildAllocationRequest(
- String resourceUnionId,
- String resourceSetId,
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- String affinityLink = (String) equipmentData.data.get("affinity-link");
- if (affinityLink == null)
- affinityLink = "1";
-
- long serviceSpeed = (Long) serviceData.data.get("service-speed-kbps");
-
- LimitAllocationRequest ar = new LimitAllocationRequest();
- ar.resourceSetId = resourceSetId;
- ar.resourceUnionId = resourceUnionId;
- ar.resourceShareGroupList = null;
- ar.resourceName = "Bandwidth";
- ar.assetId = equipmentData.equipmentId + "-" + affinityLink;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.strict = false;
- ar.checkLimit = Long.MAX_VALUE;
- ar.checkCount = 0;
- ar.allocateCount = serviceSpeed;
- return ar;
- }
-}
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 a0b698d7..e9f6e0d3 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
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,10 +24,10 @@ package org.onap.ccsdk.sli.adaptors.ra.alloc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-
import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationRule;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceRequest;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceTarget;
import org.onap.ccsdk.sli.adaptors.ra.rule.dao.RangeRuleDao;
import org.onap.ccsdk.sli.adaptors.ra.rule.dao.ResourceRuleDao;
import org.onap.ccsdk.sli.adaptors.ra.rule.data.RangeRule;
@@ -44,112 +44,127 @@ import org.slf4j.LoggerFactory;
public class DbAllocationRule implements AllocationRule {
- private static final Logger log = LoggerFactory.getLogger(DbAllocationRule.class);
-
- private ResourceRuleDao resourceRuleDao;
- private RangeRuleDao rangeRuleDao;
-
- @Override
- public AllocationRequest buildAllocationRequest(
- String resourceUnionId,
- String resourceSetId,
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- List<ResourceRule> resourceRuleList = resourceRuleDao.getResourceRules(serviceData.serviceModel,
- endPointPosition, equipmentData.equipmentLevel);
- List<RangeRule> rangeRuleList =
- rangeRuleDao.getRangeRules(serviceData.serviceModel, endPointPosition, equipmentData.equipmentLevel);
-
- List<AllocationRequest> arlist = new ArrayList<AllocationRequest>();
-
- for (ResourceRule rr : resourceRuleList) {
- if (serviceData.resourceName != null && !serviceData.resourceName.equals(rr.resourceName))
- continue;
- AllocationRequest ar1 = buildAllocationRequest(rr, resourceUnionId, resourceSetId, serviceData,
- equipmentData, checkOnly, change);
- arlist.add(ar1);
- }
- for (RangeRule rr : rangeRuleList) {
- if (serviceData.resourceName != null && !serviceData.resourceName.equals(rr.rangeName))
- continue;
- AllocationRequest ar1 = buildAllocationRequest(rr, resourceUnionId, resourceSetId, serviceData,
- equipmentData, checkOnly, change);
- arlist.add(ar1);
- }
-
- if (arlist.isEmpty())
- return null;
-
- if (arlist.size() == 1)
- return arlist.get(0);
-
- MultiResourceAllocationRequest ar = new MultiResourceAllocationRequest();
- ar.stopOnFirstFailure = false;
- ar.allocationRequestList = arlist;
- return ar;
- }
-
- private AllocationRequest buildAllocationRequest(
- ResourceRule resourceRule,
- String resourceUnionId,
- String resourceSetId,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- StrUtil.info(log, resourceRule);
-
- LimitAllocationRequest ar = new LimitAllocationRequest();
- ar.resourceSetId = resourceSetId;
- ar.resourceUnionId = resourceUnionId;
- ar.resourceName = resourceRule.resourceName;
- if (serviceData.resourceShareGroup != null)
- ar.resourceShareGroupList = Collections.singleton(serviceData.resourceShareGroup);
- ar.assetId = equipmentData.equipmentId;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.strict = false;
- ar.checkLimit = ExpressionEvaluator.evalLong(
- change ? resourceRule.hardLimitExpression : resourceRule.softLimitExpression, equipmentData.data);;
- ar.checkCount = ExpressionEvaluator.evalLong(resourceRule.allocationExpression, serviceData.data);
- ar.allocateCount = checkOnly ? 0 : ar.checkCount;
- return ar;
- }
-
- private AllocationRequest buildAllocationRequest(
- RangeRule rangeRule,
- String resourceUnionId,
- String resourceSetId,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- StrUtil.info(log, rangeRule);
-
- RangeAllocationRequest ar = new RangeAllocationRequest();
- ar.resourceSetId = resourceSetId;
- ar.resourceUnionId = resourceUnionId;
- ar.resourceName = rangeRule.rangeName;
- ar.assetId = equipmentData.equipmentId;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.check = true;
- ar.allocate = !checkOnly;
- ar.checkMin = rangeRule.minValue;
- ar.checkMax = rangeRule.maxValue;
- return ar;
- }
-
- public void setResourceRuleDao(ResourceRuleDao resourceRuleDao) {
- this.resourceRuleDao = resourceRuleDao;
- }
-
- public void setRangeRuleDao(RangeRuleDao rangeRuleDao) {
- this.rangeRuleDao = rangeRuleDao;
- }
+ private static final Logger log = LoggerFactory.getLogger(DbAllocationRule.class);
+
+ private ResourceRuleDao resourceRuleDao;
+ private RangeRuleDao rangeRuleDao;
+
+ @Override
+ public AllocationRequest buildAllocationRequest(String serviceModel, ResourceEntity resourceEntity,
+ ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change) {
+ List<ResourceRule> resourceRuleList = resourceRuleDao.getResourceRules(serviceModel,
+ resourceTarget.resourceTargetType);
+ List<RangeRule> rangeRuleList = rangeRuleDao.getRangeRules(serviceModel, resourceTarget.resourceTargetType);
+
+ List<AllocationRequest> arlist = new ArrayList<>();
+
+ for (ResourceRule rr : resourceRuleList) {
+ if (resourceRequest.resourceName != null && !resourceRequest.resourceName.equals(rr.resourceName)) {
+ continue;
+ }
+
+ boolean matches = ExpressionEvaluator.evalBoolean(rr.serviceExpression, resourceEntity.data);
+ matches = matches && ExpressionEvaluator.evalBoolean(rr.equipmentExpression, resourceTarget.data);
+
+ if (matches) {
+ AllocationRequest ar1 = buildAllocationRequest(rr, resourceEntity, resourceTarget, resourceRequest,
+ checkOnly, change);
+ arlist.add(ar1);
+ }
+ }
+
+ for (RangeRule rr : rangeRuleList) {
+ if (resourceRequest.resourceName != null && !resourceRequest.resourceName.equals(rr.rangeName)) {
+ continue;
+ }
+ if (resourceRequest.endPointPosition != null
+ && !resourceRequest.endPointPosition.equals(rr.endPointPosition)) {
+ continue;
+ }
+
+ AllocationRequest ar1 = buildAllocationRequest(rr, resourceEntity, resourceTarget, resourceRequest,
+ checkOnly, change);
+ arlist.add(ar1);
+ }
+
+ if (arlist.isEmpty()) {
+ return null;
+ }
+
+ if (arlist.size() == 1) {
+ return arlist.get(0);
+ }
+
+ MultiResourceAllocationRequest ar = new MultiResourceAllocationRequest();
+ ar.stopOnFirstFailure = false;
+ ar.allocationRequestList = arlist;
+ return ar;
+ }
+
+ private AllocationRequest buildAllocationRequest(ResourceRule resourceRule, ResourceEntity resourceEntity,
+ ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change) {
+ StrUtil.info(log, resourceRule);
+
+ LimitAllocationRequest ar = new LimitAllocationRequest();
+ ar.applicationId = resourceRequest.applicationId;
+ ar.resourceUnionId = resourceEntity.resourceEntityType + "::" + resourceEntity.resourceEntityId;
+ ar.resourceSetId = ar.resourceUnionId + "::" + resourceEntity.resourceEntityVersion;
+ ar.resourceName = resourceRule.resourceName;
+ if (resourceRequest.resourceShareGroup != null) {
+ ar.resourceShareGroupList = Collections.singleton(resourceRequest.resourceShareGroup);
+ }
+ ar.assetId = resourceTarget.resourceTargetType + "::" + resourceTarget.resourceTargetId;
+ ar.missingResourceAction = AllocationAction.Succeed_Allocate;
+ ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
+ ar.replace = resourceRequest.replace;
+ ar.strict = false;
+ ar.checkLimit = ExpressionEvaluator.evalLong(
+ change ? resourceRule.hardLimitExpression : resourceRule.softLimitExpression, resourceTarget.data);
+ ar.checkCount = ExpressionEvaluator.evalLong(resourceRule.allocationExpression, resourceEntity.data);
+ ar.allocateCount = checkOnly ? 0 : ar.checkCount;
+ return ar;
+ }
+
+ private AllocationRequest buildAllocationRequest(RangeRule rangeRule, ResourceEntity resourceEntity,
+ ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change) {
+ StrUtil.info(log, rangeRule);
+
+ 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 = rangeRule.rangeName;
+ 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.checkMin = resourceRequest.rangeMinOverride >= 0 ? resourceRequest.rangeMinOverride : rangeRule.minValue;
+ ar.checkMax = resourceRequest.rangeMaxOverride >= 0 ? resourceRequest.rangeMaxOverride : rangeRule.maxValue;
+ return ar;
+ }
+
+ public void setResourceRuleDao(ResourceRuleDao resourceRuleDao) {
+ this.resourceRuleDao = resourceRuleDao;
+ }
+
+ public void setRangeRuleDao(RangeRuleDao rangeRuleDao) {
+ this.rangeRuleDao = rangeRuleDao;
+ }
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/ServingSiteAllocationRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/ServingSiteAllocationRule.java
deleted file mode 100644
index b1c4ac44..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/ServingSiteAllocationRule.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.alloc;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationRule;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
-import org.onap.ccsdk.sli.adaptors.util.vrf.VpnParam;
-import org.onap.ccsdk.sli.adaptors.util.vrf.VrfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ServingSiteAllocationRule implements AllocationRule {
-
- private static final Logger log = LoggerFactory.getLogger(ServingSiteAllocationRule.class);
-
- @Override
- public AllocationRequest buildAllocationRequest(
- String resourceUnionId,
- String resourceSetId,
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- String vrfName = (String) serviceData.data.get("vrf-name");
- if (vrfName == null)
- return null;
-
- log.info("vrfName: " + vrfName);
-
- String v4ServingSiteStr = (String) serviceData.data.get("v4-serving-site");
- String v6ServingSiteStr = (String) serviceData.data.get("v6-serving-site");
- boolean v4ServingSite = v4ServingSiteStr != null &&
- (v4ServingSiteStr.equalsIgnoreCase("Y") || v4ServingSiteStr.equalsIgnoreCase("true"));
- boolean v6ServingSite = v6ServingSiteStr != null &&
- (v6ServingSiteStr.equalsIgnoreCase("Y") || v6ServingSiteStr.equalsIgnoreCase("true"));
- if (!v4ServingSite && !v6ServingSite)
- return null;
-
- VpnParam vpnp = VrfUtil.parseVrfInstanceName(vrfName);
-
- LimitAllocationRequest ar = new LimitAllocationRequest();
- ar.resourceSetId = resourceSetId;
- ar.resourceUnionId = resourceUnionId;
- ar.resourceName = "ServingSite";
- ar.assetId = equipmentData.equipmentId + "-" + vpnp.vpnId;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.strict = false;
- ar.checkLimit = 1;
- ar.checkCount = 1;
- ar.allocateCount = 1;
-
- return ar;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/VrfAllocationRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/VrfAllocationRule.java
deleted file mode 100644
index 74bfe663..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/alloc/VrfAllocationRule.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.alloc;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationRule;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.MultiResourceAllocationRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VrfAllocationRule implements AllocationRule {
-
- private static final Logger log = LoggerFactory.getLogger(VrfAllocationRule.class);
-
- @Override
- public AllocationRequest buildAllocationRequest(
- String resourceUnionId,
- String resourceSetId,
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- String vrfName = (String) serviceData.data.get("vrf-name");
- if (vrfName == null)
- return null;
-
- log.info("vrfName: " + vrfName);
-
- Set<String> resourceShareGroupList = new HashSet<>();
- resourceShareGroupList.add(vrfName);
-
- LimitAllocationRequest ar = new LimitAllocationRequest();
- ar.resourceSetId = resourceSetId;
- ar.resourceUnionId = resourceUnionId;
- ar.resourceShareGroupList = resourceShareGroupList;
- ar.resourceName = "VRF";
- ar.assetId = equipmentData.equipmentId;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.strict = false;
- ar.checkLimit = 999999999;
- ar.checkCount = 1;
- ar.allocateCount = 1;
-
- String v4MulticastStr = (String) serviceData.data.get("v4-multicast");
- String v6MulticastStr = (String) serviceData.data.get("v6-multicast");
- boolean v4Multicast = v4MulticastStr != null &&
- (v4MulticastStr.equalsIgnoreCase("Y") || v4MulticastStr.equalsIgnoreCase("true"));
- boolean v6Multicast = v6MulticastStr != null &&
- (v6MulticastStr.equalsIgnoreCase("Y") || v6MulticastStr.equalsIgnoreCase("true"));
- if (v4Multicast || v6Multicast) {
- LimitAllocationRequest ar2 = new LimitAllocationRequest();
- ar2.resourceSetId = resourceSetId;
- ar2.resourceUnionId = resourceUnionId;
- ar2.resourceShareGroupList = resourceShareGroupList;
- ar2.resourceName = "MVRF";
- ar2.assetId = equipmentData.equipmentId;
- ar2.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar2.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar2.replace = true;
- ar2.strict = false;
- ar2.checkLimit = 999999999;
- ar2.checkCount = 1;
- ar2.allocateCount = 1;
-
- MultiResourceAllocationRequest mar = new MultiResourceAllocationRequest();
- mar.resourceSetId = resourceSetId;
- mar.resourceUnionId = resourceUnionId;
- mar.resourceShareGroupList = resourceShareGroupList;
- mar.assetId = equipmentData.equipmentId;
- mar.missingResourceAction = AllocationAction.Succeed_Allocate;
- mar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- mar.allocationRequestList = new ArrayList<>();
- mar.allocationRequestList.add(ar);
- mar.allocationRequestList.add(ar2);
-
- return mar;
- }
-
- return ar;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/AnyVrfPresentCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/AnyVrfPresentCheck.java
deleted file mode 100644
index 6f4de269..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/AnyVrfPresentCheck.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AnyVrfPresentCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(AnyVrfPresentCheck.class);
-
- private ResourceManager resourceManager;
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String vrfNameListStr = (String) serviceData.data.get("vrf-name-list");
- if (vrfNameListStr == null)
- vrfNameListStr = (String) serviceData.data.get("vrf-name");
- if (vrfNameListStr == null)
- return true;
-
- String vrfRequiredStr = (String) equipmentConstraints.get("vrf-required");
- if (vrfRequiredStr == null || !vrfRequiredStr.equalsIgnoreCase("true"))
- return true;
-
- String[] vrfNameList = vrfNameListStr.split(",");
-
- Resource r = resourceManager.getResource("VRF", equipData.equipmentId);
- if (r != null && r.allocationItems != null)
- for (AllocationItem ai : r.allocationItems)
- for (String vrfName : vrfNameList)
- if (ai.resourceShareGroupList.contains(vrfName))
- return true;
-
- log.info("Skipping VPE " + equipData.equipmentId +
- ": Existing VRF is required, but there is no existing VRF on the VPE for any of the requested VPNs.");
- return false;
- }
-
- public void setResourceManager(ResourceManager resourceManager) {
- this.resourceManager = resourceManager;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ExcludeVpeCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ExcludeVpeCheck.java
deleted file mode 100644
index 020c165a..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ExcludeVpeCheck.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ExcludeVpeCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(ExcludeVpeCheck.class);
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String excludeVpeListStr = (String) equipmentConstraints.get("exclude-vpe-list");
- if (excludeVpeListStr == null)
- return true;
-
- String vpeName = (String) equipData.data.get("vpe-id");
-
- String[] excludeVpeList = excludeVpeListStr.split(",");
- for (String excludeVpe : excludeVpeList)
- if (excludeVpe.equals(vpeName)) {
- log.info("Skipping VPE " + equipData.equipmentId + ": Present in the exclude VPE list.");
- return false;
- }
-
- return true;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/HubWithRgCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/HubWithRgCheck.java
deleted file mode 100644
index 22fdeca3..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/HubWithRgCheck.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
-import org.onap.ccsdk.sli.adaptors.util.vrf.VpnParam;
-import org.onap.ccsdk.sli.adaptors.util.vrf.VrfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HubWithRgCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(HubWithRgCheck.class);
-
- private ResourceManager resourceManager;
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String vrfName = (String) serviceData.data.get("vrf-name");
- if (vrfName == null)
- return true;
-
- // Check if this is HUB. If not, this check is not applicable
- VpnParam vpnp = VrfUtil.parseVrfInstanceName(vrfName);
- if (vpnp.siteType == null || !vpnp.siteType.equals("HUB"))
- return true;
-
- boolean rgPresent = vpnp.routeGroupName != null;
-
- // First check if a new VRF would be required. If not, we are good
- Resource r = resourceManager.getResource("VRF", equipData.equipmentId);
- if (r != null && r.allocationItems != null) {
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceShareGroupList.contains(vrfName))
- return true;
-
- String resourceUnionId = serviceData.serviceInstanceId + '/' + serviceData.endPointPosition;
-
- // Check if there is already another HUB VRF with RG presence that does not match the requested
- for (AllocationItem ai : r.allocationItems) {
-
- // Skip the allocation item for the current service instance, if there, in case it is a change order
- if (ai.resourceUnionId.equals(resourceUnionId))
- continue;
-
- if (ai.resourceShareGroupList != null && ai.resourceShareGroupList.size() > 0) {
- String vrfName2 = ai.resourceShareGroupList.iterator().next();
- VpnParam vpnp2 = VrfUtil.parseVrfInstanceName(vrfName2);
-
- if (vpnp2.siteType == null || !vpnp2.siteType.equals("HUB"))
- continue;
-
- boolean rgPresent2 = vpnp2.routeGroupName != null;
-
- if (rgPresent && !rgPresent2) {
- log.info("Skipping VPE " + equipData.equipmentId +
- ": This request requires new HUB with RG VRF, " +
- "but there is already another HUB VRF with no RG: " + vrfName2 + ".");
- return false;
- }
- if (!rgPresent && rgPresent2) {
- log.info("Skipping VPE " + equipData.equipmentId +
- ": This request requires new HUB VRF with no RG, " +
- "but there is already another HUB with RG VRF: " + vrfName2 + ".");
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- public void setResourceManager(ResourceManager resourceManager) {
- this.resourceManager = resourceManager;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/OneMVrfCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/OneMVrfCheck.java
deleted file mode 100644
index e54d89cb..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/OneMVrfCheck.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
-import org.onap.ccsdk.sli.adaptors.util.vrf.VpnParam;
-import org.onap.ccsdk.sli.adaptors.util.vrf.VrfUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class OneMVrfCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(OneMVrfCheck.class);
-
- private ResourceManager resourceManager;
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String vrfName = (String) serviceData.data.get("vrf-name");
- if (vrfName == null)
- return true;
-
- String v4MulticastStr = (String) serviceData.data.get("v4-multicast");
- String v6MulticastStr = (String) serviceData.data.get("v6-multicast");
- boolean v4Multicast = v4MulticastStr != null &&
- (v4MulticastStr.equalsIgnoreCase("Y") || v4MulticastStr.equalsIgnoreCase("true"));
- boolean v6Multicast = v6MulticastStr != null &&
- (v6MulticastStr.equalsIgnoreCase("Y") || v6MulticastStr.equalsIgnoreCase("true"));
- if (!v4Multicast && !v6Multicast)
- return true;
-
- // First check if a new VRF would be required. If not, we are good
- Resource r = resourceManager.getResource("VRF", equipData.equipmentId);
- if (r != null && r.allocationItems != null)
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceShareGroupList.contains(vrfName))
- return true;
-
- String resourceUnionId = serviceData.serviceInstanceId + '/' + serviceData.endPointPosition;
-
- // Check if there is already another multicast VRF for the same VPN
- VpnParam vpnp = VrfUtil.parseVrfInstanceName(vrfName);
- r = resourceManager.getResource("MVRF", equipData.equipmentId);
- if (r != null && r.allocationItems != null) {
- for (AllocationItem ai : r.allocationItems) {
-
- // Skip the allocation item for the current service instance, if there, in case it is a change order
- if (ai.resourceUnionId.equals(resourceUnionId))
- continue;
-
- if (ai.resourceShareGroupList != null && ai.resourceShareGroupList.size() > 0) {
- String vrfName2 = ai.resourceShareGroupList.iterator().next();
- VpnParam vpnp2 = VrfUtil.parseVrfInstanceName(vrfName2);
- if (vpnp.vpnId.equals(vpnp2.vpnId)) {
- log.info("Skipping VPE " + equipData.equipmentId +
- ": This request requires new multicast VRF, " +
- "but there is already another multicast VRF for the same VPN: " + vrfName2 + ".");
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- public void setResourceManager(ResourceManager resourceManager) {
- this.resourceManager = resourceManager;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ProvStatusCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ProvStatusCheck.java
deleted file mode 100644
index f851b53b..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/ProvStatusCheck.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ProvStatusCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(ProvStatusCheck.class);
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String provStatus = (String) equipData.data.get("provisioning-status");
- if (provStatus == null || !provStatus.equals("PROV")) {
- log.info("Skipping VPE " + equipData.equipmentId + ": Not in PROV status.");
- return false;
- }
- return true;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VlanSpeedCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VlanSpeedCheck.java
deleted file mode 100644
index 28e6278d..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VlanSpeedCheck.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VlanSpeedCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(VlanSpeedCheck.class);
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String vpeName = (String) equipData.data.get("vpe-id");
- Long serviceSpeed = (Long) serviceData.data.get("service-speed-kbps");
- if (serviceSpeed != null && serviceSpeed > 0 && serviceSpeed < 1000) {
- log.info("Skipping VPE " + vpeName + ": Service speed < 1Mbps is not supported.");
- return false;
- }
- return true;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VpeLockCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VpeLockCheck.java
deleted file mode 100644
index 503e1ffc..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/check/VpeLockCheck.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.check;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.EquipmentCheck;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.rule.dao.VpeLockDao;
-import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class VpeLockCheck implements EquipmentCheck {
-
- private static final Logger log = LoggerFactory.getLogger(VpeLockCheck.class);
-
- private VpeLockDao vpeLockDao;
- private ResourceManager resourceManager;
-
- @Override
- public boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints) {
- String vrfName = (String) serviceData.data.get("vrf-name");
- if (vrfName == null)
- return true;
-
- String vpeName = (String) equipData.data.get("vpe-id");
- String vpeLock = vpeLockDao.getVpeLock(vpeName);
- if (vpeLock == null)
- return true;
-
- if (vpeLock.equals("vpe-total-lock")) {
- log.info("Skipping VPE " + vpeName + ": There is a " + vpeLock + " on it.");
- return false;
- }
-
- if (vpeLock.equals("vpe-vrf-lock") && requiresNewVrf(equipData.equipmentId, vrfName)) {
- log.info("Skipping VPE " + vpeName + ": There is a " + vpeLock +
- " on it and it requires a new VRF for VPN: " + vrfName + ".");
- return false;
- }
-
- if (vpeLock.equals("vpe-mvrf-lock") && requiresNewMVrf(equipData.equipmentId, vrfName)) {
- log.info("Skipping VPE " + vpeName + ": There is a " + vpeLock +
- " on it and it requires a new multicast VRF for VPN: " + vrfName + ".");
- return false;
- }
-
- return true;
- }
-
- boolean requiresNewVrf(String equipmentId, String vrfName) {
- Resource r = resourceManager.getResource("VRF", equipmentId);
- if (r == null || r.allocationItems == null)
- return true;
-
- for (AllocationItem ai : r.allocationItems) {
- if (ai.resourceShareGroupList.contains(vrfName))
- return false;
- }
-
- return true;
- }
-
- boolean requiresNewMVrf(String equipmentId, String vrfName) {
- Resource r = resourceManager.getResource("MVRF", equipmentId);
- if (r == null || r.allocationItems == null)
- return true;
-
- for (AllocationItem ai : r.allocationItems) {
- if (ai.resourceShareGroupList.contains(vrfName))
- return false;
- }
-
- return true;
- }
-
- public void setVpeLockDao(VpeLockDao vpeLockDao) {
- this.vpeLockDao = vpeLockDao;
- }
-
- public void setResourceManager(ResourceManager resourceManager) {
- this.resourceManager = resourceManager;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationRule.java
index 831cac0c..0e973741 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationRule.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationRule.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,17 +21,10 @@
package org.onap.ccsdk.sli.adaptors.ra.comp;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
public interface AllocationRule {
- AllocationRequest buildAllocationRequest(
- String resourceUnionId,
- String resourceSetId,
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change);
+ AllocationRequest buildAllocationRequest(String serviceModel, ResourceEntity resourceEntity,
+ ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change);
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocationDefinition.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocationDefinition.java
deleted file mode 100644
index 589fafcd..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocationDefinition.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.comp;
-
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.comp.EquipmentReader;
-
-public class EndPointAllocationDefinition {
-
- public String serviceModel;
- public String endPointPosition;
- public EquipmentReader equipmentReader;
- public List<EquipmentCheck> equipmentCheckList;
- public List<PreferenceRule> preferenceRuleList;
- public List<AllocationRule> allocationRuleList;
-
- public void setServiceModel(String serviceModel) {
- this.serviceModel = serviceModel;
- }
-
- public void setEndPointPosition(String endPointPosition) {
- this.endPointPosition = endPointPosition;
- }
-
- public void setEquipmentReader(EquipmentReader equipmentReader) {
- this.equipmentReader = equipmentReader;
- }
-
- public void setEquipmentCheckList(List<EquipmentCheck> equipmentCheckList) {
- this.equipmentCheckList = equipmentCheckList;
- }
-
- public void setPreferenceRuleList(List<PreferenceRule> preferenceRuleList) {
- this.preferenceRuleList = preferenceRuleList;
- }
-
- public void setAllocationRuleList(List<AllocationRule> allocationRuleList) {
- this.allocationRuleList = allocationRuleList;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocator.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocator.java
index 08713cd7..c6461d49 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocator.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocator.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,14 +22,14 @@
package org.onap.ccsdk.sli.adaptors.ra.comp;
import java.util.List;
-import java.util.Map;
public interface EndPointAllocator {
- List<EndPointData> allocateEndPoints(
- ServiceData serviceData,
- Map<String, Object> equipmentConstraints,
- boolean checkOnly,
- boolean change,
- int changeNumber);
+ List<ResourceData> allocateResources(String serviceModel, ResourceEntity resourceEntity,
+ ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change);
+
+ List<ResourceData> getResourcesForEntity(String resourceEntityType, String resourceEntityId,
+ String resourceEntityVersion);
+
+ ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName);
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocatorImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocatorImpl.java
index db30bf62..e904035b 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocatorImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointAllocatorImpl.java
@@ -3,7 +3,7 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,226 +22,237 @@
package org.onap.ccsdk.sli.adaptors.ra.comp;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collections;
+import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
-import org.apache.commons.lang.NotImplementedException;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationOutcome;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationStatus;
import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationItem;
+import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationOutcome;
import org.onap.ccsdk.sli.adaptors.rm.data.LimitResource;
+import org.onap.ccsdk.sli.adaptors.rm.data.MultiResourceAllocationOutcome;
import org.onap.ccsdk.sli.adaptors.rm.data.RangeAllocationItem;
+import org.onap.ccsdk.sli.adaptors.rm.data.RangeAllocationOutcome;
import org.onap.ccsdk.sli.adaptors.rm.data.RangeResource;
import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
+import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class EndPointAllocatorImpl implements EndPointAllocator {
+ @SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(EndPointAllocatorImpl.class);
- private Map<String, List<EndPointAllocationDefinition>> endPointAllocationDefinitionMap;
-
private ResourceManager resourceManager;
- @Override
- public List<EndPointData> allocateEndPoints(
- ServiceData serviceData,
- Map<String, Object> equipmentConstraints,
- boolean checkOnly,
- boolean change,
- int changeNumber) {
- List<EndPointAllocationDefinition> defList = endPointAllocationDefinitionMap.get(serviceData.serviceModel);
- if (defList == null)
- throw new NotImplementedException("Service model: " + serviceData.serviceModel + " not supported");
-
- List<EndPointData> epList = new ArrayList<>();
- for (EndPointAllocationDefinition def : defList) {
- if (serviceData.endPointPosition != null && !serviceData.endPointPosition.equals(def.endPointPosition))
- continue;
-
- log.info(
- "Starting allocation of end point: " + def.endPointPosition + ": " + serviceData.serviceInstanceId);
-
- String resourceUnionId = serviceData.serviceInstanceId + '/' + def.endPointPosition;
- String resourceSetId = resourceUnionId + '/' + changeNumber;
-
- String equipmentId = (String) equipmentConstraints.get("equipment-id");
- if (equipmentId == null) {
- EndPointData epExisting = readEndPoint(resourceUnionId, resourceSetId);
- if (epExisting != null && epExisting.equipmentId != null) {
- equipmentConstraints.put("equipment-id", epExisting.equipmentId);
-
- log.info("Trying assignment on the current equipment: " + epExisting.equipmentId);
- }
- }
-
- List<EquipmentData> equipList = def.equipmentReader.readEquipment(equipmentConstraints);
- if (equipList == null || equipList.isEmpty()) {
- log.info("Equipment not found for " + def.endPointPosition);
- break;
- }
+ private Map<String, List<AllocationRule>> allocationRuleMap;
- if (def.equipmentCheckList != null) {
- for (EquipmentCheck filter : def.equipmentCheckList) {
- List<EquipmentData> newEquipList = new ArrayList<>();
- for (EquipmentData equipData : equipList)
- if (filter.checkEquipment(def.endPointPosition, serviceData, equipData, equipmentConstraints))
- newEquipList.add(equipData);
- equipList = newEquipList;
- }
- if (equipList.isEmpty()) {
- log.info("No equipment meets the requiremets for the service for: " + def.endPointPosition);
- break;
- }
- }
-
- if (equipList.size() > 1 && def.preferenceRuleList != null && !def.preferenceRuleList.isEmpty()) {
-
- List<PrefEquipment> prefEquipList = new ArrayList<>();
- for (EquipmentData equipData : equipList) {
- PrefEquipment prefEquip = new PrefEquipment();
- prefEquip.equipData = equipData;
- prefEquip.prefNumbers = new long[def.preferenceRuleList.size()];
- prefEquipList.add(prefEquip);
-
- int i = 0;
- for (PreferenceRule prefRule : def.preferenceRuleList)
- prefEquip.prefNumbers[i++] =
- prefRule.assignOrderNumber(def.endPointPosition, serviceData, equipData);
- }
+ @Override
+ public List<ResourceData> allocateResources(String serviceModel, ResourceEntity resourceEntity,
+ ResourceTarget resourceTarget, ResourceRequest resourceRequest, boolean checkOnly, boolean change) {
- Collections.sort(prefEquipList);
+ List<ResourceData> resourceList = new ArrayList<>();
- equipList = new ArrayList<>();
- for (PrefEquipment prefEquip : prefEquipList)
- equipList.add(prefEquip.equipData);
+ if (allocationRuleMap != null) {
+ List<AllocationRule> allocationRuleList = allocationRuleMap.get(serviceModel);
+ if (allocationRuleList == null) {
+ allocationRuleList = allocationRuleMap.get("DEFAULT");
}
- for (EquipmentData equipData : equipList) {
+ if (allocationRuleList != null) {
boolean allgood = true;
- if (def.allocationRuleList != null)
- for (AllocationRule allocationRule : def.allocationRuleList) {
- AllocationRequest ar = allocationRule.buildAllocationRequest(resourceUnionId, resourceSetId,
- def.endPointPosition, serviceData, equipData, checkOnly, change);
- if (ar != null) {
- AllocationOutcome ao = resourceManager.allocateResources(ar);
- if (ao.status != AllocationStatus.Success) {
- allgood = false;
- break;
- }
+ for (AllocationRule allocationRule : allocationRuleList) {
+ AllocationRequest ar = allocationRule.buildAllocationRequest(serviceModel, resourceEntity,
+ resourceTarget, resourceRequest, checkOnly, change);
+ if (ar != null) {
+ AllocationOutcome ao = resourceManager.allocateResources(ar);
+ List<ResourceData> rr = getResourceData(ao);
+ resourceList.addAll(rr);
+
+ if (ao.status != AllocationStatus.Success) {
+ allgood = false;
}
}
- if (allgood) {
- EndPointData ep = readEndPoint(resourceUnionId, resourceSetId);
- epList.add(ep);
- break;
+ }
+
+ if (!allgood) {
+ String resourceSetId = resourceEntity.resourceEntityType + "::" + resourceEntity.resourceEntityId
+ + "::" + resourceEntity.resourceEntityVersion;
+ resourceManager.releaseResourceSet(resourceSetId);
}
}
}
- return epList;
+ return resourceList;
}
- private EndPointData readEndPoint(String resourceUnionId, String resourceSetId) {
- EndPointData ep = new EndPointData();
- ep.resourceUnionId = resourceUnionId;
- ep.resourceSetId = resourceSetId;
+ private List<ResourceData> getResourceData(AllocationOutcome ao) {
+ if (ao instanceof MultiResourceAllocationOutcome) {
+ List<ResourceData> rr = new ArrayList<>();
+ for (AllocationOutcome ao1 : ((MultiResourceAllocationOutcome) ao).allocationOutcomeList) {
+ rr.addAll(getResourceData(ao1));
+ }
+ return rr;
+ }
+
+ ResourceData rd = new ResourceData();
+ rd.data = new HashMap<>();
+
+ AllocationRequest ar = ao.request;
+ rd.resourceName = ar.resourceName;
+ rd.endPointPosition = ar.endPointPosition;
+ int i1 = ar.assetId.indexOf("::");
+ if (i1 > 0) {
+ rd.resourceTargetType = ar.assetId.substring(0, i1);
+ rd.resourceTargetId = ar.assetId.substring(i1 + 2);
+ } else {
+ rd.resourceTargetType = "";
+ rd.resourceTargetId = ar.assetId;
+ }
+ rd.status = ao.status.toString();
+
+ if (ao instanceof LimitAllocationOutcome) {
+ LimitAllocationOutcome lao = (LimitAllocationOutcome) ao;
+ rd.data.put("allocated", String.valueOf(lao.allocatedCount));
+ rd.data.put("used", String.valueOf(lao.used));
+ rd.data.put("limit", String.valueOf(lao.limit));
+ rd.data.put("available", String.valueOf(lao.limit - lao.used));
+ } else if (ao instanceof RangeAllocationOutcome) {
+ RangeAllocationOutcome rao = (RangeAllocationOutcome) ao;
+ rd.data.put("allocated", String.valueOf(StrUtil.listInt(rao.allocated)));
+ rd.data.put("used", String.valueOf(StrUtil.listInt(rao.used)));
+ }
- int i1 = resourceUnionId.indexOf('/');
- if (i1 > 0)
- ep.endPointPosition = resourceUnionId.substring(i1 + 1);
+ return Collections.singletonList(rd);
+ }
- ep.data = new HashMap<>();
+ @Override
+ public List<ResourceData> getResourcesForEntity(String resourceEntityType, String resourceEntityId,
+ String resourceEntityVersion) {
+ List<ResourceData> rdlist = new ArrayList<>();
+ String resourceUnionId = resourceEntityType + "::" + resourceEntityId;
List<Resource> rlist = resourceManager.getResourceUnion(resourceUnionId);
+
for (Resource r : rlist) {
- if (r instanceof RangeResource) {
- RangeResource rr = (RangeResource) r;
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceUnionId.equals(resourceUnionId)) {
- RangeAllocationItem rai = (RangeAllocationItem) ai;
- ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName, rai.used.first());
+
+ // Find the needed allocation item: if resourceEntityVersion is specified, use that,
+ // otherwise, find the latest allocation item
+ AllocationItem ai = null;
+ if (resourceEntityVersion != null) {
+ String resourceSetId = resourceUnionId + "::" + resourceEntityVersion;
+ for (AllocationItem ai1 : r.allocationItems) {
+ if (ai1.resourceSetId.equals(resourceSetId)) {
+ ai = ai1;
+ break;
}
- }
- if (r instanceof LimitResource) {
- LimitResource rr = (LimitResource) r;
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceUnionId.equals(resourceUnionId)) {
- LimitAllocationItem rai = (LimitAllocationItem) ai;
- ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".allocated", rai.used);
- ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".used", rr.used);
- ep.data.put(ep.endPointPosition + '.' + rr.resourceKey.resourceName + ".assetId",
- r.resourceKey.assetId);
+ }
+ } else {
+ Date aitime = null;
+ for (AllocationItem ai1 : r.allocationItems) {
+ if (ai1.resourceUnionId.equals(resourceUnionId)) {
+ if (aitime == null || ai1.allocationTime.after(aitime)) {
+ ai = ai1;
+ aitime = ai1.allocationTime;
+ }
}
+ }
}
- }
- return ep;
- }
+ if (ai != null) {
+ ResourceData rd = new ResourceData();
+ rdlist.add(rd);
+
+ rd.resourceName = r.resourceKey.resourceName;
+ int i1 = r.resourceKey.assetId.indexOf("::");
+ if (i1 > 0) {
+ rd.resourceTargetType = r.resourceKey.assetId.substring(0, i1);
+ rd.resourceTargetId = r.resourceKey.assetId.substring(i1 + 2);
+
+ int i2 = r.resourceKey.assetId.lastIndexOf("::");
+ if (i2 > i1) {
+ rd.resourceTargetValue = r.resourceKey.assetId.substring(i2 + 2);
+ }
+ } else {
+ rd.resourceTargetType = "";
+ rd.resourceTargetId = r.resourceKey.assetId;
+ }
+
+ rd.data = new HashMap<>();
+
+ if (ai instanceof RangeAllocationItem) {
+ RangeAllocationItem rai = (RangeAllocationItem) ai;
- private static class PrefEquipment implements Comparable<PrefEquipment> {
+ String ss = String.valueOf(rai.used);
+ ss = ss.substring(1, ss.length() - 1);
+ rd.data.put("allocated", ss);
- public long[] prefNumbers;
- public EquipmentData equipData;
+ } else if (ai instanceof LimitAllocationItem) {
+ LimitAllocationItem lai = (LimitAllocationItem) ai;
- @Override
- public int compareTo(PrefEquipment o) {
- for (int i = 0; i < prefNumbers.length; i++) {
- if (prefNumbers[i] < o.prefNumbers[i])
- return -1;
- if (prefNumbers[i] > o.prefNumbers[i])
- return 1;
+ rd.data.put("allocated", String.valueOf(lai.used));
+ }
}
- return 0;
}
- @Override
- public boolean equals(Object object) {
- if (this == object) {
- return true;
- }
- if (!(object instanceof PrefEquipment)) {
- return false;
- }
- if (!super.equals(object)) {
- return false;
- }
+ return rdlist;
+ }
- PrefEquipment that = (PrefEquipment) object;
- if (equipData != null ? !equipData.equals(that.equipData) : that.equipData != null) {
- return false;
+ @Override
+ public ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName) {
+ ResourceData rd = new ResourceData();;
+ String assetId = resourceTargetType + "::" + resourceTargetId;
+ Resource r = resourceManager.getResource(resourceName, assetId);
+ if (r != null) {
+ log.info("ResourceName:" + r.resourceKey.resourceName + " assetId:" + r.resourceKey.assetId);
+
+ rd.resourceName = r.resourceKey.resourceName;
+ int i1 = r.resourceKey.assetId.indexOf("::");
+ if (i1 > 0) {
+ rd.resourceTargetType = r.resourceKey.assetId.substring(0, i1);
+ rd.resourceTargetId = r.resourceKey.assetId.substring(i1 + 2);
+
+ int i2 = r.resourceKey.assetId.lastIndexOf("::");
+ if (i2 > i1) {
+ rd.resourceTargetValue = r.resourceKey.assetId.substring(i2 + 2);
+ }
+ } else {
+ rd.resourceTargetType = "";
+ rd.resourceTargetId = r.resourceKey.assetId;
}
- if (!Arrays.equals(prefNumbers, that.prefNumbers)) {
- return false;
- }
+ rd.data = new HashMap<>();
- return true;
- }
+ if (r instanceof RangeResource) {
+ RangeResource rr = (RangeResource) r;
+
+ log.info("rr.used: " + rr.used);
+ String ss = String.valueOf(rr.used);
+ ss = ss.substring(1, ss.length() - 1);
+ rd.data.put("allocated", ss);
- @Override
- public int hashCode() {
- int result = super.hashCode();
- result = 31 * result + (equipData != null ? equipData.hashCode() : 0);
- result = 31 * result + Arrays.hashCode(prefNumbers);
- return result;
+ } else if (r instanceof LimitResource) {
+ LimitResource lr = (LimitResource) r;
+
+ log.info("lr.used: " + lr.used);
+ rd.data.put("allocated", String.valueOf(lr.used));
+ }
}
- }
- public void setEndPointAllocationDefinitionMap(
- Map<String, List<EndPointAllocationDefinition>> endPointAllocationDefinitionMap) {
- this.endPointAllocationDefinitionMap = endPointAllocationDefinitionMap;
+ return rd;
}
public void setResourceManager(ResourceManager resourceManager) {
this.resourceManager = resourceManager;
}
+
+ public void setAllocationRuleMap(Map<String, List<AllocationRule>> allocationRuleMap) {
+ this.allocationRuleMap = allocationRuleMap;
+ }
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EquipmentCheck.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EquipmentCheck.java
deleted file mode 100644
index 70f2abde..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EquipmentCheck.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.comp;
-
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-
-public interface EquipmentCheck {
-
- boolean checkEquipment(
- String endPointPosition,
- ServiceData serviceData,
- EquipmentData equipData,
- Map<String, Object> equipmentConstraints);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ServiceData.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java
index 238ea1d1..a5881b95 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ServiceData.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,14 +23,13 @@ package org.onap.ccsdk.sli.adaptors.ra.comp;
import java.util.Map;
-public class ServiceData {
+public class ResourceData {
- public String serviceModel;
- public String serviceInstanceId;
- public String resourceSetId;
- public String resourceUnionId;
- public String resourceShareGroup;
- public String endPointPosition;
public String resourceName;
- public Map<String, Object> data;
+ public String resourceTargetId;
+ public String resourceTargetValue;
+ public String resourceTargetType;
+ public String status;
+ public Map<String, String> data;
+ public String endPointPosition;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointData.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceEntity.java
index dc1cb0a6..12fb695b 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/EndPointData.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceEntity.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,11 +23,10 @@ package org.onap.ccsdk.sli.adaptors.ra.comp;
import java.util.Map;
-public class EndPointData {
+public class ResourceEntity {
- public String resourceSetId;
- public String resourceUnionId;
- public String endPointPosition;
- public String equipmentId;
- public Map<String, Object> data;
+ public String resourceEntityId;
+ public String resourceEntityVersion;
+ public String resourceEntityType;
+ public Map<String, String> data;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/PreferenceRule.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
index ca8a3719..b5c24fa7 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/PreferenceRule.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceRequest.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,10 +21,19 @@
package org.onap.ccsdk.sli.adaptors.ra.comp;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
+public class ResourceRequest {
-public interface PreferenceRule {
-
- // Smaller order number is preferred
- int assignOrderNumber(String endPointPosition, ServiceData serviceData, EquipmentData equipData);
+ public String resourceName;
+ public String resourceShareGroup;
+ public String rangeRequestedNumbers;
+ public String rangeExcludeNumbers;
+ public boolean rangeReverseOrder;
+ public int rangeMinOverride;
+ public int rangeMaxOverride;
+ public boolean replace;
+ public String requestType;
+ public String serviceModel;
+ public boolean checkOnly;
+ public String applicationId;
+ public String endPointPosition;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceResponse.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceResponse.java
new file mode 100644
index 00000000..989333c3
--- /dev/null
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceResponse.java
@@ -0,0 +1,13 @@
+package org.onap.ccsdk.sli.adaptors.ra.comp;
+
+public class ResourceResponse {
+ public String resourceName;
+ public String endPointPosition;
+ public String resourceTargetType;
+ public String resourceTargetId;
+ public String resourceLimit;
+ public String resourceAvailable;
+ public String resourceUsed;
+ public String resourceAllocated;
+ public String status;
+}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceTarget.java
index f9f7ee3d..95cec330 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDao.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceTarget.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,12 +19,13 @@
* ============LICENSE_END=========================================================
*/
-package org.onap.ccsdk.sli.adaptors.ra.equip.dao;
+package org.onap.ccsdk.sli.adaptors.ra.comp;
-import java.util.List;
import java.util.Map;
-public interface ServerDao {
+public class ResourceTarget {
- List<Map<String, Object>> getServerData(String aicSiteId);
+ public String resourceTargetId;
+ public String resourceTargetType;
+ public Map<String, String> data;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/comp/EquipmentReader.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/comp/EquipmentReader.java
deleted file mode 100644
index 03f96e27..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/comp/EquipmentReader.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.comp;
-
-import java.util.List;
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-
-public interface EquipmentReader {
-
- List<EquipmentData> readEquipment(Map<String, Object> equipmentConstraints);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDaoImpl.java
deleted file mode 100644
index f51dc140..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/ServerDaoImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.dao;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-public class ServerDaoImpl implements ServerDao {
-
- private static final Logger log = LoggerFactory.getLogger(ServerDaoImpl.class);
-
- private static final String GET_SERVER_COUNT_SQL = "SELECT count(*) FROM PSERVER WHERE aic_site_id = ?";
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public List<Map<String, Object>> getServerData(String aicSiteId) {
- List<Map<String, Object>> ll = new ArrayList<Map<String, Object>>();
- Map<String, Object> sd = new HashMap<String, Object>();
- sd.put("aic-site-id", aicSiteId);
- sd.put("server-id", aicSiteId + "/Server1");
- sd.put("server-model", "Unknown");
- sd.put("server-count", getServerCount(aicSiteId));
- ll.add(sd);
- return ll;
- }
-
- private int getServerCount(String aicSiteId) {
- int n = jdbcTemplate.queryForInt(GET_SERVER_COUNT_SQL, aicSiteId);
-
- log.info("Number of servers in " + aicSiteId + ": " + n);
-
- return n;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDao.java
deleted file mode 100644
index 1a86c6f8..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDao.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.dao;
-
-import java.util.List;
-import java.util.Map;
-
-public interface VpePortDao {
-
- List<Map<String, Object>> getVpePortData(String aicSiteId);
-
- List<Map<String, Object>> getVpePortData(String aicSiteId, String vpeName);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDaoImpl.java
deleted file mode 100644
index 05d2e76d..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VpePortDaoImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-
-public class VpePortDaoImpl implements VpePortDao {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(VpePortDaoImpl.class);
-
- private static final String GET_SQL = "SELECT * FROM VPE_POOL WHERE aic_site_id = ?";
- private static final String GET2_SQL = "SELECT * FROM VPE_POOL WHERE vpe_name = ?";
- private static final String GET3_SQL =
- "SELECT * FROM VPE_POOL WHERE substring(aic_site_id, 1, 8) = substring(?, 1, 8)";
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public List<Map<String, Object>> getVpePortData(String aicSiteId) {
- return jdbcTemplate.query(GET_SQL, new Object[] { aicSiteId }, new VpePortRowMapper());
- }
-
- @Override
- public List<Map<String, Object>> getVpePortData(String aicSiteId, String vpeName) {
- String sql = vpeName != null ? GET2_SQL : GET3_SQL;
- Object[] param = new Object[] { vpeName != null ? vpeName : aicSiteId };
-
- return jdbcTemplate.query(sql, param, new VpePortRowMapper());
- }
-
- private static class VpePortRowMapper implements RowMapper<Map<String, Object>> {
-
- @Override
- public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
- Map<String, Object> mm = new HashMap<String, Object>();
- mm.put("vpe-id", rs.getString("vpe_name"));
- mm.put("aic-site-id", rs.getString("aic_site_id"));
- mm.put("availability-zone", rs.getString("availability_zone"));
- mm.put("image-file-name", rs.getString("image_filename"));
- mm.put("vendor", rs.getString("vendor"));
- mm.put("provisioning-status", rs.getString("provisioning_status"));
- mm.put("physical-interface-name", rs.getString("physical_intf_name"));
- mm.put("physical-interface-speed", rs.getLong("physical_intf_speed"));
- mm.put("physical-interface-speed-unit", rs.getString("physical_intf_units"));
- return mm;
- }
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDao.java
deleted file mode 100644
index 20cb83ff..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDao.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.dao;
-
-import java.util.List;
-import java.util.Map;
-
-public interface VplspePortDao {
-
- List<Map<String, Object>> getVplspePortData(String aicSiteId);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDaoImpl.java
deleted file mode 100644
index 6c3d368b..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/dao/VplspePortDaoImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-
-public class VplspePortDaoImpl implements VplspePortDao {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(VplspePortDaoImpl.class);
-
- private static final String GET_SQL = "SELECT * FROM VPLSPE_POOL WHERE aic_site_id = ?";
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public List<Map<String, Object>> getVplspePortData(String aicSiteId) {
- List<Map<String, Object>> ll =
- jdbcTemplate.query(GET_SQL, new Object[] { aicSiteId }, new RowMapper<Map<String, Object>>() {
-
- @Override
- public Map<String, Object> mapRow(ResultSet rs, int rowNum) throws SQLException {
- Map<String, Object> mm = new HashMap<String, Object>();
- mm.put("vplspe-id", rs.getString("vplspe_name"));
- mm.put("aic-site-id", rs.getString("aic_site_id"));
- mm.put("availability-zone", rs.getString("availability_zone"));
- mm.put("image-file-name", rs.getString("image_filename"));
- mm.put("vendor", rs.getString("vendor"));
- mm.put("provisioning-status", rs.getString("provisioning_status"));
- mm.put("physical-interface-name", rs.getString("physical_intf_name"));
- mm.put("physical-interface-speed", rs.getLong("physical_intf_speed"));
- mm.put("physical-interface-speed-unit", rs.getString("physical_intf_units"));
- return mm;
- }
- });
- return ll;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentData.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentData.java
deleted file mode 100644
index 15342a69..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentData.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.data;
-
-import java.util.Map;
-
-public class EquipmentData {
-
- public String equipmentId;
- public EquipmentLevel equipmentLevel;
- public Map<String, Object> data;
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentLevel.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentLevel.java
deleted file mode 100644
index c77e3685..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/equip/data/EquipmentLevel.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.equip.data;
-
-public enum EquipmentLevel {
- Port, Device, Server, Site
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/AffinityLinkPref.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/AffinityLinkPref.java
deleted file mode 100644
index 0e510ac1..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/AffinityLinkPref.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.pref;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.PreferenceRule;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitResource;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AffinityLinkPref implements PreferenceRule {
-
- private static final Logger log = LoggerFactory.getLogger(AffinityLinkPref.class);
-
- private ResourceManager resourceManager;
- private List<String> affinityLinkIdList;
-
- public AffinityLinkPref() {
- // Set default values for affinity link ids (can be overridden by the spring config)
- affinityLinkIdList = new ArrayList<>();
- affinityLinkIdList.add("1");
- affinityLinkIdList.add("2");
- }
-
- @Override
- public int assignOrderNumber(String endPointPosition, ServiceData serviceData, EquipmentData equipData) {
-
- // This class does not really assign order number, but instead sets the affinity link with the lowest
- // assigned bandwidth in the equipment data
-
- String preferedAffinityLinkId = "1";
- long lowestAssignedBw = Long.MAX_VALUE;
- for (String affinityLinkId : affinityLinkIdList) {
- String assetId = equipData.equipmentId + "-" + affinityLinkId;
- Resource r = resourceManager.getResource("Bandwidth", assetId);
- if (r != null) {
- LimitResource ll = (LimitResource) r;
- if (ll.used < lowestAssignedBw) {
- lowestAssignedBw = ll.used;
- preferedAffinityLinkId = affinityLinkId;
- }
- log.info("Assigned bandwidth on affinity link: " + assetId + ": " + ll.used);
- }
- }
-
- equipData.data.put("affinity-link", preferedAffinityLinkId);
-
- log.info("Prefered affinity link for " + equipData.equipmentId + ": " + preferedAffinityLinkId);
-
- return 0;
- }
-
- public void setResourceManager(ResourceManager resourceManager) {
- this.resourceManager = resourceManager;
- }
-
- public void setAffinityLinkIdList(List<String> affinityLinkIdList) {
- this.affinityLinkIdList = affinityLinkIdList;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/EvcExistingVrfPref.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/EvcExistingVrfPref.java
deleted file mode 100644
index 559f7968..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/pref/EvcExistingVrfPref.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.pref;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.PreferenceRule;
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManager;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
-import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class EvcExistingVrfPref implements PreferenceRule {
-
- private static final Logger log = LoggerFactory.getLogger(EvcExistingVrfPref.class);
-
- private ResourceManager resourceManager;
-
- @Override
- public int assignOrderNumber(String endPointPosition, ServiceData serviceData, EquipmentData equipData) {
- String vrfName = (String) serviceData.data.get("vrf-name");
- if (vrfName == null)
- return 0;
-
- Resource r = resourceManager.getResource("VRF", equipData.equipmentId);
- if (r != null && r.allocationItems != null)
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceShareGroupList.contains(vrfName)) {
- log.info("VRF for VPN: " + vrfName + " found on VPE: " + equipData.equipmentId);
- return 1;
- }
-
- log.info("VRF for VPN: " + vrfName + " NOT found on VPE: " + equipData.equipmentId);
- return 2;
- }
-
- public void setResourceManager(ResourceManager resourceManager) {
- this.resourceManager = resourceManager;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/AicSiteReader.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/AicSiteReader.java
deleted file mode 100644
index 1faf254f..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/AicSiteReader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.reader;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.comp.EquipmentReader;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
-
-public class AicSiteReader implements EquipmentReader {
-
- @Override
- public List<EquipmentData> readEquipment(Map<String, Object> equipmentConstraints) {
- String aicSiteId = (String) equipmentConstraints.get("aic-site-id");
-
- EquipmentData equipData = new EquipmentData();
- equipData.equipmentLevel = EquipmentLevel.Site;
- equipData.equipmentId = aicSiteId;
- equipData.data = new HashMap<String, Object>();
-
- List<EquipmentData> equipList = new ArrayList<>();
- equipList.add(equipData);
-
- return equipList;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/UplinkCircuitReader.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/UplinkCircuitReader.java
deleted file mode 100644
index 4943c506..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/UplinkCircuitReader.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.reader;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.comp.EquipmentReader;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
-
-public class UplinkCircuitReader implements EquipmentReader {
-
- @SuppressWarnings("unchecked")
- @Override
- public List<EquipmentData> readEquipment(Map<String, Object> equipmentConstraints) {
- List<EquipmentData> equipList = new ArrayList<>();
-
- List<Map<String, Object>> uplinkCircuitList =
- (List<Map<String, Object>>) equipmentConstraints.get("uplink-circuit-list");
- if (uplinkCircuitList == null || uplinkCircuitList.isEmpty())
- return equipList;
-
- for (Map<String, Object> uplinkCircuit : uplinkCircuitList) {
- EquipmentData equipData = new EquipmentData();
- equipData.equipmentLevel = EquipmentLevel.Device;
- equipData.equipmentId = (String) uplinkCircuit.get("uplink-circuit-id");
- equipData.data = uplinkCircuit;
- equipList.add(equipData);
- }
-
- return equipList;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VnfReader.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VnfReader.java
deleted file mode 100644
index d5d3d005..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VnfReader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.reader;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.comp.EquipmentReader;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
-
-public class VnfReader implements EquipmentReader {
-
- @Override
- public List<EquipmentData> readEquipment(Map<String, Object> equipmentConstraints) {
- String vnfName = (String) equipmentConstraints.get("vnf-name");
-
- EquipmentData equipData = new EquipmentData();
- equipData.equipmentLevel = EquipmentLevel.Device;
- equipData.equipmentId = vnfName;
- equipData.data = new HashMap<String, Object>();
-
- List<EquipmentData> equipList = new ArrayList<>();
- equipList.add(equipData);
-
- return equipList;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VpePortReader.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VpePortReader.java
deleted file mode 100644
index 59328f97..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/reader/VpePortReader.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.reader;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.comp.EquipmentReader;
-import org.onap.ccsdk.sli.adaptors.ra.equip.dao.VpePortDao;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
-
-public class VpePortReader implements EquipmentReader {
-
- private VpePortDao vpePortDao;
-
- @Override
- public List<EquipmentData> readEquipment(Map<String, Object> equipmentConstraints) {
- String clli = (String) equipmentConstraints.get("clli");
- String vpeName = (String) equipmentConstraints.get("vpe-name");
- if (vpeName == null) {
- String equipmentId = (String) equipmentConstraints.get("equipment-id");
- if (equipmentId != null) {
- int i1 = equipmentId.indexOf('/');
- if (i1 > 0)
- equipmentId = equipmentId.substring(0, i1);
- vpeName = equipmentId;
- }
- }
-
- List<Map<String, Object>> vpeDataList = vpePortDao.getVpePortData(clli, vpeName);
-
- List<EquipmentData> equipList = new ArrayList<>();
- for (Map<String, Object> vpeData : vpeDataList) {
- EquipmentData equipData = new EquipmentData();
- equipData.equipmentLevel = EquipmentLevel.Port;
- equipData.equipmentId =
- (String) vpeData.get("vpe-id") + '/' + (String) vpeData.get("physical-interface-name");
- equipData.data = vpeData;
-
- equipList.add(equipData);
- }
-
- return equipList;
- }
-
- public void setVpePortDao(VpePortDao vpePortDao) {
- this.vpePortDao = vpePortDao;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilder.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilder.java
deleted file mode 100644
index e4361f1d..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilder.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.comp;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.rule.data.ThresholdStatus;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationOutcome;
-
-public interface AllocationRequestBuilder {
-
- AllocationRequest buildAllocationRequest(
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change);
-
- ThresholdStatus getThresholdStatus(
- ServiceData serviceData,
- EquipmentData equipmentData,
- LimitAllocationOutcome limitAllocationOutcome);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilderImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilderImpl.java
deleted file mode 100644
index ab0ef3b6..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/comp/AllocationRequestBuilderImpl.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.comp;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.comp.ServiceData;
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentData;
-import org.onap.ccsdk.sli.adaptors.ra.rule.dao.RangeRuleDao;
-import org.onap.ccsdk.sli.adaptors.ra.rule.dao.ResourceRuleDao;
-import org.onap.ccsdk.sli.adaptors.ra.rule.data.RangeRule;
-import org.onap.ccsdk.sli.adaptors.ra.rule.data.ResourceRule;
-import org.onap.ccsdk.sli.adaptors.ra.rule.data.ResourceThreshold;
-import org.onap.ccsdk.sli.adaptors.ra.rule.data.ThresholdStatus;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationAction;
-import org.onap.ccsdk.sli.adaptors.rm.data.AllocationRequest;
-import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationOutcome;
-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.RangeAllocationRequest;
-import org.onap.ccsdk.sli.adaptors.util.expr.ExpressionEvaluator;
-import org.onap.ccsdk.sli.adaptors.util.str.StrUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class AllocationRequestBuilderImpl implements AllocationRequestBuilder {
-
- private static final Logger log = LoggerFactory.getLogger(AllocationRequestBuilderImpl.class);
-
- private ResourceRuleDao resourceRuleDao;
- private RangeRuleDao rangeRuleDao;
-
- @Override
- public AllocationRequest buildAllocationRequest(
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- List<ResourceRule> resourceRuleList = resourceRuleDao.getResourceRules(serviceData.serviceModel,
- serviceData.endPointPosition, equipmentData.equipmentLevel);
- List<RangeRule> rangeRuleList = rangeRuleDao.getRangeRules(serviceData.serviceModel,
- serviceData.endPointPosition, equipmentData.equipmentLevel);
- if (resourceRuleList.isEmpty() && rangeRuleList.isEmpty())
- return null;
- if (resourceRuleList.size() == 1 && rangeRuleList.isEmpty())
- return buildAllocationRequest(resourceRuleList.get(0), serviceData, equipmentData, checkOnly, change);
-
- if (resourceRuleList.isEmpty() && rangeRuleList.size() == 1)
- return buildAllocationRequest(rangeRuleList.get(0), serviceData, equipmentData, checkOnly, change);
-
- MultiResourceAllocationRequest ar = new MultiResourceAllocationRequest();
- ar.stopOnFirstFailure = false;
- ar.allocationRequestList = new ArrayList<AllocationRequest>();
- for (ResourceRule rr : resourceRuleList) {
- AllocationRequest ar1 = buildAllocationRequest(rr, serviceData, equipmentData, checkOnly, change);
- ar.allocationRequestList.add(ar1);
- }
- for (RangeRule rr : rangeRuleList) {
- AllocationRequest ar1 = buildAllocationRequest(rr, serviceData, equipmentData, checkOnly, change);
- ar.allocationRequestList.add(ar1);
- }
- return ar;
- }
-
- private AllocationRequest buildAllocationRequest(
- ResourceRule resourceRule,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- StrUtil.info(log, resourceRule);
-
- LimitAllocationRequest ar = new LimitAllocationRequest();
- ar.resourceSetId = serviceData.resourceSetId;
- ar.resourceUnionId = serviceData.resourceUnionId;
- ar.resourceName = resourceRule.resourceName;
- ar.assetId = equipmentData.equipmentId;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.strict = false;
- ar.checkLimit = ExpressionEvaluator.evalLong(
- change ? resourceRule.hardLimitExpression : resourceRule.softLimitExpression, equipmentData.data);
- ar.checkCount = ExpressionEvaluator.evalLong(resourceRule.allocationExpression, serviceData.data);
- ar.allocateCount = checkOnly ? 0 : ar.checkCount;
- return ar;
- }
-
- private AllocationRequest buildAllocationRequest(
- RangeRule rangeRule,
- ServiceData serviceData,
- EquipmentData equipmentData,
- boolean checkOnly,
- boolean change) {
- StrUtil.info(log, rangeRule);
-
- RangeAllocationRequest ar = new RangeAllocationRequest();
- ar.resourceSetId = serviceData.resourceSetId;
- ar.resourceUnionId = serviceData.resourceUnionId;
- ar.resourceName = rangeRule.rangeName;
- ar.assetId = equipmentData.equipmentId;
- ar.missingResourceAction = AllocationAction.Succeed_Allocate;
- ar.expiredResourceAction = AllocationAction.Succeed_Allocate;
- ar.replace = true;
- ar.check = true;
- ar.allocate = !checkOnly;
- ar.checkMin = rangeRule.minValue;
- ar.checkMax = rangeRule.maxValue;
- return ar;
- }
-
- @Override
- public ThresholdStatus getThresholdStatus(
- ServiceData serviceData,
- EquipmentData equipmentData,
- LimitAllocationOutcome limitAllocationOutcome) {
- ResourceRule rr = resourceRuleDao.getResourceRule(serviceData.serviceModel, serviceData.endPointPosition,
- equipmentData.equipmentLevel, limitAllocationOutcome.request.resourceName);
- if (rr == null || rr.thresholdList == null || rr.thresholdList.isEmpty())
- return null;
-
- ThresholdStatus thresholdStatus = null;
- long maxThresholdValue = 0;
- for (ResourceThreshold th : rr.thresholdList) {
- long thresholdValue = ExpressionEvaluator.evalLong(th.expression, equipmentData.data);
-
- if (thresholdValue > maxThresholdValue) {
- maxThresholdValue = thresholdValue;
-
- if (limitAllocationOutcome.used >= thresholdValue) {
- thresholdStatus = new ThresholdStatus();
- thresholdStatus.resourceRule = rr;
- thresholdStatus.resourceThreshold = th;
- thresholdStatus.limitValue = limitAllocationOutcome.limit;
- thresholdStatus.thresholdValue = thresholdValue;
- thresholdStatus.used = limitAllocationOutcome.used;
- thresholdStatus.lastAdded = limitAllocationOutcome.allocatedCount;
- }
- }
- }
-
- return thresholdStatus;
- }
-
- public void setResourceRuleDao(ResourceRuleDao resourceRuleDao) {
- this.resourceRuleDao = resourceRuleDao;
- }
-
- public void setRangeRuleDao(RangeRuleDao rangeRuleDao) {
- this.rangeRuleDao = rangeRuleDao;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDao.java
deleted file mode 100644
index 8adf2511..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDao.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-public interface MaxPortSpeedDao {
-
- // Returns max speed in kbps
- long getMaxPortSpeed(String imageFile, String endPointPosition, String interfaceName);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDaoImpl.java
deleted file mode 100644
index 481c6f45..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxPortSpeedDaoImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-
-public class MaxPortSpeedDaoImpl implements MaxPortSpeedDao {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MaxPortSpeedDaoImpl.class);
-
- private final static String GET_SQL =
- "SELECT * FROM MAX_PORT_SPEED WHERE image_file_name = ? AND end_point_position = ? AND interface_name = ?";
-
- private JdbcTemplate jdbcTemplate;
- private long defaultMaxPortSpeed = 5000000;
- private SpeedUtil speedUtil;
-
- @Override
- public long getMaxPortSpeed(String imageFile, String endPointPosition, String interfaceName) {
- List<MaxPortSpeed> maxPortSpeedList =
- jdbcTemplate.query(GET_SQL, new Object[] { imageFile, endPointPosition, interfaceName },
- new RowMapper<MaxPortSpeed>() {
-
- @Override
- public MaxPortSpeed mapRow(ResultSet rs, int rowNum) throws SQLException {
- MaxPortSpeed mps = new MaxPortSpeed();
- mps.maxSpeed = rs.getLong("max_speed");
- mps.unit = rs.getString("unit");
- return mps;
- }
- });
-
- if (maxPortSpeedList.isEmpty())
- return defaultMaxPortSpeed;
-
- MaxPortSpeed mps = maxPortSpeedList.get(0);
- return speedUtil.convertToKbps(mps.maxSpeed, mps.unit);
- }
-
- private static class MaxPortSpeed {
-
- public long maxSpeed;
- public String unit;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- public void setDefaultMaxPortSpeed(long defaultMaxPortSpeed) {
- this.defaultMaxPortSpeed = defaultMaxPortSpeed;
- }
-
- public void setSpeedUtil(SpeedUtil speedUtil) {
- this.speedUtil = speedUtil;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDao.java
deleted file mode 100644
index 607cc0a3..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDao.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-public interface MaxServerSpeedDao {
-
- // Returns max speed in kbps
- long getMaxServerSpeed(String serverModel, int evcCount);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDaoImpl.java
deleted file mode 100644
index 445166bb..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/MaxServerSpeedDaoImpl.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-
-public class MaxServerSpeedDaoImpl implements MaxServerSpeedDao {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MaxServerSpeedDaoImpl.class);
-
- private final static String GET_SQL =
- "SELECT * FROM MAX_SERVER_SPEED\n" +
- "WHERE (server_model = ? OR server_model = 'ALL') AND evc_count >= ?\n" +
- "ORDER BY evc_count";
-
- private JdbcTemplate jdbcTemplate;
- private long defaultMaxServerSpeed = 1600000;
- private SpeedUtil speedUtil;
-
- @Override
- public long getMaxServerSpeed(String serverModel, int evcCount) {
- List<MaxServerSpeed> maxServerSpeedList =
- jdbcTemplate.query(GET_SQL, new Object[] { serverModel, evcCount }, new RowMapper<MaxServerSpeed>() {
-
- @Override
- public MaxServerSpeed mapRow(ResultSet rs, int rowNum) throws SQLException {
- MaxServerSpeed mps = new MaxServerSpeed();
- mps.maxSpeed = rs.getLong("max_speed");
- mps.unit = rs.getString("unit");
- return mps;
- }
- });
-
- if (maxServerSpeedList.isEmpty())
- return defaultMaxServerSpeed;
-
- MaxServerSpeed mps = maxServerSpeedList.get(0);
- return speedUtil.convertToKbps(mps.maxSpeed, mps.unit);
- }
-
- private static class MaxServerSpeed {
-
- public long maxSpeed;
- public String unit;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-
- public void setDefaultMaxServerSpeed(long defaultMaxServerSpeed) {
- this.defaultMaxServerSpeed = defaultMaxServerSpeed;
- }
-
- public void setSpeedUtil(SpeedUtil speedUtil) {
- this.speedUtil = speedUtil;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDao.java
deleted file mode 100644
index 724ee199..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDao.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-public interface ParameterDao {
-
- String getParameter(String name);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDaoImpl.java
deleted file mode 100644
index eb061f99..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ParameterDaoImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-import java.util.List;
-import java.util.Map;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-public class ParameterDaoImpl implements ParameterDao {
-
- private static final Logger log = LoggerFactory.getLogger(ParameterDaoImpl.class);
-
- private final static String GET_SQL = "SELECT * FROM PARAMETERS WHERE name = ?";
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public String getParameter(String name) {
- List<Map<String, Object>> ll = jdbcTemplate.queryForList(GET_SQL, name);
-
- if (ll == null || ll.isEmpty()) {
- log.info("Parameter: " + name + " not found in DB");
- return null;
- }
-
- String v = (String) ll.get(0).get("value");
- log.info("Parameter from DB: " + name + "='" + v + "'");
-
- return v;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDao.java
index ad1498d0..a7fcb61f 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDao.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/RangeRuleDao.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,11 +22,9 @@
package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
import org.onap.ccsdk.sli.adaptors.ra.rule.data.RangeRule;
public interface RangeRuleDao {
- List<RangeRule> getRangeRules(String serviceModel, String endPointPosition, EquipmentLevel equipLevel);
+ List<RangeRule> getRangeRules(String serviceModel, String equipLevel);
}
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 29a4aea2..825261ef 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
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,8 +24,6 @@ package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
import org.onap.ccsdk.sli.adaptors.ra.rule.data.RangeRule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -37,30 +35,28 @@ public class RangeRuleDaoImpl implements RangeRuleDao {
@SuppressWarnings("unused")
private static final Logger log = LoggerFactory.getLogger(RangeRuleDaoImpl.class);
- private static final String GET_SQL =
- "SELECT * FROM RANGE_RULE WHERE service_model = ? AND end_point_position = ? AND equipment_level = ?";
+ private static final String GET_SQL = "SELECT * FROM RANGE_RULE WHERE service_model = ? AND equipment_level = ?";
private JdbcTemplate jdbcTemplate;
@Override
- public List<RangeRule> getRangeRules(String serviceModel, String endPointPosition, EquipmentLevel equipLevel) {
+ public List<RangeRule> getRangeRules(String serviceModel, String equipLevel) {
List<RangeRule> rangeRuleList =
- jdbcTemplate.query(GET_SQL, new Object[] { serviceModel, endPointPosition, equipLevel.toString() },
- new RowMapper<RangeRule>() {
+ jdbcTemplate.query(GET_SQL, new Object[] {serviceModel, equipLevel}, new RowMapper<RangeRule>() {
- @Override
- public RangeRule mapRow(ResultSet rs, int rowNum) throws SQLException {
- RangeRule rl = new RangeRule();
- rl.id = rs.getLong("range_rule_id");
- rl.rangeName = rs.getString("range_name");
- rl.serviceModel = rs.getString("service_model");
- rl.endPointPosition = rs.getString("end_point_position");
- rl.equipmentLevel = rs.getString("equipment_level");
- rl.minValue = rs.getInt("min_value");
- rl.maxValue = rs.getInt("max_value");
- return rl;
- }
- });
+ @Override
+ public RangeRule mapRow(ResultSet rs, int rowNum) throws SQLException {
+ RangeRule rl = new RangeRule();
+ rl.id = rs.getLong("range_rule_id");
+ rl.rangeName = rs.getString("range_name");
+ rl.serviceModel = rs.getString("service_model");
+ rl.endPointPosition = rs.getString("end_point_position");
+ rl.equipmentLevel = rs.getString("equipment_level");
+ rl.minValue = rs.getInt("min_value");
+ rl.maxValue = rs.getInt("max_value");
+ return rl;
+ }
+ });
return rangeRuleList;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDao.java
index 9d879fbe..54fdcbc2 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDao.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDao.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,17 +22,11 @@
package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
import org.onap.ccsdk.sli.adaptors.ra.rule.data.ResourceRule;
public interface ResourceRuleDao {
- List<ResourceRule> getResourceRules(String serviceModel, String endPointPosition, EquipmentLevel equipLevel);
+ List<ResourceRule> getResourceRules(String serviceModel, String equipLevel);
- ResourceRule getResourceRule(
- String serviceModel,
- String endPointPosition,
- EquipmentLevel equipLevel,
- String resourceName);
+ ResourceRule getResourceRule(String serviceModel, String endPointPosition, String equipLevel, String resourceName);
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDaoImpl.java
index 0e765f38..451dc57c 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDaoImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/ResourceRuleDaoImpl.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,8 +24,6 @@ package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.equip.data.EquipmentLevel;
import org.onap.ccsdk.sli.adaptors.ra.rule.data.ResourceRule;
import org.onap.ccsdk.sli.adaptors.ra.rule.data.ResourceThreshold;
import org.slf4j.Logger;
@@ -39,7 +37,7 @@ public class ResourceRuleDaoImpl implements ResourceRuleDao {
private static final Logger log = LoggerFactory.getLogger(ResourceRuleDaoImpl.class);
private static final String GET1_SQL =
- "SELECT * FROM RESOURCE_RULE WHERE service_model = ? AND end_point_position = ? AND equipment_level = ?";
+ "SELECT * FROM RESOURCE_RULE WHERE service_model = ? AND equipment_level = ?";
private static final String GET2_SQL =
"SELECT * FROM RESOURCE_RULE WHERE service_model = ? AND end_point_position = ? AND equipment_level = ? AND resource_name = ?";
private static final String THRESHOLD_SQL = "SELECT * FROM RESOURCE_THRESHOLD WHERE resource_rule_id = ?";
@@ -49,34 +47,29 @@ public class ResourceRuleDaoImpl implements ResourceRuleDao {
ResourceThresholdRowMapper resourceThresholdRowMapper = new ResourceThresholdRowMapper();
@Override
- public List<ResourceRule> getResourceRules(
- String serviceModel,
- String endPointPosition,
- EquipmentLevel equipLevel) {
- List<ResourceRule> resourceRuleList = jdbcTemplate.query(GET1_SQL,
- new Object[] { serviceModel, endPointPosition, equipLevel.toString() }, resourceRuleRowMapper);
+ public List<ResourceRule> getResourceRules(String serviceModel, String equipLevel) {
+ List<ResourceRule> resourceRuleList =
+ jdbcTemplate.query(GET1_SQL, new Object[] {serviceModel, equipLevel}, resourceRuleRowMapper);
- for (ResourceRule rr : resourceRuleList)
- rr.thresholdList = jdbcTemplate.query(THRESHOLD_SQL, new Object[] { rr.id }, resourceThresholdRowMapper);
+ for (ResourceRule rr : resourceRuleList) {
+ rr.thresholdList = jdbcTemplate.query(THRESHOLD_SQL, new Object[] {rr.id}, resourceThresholdRowMapper);
+ }
return resourceRuleList;
}
@Override
- public ResourceRule getResourceRule(
- String serviceModel,
- String endPointPosition,
- EquipmentLevel equipLevel,
+ public ResourceRule getResourceRule(String serviceModel, String endPointPosition, String equipLevel,
String resourceName) {
List<ResourceRule> resourceRuleList = jdbcTemplate.query(GET2_SQL,
- new Object[] { serviceModel, endPointPosition, equipLevel.toString(), resourceName },
- resourceRuleRowMapper);
+ new Object[] {serviceModel, endPointPosition, equipLevel, resourceName}, resourceRuleRowMapper);
- if (resourceRuleList == null || resourceRuleList.isEmpty())
+ if (resourceRuleList == null || resourceRuleList.isEmpty()) {
return null;
+ }
ResourceRule rr = resourceRuleList.get(0);
- rr.thresholdList = jdbcTemplate.query(THRESHOLD_SQL, new Object[] { rr.id }, resourceThresholdRowMapper);
+ rr.thresholdList = jdbcTemplate.query(THRESHOLD_SQL, new Object[] {rr.id}, resourceThresholdRowMapper);
return rr;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDao.java
deleted file mode 100644
index b51cb2e8..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDao.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-public interface VpeLockDao {
-
- String getVpeLock(String vpeName);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDaoImpl.java
deleted file mode 100644
index 443f5066..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/rule/dao/VpeLockDaoImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.rule.dao;
-
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-
-public class VpeLockDaoImpl implements VpeLockDao {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(VpeLockDaoImpl.class);
-
- private final static String GET_SQL = "SELECT vpn_lock FROM VPE_LOCK WHERE vpe_name = ?";
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public String getVpeLock(String vpeName) {
- List<String> ll = jdbcTemplate.queryForList(GET_SQL, String.class, vpeName);
- return ll != null && !ll.isEmpty() ? ll.get(0) : null;
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDao.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDao.java
deleted file mode 100644
index 9f923a5c..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDao.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.service.dao;
-
-import org.onap.ccsdk.sli.adaptors.ra.service.data.ServiceResource;
-import org.onap.ccsdk.sli.adaptors.ra.service.data.ServiceStatus;
-
-public interface ServiceResourceDao {
-
- ServiceResource getServiceResource(String serviceInstanceId, ServiceStatus serviceStatus);
-
- void addServiceResource(ServiceResource serviceResource);
-
- void updateServiceResource(ServiceResource serviceResource);
-
- void deleteServiceResource(String serviceInstanceId, ServiceStatus serviceStatus);
-
- void updateServiceStatus(String serviceInstanceId, ServiceStatus serviceStatus, ServiceStatus newServiceStatus);
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDaoImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDaoImpl.java
deleted file mode 100644
index b0e2046f..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/dao/ServiceResourceDaoImpl.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.service.dao;
-
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.List;
-
-import org.onap.ccsdk.sli.adaptors.ra.service.data.ServiceResource;
-import org.onap.ccsdk.sli.adaptors.ra.service.data.ServiceStatus;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.core.RowMapper;
-
-public class ServiceResourceDaoImpl implements ServiceResourceDao {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(ServiceResourceDaoImpl.class);
-
- private static final String GET_SQL =
- "SELECT * FROM SERVICE_RESOURCE WHERE service_instance_id = ? AND service_status = ?";
-
- private static final String ADD_SQL = "INSERT INTO SERVICE_RESOURCE (\n"
- + " service_instance_id, service_status, service_change_number, resource_set_id, resource_union_id)\n"
- + "VALUES (?, ?, ?, ?, ?)";
-
- private static final String UPDATE_SQL =
- "UPDATE SERVICE_RESOURCE SET service_change_number = ?, resource_set_id = ?\n"
- + "WHERE service_instance_id = ? AND service_status = ?";
-
- private static final String DELETE_SQL =
- "DELETE FROM SERVICE_RESOURCE WHERE service_instance_id = ? AND service_status = ?";
-
- private static final String UPDATE_STATUS_SQL =
- "UPDATE SERVICE_RESOURCE SET service_status = ? WHERE service_instance_id = ? AND service_status = ?";
-
- private JdbcTemplate jdbcTemplate;
-
- @Override
- public ServiceResource getServiceResource(final String serviceInstanceId, final ServiceStatus serviceStatus) {
- List<ServiceResource> serviceResourceList =
- jdbcTemplate.query(GET_SQL, new Object[] { serviceInstanceId, serviceStatus.toString() },
- new RowMapper<ServiceResource>() {
-
- @Override
- public ServiceResource mapRow(ResultSet rs, int rowNum) throws SQLException {
- ServiceResource sr = new ServiceResource();
- sr.id = rs.getLong("service_resource_id");
- sr.serviceInstanceId = serviceInstanceId;
- sr.serviceStatus = serviceStatus;
- sr.serviceChangeNumber = rs.getInt("service_change_number");
- sr.resourceSetId = rs.getString("resource_set_id");
- sr.resourceUnionId = rs.getString("resource_union_id");
- return sr;
- }
- });
- if (serviceResourceList.isEmpty())
- return null;
- return serviceResourceList.get(0);
- }
-
- @Override
- public void addServiceResource(ServiceResource serviceResource) {
- jdbcTemplate.update(ADD_SQL, serviceResource.serviceInstanceId, serviceResource.serviceStatus.toString(),
- serviceResource.serviceChangeNumber, serviceResource.resourceSetId, serviceResource.resourceUnionId);
- }
-
- @Override
- public void updateServiceResource(ServiceResource serviceResource) {
- jdbcTemplate.update(UPDATE_SQL, serviceResource.serviceChangeNumber, serviceResource.resourceSetId,
- serviceResource.serviceInstanceId, serviceResource.serviceStatus.toString());
- }
-
- @Override
- public void deleteServiceResource(String serviceInstanceId, ServiceStatus serviceStatus) {
- jdbcTemplate.update(DELETE_SQL, serviceInstanceId, serviceStatus.toString());
- }
-
- @Override
- public void updateServiceStatus(
- String serviceInstanceId,
- ServiceStatus serviceStatus,
- ServiceStatus newServiceStatus) {
- jdbcTemplate.update(UPDATE_STATUS_SQL, newServiceStatus.toString(), serviceInstanceId, serviceStatus.toString());
- }
-
- public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
- this.jdbcTemplate = jdbcTemplate;
- }
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceResource.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceResource.java
deleted file mode 100644
index 519e7919..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceResource.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.service.data;
-
-public class ServiceResource {
-
- public long id;
- public String serviceInstanceId;
- public ServiceStatus serviceStatus;
- public int serviceChangeNumber;
- public String resourceSetId;
- public String resourceUnionId;
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceStatus.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceStatus.java
deleted file mode 100644
index 9fd1b37f..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/service/data/ServiceStatus.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.ra.service.data;
-
-public enum ServiceStatus {
-
- Active, Pending
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java
index bda496a1..3544075f 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/AllocationFunction.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-
import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelper;
import org.onap.ccsdk.sli.adaptors.lock.comp.ResourceLockedException;
import org.onap.ccsdk.sli.adaptors.lock.comp.SynchronizedFunction;
@@ -66,22 +65,20 @@ class AllocationFunction extends SynchronizedFunction {
private ResourceDao resourceDao;
- private String applicationId;
private AllocationRequest request;
private AllocationOutcome outcome;
- private List<Resource> updateList = new ArrayList<Resource>();
+ private List<Resource> updateList = new ArrayList<>();
- public AllocationFunction(LockHelper lockHelper, ResourceDao resourceDao, String applicationId,
- AllocationRequest request, int lockTimeout) {
+ public AllocationFunction(LockHelper lockHelper, ResourceDao resourceDao, AllocationRequest request,
+ int lockTimeout) {
super(lockHelper, getLockNames(request), lockTimeout);
- this.applicationId = applicationId;
this.resourceDao = resourceDao;
this.request = request;
}
private static Collection<String> getLockNames(AllocationRequest request) {
- Set<String> lockResourceNames = new HashSet<String>();
+ Set<String> lockResourceNames = new HashSet<>();
addLockNames(lockResourceNames, request);
return lockResourceNames;
}
@@ -89,36 +86,47 @@ class AllocationFunction extends SynchronizedFunction {
private static void addLockNames(Set<String> lockResourceNames, AllocationRequest request) {
if (request instanceof MultiAssetAllocationRequest) {
MultiAssetAllocationRequest req = (MultiAssetAllocationRequest) request;
- if (req.assetIdList != null)
+ if (req.assetIdList != null) {
lockResourceNames.addAll(req.assetIdList);
+ }
} else if (request instanceof MultiResourceAllocationRequest) {
MultiResourceAllocationRequest req = (MultiResourceAllocationRequest) request;
- if (req.allocationRequestList != null)
- for (AllocationRequest request1 : req.allocationRequestList)
+ if (req.allocationRequestList != null) {
+ for (AllocationRequest request1 : req.allocationRequestList) {
addLockNames(lockResourceNames, request1);
- } else if (request.assetId != null)
+ }
+ }
+ } else if (request.assetId != null) {
lockResourceNames.add(request.assetId);
+ }
}
@Override
public void _exec() throws ResourceLockedException {
outcome = allocate(request);
- if (outcome.status == AllocationStatus.Success)
- for (Resource r : updateList)
+ if (outcome.status == AllocationStatus.Success) {
+ for (Resource r : updateList) {
resourceDao.saveResource(r);
+ }
+ }
}
private AllocationOutcome allocate(AllocationRequest allocationRequest) throws ResourceLockedException {
- if (allocationRequest instanceof MultiAssetAllocationRequest)
+ if (allocationRequest instanceof MultiAssetAllocationRequest) {
return allocateMultiAsset((MultiAssetAllocationRequest) allocationRequest);
- if (allocationRequest instanceof MultiResourceAllocationRequest)
+ }
+ if (allocationRequest instanceof MultiResourceAllocationRequest) {
return allocateMultiResource((MultiResourceAllocationRequest) allocationRequest);
- if (allocationRequest instanceof LimitAllocationRequest)
+ }
+ if (allocationRequest instanceof LimitAllocationRequest) {
return allocateLimit((LimitAllocationRequest) allocationRequest);
- if (allocationRequest instanceof LabelAllocationRequest)
+ }
+ if (allocationRequest instanceof LabelAllocationRequest) {
return allocateLabel((LabelAllocationRequest) allocationRequest);
- if (allocationRequest instanceof RangeAllocationRequest)
+ }
+ if (allocationRequest instanceof RangeAllocationRequest) {
return allocateRange((RangeAllocationRequest) allocationRequest);
+ }
return null;
}
@@ -130,16 +138,18 @@ class AllocationFunction extends SynchronizedFunction {
private MultiResourceAllocationOutcome allocateMultiResource(MultiResourceAllocationRequest req) {
MultiResourceAllocationOutcome out = new MultiResourceAllocationOutcome();
out.request = req;
- out.allocationOutcomeList = new ArrayList<AllocationOutcome>();
+ out.allocationOutcomeList = new ArrayList<>();
out.status = AllocationStatus.Success;
- if (req.allocationRequestList != null)
+ if (req.allocationRequestList != null) {
for (AllocationRequest req1 : req.allocationRequestList) {
AllocationOutcome out1 = allocate(req1);
out.allocationOutcomeList.add(out1);
- if (out1.status != AllocationStatus.Success)
+ if (out1.status != AllocationStatus.Success) {
out.status = AllocationStatus.Failure;
+ }
}
+ }
return out;
}
@@ -167,11 +177,12 @@ class AllocationFunction extends SynchronizedFunction {
if (LimitUtil.checkLimit(l, req)) {
out.status = AllocationStatus.Success;
if (req.allocateCount > 0) {
- out.allocatedCount = LimitUtil.allocateLimit(l, req, applicationId);
+ out.allocatedCount = LimitUtil.allocateLimit(l, req);
updateList.add(l);
}
- } else
+ } else {
out.status = AllocationStatus.Failure;
+ }
out.used = l.used;
out.limit = req.checkLimit;
@@ -204,11 +215,12 @@ class AllocationFunction extends SynchronizedFunction {
out.status = AllocationStatus.Success;
out.currentLabel = l.label;
if (req.allocate) {
- out.allocatedLabel = LabelUtil.allocateLabel(l, req, applicationId);
+ out.allocatedLabel = LabelUtil.allocateLabel(l, req);
updateList.add(l);
}
- } else
+ } else {
out.status = AllocationStatus.Failure;
+ }
return out;
}
@@ -242,18 +254,19 @@ class AllocationFunction extends SynchronizedFunction {
if (req.requestedNumbers != null && req.requestedNumbers.size() > 0) {
foundNumbers = req.requestedNumbers;
out.status = AllocationStatus.Success;
- for (int n : foundNumbers)
+ for (int n : foundNumbers) {
if (!RangeUtil.checkRange(rr, req, n)) {
out.status = AllocationStatus.Failure;
break;
}
+ }
} else {
- foundNumbers = new TreeSet<Integer>();
+ foundNumbers = new TreeSet<>();
int foundCount = 0;
// First try to reuse the numbers already taken by the same resource union
SortedSet<Integer> uu = RangeUtil.getUsed(rr, req.resourceUnionId);
- if (uu != null && !uu.isEmpty()) {
+ if (uu != null && !uu.isEmpty() && req.replace) {
if (uu.size() >= req.requestedCount) {
// Just take the first req.requestedCount numbers from uu
Iterator<Integer> i = uu.iterator();
@@ -278,33 +291,48 @@ class AllocationFunction extends SynchronizedFunction {
if (RangeUtil.checkRange(rr, req, n)) {
foundNumbers.add(n);
foundCount++;
- } else if (req.sequential)
+ } else if (req.sequential) {
break;
+ }
}
for (int n = uumax; foundCount < req.requestedCount && n <= req.checkMax; n++) {
if (RangeUtil.checkRange(rr, req, n)) {
foundNumbers.add(n);
foundCount++;
- } else if (req.sequential)
+ } else if (req.sequential) {
break;
+ }
}
// If we could not find enough numbers trying to reuse currently
// allocated, reset foundNumbers and foundCount, continue with
// the normal allocation of new numbers.
if (foundCount < req.requestedCount) {
- foundNumbers = new TreeSet<Integer>();
+ foundNumbers = new TreeSet<>();
foundCount = 0;
}
}
}
- for (int n = req.checkMin; foundCount < req.requestedCount && n <= req.checkMax; n++)
- if (RangeUtil.checkRange(rr, req, n)) {
- foundNumbers.add(n);
- foundCount++;
- } else if (req.sequential)
- foundCount = 0;
+ if (req.reverseOrder) {
+ for (int n = req.checkMax; foundCount < req.requestedCount && n >= req.checkMin; n--) {
+ if (RangeUtil.checkRange(rr, req, n)) {
+ foundNumbers.add(n);
+ foundCount++;
+ } else if (req.sequential) {
+ foundCount = 0;
+ }
+ }
+ } else {
+ for (int n = req.checkMin; foundCount < req.requestedCount && n <= req.checkMax; n++) {
+ if (RangeUtil.checkRange(rr, req, n)) {
+ foundNumbers.add(n);
+ foundCount++;
+ } else if (req.sequential) {
+ foundCount = 0;
+ }
+ }
+ }
out.status = foundCount == req.requestedCount ? AllocationStatus.Success : AllocationStatus.Failure;
}
@@ -313,11 +341,12 @@ class AllocationFunction extends SynchronizedFunction {
if (out.status == AllocationStatus.Success) {
out.allocated = foundNumbers;
if (req.allocate) {
- RangeUtil.allocateRange(rr, out.allocated, req, applicationId);
+ RangeUtil.allocateRange(rr, out.allocated, req);
updateList.add(rr);
}
- } else
- out.allocated = new TreeSet<Integer>();
+ } else {
+ out.allocated = new TreeSet<>();
+ }
out.used = rr.used;
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
index 2884e989..77d8a681 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/comp/ResourceManagerImpl.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,7 +24,6 @@ package org.onap.ccsdk.sli.adaptors.rm.comp;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelper;
import org.onap.ccsdk.sli.adaptors.rm.dao.ResourceDao;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationOutcome;
@@ -42,7 +41,6 @@ public class ResourceManagerImpl implements ResourceManager {
private LockHelper lockHelper;
private ResourceDao resourceDao;
- private String applicationId;
private int lockTimeout = 10 * 60; // Default 10 min
public ResourceManagerImpl() {
@@ -59,18 +57,20 @@ public class ResourceManagerImpl implements ResourceManager {
@Override
public List<Resource> getResourceUnion(String resourceUnionId) {
List<Resource> rlist = resourceDao.getResourceUnion(resourceUnionId);
- for (Resource r : rlist)
+ for (Resource r : rlist) {
ResourceUtil.recalculate(r);
+ }
return rlist;
}
@Override
public AllocationOutcome allocateResources(AllocationRequest allocationRequest) {
- if (allocationRequest == null)
+ if (allocationRequest == null) {
throw new IllegalArgumentException("allocateResources called with null argument");
+ }
AllocationFunction allocationFunction =
- new AllocationFunction(lockHelper, resourceDao, applicationId, allocationRequest, lockTimeout);
+ new AllocationFunction(lockHelper, resourceDao, allocationRequest, lockTimeout);
allocationFunction.exec();
AllocationOutcome allocationOutcome = allocationFunction.getAllocationOutcome();
@@ -82,8 +82,9 @@ public class ResourceManagerImpl implements ResourceManager {
@Override
public void releaseResourceSet(String resourceSetId) {
List<Resource> resourceList = resourceDao.getResourceSet(resourceSetId);
- if (resourceList == null || resourceList.isEmpty())
+ if (resourceList == null || resourceList.isEmpty()) {
return;
+ }
Set<String> lockNames = getLockNames(resourceList);
ReleaseFunction releaseFunction =
@@ -94,8 +95,9 @@ public class ResourceManagerImpl implements ResourceManager {
@Override
public void releaseResourceUnion(String resourceUnionId) {
List<Resource> resourceList = resourceDao.getResourceUnion(resourceUnionId);
- if (resourceList == null || resourceList.isEmpty())
+ if (resourceList == null || resourceList.isEmpty()) {
return;
+ }
Set<String> lockNames = getLockNames(resourceList);
ReleaseFunction releaseFunction =
@@ -104,9 +106,10 @@ public class ResourceManagerImpl implements ResourceManager {
}
private Set<String> getLockNames(List<Resource> resourceList) {
- Set<String> lockNames = new HashSet<String>();
- for (Resource r : resourceList)
+ Set<String> lockNames = new HashSet<>();
+ for (Resource r : resourceList) {
lockNames.add(r.resourceKey.assetId);
+ }
return lockNames;
}
@@ -118,10 +121,6 @@ public class ResourceManagerImpl implements ResourceManager {
this.lockTimeout = lockTimeout;
}
- public void setApplicationId(String applicationId) {
- this.applicationId = applicationId;
- }
-
public void setLockHelper(LockHelper lockHelper) {
this.lockHelper = lockHelper;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/AllocationRequest.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/AllocationRequest.java
index 25a4fbba..29b49368 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/AllocationRequest.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/AllocationRequest.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,6 +25,7 @@ import java.util.Set;
public class AllocationRequest {
+ public String applicationId = null;
public String resourceUnionId = null;
public String resourceSetId = null;
public Set<String> resourceShareGroupList = null;
@@ -32,4 +33,5 @@ public class AllocationRequest {
public String assetId = null;
public AllocationAction missingResourceAction = AllocationAction.Succeed_Allocate;
public AllocationAction expiredResourceAction = AllocationAction.Succeed_Allocate;
+ public String endPointPosition = null;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java
index b42960d9..9581244b 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/data/RangeAllocationRequest.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -31,6 +31,8 @@ public class RangeAllocationRequest extends AllocationRequest {
public boolean allocate = false;
public boolean replace = false;
public SortedSet<Integer> requestedNumbers = null;
+ public SortedSet<Integer> excludeNumbers = null;
public int requestedCount = 1;
public boolean sequential = false;
+ public boolean reverseOrder = false;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LabelUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LabelUtil.java
index 7cc541dd..a67a50b3 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LabelUtil.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LabelUtil.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,6 @@ package org.onap.ccsdk.sli.adaptors.rm.util;
import java.util.ArrayList;
import java.util.Date;
-
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.LabelAllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.LabelAllocationRequest;
@@ -37,16 +36,18 @@ public class LabelUtil {
if (req.check && req.label != null && l.allocationItems != null && !l.allocationItems.isEmpty()) {
for (AllocationItem ai : l.allocationItems) {
LabelAllocationItem lai = (LabelAllocationItem) ai;
- if (!eq(req.resourceUnionId, lai.resourceUnionId) && !eq(req.label, lai.label))
+ if (!eq(req.resourceUnionId, lai.resourceUnionId) && !eq(req.label, lai.label)) {
return false;
+ }
}
}
return true;
}
- public static String allocateLabel(LabelResource l, LabelAllocationRequest req, String applicationId) {
- if (!req.allocate)
+ public static String allocateLabel(LabelResource l, LabelAllocationRequest req) {
+ if (!req.allocate) {
return null;
+ }
LabelAllocationItem lai = (LabelAllocationItem) ResourceUtil.getAllocationItem(l, req.resourceSetId);
if (lai == null) {
@@ -55,13 +56,14 @@ public class LabelUtil {
lai.resourceKey = new ResourceKey();
lai.resourceKey.assetId = req.assetId;
lai.resourceKey.resourceName = req.resourceName;
- lai.applicationId = applicationId;
+ lai.applicationId = req.applicationId;
lai.resourceSetId = req.resourceSetId;
lai.resourceUnionId = req.resourceUnionId;
lai.resourceShareGroupList = req.resourceShareGroupList;
- if (l.allocationItems == null)
- l.allocationItems = new ArrayList<AllocationItem>();
+ if (l.allocationItems == null) {
+ l.allocationItems = new ArrayList<>();
+ }
l.allocationItems.add(lai);
}
@@ -76,17 +78,19 @@ public class LabelUtil {
public static void recalculate(LabelResource l) {
l.label = null;
l.referenceCount = 0;
- if (l.allocationItems != null)
+ if (l.allocationItems != null) {
for (AllocationItem ai : l.allocationItems) {
LabelAllocationItem lai = (LabelAllocationItem) ai;
if (lai.label != null) {
l.referenceCount++;
- if (l.label == null)
+ if (l.label == null) {
l.label = lai.label;
- else if (!l.label.equals(lai.label))
+ } else if (!l.label.equals(lai.label)) {
l.label = "__BLOCKED__";
+ }
}
}
+ }
}
private static boolean eq(Object o1, Object o2) {
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LimitUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LimitUtil.java
index 8f284b59..2e36c966 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LimitUtil.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/LimitUtil.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.LimitAllocationRequest;
@@ -42,26 +41,30 @@ public class LimitUtil {
private static final Logger log = LoggerFactory.getLogger(LimitUtil.class);
public static boolean checkLimit(LimitResource l, LimitAllocationRequest req) {
- if (req.checkCount <= 0)
+ if (req.checkCount <= 0) {
return true;
+ }
long checkCount = req.checkCount;
long currentUsage = 0;
if (req.resourceSetId != null) {
LimitAllocationItem lai = (LimitAllocationItem) ResourceUtil.getAllocationItem(l, req.resourceSetId);
- if (lai != null)
+ if (lai != null) {
currentUsage = lai.used;
+ }
}
- if (!req.replace)
+ if (!req.replace) {
checkCount += currentUsage;
+ }
long used = calculateLimitUsage(l, 0, null, null);
long wouldUse = calculateLimitUsage(l, checkCount, req.resourceUnionId, req.resourceShareGroupList);
// If usage is not increasing by this request, only check the limit if
// strictCheck is true.
- if (wouldUse <= used && !req.strict)
+ if (wouldUse <= used && !req.strict) {
return true;
+ }
return wouldUse <= req.checkLimit;
}
@@ -72,8 +75,9 @@ public class LimitUtil {
String resourceUnionId,
Set<String> resourceShareGroupList) {
if ((l.allocationItems == null || l.allocationItems.isEmpty()) &&
- (resourceUnionId == null || resourceUnionId.length() == 0))
+ (resourceUnionId == null || resourceUnionId.length() == 0)) {
return 0;
+ }
long t1 = System.currentTimeMillis();
boolean logit = false;
@@ -127,48 +131,54 @@ public class LimitUtil {
// First, group the allocation items by the first resource union, using the LimitUsage structure
int regularChangeCount = 0;
- Map<String/* resourceUnionId */, List<LimitUsage>> limitUsageMap = new HashMap<String, List<LimitUsage>>();
- if (l.allocationItems != null)
+ Map<String/* resourceUnionId */, List<LimitUsage>> limitUsageMap = new HashMap<>();
+ if (l.allocationItems != null) {
for (AllocationItem ai : l.allocationItems) {
LimitAllocationItem lai = (LimitAllocationItem) ai;
boolean regularChange =
addLimitUsage(limitUsageMap, lai.resourceUnionId, lai.resourceShareGroupList, lai.used);
- if (regularChange)
+ if (regularChange) {
regularChangeCount++;
+ }
}
+ }
if (checkCount > 0 && resourceUnionId != null) {
boolean regularChange = addLimitUsage(limitUsageMap, resourceUnionId, resourceShareGroupList, checkCount);
- if (regularChange)
+ if (regularChange) {
regularChangeCount++;
+ }
}
// Generate all the combinations, containing one LimitUsage object for each firstResourceUnion
int significantChangeCount = 0;
- List<List<LimitUsage>> allCombinations = new ArrayList<List<LimitUsage>>();
+ List<List<LimitUsage>> allCombinations = new ArrayList<>();
for (String firstResourceUnion : limitUsageMap.keySet()) {
List<LimitUsage> limitUsageList = limitUsageMap.get(firstResourceUnion);
- if (limitUsageList.size() > 1)
+ if (limitUsageList.size() > 1) {
significantChangeCount++;
+ }
if (allCombinations.isEmpty()) {
for (LimitUsage limitUsage : limitUsageList) {
- List<LimitUsage> newCombination = new ArrayList<LimitUsage>();
+ List<LimitUsage> newCombination = new ArrayList<>();
newCombination.add(limitUsage);
allCombinations.add(newCombination);
}
} else {
if (limitUsageList.size() == 1) {
// No new combinations are generated - just add this one to all combinations we have until now
- for (List<LimitUsage> combination : allCombinations)
+ for (List<LimitUsage> combination : allCombinations) {
combination.add(limitUsageList.get(0));
+ }
} else {
// We have to duplicate each of the current combinations for each element of limitUsageList
- List<List<LimitUsage>> newAllCombinations = new ArrayList<List<LimitUsage>>();
- for (List<LimitUsage> combination : allCombinations)
+ List<List<LimitUsage>> newAllCombinations = new ArrayList<>();
+ for (List<LimitUsage> combination : allCombinations) {
for (LimitUsage limitUsage : limitUsageList) {
- List<LimitUsage> newCombination = new ArrayList<LimitUsage>(combination);
+ List<LimitUsage> newCombination = new ArrayList<>(combination);
newCombination.add(limitUsage);
newAllCombinations.add(newCombination);
}
+ }
allCombinations = newAllCombinations;
}
}
@@ -178,8 +188,9 @@ public class LimitUtil {
long maxUsage = 0;
for (List<LimitUsage> combination : allCombinations) {
long usage = calculateUsage(combination);
- if (usage > maxUsage)
+ if (usage > maxUsage) {
maxUsage = usage;
+ }
}
long t2 = System.currentTimeMillis();
@@ -202,7 +213,7 @@ public class LimitUtil {
long used) {
List<LimitUsage> limitUsageList = limitUsageMap.get(resourceUnionId);
if (limitUsageList == null) {
- limitUsageList = new ArrayList<LimitUsage>();
+ limitUsageList = new ArrayList<>();
limitUsageMap.put(resourceUnionId, limitUsageList);
}
// See if we already have the same shareResourceUnionSet in the list. In such case just update the usage
@@ -221,8 +232,9 @@ public class LimitUtil {
}
}
if (limitUsage != null) {
- if (limitUsage.usage < used)
+ if (limitUsage.usage < used) {
limitUsage.usage = used;
+ }
return true;
}
@@ -243,14 +255,18 @@ public class LimitUtil {
}
private static boolean hasCommonSharedResource(LimitUsage limitUsage1, LimitUsage limitUsage2) {
- if (limitUsage1.resourceShareGroupList == null || limitUsage1.resourceShareGroupList.isEmpty())
+ if (limitUsage1.resourceShareGroupList == null || limitUsage1.resourceShareGroupList.isEmpty()) {
return false;
- if (limitUsage2.resourceShareGroupList == null || limitUsage2.resourceShareGroupList.isEmpty())
+ }
+ if (limitUsage2.resourceShareGroupList == null || limitUsage2.resourceShareGroupList.isEmpty()) {
return false;
+ }
- for (String resourceUnion : limitUsage1.resourceShareGroupList)
- if (limitUsage2.resourceShareGroupList.contains(resourceUnion))
+ for (String resourceUnion : limitUsage1.resourceShareGroupList) {
+ if (limitUsage2.resourceShareGroupList.contains(resourceUnion)) {
return true;
+ }
+ }
return false;
}
@@ -260,7 +276,7 @@ public class LimitUtil {
// split the combination in sets that have common value. Then the usage of each set will be the maximum of
// the usages of the LimitUsage objects in the set. The usage of the combination will be the sum of the usages
// of all sets.
- List<List<LimitUsage>> sharedSets = new ArrayList<List<LimitUsage>>();
+ List<List<LimitUsage>> sharedSets = new ArrayList<>();
for (LimitUsage limitUsage : combination) {
// See if we can put limitUsage in any of the existing sets - is it has a common resource union with
// any of the LimitUsage objects in a set.
@@ -279,7 +295,7 @@ public class LimitUtil {
}
if (!found) {
// Start a new set
- List<LimitUsage> newSharedSet = new ArrayList<LimitUsage>();
+ List<LimitUsage> newSharedSet = new ArrayList<>();
newSharedSet.add(limitUsage);
sharedSets.add(newSharedSet);
}
@@ -288,18 +304,21 @@ public class LimitUtil {
long sum = 0;
for (List<LimitUsage> sharedSet : sharedSets) {
float max = 0;
- for (LimitUsage limitUsage : sharedSet)
- if (max < limitUsage.usage)
+ for (LimitUsage limitUsage : sharedSet) {
+ if (max < limitUsage.usage) {
max = limitUsage.usage;
+ }
+ }
sum += max;
}
return sum;
}
- public static long allocateLimit(LimitResource l, LimitAllocationRequest req, String applicationId) {
- if (req.allocateCount <= 0)
+ public static long allocateLimit(LimitResource l, LimitAllocationRequest req) {
+ if (req.allocateCount <= 0) {
return 0;
+ }
long uu = l.used;
LimitAllocationItem lai = (LimitAllocationItem) ResourceUtil.getAllocationItem(l, req.resourceSetId);
@@ -309,17 +328,19 @@ public class LimitUtil {
lai.resourceKey = new ResourceKey();
lai.resourceKey.assetId = req.assetId;
lai.resourceKey.resourceName = req.resourceName;
- lai.applicationId = applicationId;
+ lai.applicationId = req.applicationId;
lai.resourceSetId = req.resourceSetId;
lai.resourceUnionId = req.resourceUnionId;
lai.resourceShareGroupList = req.resourceShareGroupList;
lai.used = req.allocateCount;
- if (l.allocationItems == null)
- l.allocationItems = new ArrayList<AllocationItem>();
+ if (l.allocationItems == null) {
+ l.allocationItems = new ArrayList<>();
+ }
l.allocationItems.add(lai);
- } else
+ } else {
lai.used = req.replace ? req.allocateCount : lai.used + req.allocateCount;
+ }
lai.allocationTime = new Date();
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 f01d3578..04f6e8c5 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
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,9 +23,9 @@ package org.onap.ccsdk.sli.adaptors.rm.util;
import java.util.ArrayList;
import java.util.Date;
+import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.RangeAllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.RangeAllocationRequest;
@@ -36,51 +36,62 @@ import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
public class RangeUtil {
public static void recalculate(RangeResource r) {
- r.used = new TreeSet<Integer>();
- if (r.allocationItems != null)
+ r.used = new TreeSet<>();
+ if (r.allocationItems != null) {
for (AllocationItem ai : r.allocationItems) {
RangeAllocationItem rai = (RangeAllocationItem) ai;
- if (rai.used != null)
+ if (rai.used != null) {
r.used.addAll(rai.used);
+ }
}
+ }
}
public static boolean checkRange(RangeResource r, RangeAllocationRequest req, int num) {
- if (num < req.checkMin || num > req.checkMax)
+ if (num < req.checkMin || num > req.checkMax) {
+ return false;
+ }
+
+ if (req.excludeNumbers != null && req.excludeNumbers.contains(num)) {
return false;
+ }
- if (r.allocationItems != null)
+ if (r.allocationItems != null) {
for (AllocationItem ai : r.allocationItems) {
RangeAllocationItem rai = (RangeAllocationItem) ai;
- if (!eq(req.resourceUnionId, rai.resourceUnionId) && rai.used != null && rai.used.contains(num))
+ if (!eq(req.resourceUnionId, rai.resourceUnionId) && rai.used != null && rai.used.contains(num)) {
+ if (!overlap(rai.resourceShareGroupList, req.resourceShareGroupList)) {
+ return false;
+ }
+ }
+ if (!req.replace && eq(req.resourceSetId, rai.resourceSetId) && rai.used != null
+ && rai.used.contains(num)) {
return false;
+ }
}
+ }
return true;
}
- private static boolean eq(Object o1, Object o2) {
- return o1 == null ? o2 == null : o1.equals(o2);
- }
-
public static SortedSet<Integer> getUsed(RangeResource r, String resourceUnionId) {
- SortedSet<Integer> used = new TreeSet<Integer>();
- if (r.allocationItems != null)
+ SortedSet<Integer> used = new TreeSet<>();
+ if (r.allocationItems != null) {
for (AllocationItem ai : r.allocationItems) {
RangeAllocationItem rai = (RangeAllocationItem) ai;
- if (eq(resourceUnionId, rai.resourceUnionId) && rai.used != null)
+ if (eq(resourceUnionId, rai.resourceUnionId) && rai.used != null) {
used.addAll(rai.used);
+ }
}
+ }
return used;
}
- public static void allocateRange(
- RangeResource rr,
- SortedSet<Integer> requestedNumbers,
- RangeAllocationRequest req,
- String applicationId) {
- if (!req.allocate)
+ public static void allocateRange(RangeResource rr, SortedSet<Integer> requestedNumbers,
+ RangeAllocationRequest req) {
+ if (!req.allocate) {
return;
+ }
RangeAllocationItem rai = (RangeAllocationItem) ResourceUtil.getAllocationItem(rr, req.resourceSetId);
if (rai == null) {
@@ -89,22 +100,40 @@ public class RangeUtil {
rai.resourceKey = new ResourceKey();
rai.resourceKey.assetId = req.assetId;
rai.resourceKey.resourceName = req.resourceName;
- rai.applicationId = applicationId;
+ rai.applicationId = req.applicationId;
rai.resourceSetId = req.resourceSetId;
rai.resourceUnionId = req.resourceUnionId;
rai.resourceShareGroupList = req.resourceShareGroupList;
rai.used = requestedNumbers;
- if (rr.allocationItems == null)
- rr.allocationItems = new ArrayList<AllocationItem>();
+ if (rr.allocationItems == null) {
+ rr.allocationItems = new ArrayList<>();
+ }
rr.allocationItems.add(rai);
- } else if (req.replace)
+ } else if (req.replace) {
rai.used = requestedNumbers;
- else
+ } else {
rai.used.addAll(requestedNumbers);
+ }
rai.allocationTime = new Date();
recalculate(rr);
}
+
+ private static boolean eq(Object o1, Object o2) {
+ return o1 == null ? o2 == null : o1.equals(o2);
+ }
+
+ private static boolean overlap(Set<String> s1, Set<String> s2) {
+ if (s1 == null || s1.isEmpty() || s2 == null || s2.isEmpty()) {
+ return false;
+ }
+ for (String ss1 : s1) {
+ if (s2.contains(ss1)) {
+ return true;
+ }
+ }
+ return false;
+ }
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/ResourceUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/ResourceUtil.java
index ae7c2157..3db63804 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/ResourceUtil.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/rm/util/ResourceUtil.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -24,26 +24,34 @@ package org.onap.ccsdk.sli.adaptors.rm.util;
import org.onap.ccsdk.sli.adaptors.rm.data.AllocationItem;
import org.onap.ccsdk.sli.adaptors.rm.data.LabelResource;
import org.onap.ccsdk.sli.adaptors.rm.data.LimitResource;
+import org.onap.ccsdk.sli.adaptors.rm.data.RangeResource;
import org.onap.ccsdk.sli.adaptors.rm.data.Resource;
import org.onap.ccsdk.sli.adaptors.rm.data.ResourceType;
public class ResourceUtil {
public static AllocationItem getAllocationItem(Resource r, String resourceSetId) {
- if (r.allocationItems != null)
- for (AllocationItem ai : r.allocationItems)
- if (ai.resourceSetId != null && ai.resourceSetId.equals(resourceSetId))
+ if (r.allocationItems != null) {
+ for (AllocationItem ai : r.allocationItems) {
+ if (ai.resourceSetId != null && ai.resourceSetId.equals(resourceSetId)) {
return ai;
+ }
+ }
+ }
return null;
}
public static void recalculate(Resource r) {
- if (r == null)
+ if (r == null) {
return;
+ }
- if (r.resourceType == ResourceType.Limit)
+ if (r.resourceType == ResourceType.Limit) {
LimitUtil.recalculate((LimitResource) r);
- else if (r.resourceType == ResourceType.Label)
+ } else if (r.resourceType == ResourceType.Range) {
+ RangeUtil.recalculate((RangeResource) r);
+ } else if (r.resourceType == ResourceType.Label) {
LabelUtil.recalculate((LabelResource) r);
+ }
}
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/CachedDataSourceWrap.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/CachedDataSourceWrap.java
index 0e46868b..3fa3952f 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/CachedDataSourceWrap.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/db/CachedDataSourceWrap.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,9 +25,7 @@ import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
-
import javax.sql.DataSource;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,6 +34,7 @@ public class CachedDataSourceWrap implements DataSource {
private static final Logger log = LoggerFactory.getLogger(CachedDataSourceWrap.class);
private ThreadLocal<ConnectionWrap> con = new ThreadLocal<>();
+ private ThreadLocal<Boolean> autoCommit = new ThreadLocal<>();
private DataSource dataSource;
@@ -78,12 +77,17 @@ public class CachedDataSourceWrap implements DataSource {
public Connection getConnection() throws SQLException {
if (con.get() == null) {
Connection c = dataSource.getConnection();
+
ConnectionWrap cc = new ConnectionWrap(c);
con.set(cc);
+ autoCommit.set(c.getAutoCommit());
+ c.setAutoCommit(false);
+
log.info("Got new DB connection: " + c);
- } else
+ } else {
log.info("Using thread DB connection: " + con.get().getCon());
+ }
return con.get();
}
@@ -92,12 +96,17 @@ public class CachedDataSourceWrap implements DataSource {
public Connection getConnection(String username, String password) throws SQLException {
if (con.get() == null) {
Connection c = dataSource.getConnection(username, password);
+
ConnectionWrap cc = new ConnectionWrap(c);
con.set(cc);
+ autoCommit.set(c.getAutoCommit());
+ c.setAutoCommit(false);
+
log.info("Got new DB connection: " + c);
- } else
+ } else {
log.info("Using thread DB connection: " + con.get().getCon());
+ }
return con.get();
}
@@ -105,6 +114,7 @@ public class CachedDataSourceWrap implements DataSource {
public void releaseConnection() {
if (con.get() != null) {
try {
+ con.get().setAutoCommit(autoCommit.get());
con.get().realClose();
log.info("DB Connection released: " + con.get().getCon());
@@ -116,6 +126,30 @@ public class CachedDataSourceWrap implements DataSource {
}
}
+ public void commit() {
+ if (con.get() != null) {
+ try {
+ con.get().commit();
+
+ log.info("DB Connection committed: " + con.get().getCon());
+ } catch (Exception e) {
+ log.warn("Failed to commit DB connection", e);
+ }
+ }
+ }
+
+ public void rollback() {
+ if (con.get() != null) {
+ try {
+ con.get().rollback();
+
+ log.info("DB Connection rolled back: " + con.get().getCon());
+ } catch (Exception e) {
+ log.warn("Failed to roll back DB connection", e);
+ }
+ }
+ }
+
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/expr/ExpressionEvaluator.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/expr/ExpressionEvaluator.java
index 037b78b7..8ba454bf 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/expr/ExpressionEvaluator.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/expr/ExpressionEvaluator.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,36 +25,42 @@ import java.util.Map;
public class ExpressionEvaluator {
- public static long evalLong(String expr, Map<String, Object> vars) {
+ public static long evalLong(String expr, Map<String, String> vars) {
return (long) evalFloat(expr, vars);
}
- public static float evalFloat(String expr, Map<String, Object> vars) {
+ public static float evalFloat(String expr, Map<String, String> vars) {
expr = expr.trim();
int sl = expr.length();
- if (sl == 0)
+ if (sl == 0) {
throw new IllegalArgumentException("Cannot interpret empty string.");
+ }
// Remove parentheses if any
- if (expr.charAt(0) == '(' && expr.charAt(sl - 1) == ')')
+ if (expr.charAt(0) == '(' && expr.charAt(sl - 1) == ')') {
return evalFloat(expr.substring(1, sl - 1), vars);
+ }
// Look for operators in the order of least priority
String[] sss = findOperator(expr, "-", true);
- if (sss != null)
+ if (sss != null) {
return evalFloat(sss[0], vars) - evalFloat(sss[1], vars);
+ }
sss = findOperator(expr, "+", true);
- if (sss != null)
+ if (sss != null) {
return evalFloat(sss[0], vars) + evalFloat(sss[1], vars);
+ }
sss = findOperator(expr, "/", true);
- if (sss != null)
+ if (sss != null) {
return evalFloat(sss[0], vars) / evalFloat(sss[1], vars);
+ }
sss = findOperator(expr, "*", true);
- if (sss != null)
+ if (sss != null) {
return evalFloat(sss[0], vars) * evalFloat(sss[1], vars);
+ }
// Check if expr is a number
try {
@@ -63,74 +69,122 @@ public class ExpressionEvaluator {
}
// Must be a variable
- Object v = vars.get(expr);
- if (v != null) {
- if (v instanceof Float)
- return (Float) v;
- if (v instanceof Long)
- return (Long) v;
- if (v instanceof Integer)
- return (Integer) v;
+ String v = vars.get(expr);
+ try {
+ return Float.valueOf(v);
+ } catch (Exception e) {
}
return 0;
}
- public static boolean evalBoolean(String expr, Map<String, Object> vars) {
+ public static String evalString(String expr, Map<String, String> vars) {
expr = expr.trim();
int sl = expr.length();
- if (sl == 0)
+ if (sl == 0) {
throw new IllegalArgumentException("Cannot interpret empty string.");
+ }
+
+ // Remove parentheses if any
+ if (expr.charAt(0) == '(' && expr.charAt(sl - 1) == ')') {
+ return evalString(expr.substring(1, sl - 1), vars);
+ }
+
+ // Look for operators in the order of least priority
+ String[] sss = findOperator(expr, "+", true);
+ if (sss != null) {
+ return evalString(sss[0], vars) + evalString(sss[1], vars);
+ }
+
+ // Check if expr is a number
+ try {
+ return Float.valueOf(expr).toString();
+ } catch (Exception e) {
+ }
+
+ // Check for quotes
+ if (expr.charAt(0) == '"' && expr.charAt(sl - 1) == '"') {
+ return expr.substring(1, sl - 1);
+ }
+ if (expr.charAt(0) == '\'' && expr.charAt(sl - 1) == '\'') {
+ return expr.substring(1, sl - 1);
+ }
+
+ // Must be a variable
+ String v = vars.get(expr);
+ return v != null ? v : "";
+ }
- if (expr.equalsIgnoreCase("true"))
+ public static boolean evalBoolean(String expr, Map<String, String> vars) {
+ expr = expr.trim();
+ int sl = expr.length();
+ if (sl == 0) {
+ throw new IllegalArgumentException("Cannot interpret empty string.");
+ }
+
+ if (expr.equalsIgnoreCase("true")) {
return true;
+ }
- if (expr.equalsIgnoreCase("false"))
+ if (expr.equalsIgnoreCase("false")) {
return false;
+ }
// Remove parentheses if any
- if (expr.charAt(0) == '(' && expr.charAt(sl - 1) == ')')
+ if (expr.charAt(0) == '(' && expr.charAt(sl - 1) == ')') {
return evalBoolean(expr.substring(1, sl - 1), vars);
+ }
// Look for operators in the order of least priority
String[] sss = findOperator(expr, "or", true);
- if (sss != null)
+ if (sss != null) {
return evalBoolean(sss[0], vars) || evalBoolean(sss[1], vars);
+ }
sss = findOperator(expr, "and", true);
- if (sss != null)
+ if (sss != null) {
return evalBoolean(sss[0], vars) && evalBoolean(sss[1], vars);
+ }
sss = findOperator(expr, "not", true);
- if (sss != null)
+ if (sss != null) {
return !evalBoolean(sss[1], vars);
+ }
sss = findOperator(expr, "!=", false);
- if (sss == null)
+ if (sss == null) {
sss = findOperator(expr, "<>", false);
- if (sss != null)
- return evalLong(sss[0], vars) != evalLong(sss[1], vars);
+ }
+ if (sss != null) {
+ return !evalString(sss[0], vars).equals(evalString(sss[1], vars));
+ }
sss = findOperator(expr, "==", false);
- if (sss == null)
+ if (sss == null) {
sss = findOperator(expr, "=", false);
- if (sss != null)
- return evalLong(sss[0], vars) == evalLong(sss[1], vars);
+ }
+ if (sss != null) {
+ return evalString(sss[0], vars).equals(evalString(sss[1], vars));
+ }
sss = findOperator(expr, ">=", false);
- if (sss != null)
+ if (sss != null) {
return evalLong(sss[0], vars) >= evalLong(sss[1], vars);
+ }
sss = findOperator(expr, ">", false);
- if (sss != null)
+ if (sss != null) {
return evalLong(sss[0], vars) > evalLong(sss[1], vars);
+ }
sss = findOperator(expr, "<=", false);
- if (sss != null)
+ if (sss != null) {
return evalLong(sss[0], vars) <= evalLong(sss[1], vars);
+ }
sss = findOperator(expr, "<", false);
- if (sss != null)
+ if (sss != null) {
return evalLong(sss[0], vars) < evalLong(sss[1], vars);
+ }
throw new IllegalArgumentException("Cannot interpret '" + expr + "': Invalid expression.");
}
@@ -142,26 +196,29 @@ public class ExpressionEvaluator {
int pcount = 0, qcount = 0;
for (int i = 0; i < sl; i++) {
char c = s.charAt(i);
- if (c == '(' && qcount == 0)
+ if (c == '(' && qcount == 0) {
pcount++;
- else if (c == ')' && qcount == 0) {
+ } else if (c == ')' && qcount == 0) {
pcount--;
- if (pcount < 0)
+ if (pcount < 0) {
throw new IllegalArgumentException("Cannot interpret '" + s + "': Parentheses do not match.");
- } else if (c == '\'')
+ }
+ } else if (c == '\'') {
qcount = (qcount + 1) % 2;
- else if (i <= sl - opl && pcount == 0 && qcount == 0) {
+ } else if (i <= sl - opl && pcount == 0 && qcount == 0) {
String ss = s.substring(i, i + opl);
if (ss.equalsIgnoreCase(op)) {
boolean found = true;
if (delimiterRequired) {
// Check for delimiter before and after to make sure it is not part of another word
char chbefore = '\0';
- if (i > 0)
+ if (i > 0) {
chbefore = s.charAt(i - 1);
+ }
char chafter = '\0';
- if (i < sl - opl)
+ if (i < sl - opl) {
chafter = s.charAt(i + opl);
+ }
found = delimiters.indexOf(chbefore) >= 0 && delimiters.indexOf(chafter) >= 0;
}
if (found) {
@@ -174,23 +231,29 @@ public class ExpressionEvaluator {
}
}
}
- if (pcount > 0)
+ if (pcount > 0) {
throw new IllegalArgumentException("Cannot interpret '" + s + "': Parentheses do not match.");
- if (qcount > 0)
+ }
+ if (qcount > 0) {
throw new IllegalArgumentException("Cannot interpret '" + s + "': No closing '.");
+ }
return null;
}
+ @SuppressWarnings("unused")
private static Object parseObject(String s) {
s = s.trim();
int sl = s.length();
- if (sl == 0)
+ if (sl == 0) {
throw new IllegalArgumentException("Cannot interpret empty string.");
- if (s.equalsIgnoreCase("null"))
+ }
+ if (s.equalsIgnoreCase("null")) {
return null;
+ }
if (s.charAt(0) == '\'') {
- if (sl < 2 || s.charAt(sl - 1) != '\'')
+ if (sl < 2 || s.charAt(sl - 1) != '\'') {
throw new IllegalArgumentException("Cannot interpret '" + s + "': No closing '.");
+ }
return s.substring(1, sl - 1);
}
// Not in quotes - must be a number
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/speed/SpeedUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/speed/SpeedUtil.java
index 1aad8f50..0d1359cf 100644
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/speed/SpeedUtil.java
+++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/speed/SpeedUtil.java
@@ -8,9 +8,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -26,12 +26,28 @@ public class SpeedUtil {
private long unitFactor = 1000;
public long convertToKbps(long maxSpeed, String unit) {
- if (unit.equalsIgnoreCase("kbps"))
+ if (unit.equalsIgnoreCase("kbps")) {
return maxSpeed;
- if (unit.equalsIgnoreCase("Mbps"))
+ }
+ if (unit.equalsIgnoreCase("Mbps")) {
return maxSpeed * unitFactor;
- if (unit.equalsIgnoreCase("Gbps"))
+ }
+ if (unit.equalsIgnoreCase("Gbps")) {
return maxSpeed * unitFactor * unitFactor;
+ }
+ return 0;
+ }
+
+ public long convertToMbps(long maxSpeed, String unit) {
+ if (unit.equalsIgnoreCase("kbps")) {
+ return maxSpeed / unitFactor;
+ }
+ if (unit.equalsIgnoreCase("Mbps")) {
+ return maxSpeed;
+ }
+ if (unit.equalsIgnoreCase("Gbps")) {
+ return maxSpeed * unitFactor;
+ }
return 0;
}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VpnParam.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VpnParam.java
deleted file mode 100644
index 11e64ae1..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VpnParam.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.util.vrf;
-
-public class VpnParam {
-
- public String vpnId;
- public String siteType;
- public String spokeServiceInstanceId;
- public String routeGroupName;
-}
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VrfUtil.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VrfUtil.java
deleted file mode 100644
index 74025f15..00000000
--- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/util/vrf/VrfUtil.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.adaptors.util.vrf;
-
-public class VrfUtil {
-
- public static String createVrfInstanceName(
- String serviceInstanceId,
- String vpnId,
- String siteType,
- String routeGroup) {
- if (vpnId == null || vpnId.trim().length() == 0)
- return null;
-
- String ss = "VPN-" + vpnId;
- if (siteType != null && siteType.equalsIgnoreCase("hub"))
- ss += "-HUB";
- if (siteType != null && siteType.equalsIgnoreCase("spoke"))
- ss += "-SP-" + serviceInstanceId;
- if (routeGroup != null && routeGroup.trim().length() > 0)
- ss += "-RG-" + routeGroup;
-
- return ss;
- }
-
- public static VpnParam parseVrfInstanceName(String vrfInstanceName) {
- VpnParam vpnParam = new VpnParam();
-
- int i1 = vrfInstanceName.indexOf("-HUB");
- if (i1 > 0)
- vpnParam.siteType = "HUB";
-
- int i2 = vrfInstanceName.indexOf("-SP-");
- if (i2 > 0)
- vpnParam.siteType = "SPOKE";
-
- int i3 = vrfInstanceName.indexOf("-RG-");
- if (i3 > 0)
- vpnParam.routeGroupName = vrfInstanceName.substring(i3 + 4);
-
- int i4 = vrfInstanceName.length();
- if (i1 > 0)
- i4 = i1;
- else if (i2 > 0)
- i4 = i2;
- else if (i3 > 0)
- i4 = i3;
- vpnParam.vpnId = vrfInstanceName.substring(4, i4);
-
- if (i2 > 0 && i3 < 0)
- vpnParam.spokeServiceInstanceId = vrfInstanceName.substring(i2 + 4);
- if (i2 > 0 && i3 > 0)
- vpnParam.spokeServiceInstanceId = vrfInstanceName.substring(i2 + 4, i3);
-
- return vpnParam;
- }
-}
diff --git a/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment-blueprint.xml b/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment-blueprint.xml
index c2298af7..11c284d6 100755
--- a/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment-blueprint.xml
+++ b/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment-blueprint.xml
@@ -26,4 +26,6 @@
<reference id="dblib.dataSource" interface="javax.sql.DataSource" filter="(objectClass=org.onap.ccsdk.sli.core.dblib.DbLibService)"/>
+ <service ref="resourceAllocator" interface="org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator"/>
+
</blueprint>
diff --git a/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment.xml b/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment.xml
index 6e11c664..3fba3c78 100755
--- a/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment.xml
+++ b/resource-assignment/provider/src/main/resources/org/opendaylight/blueprint/resource-assignment.xml
@@ -77,7 +77,6 @@
<bean id="resourceManager" class="org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManagerImpl">
<property name="lockHelper" ref="lockHelper" />
<property name="resourceDao" ref="resourceDao" />
- <property name="applicationId" value="SDNC" />
<property name="lockTimeout" value="600" /> <!-- Seconds -->
</bean>
@@ -105,29 +104,17 @@
<bean id="endPointAllocator" class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocatorImpl">
<property name="resourceManager" ref="resourceManager" />
- <property name="endPointAllocationDefinitionMap">
+ <property name="allocationRuleMap">
<map>
<entry key="DEFAULT">
<list>
- <bean class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocationDefinition">
- <property name="serviceModel" value="DEFAULT" />
- <property name="endPointPosition" value="DEFAULT" />
- <property name="equipmentReader" ref="vnfReader" />
- <property name="allocationRuleList">
- <list>
- <ref component-id="dbAllocationRule" />
- </list>
- </property>
- </bean>
+ <ref component-id="dbAllocationRule" />
</list>
</entry>
</map>
</property>
</bean>
- <bean id="vnfReader" class="org.onap.ccsdk.sli.adaptors.ra.reader.VnfReader">
- </bean>
-
<!-- Resource Allocation Rule Configuration -->
<bean id="dbAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.DbAllocationRule">
diff --git a/resource-assignment/provider/src/main/resources/resource-allocator.properties b/resource-assignment/provider/src/main/resources/resource-allocator.properties
deleted file mode 100644
index 72dbcf87..00000000
--- a/resource-assignment/provider/src/main/resources/resource-allocator.properties
+++ /dev/null
@@ -1,26 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. All rights
-# reserved.
-# ================================================================================
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# ============LICENSE_END=========================================================
-###
-
-org.onap.ccsdk.sli.adaptors.dbtype = jdbc
-org.onap.ccsdk.sli.adaptors.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl
-org.onap.ccsdk.sli.adaptors.jdbc.database = sdnctl
-org.onap.ccsdk.sli.adaptors.jdbc.user = sdnctl
-org.onap.ccsdk.sli.adaptors.jdbc.password = gamma
diff --git a/resource-assignment/provider/src/main/resources/sql/001_resource_rule_ddl.sql b/resource-assignment/provider/src/main/resources/sql/001_resource_rule_ddl.sql
deleted file mode 100644
index f69b6bcd..00000000
--- a/resource-assignment/provider/src/main/resources/sql/001_resource_rule_ddl.sql
+++ /dev/null
@@ -1,32 +0,0 @@
----
--- ============LICENSE_START=======================================================
--- openECOMP : SDN-C
--- ================================================================================
--- Copyright (C) 2017 AT&T Intellectual Property. All rights
--- reserved.
--- ================================================================================
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- ============LICENSE_END=========================================================
----
-
-CREATE TABLE resource_rule (
- resource_rule_id SERIAL PRIMARY KEY,
- resource_name VARCHAR(50) NOT NULL,
- end_point_position VARCHAR(50) NOT NULL,
- service_expression VARCHAR(2000) NOT NULL,
- equipment_level VARCHAR(50) NOT NULL,
- equipment_expression VARCHAR(2000) NOT NULL,
- allocation_expression VARCHAR(2000) NOT NULL,
- soft_limit_expression VARCHAR(2000) NOT NULL,
- hard_limit_expression VARCHAR(2000) NOT NULL
-);
diff --git a/resource-assignment/provider/src/main/resources/sql/002_max_port_speed_ddl.sql b/resource-assignment/provider/src/main/resources/sql/002_max_port_speed_ddl.sql
deleted file mode 100644
index bc7babaf..00000000
--- a/resource-assignment/provider/src/main/resources/sql/002_max_port_speed_ddl.sql
+++ /dev/null
@@ -1,29 +0,0 @@
----
--- ============LICENSE_START=======================================================
--- openECOMP : SDN-C
--- ================================================================================
--- Copyright (C) 2017 AT&T Intellectual Property. All rights
--- reserved.
--- ================================================================================
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- ============LICENSE_END=========================================================
----
-
-CREATE TABLE max_port_speed (
- max_port_speed_id SERIAL PRIMARY KEY,
- image_file_name VARCHAR(50) NOT NULL,
- end_point_position VARCHAR(50) NOT NULL,
- interface_name VARCHAR(100) NOT NULL,
- max_speed BIGINT NOT NULL,
- unit VARCHAR(10) NOT NULL
-);
diff --git a/resource-assignment/provider/src/main/resources/sql/003_max_server_speed_ddl.sql b/resource-assignment/provider/src/main/resources/sql/003_max_server_speed_ddl.sql
deleted file mode 100644
index e3f18390..00000000
--- a/resource-assignment/provider/src/main/resources/sql/003_max_server_speed_ddl.sql
+++ /dev/null
@@ -1,28 +0,0 @@
----
--- ============LICENSE_START=======================================================
--- openECOMP : SDN-C
--- ================================================================================
--- Copyright (C) 2017 AT&T Intellectual Property. All rights
--- reserved.
--- ================================================================================
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
--- ============LICENSE_END=========================================================
----
-
-CREATE TABLE max_server_speed (
- max_server_speed_id SERIAL PRIMARY KEY,
- server_model VARCHAR(50) NOT NULL,
- evc_count SMALLINT NOT NULL,
- max_speed BIGINT NOT NULL,
- unit VARCHAR(10) NOT NULL
-);
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
index ba57f626..bba8e2b9 100644
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/DataSetup.java
@@ -3,14 +3,14 @@
* openECOMP : SDN-C
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
+ * reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,8 +21,6 @@
package jtest.org.onap.ccsdk.sli.adaptors.ra;
-import java.util.Date;
-
import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestDb;
import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable;
@@ -30,231 +28,29 @@ public class DataSetup {
private TestDb testDb;
- private TestTable vpePool = null;
- private TestTable vplspePool = null;
- private TestTable pserver = null;
- private TestTable serviceResource = null;
private TestTable resource = null;
private TestTable allocationItem = null;
- private static final String[] VPE_POOL_COLUMNS = {
- "vpe_name", "ipv4_oam_address", "loopback0_ipv4_address", "provisioning_status", "aic_site_id",
- "availability_zone", "vlan_id_outer", "vendor", "physical_intf_name", "physical_intf_speed",
- "physical_intf_units", "vpe_uuid", "vpe_id", "image_filename" };
-
- private static final String[] VPLSPE_POOL_COLUMNS = {
- "vplspe_name", "aic_site_id", "availability_zone", "physical_intf_name", "physical_intf_speed",
- "physical_intf_units", "loopback0_ipv4_address", "vlan_id_outer", "vplspe_uuid", "image_filename",
- "provisioning_status", "vendor" };
-
- private static final String[] PSERVER_COLUMNS = {
- "hostname", "ptnii_equip_name", "number_of_cpus", "disk_in_gigabytes", "ram_in_megabytes", "equip_type",
- "equip_vendor", "equip_model", "fqdn", "pserver_selflink", "ipv4_oam_address", "serial_number",
- "pserver_id", "internet_topology", "aic_site_id", "in_maint", "pserver_name2", "purpose" };
-
- private static final String[] SERVICE_RESOURCE_COLUMNS = {
- "service_instance_id", "service_status", "service_change_number", "resource_set_id", "resource_union_id" };
+ private static final String[] RESOURCE_COLUMNS = {"asset_id", "resource_name", "resource_type", "lt_used"};
- 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[] ALLOCATION_ITEM_COLUMNS = {"resource_id", "application_id", "resource_set_id",
+ "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time"};
private void initTables() {
- if (vpePool == null)
- vpePool = testDb.table("VPE_POOL", "vpe_name", VPE_POOL_COLUMNS);
- if (vplspePool == null)
- vplspePool = testDb.table("VPLSPE_POOL", "vplspe_name", VPLSPE_POOL_COLUMNS);
- if (pserver == null)
- pserver = testDb.table("PSERVER", "hostname", PSERVER_COLUMNS);
- if (serviceResource == null)
- serviceResource = testDb.table("SERVICE_RESOURCE", "service_resource_id", SERVICE_RESOURCE_COLUMNS);
- if (resource == null)
+ if (resource == null) {
resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS);
- if (allocationItem == null)
+ }
+ if (allocationItem == null) {
allocationItem = testDb.table("ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
+ }
}
public void cleanup() {
initTables();
- vpePool.delete("true");
- vplspePool.delete("true");
- pserver.delete("true");
- serviceResource.delete("true");
allocationItem.delete("true");
resource.delete("true");
}
- public void setupVpePort(
- String aicSiteId,
- String vpeId,
- String interfaceName,
- String provStatus,
- String imageFileName) {
- initTables();
- vpePool.add(vpeId, "127.0.0.1", "107.134.152.139", provStatus, aicSiteId, "mtanj-esx-az01", "3501",
- "JUNIPER", interfaceName, "1", "GBPS", "vpe002", "VPESAT-auttx200me6", imageFileName);
- }
-
- public void setupVplspePort(
- String aicSiteId,
- String vplspeId,
- String interfaceName,
- String provStatus,
- String imageFileName) {
- initTables();
- vplspePool.add(vplspeId, aicSiteId, "mtanj-esx-az01", interfaceName, "100", "GBPS", "192.168.119.32", "3501",
- "vpls002", imageFileName, provStatus, "JUNIPER");
- }
-
- public void setupPserver(String hostname, String aicSiteId) {
- initTables();
- pserver.add(hostname, hostname + "srv1", 4, 1000, 16000, "equip_type", "equip_vendor", "equip_model", "fqdn",
- "pserver_selflink", "123.123.123.123", "serial_number", "pserver_id", "internet_topology", aicSiteId,
- "N", hostname, "purpose");
- }
-
- public void setupService(
- String serviceInstanceId,
- String status,
- int changeNumber,
- long speedKbps,
- String vpeId,
- String vplspeId,
- String serverId) {
- initTables();
-
- String resourceSetId = serviceInstanceId + "/" + changeNumber;
- String resourceUnionId = serviceInstanceId;
-
- serviceResource.add(serviceInstanceId, status, changeNumber, resourceSetId, resourceUnionId);
-
- Long rid = resource.getId("asset_id = '" + vpeId + "/ae0' AND resource_name = 'Bandwidth'");
- if (rid == null) {
- resource.add(vpeId + "/ae0", "Bandwidth", "Limit", 1);
- rid = resource.getLastId();
- }
- allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, speedKbps, new Date());
-
- rid = resource.getId("asset_id = '" + vplspeId + "' AND resource_name = 'Bandwidth'");
- if (rid == null) {
- resource.add(vplspeId, "Bandwidth", "Limit", 1);
- rid = resource.getLastId();
- }
- allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, speedKbps, new Date());
-
- rid = resource.getId("asset_id = '" + serverId + "' AND resource_name = 'Bandwidth'");
- if (rid == null) {
- resource.add(serverId, "Bandwidth", "Limit", 1);
- rid = resource.getLastId();
- }
- allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, speedKbps, new Date());
-
- rid = resource.getId("asset_id = '" + serverId + "' AND resource_name = 'Connection'");
- if (rid == null) {
- resource.add(serverId, "Connection", "Limit", 1);
- rid = resource.getLastId();
- }
- allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, 1, new Date());
- }
-
- public boolean serviceNotInDb(String serviceInstanceId, String status, Integer changeNumber) {
- String where = "service_instance_id = '" + serviceInstanceId + "'";
- if (status != null)
- where += " AND service_status = '" + status + "'";
- if (changeNumber != null)
- where += " AND service_change_number = " + changeNumber;
-
- if (serviceResource.exists(where))
- return false;
-
- where = "resource_union_id = '" + serviceInstanceId + "'";
- if (changeNumber != null)
- where += " AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "'";
-
- if (allocationItem.exists(where))
- return false;
-
- return true;
- }
-
- public boolean serviceCorrectInDb(String serviceInstanceId, String status, int changeNumber, long speedKbps) {
- String where = "service_instance_id = '" + serviceInstanceId + "' AND service_status = '" + status +
- "' AND service_change_number = " + changeNumber;
- if (!serviceResource.exists(where))
- return false;
-
- where = "resource_union_id = '" + serviceInstanceId + "' AND resource_set_id = '" + serviceInstanceId + "/" +
- changeNumber + "' AND lt_used = " + speedKbps;
- if (!allocationItem.exists(where))
- return false;
-
- return true;
- }
-
- public boolean serviceCorrectInDb(
- String vpeId,
- String aicSiteId,
- String serviceInstanceId,
- String status,
- int changeNumber,
- long speedKbps) {
-
- String where = "service_instance_id = '" + serviceInstanceId + "' AND service_status = '" + status +
- "' AND service_change_number = " + changeNumber;
- if (!serviceResource.exists(where))
- return false;
-
- Long vpebwrid = resource.getId("asset_id = '" + vpeId + "/ae0' AND resource_name = 'Bandwidth'");
- if (vpebwrid == null)
- return false;
-
- where = "resource_id = " + vpebwrid + " AND resource_union_id = '" + serviceInstanceId +
- "' AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "' AND lt_used = " + speedKbps;
- if (!allocationItem.exists(where))
- return false;
-
- Long srvbwrid = resource.getId("asset_id = '" + aicSiteId + "/Server1' AND resource_name = 'Bandwidth'");
- if (srvbwrid == null)
- return false;
-
- where = "resource_id = " + srvbwrid + " AND resource_union_id = '" + serviceInstanceId +
- "' AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "' AND lt_used = " + speedKbps;
- if (!allocationItem.exists(where))
- return false;
-
- Long srvconrid = resource.getId("asset_id = '" + aicSiteId + "/Server1' AND resource_name = 'Connection'");
- if (srvconrid == null)
- return false;
-
- where = "resource_id = " + srvconrid + " AND resource_union_id = '" + serviceInstanceId +
- "' AND resource_set_id = '" + serviceInstanceId + "/" + changeNumber + "' AND lt_used = 1";
- if (!allocationItem.exists(where))
- return false;
-
- return true;
- }
-
- public boolean serviceCorrectInDb(
- String serviceInstanceId,
- String endPointPosition,
- String status,
- int changeNumber,
- long speedKbps) {
- String where = "service_instance_id = '" + serviceInstanceId + "' AND service_status = '" + status +
- "' AND service_change_number = " + changeNumber;
- if (!serviceResource.exists(where))
- return false;
-
- where = "resource_union_id = '" + serviceInstanceId + "/" + endPointPosition + "' AND resource_set_id = '" +
- serviceInstanceId + "/" + endPointPosition + "/" + changeNumber + "' AND lt_used = " + speedKbps;
- if (!allocationItem.exists(where))
- return false;
-
- return true;
- }
-
public void setTestDb(TestDb testDb) {
this.testDb = testDb;
}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java
deleted file mode 100644
index 4dee2d61..00000000
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestIsAvailable.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package jtest.org.onap.ccsdk.sli.adaptors.ra;
-
-import org.junit.Assert;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:test-context.xml" })
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestIsAvailable {
-
- private static final Logger log = LoggerFactory.getLogger(TestIsAvailable.class);
-
- @Autowired(required = true)
- private ResourceAllocator resourceAllocator;
-
- @Autowired(required = true)
- private DataSetup dataSetup;
-
- @Test
- public void test001() throws Exception {
- String t = "001";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test successful response - all resources available");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test002() throws Exception {
- String t = "002";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - request very big number that is above the limits");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("960000"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test003() throws Exception {
- String t = "003";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - PROV check for VPE");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "---", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("0"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test004() throws Exception {
- String t = "004";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - PROV check for VPLSPE");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "---", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("0"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test005() throws Exception {
- String t = "005";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - VPE not found in DB");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("0"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test006() throws Exception {
- String t = "006";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - VPLSPE not found in DB");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("0"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test007() throws Exception {
- String t = "007";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - test max available speed calculation");
-
- String service1 = "isAvailable" + t + "/service1";
- String existingService1 = "isAvailable" + t + "/existing-service1";
- String existingService2 = "isAvailable" + t + "/existing-service2";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv127", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(existingService1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1",
- "MTSNJA4LCP1/Server1");
- dataSetup.setupService(existingService2, "Active", 3, 100000, "mtanjrsv127", "mtsnj303vr1",
- "MTSNJA4LCP1/Server1");
- dataSetup.setupService(existingService2, "Pending", 4, 500000, "mtanjrsv127", "mtsnj303vr1",
- "MTSNJA4LCP1/Server1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("260000"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test008() throws Exception {
- String t = "008";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test capacity not found - test server limit depending on number of connections");
-
- String service1 = "isAvailable" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv127", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 13; i++)
- dataSetup.setupService("isAvailable" + t + "/existing-service" + i, "Active", 2, 20000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- String maxAvailableSpeed = ctx.getAttribute("tmp.resource-allocator-output.max-available-speed");
- String speedUnit = ctx.getAttribute("tmp.resource-allocator-output.speed-unit");
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " + maxAvailableSpeed);
- log.info(" tmp.resource-allocator-output.speed-unit: " + speedUnit);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(maxAvailableSpeed.equals("340000"));
- Assert.assertTrue(speedUnit.equals("kbps"));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test009() throws Exception {
- String t = "009";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test successful response - no service instance id in input - all resources available");
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- }
-
- @Test
- public void test010() throws Exception {
- String t = "010";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test input validations - no aic-site-id in input");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
-
- try {
- resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "tmp.resource-allocator.aic-site-id is required in ResourceAllocator"));
- return;
- }
- Assert.fail("SvcLogicException expected");
- }
-
- @Test
- public void test011() throws Exception {
- String t = "011";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test input validations - speed not a number in input");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.speed", "nnnnn");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- try {
- resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals("Invalid tmp.resource-allocator.speed. Must be a number."));
- return;
- }
- Assert.fail("SvcLogicException expected");
- }
-
- @Test
- public void test012() throws Exception {
- String t = "012";
- log.info("============== isAvailable " + t + " ================================");
- log.info("=== Test input validations - speed-unit missing in input");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- try {
- resourceAllocator.isAvailable("NetworkCapacity", null, null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "tmp.resource-allocator.speed-unit is required in ResourceAllocator"));
- return;
- }
- Assert.fail("SvcLogicException expected");
- }
-}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java
new file mode 100644
index 00000000..6564dc3d
--- /dev/null
+++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestLockHelper.java
@@ -0,0 +1,59 @@
+package jtest.org.onap.ccsdk.sli.adaptors.ra;
+
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.sli.adaptors.lock.comp.LockHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = { "classpath:test-context.xml" })
+@FixMethodOrder(MethodSorters.NAME_ASCENDING)
+public class TestLockHelper {
+
+ private static final Logger log = LoggerFactory.getLogger(TestLockHelper.class);
+
+ @Autowired
+ private LockHelper lockHelper;
+
+ @Test
+ public void test1() throws Exception {
+ LockThread t1 = new LockThread("req1");
+ LockThread t2 = new LockThread("req2");
+ LockThread t3 = new LockThread("req3");
+
+ t1.start();
+ t2.start();
+ t3.start();
+
+ t1.join();
+ t2.join();
+ t3.join();
+ }
+
+ private class LockThread extends Thread {
+ private String requester;
+
+ public LockThread(String requester) {
+ this.requester = requester;
+ }
+
+ @Override
+ public void run() {
+ lockHelper.lock("resource1", requester, 20);
+
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ log.warn("Thread interrupted: " + e.getMessage(), e);
+ }
+
+ lockHelper.unlock("resource1", false);
+ }
+ }
+}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java
deleted file mode 100644
index 435f4aaa..00000000
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQuery.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package jtest.org.onap.ccsdk.sli.adaptors.ra;
-
-import org.junit.Assert;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:test-context.xml" })
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestQuery {
-
- private static final Logger log = LoggerFactory.getLogger(TestQuery.class);
-
- @Autowired(required = true)
- private ResourceAllocator resourceAllocator;
-
- @Autowired(required = true)
- private DataSetup dataSetup;
-
- @Test
- public void test001() throws Exception {
- String t = "001";
- log.info("============== query " + t + " ================================");
- log.info("=== Test reading assigned resources (subinterface-id, vlan-id-inner)");
-
- String service1 = "ICOREPVC" + t + "-1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-model", "L3AVPN-EVC");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
- ctx.setAttribute("tmp.resource-allocator.vpn-id", "123");
- ctx.setAttribute("tmp.resource-allocator.vrf-required", "false");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000));
-
- st = resourceAllocator.query("NetworkCapacity", true, null, service1, "end-point", null, ctx);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertEquals(ctx.getAttribute("end-point.subinterface-id"), "100");
- Assert.assertEquals(ctx.getAttribute("end-point.vlan-id-inner"), "2");
- Assert.assertEquals(ctx.getAttribute("end-point.vpe-name"), "mtanjrsv126");
- Assert.assertEquals(ctx.getAttribute("end-point.affinity-link"), "1");
- }
-}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java
deleted file mode 100644
index 62102254..00000000
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestRelease.java
+++ /dev/null
@@ -1,430 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package jtest.org.onap.ccsdk.sli.adaptors.ra;
-
-import org.junit.Assert;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:test-context.xml" })
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestRelease {
-
- private static final Logger log = LoggerFactory.getLogger(TestRelease.class);
-
- @Autowired(required = true)
- private ResourceAllocator resourceAllocator;
-
- @Autowired(required = true)
- private DataSetup dataSetup;
-
- @Test
- public void test001() throws Exception {
- String t = "001";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - cancel - new start");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test002() throws Exception {
- String t = "002";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - cancel - change");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 3, 400000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test003() throws Exception {
- String t = "003";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - cancel - active there, but no pending - should do nothing and return success");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- }
-
- @Test
- public void test004() throws Exception {
- String t = "004";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - cancel - nothing in DB - should return success");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test005() throws Exception {
- String t = "005";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - activate - new start");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Activate");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- }
-
- @Test
- public void test006() throws Exception {
- String t = "006";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - actovate - change");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 3, 400000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Activate");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 3, 400000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
- }
-
- @Test
- public void test007() throws Exception {
- String t = "007";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - activate - active there, but no pending - should do nothing and return success");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Activate");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- }
-
- @Test
- public void test008() throws Exception {
- String t = "008";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - activate - nothing in DB - should return success");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Activate");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test009() throws Exception {
- String t = "009";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - disconnect - only pending in DB");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test010() throws Exception {
- String t = "010";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - disconnect - only active in DB");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test011() throws Exception {
- String t = "011";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - disconnect - both active and pending in DB");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "Pending", 3, 400000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test012() throws Exception {
- String t = "012";
- log.info("============== release " + t + " ================================");
- log.info("=== Test release - disconnect - nothing in DB - should return success");
-
- String service1 = "release" + t + "/service1";
-
- dataSetup.cleanup();
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Disconnect");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- QueryStatus st = resourceAllocator.release("NetworkCapacity", null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test013() throws Exception {
- String t = "013";
- log.info("============== release " + t + " ================================");
- log.info("=== Test input validations - request-type missing in input");
-
- String service1 = "release" + t + "/service1";
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- try {
- resourceAllocator.release("NetworkCapacity", null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "tmp.resource-allocator.request-type is required in ResourceAllocator"));
- return;
- }
- Assert.fail("SvcLogicException expected");
- }
-
- @Test
- public void test014() throws Exception {
- String t = "014";
- log.info("============== release " + t + " ================================");
- log.info("=== Test input validations - invalid request-type in input");
-
- String service1 = "release" + t + "/service1";
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "xxxxx");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
-
- try {
- resourceAllocator.release("NetworkCapacity", null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "Invalid tmp.resource-allocator.request-type: xxxxx. Supported values are Cancel, Activate, Disconnect."));
- return;
- }
- Assert.fail("SvcLogicException expected");
- }
-
- @Test
- public void test015() throws Exception {
- String t = "015";
- log.info("============== release " + t + " ================================");
- log.info("=== Test input validations - missing service-instance-id in input");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Cancel");
-
- try {
- resourceAllocator.release("NetworkCapacity", null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "tmp.resource-allocator.service-instance-id is required in ResourceAllocator"));
- return;
- }
- Assert.fail("SvcLogicException expected");
- }
-}
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 a4ee5254..c4200751 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,51 +1,58 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
package jtest.org.onap.ccsdk.sli.adaptors.ra;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
+import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
+import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity;
+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.util.str.StrUtil;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
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 {
private static final Logger log = LoggerFactory.getLogger(TestReserve.class);
+ 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"};
+
+
+ @Autowired
+ public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
+ this.jdbcTemplate = jdbcTemplate;
+ }
+
@Autowired(required = true)
private ResourceAllocator resourceAllocator;
+ /*
+ * @Autowired(required = true) private ResourceAllocatorApi resourceAllocatorApi;
+ */
+
@Autowired(required = true)
private DataSetup dataSetup;
@@ -55,627 +62,576 @@ public class TestReserve {
log.info("============== reserve " + t + " ================================");
log.info("=== Test successful response - new start - all resources available");
- String service1 = "reserve" + t + "/service1";
+ // String service1 = "reserve" + t + "/service1";
dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ TestTable resource = new TestTable(jdbcTemplate, "RESOURCE", "resource_id", RESOURCE_COLUMNS);
+ TestTable allocationItem =
+ new TestTable(jdbcTemplate, "ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 300000));
- }
-
- @Test
- public void test002() throws Exception {
- String t = "002";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - new start supp - all resources available");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
SvcLogicContext ctx = new SvcLogicContext();
- // ctx.setAttribute("tmp.resource-allocator.request-type", "New"); - Default is New
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "400");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+ ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
+ ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-type", "VNF");
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ ctx.setAttribute("ra-input.reservation-target-data.max-vpe-bandwidth-mbps", "5000");
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
- }
-
- @Test
- public void test003() throws Exception {
- String t = "003";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - change - all resources available");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "400");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
- }
- @Test
- public void test004() throws Exception {
- String t = "004";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - change supp - all resources available");
-
- String service1 = "reserve" + t + "/service1";
+ resource.print();
+ allocationItem.print();
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "500");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ ctx.setAttribute("ra-input.reservation-target-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-target-data.service-speed-unit", "Mbps");
+ ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
+ ctx.setAttribute("ra-input.reservation-target-type", "Port");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 4, 500000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
- @Test
- public void test005() throws Exception {
- String t = "005";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - change - check that hard limits are applied, not soft for change");
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "SI");
+ ctx.setAttribute("ra-input.reservation-entity-id", "ICOREPVCID-123456");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed", "100");
+ ctx.setAttribute("ra-input.reservation-entity-data.service-speed-unit", "Mbps");
- String service1 = "reserve" + t + "/service1";
+ ctx.setAttribute("ra-input.reservation-target-data.vnf-type", "VPE");
+ ctx.setAttribute("ra-input.reservation-target-data.vpe-name", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-id", "mdt300vpe54");
+ ctx.setAttribute("ra-input.reservation-target-type", "AffinityLink");
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1200000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "kbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 1200000));
- }
-
- @Test
- public void test006() throws Exception {
- String t = "006";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - new start");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Gbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test007() throws Exception {
- String t = "007";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - new start supp");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Pending", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "2000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 200000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test008() throws Exception {
- String t = "008";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - change");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "2000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test009() throws Exception {
- String t = "009";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test capacity not found - change supp");
-
- String service1 = "reserve" + t + "/service1";
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupService(service1, "Active", 2, 200000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 400000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "2000");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 200000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 400000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 4));
- }
-
- @Test
- public void test010() throws Exception {
- String t = "010";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test border condition - connection limit - new start - adding connection " +
- "when we are on the limit should fail");
-
- String service1 = "reserve" + t + "/service1";
+ resource.print();
+ allocationItem.print();
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 40; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 40; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
-
- @Test
- public void test011() throws Exception {
- String t = "011";
- log.info("============== reserve " + t + " ================================");
- log.info(
- "=== Test border condition - connection limit - new start supp should succeed as no new connection being added");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 39; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 39; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ /* 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");
- dataSetup.setupService(service1, "Pending", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 2, 1000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "5");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 2));
- }
-
- @Test
- public void test012() throws Exception {
- String t = "012";
- log.info("============== reserve " + t + " ================================");
- log.info(
- "=== Test border condition - connection limit - change should succeed as no new connection being added");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 39; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 39; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Active", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "5");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
+ /* Query Using ReservationTargetId using ServiceLogicContext */
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "ADIG");
+ ctx.setAttribute("ra-input.reservation-target-id", "ICORESITEID-123456");
+ ctx.setAttribute("ra-input.reservation-target-type", "Port");
+ ctx.setAttribute("ra-input.resource-name", "Bandwidth");
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
- }
- @Test
- public void test013() throws Exception {
- String t = "013";
- log.info("============== reserve " + t + " ================================");
- log.info(
- "=== Test border condition - connection limit - change supp should succeed as no new connection being added");
+ log.info("======================== Query Using ResourceEntity==============================");
+ /* Query Using ResourceEntity bean */
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "ICOREPVCID-123456";
+ sd.resourceEntityType = "SI";
- String service1 = "reserve" + t + "/service1";
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- for (int i = 1; i <= 39; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- for (int i = 1; i <= 39; i += 4)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Pending", 3, 1000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ ResourceRequest rr = new ResourceRequest();
+ rr.serviceModel = "ADIG";
+ rr.resourceName = "cust-vlan-id";
+ rr.requestType = "New";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
- dataSetup.setupService(service1, "Active", 2, 1000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
- dataSetup.setupService(service1, "Pending", 3, 5000, "mtanjrsv126", "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ List<ResourceResponse> rsList = new ArrayList<>();
+ resourceAllocator.query(sd, null, null, rsList);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 3, 5000));
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "Change");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "10");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ log.info("======================== release Using ResourceEntity==============================");
+ rsList = new ArrayList<>();
+ AllocationStatus status = resourceAllocator.release(sd);
+ Assert.assertTrue(status == AllocationStatus.Success);
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- log.info("Result: " + st);
+ log.info("======================== Query Using ResourceEntity==============================");
+ rsList = new ArrayList<>();
+ resourceAllocator.query(sd, null, null, rsList);
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Active", 2, 1000));
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 4, 10000));
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, 3));
- }
-
- @Test
- public void test014() throws Exception {
- String t = "014";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test input validations - invalid request-type in input");
- String service1 = "reserve" + t + "/service1";
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "xxxxx");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "10");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- try {
- resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
- } catch (SvcLogicException e) {
- Assert.assertTrue(e.getMessage().equals(
- "Invalid tmp.resource-allocator.request-type: xxxxx. Supported values are New, Change."));
- return;
- }
- Assert.fail("SvcLogicException expected");
}
@Test
- public void test015() throws Exception {
- String t = "015";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test server bw limit depends on number of servers - limit is 960Mbps for 1 server, 1920 for 2");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1200");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1200000));
- }
-
- @Test
- public void test016() throws Exception {
- String t = "016";
+ public void test002() throws Exception {
+ String t = "002";
log.info("============== reserve " + t + " ================================");
- log.info("=== Test resource threshold output");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "1605");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ log.info("=== Test successful response - new start - all resources available");
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+ Map<String, String> data = new HashMap<>();
+ data.put("service-speed", "100");
+ data.put("service-speed-unit", "Mbps");
- log.info("Result: " + st);
- for (String key : ctx.getAttributeKeySet())
- if (key.startsWith("tmp.resource-allocator-output"))
- log.info(" " + key + ": " + ctx.getAttribute(key));
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "ICOREPVCID-123456";
+ sd.resourceEntityType = "SI";
+ sd.data = data;
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 1605000));
- }
+ data = new HashMap<>();
+ data.put("vnf-type", "VPE");
+ data.put("vpe-name", "mdt300vpe54");
+ data.put("max-vpe-bandwidth-mbps", "5000");
- @Test
- public void test017() throws Exception {
- String t = "017";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test if evc_count lookup in MAX_SERVER_SPEED depends on the number of primary servers.");
- log.info("=== For 10 existing EVC, it should take the first row, not the second (see data.sql).");
- log.info("=== Applied limit should be 1920Mbps, not 1680Mbps.");
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "mdt300vpe54";
+ rt.resourceTargetType = "VNF";
+ rt.data = data;
- String service1 = "reserve" + t + "/service1";
+ ResourceRequest rr = new ResourceRequest();
+ rr.serviceModel = "ADIG";
+ // rr.resourceName = "cust-vlan-id";
+ rr.requestType = "New";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
+ List<ResourceResponse> rsList = new ArrayList<>();
- for (int i = 1; i <= 10; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 100000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
+ resourceAllocator.reserve(sd, rt, rr, rsList);
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "800"); // 10*100Mbps existing + 800 = 1800
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<>();
+ resourceAllocator.query(sd, null, rr, rsList);
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb("mtanjrsv126", "MTSNJA4LCP1", service1, "Pending", 1, 800000));
}
-
+
+
@Test
- public void test018() throws Exception {
- String t = "018";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test if evc_count lookup in MAX_SERVER_SPEED depends on the number of primary servers.");
- log.info("=== For 11 existing EVC, it should take the second row (see data.sql).");
- log.info("=== Applied limit should be 1680Mbps. We have 11*100 + 700, so this should fail.");
-
- String service1 = "reserve" + t + "/service1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
- dataSetup.setupVplspePort("MTSNJA4LCP1", "mtsnj303vr1", "xe-0/0/2", "PROV", null);
- dataSetup.setupPserver("server1", "MTSNJA4LCP1");
- dataSetup.setupPserver("server2", "MTSNJA4LCP1");
- dataSetup.setupPserver("server3", "MTSNJA4LCP1");
- dataSetup.setupPserver("server4", "MTSNJA4LCP1");
-
- for (int i = 1; i <= 11; i++)
- dataSetup.setupService("reserve" + t + "/existing-service" + i, "Active", 2, 100000, "mtanjrsv126",
- "mtsnj303vr1", "MTSNJA4LCP1/Server1");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "700"); // 11*100Mbps existing + 700 = 1800
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- log.info("Result: " + st);
- log.info(" tmp.resource-allocator-output.max-available-speed: " +
- ctx.getAttribute("tmp.resource-allocator-output.max-available-speed"));
- log.info(" tmp.resource-allocator-output.speed-unit: " +
- ctx.getAttribute("tmp.resource-allocator-output.speed-unit"));
-
- log.info("Result: " + st);
-
- Assert.assertTrue(st == QueryStatus.NOT_FOUND);
- Assert.assertTrue(dataSetup.serviceNotInDb(service1, null, null));
- }
+ public void test003() throws Exception {
+ String t = "003";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Cust";
+ //rr.requestType = "New";
+ //rr.rangeMaxOverride = 5;
+ //rr.rangeMinOverride = 5;
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ }
+
+
+
+
+ @Test
+ public void test004() throws Exception {
+ String t = "004";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VNF";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+ List<ResourceRequest> rrs = new ArrayList<ResourceRequest>();
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Cust";
+ rrs.add(rr);
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Core1";
+ rrs.add(rr);
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ rr.resourceName = "VPE-Core2";
+ rrs.add(rr);
+
+
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ //resourceAllocator.reserve(sd, rt, rrs, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ }
+
+
+ @Test
+ public void test005() throws Exception {
+ String t = "005";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ //String service1 = "reserve" + t + "/service1";
+
+ 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);
+
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Cust");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ ctx.setAttribute("ra-input.resource-name", "cust-vlan-id");
+
+
+ QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ resource.print();
+ allocationItem.print();
+
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core1");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
+
+
+ st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
+
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ resource.print();
+ allocationItem.print();
+
+ ctx = new SvcLogicContext();
+ ctx.setAttribute("ra-input.service-model", "MY-SERV-MODEL-1");
+ ctx.setAttribute("ra-input.check-only", "false");
+ ctx.setAttribute("ra-input.reservation-entity-type", "VPE-Core2");
+ ctx.setAttribute("ra-input.reservation-entity-id", "gblond2003me6");
+
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+
+ 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);
+
+ 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");
+ ctx.setAttribute("ra-input.reservation-target-id", "MDTWNJ21A5");
+ ctx.setAttribute("ra-input.reservation-target-type", "Site");
+ ctx.setAttribute("ra-input.resource-name", "vlan-id-inner");
+
+ st = resourceAllocator.query("NetworkCapacity", false, null, null, null, null, ctx);
+ Assert.assertTrue(st == QueryStatus.SUCCESS);
+
+ log.info("======================== Query Using ResourceEntity==============================");
+ /*Query Using ResourceEntity bean*/
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE-Core1";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL-1";
+ rr.resourceName = "vlan-id-inner";
+ rr.requestType = "New";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.query(sd, null, null, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ /*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);
+
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });*/
+
+ }
+
+
+
+ @Test
+ public void test006() throws Exception {
+ String t = "006";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ ResourceEntity sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE-Cust";
+
+ ResourceTarget rt = new ResourceTarget();
+ 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<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ }
+
+ @Test
+ public void test007() throws Exception {
+ String t = "007";
+ log.info("============== reserve " + t + " ================================");
+ log.info("=== Test successful response - new start - all resources available");
+
+ 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 = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ ResourceTarget rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ ResourceRequest rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-outer";
+ rr.endPointPosition="VPE-Cust";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ List <ResourceResponse> rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ //VPE-Core1
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-filter";
+ rr.endPointPosition="VPE-Core1";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+
+ //VPE-Core2
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-filter";
+ rr.endPointPosition="VPE-Core2";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+
+ //VPE-Core3
+ sd = new ResourceEntity();
+ sd.resourceEntityId = "gblond2003me6";
+ sd.resourceEntityType = "VPE";
+ sd.resourceEntityVersion = "1";
+
+ rt = new ResourceTarget();
+ rt.resourceTargetId = "MDTWNJ21A5";
+ rt.resourceTargetType = "Site";
+
+
+ rr= new ResourceRequest();
+ rr.serviceModel = "MY-SERV-MODEL";
+ //rr.resourceName = "vlan-id-filter";
+ rr.endPointPosition="VPE-Core3";
+ rr.rangeMaxOverride = -1;
+ rr.rangeMinOverride = -1;
+
+
+ rsList = new ArrayList<ResourceResponse>();
+ resourceAllocator.reserve(sd, rt, rr, rsList);
+
+ rsList.forEach(r -> {
+ StrUtil.info(log, r);
+ });
+
+ resource.print();
+ allocationItem.print();
+
+ log.info("======================== Query + t ==============================");
+ rsList = new ArrayList<org.onap.ccsdk.sli.adaptors.ra.comp.ResourceResponse>();
+ resourceAllocator.query(sd, null, rr, rsList);
+
+ rsList.forEach(r -> {
+ 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);
+
+ }
}
diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java
deleted file mode 100644
index 7ae16976..00000000
--- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestReserve2.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package jtest.org.onap.ccsdk.sli.adaptors.ra;
-
-import org.junit.Assert;
-import org.junit.FixMethodOrder;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.MethodSorters;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus;
-import org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = { "classpath:test-context.xml" })
-@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestReserve2 {
-
- private static final Logger log = LoggerFactory.getLogger(TestReserve2.class);
-
- @Autowired(required = true)
- private ResourceAllocator resourceAllocator;
-
- @Autowired(required = true)
- private DataSetup dataSetup;
-
- @Test
- public void test001() throws Exception {
- String t = "001";
- log.info("============== reserve " + t + " ================================");
- log.info("=== Test successful response - new start - all resources available");
-
- String service1 = "ICOREPVC" + t + "-1";
-
- dataSetup.cleanup();
- dataSetup.setupVpePort("MTSNJA4LCP1", "mtanjrsv126", "ae0", "PROV", "juniper-vpe-image");
-
- SvcLogicContext ctx = new SvcLogicContext();
- ctx.setAttribute("tmp.resource-allocator.request-type", "New");
- ctx.setAttribute("tmp.resource-allocator.service-model", "L3AVPN-EVC");
- ctx.setAttribute("tmp.resource-allocator.service-instance-id", service1);
- ctx.setAttribute("tmp.resource-allocator.speed", "300");
- ctx.setAttribute("tmp.resource-allocator.speed-unit", "Mbps");
- ctx.setAttribute("tmp.resource-allocator.aic-site-id", "MTSNJA4LCP1");
- ctx.setAttribute("tmp.resource-allocator.vpn-id", "123");
- ctx.setAttribute("tmp.resource-allocator.vrf-required", "false");
-
- QueryStatus st = resourceAllocator.reserve("NetworkCapacity", null, null, null, ctx);
-
- Assert.assertTrue(st == QueryStatus.SUCCESS);
- Assert.assertTrue(dataSetup.serviceCorrectInDb(service1, "VPE-Cust", "Pending", 1, 300000));
- }
-}
diff --git a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestDb.java b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestDb.java
index 6446240d..6446240d 100644
--- a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestDb.java
+++ b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestDb.java
diff --git a/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java
new file mode 100644
index 00000000..e2541f39
--- /dev/null
+++ b/resource-assignment/provider/src/test/java/jtest/util/org/onap/ccsdk/sli/adaptors/ra/TestTable.java
@@ -0,0 +1,135 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package jtest.util.org.onap.ccsdk.sli.adaptors.ra;
+
+import java.sql.ResultSetMetaData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.support.rowset.SqlRowSet;
+
+public class TestTable {
+
+ private String tableName;
+ private String[] columnList;
+ private String idName;
+
+ private String insertSql;
+
+ private JdbcTemplate jdbcTemplate;
+
+ private static final Logger log = LoggerFactory.getLogger(TestTable.class);
+
+ public TestTable(JdbcTemplate jdbcTemplate, String tableName, String idName, String... columnList) {
+ this.jdbcTemplate = jdbcTemplate;
+ this.tableName = tableName;
+ this.idName = idName;
+ this.columnList = columnList;
+ createInsertSql();
+ }
+
+ public TestTable(JdbcTemplate jdbcTemplate, String tableName) {
+ this.jdbcTemplate = jdbcTemplate;
+ this.tableName = tableName;
+ }
+
+ private void createInsertSql() {
+ StringBuilder ss = new StringBuilder();
+ ss.append("INSERT INTO ").append(tableName).append(" (");
+ for (String s : columnList)
+ ss.append(s).append(", ");
+ ss.setLength(ss.length() - 2);
+ ss.append(") VALUES (");
+ for (int i = 0; i < columnList.length; i++)
+ ss.append("?, ");
+ ss.setLength(ss.length() - 2);
+ ss.append(")");
+ insertSql = ss.toString();
+ }
+
+ public void add(Object... values) {
+ jdbcTemplate.update(insertSql, values);
+ }
+
+ public void update(String updateSql, Object... values) {
+ jdbcTemplate.update(updateSql, values);
+ }
+
+ public long getLastId() {
+ return jdbcTemplate.queryForObject("SELECT max(" + idName + ") FROM " + tableName, Long.class);
+ }
+
+ public Long getId(String where) {
+ String selectSql = "SELECT " + idName + " FROM " + tableName + " WHERE " + where;
+ SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql);
+ if (rs.first())
+ return rs.getLong(idName);
+ return null;
+ }
+
+ public Object getColumn(String columnName, String where) {
+ String selectSql = "SELECT " + columnName + " FROM " + tableName + " WHERE " + where;
+ SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql);
+ if (rs.first())
+ return rs.getObject(columnName);
+ return null;
+ }
+
+ public boolean exists(String where) {
+ String selectSql = "SELECT * FROM " + tableName + " WHERE " + where;
+ SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql);
+ return rs.first();
+ }
+
+ public void delete(String where) {
+ jdbcTemplate.update("DELETE FROM " + tableName + " WHERE " + where);
+ }
+
+ public void print() {
+
+ jdbcTemplate.query("SELECT * FROM " + tableName,
+ (rs, rowNum) -> {
+ String row = "Table Data for " + tableName +"\n";
+ String col = "";
+
+ final ResultSetMetaData meta = rs.getMetaData();
+ final int columnCount = meta.getColumnCount();
+
+ do {
+ col = "";
+
+ for (int column = 1; column <= columnCount; ++column) {
+ Object obj = rs.getObject(column);
+ if(!rs.wasNull()) {
+ col = col + obj + ",";
+ }
+ }
+ col = col.trim().length() == 0 ? "" : (col.trim().substring(0, col.trim().length() - 1));
+ row = row + col + "\n";
+ } while (rs.next());
+
+ return row;
+ }).forEach(row -> {
+ log.info(row);
+ });
+ }
+} \ No newline at end of file
diff --git a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java b/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java
deleted file mode 100644
index cda7302c..00000000
--- a/resource-assignment/provider/src/test/java/jtest/util/org/openecomp/sdnc/ra/TestTable.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package jtest.util.org.onap.ccsdk.sli.adaptors.ra;
-
-import org.springframework.jdbc.core.JdbcTemplate;
-import org.springframework.jdbc.support.rowset.SqlRowSet;
-
-public class TestTable {
-
- private String tableName;
- private String[] columnList;
- private String idName;
-
- private String insertSql;
-
- private JdbcTemplate jdbcTemplate;
-
- public TestTable(JdbcTemplate jdbcTemplate, String tableName, String idName, String... columnList) {
- this.jdbcTemplate = jdbcTemplate;
- this.tableName = tableName;
- this.idName = idName;
- this.columnList = columnList;
- createInsertSql();
- }
-
- private void createInsertSql() {
- StringBuilder ss = new StringBuilder();
- ss.append("INSERT INTO ").append(tableName).append(" (");
- for (String s : columnList)
- ss.append(s).append(", ");
- ss.setLength(ss.length() - 2);
- ss.append(") VALUES (");
- for (int i = 0; i < columnList.length; i++)
- ss.append("?, ");
- ss.setLength(ss.length() - 2);
- ss.append(")");
- insertSql = ss.toString();
- }
-
- public void add(Object... values) {
- jdbcTemplate.update(insertSql, values);
- }
-
- public long getLastId() {
- return jdbcTemplate.queryForObject("SELECT max(" + idName + ") FROM " + tableName, Long.class);
- }
-
- public Long getId(String where) {
- String selectSql = "SELECT " + idName + " FROM " + tableName + " WHERE " + where;
- SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql);
- if (rs.first())
- return rs.getLong(idName);
- return null;
- }
-
- public boolean exists(String where) {
- String selectSql = "SELECT * FROM " + tableName + " WHERE " + where;
- SqlRowSet rs = jdbcTemplate.queryForRowSet(selectSql);
- return rs.first();
- }
-
- public void delete(String where) {
- jdbcTemplate.update("DELETE FROM " + tableName + " WHERE " + where);
- }
-}
diff --git a/resource-assignment/provider/src/test/resources/homing-req.json b/resource-assignment/provider/src/test/resources/homing-req.json
deleted file mode 100644
index 1f061eca..00000000
--- a/resource-assignment/provider/src/test/resources/homing-req.json
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-{
- "input":{
- "sdnc-homing-header":{
- "svc-request-id":"omx-123",
- "svc-action":"homing"
- },
- "request-information":{
- "request-id":"mso-1234",
- "request-action":"GetAicNodesRequest",
- "source":"OMX",
- "list-length":1
- },
- "homing-request-information":{
- "service-type":"SDN-ETHERNET-INTERNET",
- "global-customer-id":"custid-123",
- "customer-location":{
- "lata":332
- }
- },
- "homing-other-information":{
- "bandwidth-value":150,
- "bandwidth-units":"Mbps"
- }
- }
-}
diff --git a/resource-assignment/provider/src/test/resources/param.txt b/resource-assignment/provider/src/test/resources/param.txt
deleted file mode 100755
index a20ac909..00000000
--- a/resource-assignment/provider/src/test/resources/param.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-isAvailable:
- Input in ctx:
- tmp.resource-allocator.aic-site-id
- tmp.resource-allocator.speed
- tmp.resource-allocator.speed-unit
- Output in ctx:
- tmp.resource-allocator.max-available-speed
- tmp.resource-allocator.speed-unit
- Return:
- SUCCESS – capacity available
- NOT_FOUND – capacity not available
- Error message in: error-message, error-code
- FAILURE – the check has failed (data error, code defect, etc)
- Error message in: error-message, error-code
-
-Reserve:
- Input in ctx:
- tmp.resource-allocator.aic-site-id
- tmp.resource-allocator.speed
- tmp.resource-allocator.speed-unit
- tmp.resource-allocator.service-instance-id
- tmp.resource-allocator.request-type { New, Change }
- Output in ctx:
- tmp.resource-allocator-output.max-available-speed
- tmp.resource-allocator-output.speed-unit
- Return:
- SUCCESS – capacity available
- NOT_FOUND – capacity not available
- Error message in: error-message, error-code
- FAILURE – the check has failed (data error, code defect, etc)
- Error message in: error-message, error-code
-
-Release:
- Input in ctx:
- tmp.resource-allocator.service-instance-id
- tmp.resource-allocator.request-type { Activate, Cancel, Disconnect }
- Return:
- SUCCESS – capacity available
- FAILURE – the check has failed (data error, code defect, etc)
- Error message in: error-message, error-code
-
-
-Plugin name: org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator
-Resource: NetworkCapacity
diff --git a/resource-assignment/provider/src/test/resources/sql/data.sql b/resource-assignment/provider/src/test/resources/sql/data.sql
index 5fd4c757..681a9c45 100644
--- a/resource-assignment/provider/src/test/resources/sql/data.sql
+++ b/resource-assignment/provider/src/test/resources/sql/data.sql
@@ -118,3 +118,69 @@ INSERT INTO PARAMETERS (name, value, category, memo)
VALUES ('homing.pserver.sparing.ratio', '1:1', 'homing',
'Ratio of primary to backup servers within any of the AIC sites. Used in RA to calculate the max allowed bw in an AIC site.');
+INSERT INTO RESOURCE_RULE (
+ resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression,
+ allocation_expression, soft_limit_expression, hard_limit_expression)
+VALUES (
+ 'PortBandwidth', 'ADIG', 'VPE', 'true', 'Port', 'true',
+ 'service-speed-mbps', 'service-speed-mbps', 'service-speed-mbps');
+
+INSERT INTO RESOURCE_RULE (
+ resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression,
+ allocation_expression, soft_limit_expression, hard_limit_expression)
+VALUES (
+ 'Bandwidth', 'ADIG', 'VPE', 'true', 'VNF', 'vnf-type = "VPE"',
+ 'service-speed-mbps', '0.5 * max-vpe-bandwidth-mbps', '0.9 * max-vpe-bandwidth-mbps');
+
+
+INSERT INTO RESOURCE_RULE (
+ resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression,
+ allocation_expression, soft_limit_expression, hard_limit_expression)
+VALUES (
+ 'Bandwidth', 'ADIG', 'VPE', 'true', 'AffinityLink', 'true',
+ 'service-speed-mbps', '9999999999', '9999999999');
+
+INSERT INTO RESOURCE_RULE (
+ resource_name, service_model, end_point_position, service_expression, equipment_level, equipment_expression,
+ allocation_expression, soft_limit_expression, hard_limit_expression)
+VALUES (
+ 'Connection', 'ADIG', 'VPE', 'true', 'VNF', 'true',
+ '1', '200', '200');
+
+INSERT INTO RANGE_RULE (
+ range_name, service_model, end_point_position, equipment_level, min_value,
+ max_value)
+VALUES (
+ 'cust-vlan-id', 'ADIG', 'VPE', 'VNF', '2', '1000');
+
+INSERT INTO RANGE_RULE (
+ range_name, service_model, end_point_position, equipment_level, min_value,
+ max_value)
+VALUES (
+ 'vlan-id-inner', 'ADIG', 'VPE', 'VNF', '1002', '2000');
+
+
+INSERT INTO RANGE_RULE (
+ range_name, service_model, end_point_position, equipment_level, min_value,
+ max_value)
+VALUES (
+ 'vlan-id-outer', 'MY-SERV-MODEL', 'VPE-Cust', 'Site', '2', '1000');
+
+INSERT INTO RANGE_RULE (
+ range_name, service_model, end_point_position, equipment_level, min_value,
+ max_value)
+VALUES (
+ 'vlan-id-filter', 'MY-SERV-MODEL', 'VPE-Core1', 'Site', '1002', '2000');
+
+INSERT INTO RANGE_RULE (
+ range_name, service_model, end_point_position, equipment_level, min_value,
+ max_value)
+VALUES (
+ 'vlan-id-filter', 'MY-SERV-MODEL', 'VPE-Core2', 'Site', '1002', '2000');
+
+INSERT INTO RANGE_RULE (
+ range_name, service_model, end_point_position, equipment_level, min_value,
+ max_value)
+VALUES (
+ 'vlan-id-filter', 'MY-SERV-MODEL', 'VPE-Core3', 'Site', '400', '600');
+ \ No newline at end of file
diff --git a/resource-assignment/provider/src/test/resources/svc-topology-req.json b/resource-assignment/provider/src/test/resources/svc-topology-req.json
deleted file mode 100644
index ab8afb66..00000000
--- a/resource-assignment/provider/src/test/resources/svc-topology-req.json
+++ /dev/null
@@ -1,195 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-{
- "input":{
- "sdnc-request-header":{
- "svc-request-id":"omx-123",
- "svc-action":"assign"
- },
- "sdnc-topology-additional-data":{
- "svc-vnf-type":"vce"
- },
- "request-information":{
- "request-id":"mso-1234",
- "request-action":"Layer3ServiceActivateRequest",
- "source":"OMX"
- },
- "service-information":{
- "service-type":"SDN-ETHERNET-INTERNET",
- "service-instance-id":"service-instance-123",
- "subscriber-name":"ssb-subscriber"
- },
- "l2-homing-information":{
- "evc-name":"EVC-123",
- "topology":"PointToPoint",
- "preferred-aic-clli":"ATLNGATL001"
- }
- "internet-evc-access-information":{
- "internet-evc-speed-value":"150",
- "internet-evc-speed-units":"Mbps",
- "ip-version":"v6"
- }
- "vr-lan":{
- "routing-protocol":"none",
- {
- "v6-vr-lan-prefix":"string",
- "v6-public-lan-prefixes":{
- "t-provided-v6-lan-public-prefixes":[
- {
- "v6-lan-public-prefix-length":"integer",
- "v6-lan-public-prefix":"string",
- "request-index":"integer"
- }
- ]
- },
- "v6-vr-lan-prefix-length":"integer",
- "v4-vr-lan-prefix-length":"integer",
- "firewall-lite":{
- "v6-firewall-packet-filters":[
- {
- "v6-firewall-prefix-length":"integer",
- "udp-port-list":[
- {
- "port-number":"integer"
- }
- ],
- "tcp-port-list":[
- {
- "port-number":"integer"
- }
- ],
- "v6-firewall-prefix":"string"
- }
- ],
- "v4-firewall-packet-filters":[
- {
- "v4-firewall-prefix-length":"integer",
- "udp-port-list":[
- {
- "port-number":"integer"
- }
- ],
- "tcp-port-list":[
- {
- "port-number":"integer"
- }
- ],
- "v4-firewall-prefix":"string"
- }
- ]
- },
- "v6-vce-wan-address":"string",
- "v4-public-lan-prefixes":{
- "t-provided-v4-lan-public-prefixes":[
- {
- "v4-lan-public-prefix":"string",
- "v4-lan-public-prefix-length":"integer",
- "request-index":"integer"
- }
- ]
- },
- "pat":{
- "v4-pat-default-pool-prefix-length":"integer",
- "v4-pat-pools":[
- {
- "v4-pat-pool-next-hop-address":"string",
- "v4-pat-pool-prefix-length":"integer",
- "v4-pat-pool-prefix":"string"
- }
- ],
- "v4-pat-default-pool-prefix":"string"
- },
- "v4-vce-loopback-address":"string",
- "v4-vr-lan-prefix":"string",
- "dhcp":{
- "v4-dhcp-pools":[
- {
- "v4-dhcp-relay-next-hop-address":"string",
- "excluded-v4-addresses":[
- {
- "excluded-v4-address":"string"
- }
- ],
- "v4-dhcp-pool-prefix":"string",
- "v4-dhcp-relay-gateway-address":"string",
- "v4-dhcp-pool-prefix-length":"integer"
- }
- ],
- "excluded-v4-dhcp-addresses-from-default-pool":[
- {
- "excluded-v4-address":"string"
- }
- ],
- "v6-dhcp-pools":[
- {
- "v6-dhcp-relay-gateway-address":"string",
- "excluded-v6-addresses":[
- {
- "excluded-v6-address":"string"
- }
- ],
- "v6-dhcp-pool-prefix-length":"integer",
- "v6-dhcp-relay-next-hop-address":"string",
- "v6-dhcp-pool-prefix":"string"
- }
- ],
- "v6-dhcp-default-pool-prefix":"string",
- "v6-dhcp-default-pool-prefix-length":"integer",
- "v4-dhcp-default-pool-prefix":"string",
- "excluded-v6-dhcp-addresses-from-default-pool":[
- {
- "excluded-v6-address":"string"
- }
- ],
- "v4-dhcp-default-pool-prefix-length":"integer"
- },
- "nat":{
- "v4-nat-mapping-entries":[
- {
- "v4-nat-external":"string",
- "v4-nat-next-hop-address":"string",
- "v4-nat-internal":"string"
- }
- ]
- },
- "static-routes":{
- "v6-static-routes":[
- {
- "v6-static-route-prefix-length":"integer",
- "v6-next-hop-address":"string",
- "v6-static-route-prefix":"string"
- }
- ],
- "v4-static-routes":[
- {
- "v4-static-route-prefix-length":"integer",
- "v4-static-route-prefix":"string",
- "v4-next-hop-address":"string"
- }
- ]
- }
- }
-
- }
-
- }
-}
diff --git a/resource-assignment/provider/src/test/resources/test-context.xml b/resource-assignment/provider/src/test/resources/test-context.xml
index c3b09a1f..32b54e9e 100644
--- a/resource-assignment/provider/src/test/resources/test-context.xml
+++ b/resource-assignment/provider/src/test/resources/test-context.xml
@@ -4,7 +4,7 @@
openECOMP : SDN-C
================================================================================
Copyright (C) 2017 AT&T Intellectual Property. All rights
- reserved.
+ reserved.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,22 +20,23 @@
============LICENSE_END=========================================================
-->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
- http://www.springframework.org/schema/jdbc
- http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
- ">
+ http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
+ http://www.springframework.org/schema/jdbc
+ http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ ">
<context:annotation-config />
- <!-- JDBC setup -->
+ <!-- JDBC setup -->
- <bean id="test.dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" lazy-init="false">
+ <bean id="test.dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"
+ lazy-init="false" primary="true">
<property name="driverClassName" value="org.h2.Driver" />
<property name="url" value="jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;MODE=MySQL" />
</bean>
@@ -45,10 +46,18 @@
<jdbc:script location="sql/data.sql" />
</jdbc:initialize-database>
- <bean id="rm.jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
+ <bean id="lock.dataSource" class="org.onap.ccsdk.sli.adaptors.util.db.CachedDataSourceWrap">
<property name="dataSource" ref="test.dataSource" />
</bean>
+ <bean id="rm.jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" primary="true">
+ <property name="dataSource" ref="test.dataSource" />
+ </bean>
+
+ <bean id="lock.jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
+ <property name="dataSource" ref="lock.dataSource" />
+ </bean>
+
<bean id="testDb" class="jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestDb">
<property name="jdbcTemplate" ref="rm.jdbcTemplate" />
</bean>
@@ -57,17 +66,10 @@
<property name="testDb" ref="testDb" />
</bean>
- <!-- Utils Configuration -->
-
- <bean id="speedUtil" class="org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil">
- <property name="unitFactor" value="1000" />
- </bean>
-
- <!-- Resource Lock Configuration -->
+ <!-- Resource Lock Configuration -->
<bean id="resourceLockDao" class="org.onap.ccsdk.sli.adaptors.lock.dao.ResourceLockDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- <property name="testing" value="true" />
+ <property name="jdbcTemplate" ref="lock.jdbcTemplate" />
</bean>
<bean id="lockHelper" class="org.onap.ccsdk.sli.adaptors.lock.comp.LockHelperImpl">
@@ -76,7 +78,7 @@
<property name="lockWait" value="5" /> <!-- Seconds -->
</bean>
- <!-- RM Configuration -->
+ <!-- RM Configuration -->
<bean id="resourceJdbcDao" class="org.onap.ccsdk.sli.adaptors.rm.dao.jdbc.ResourceJdbcDaoImpl">
<property name="jdbcTemplate" ref="rm.jdbcTemplate" />
@@ -99,35 +101,10 @@
<bean id="resourceManager" class="org.onap.ccsdk.sli.adaptors.rm.comp.ResourceManagerImpl">
<property name="lockHelper" ref="lockHelper" />
<property name="resourceDao" ref="resourceDao" />
- <property name="applicationId" value="SDNC" />
<property name="lockTimeout" value="600" /> <!-- Seconds -->
</bean>
- <!-- Equipment DAO Configuration -->
-
- <bean id="serverDao" class="org.onap.ccsdk.sli.adaptors.ra.equip.dao.ServerDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- </bean>
-
- <bean id="vpePortDao" class="org.onap.ccsdk.sli.adaptors.ra.equip.dao.VpePortDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- </bean>
-
- <bean id="vplspePortDao" class="org.onap.ccsdk.sli.adaptors.ra.equip.dao.VplspePortDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- </bean>
-
- <!-- Rule DAO Configuration -->
-
- <bean id="maxPortSpeedDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.MaxPortSpeedDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- <property name="speedUtil" ref="speedUtil" />
- </bean>
-
- <bean id="maxServerSpeedDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.MaxServerSpeedDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- <property name="speedUtil" ref="speedUtil" />
- </bean>
+ <!-- Rule DAO Configuration -->
<bean id="resourceRuleDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.ResourceRuleDaoImpl">
<property name="jdbcTemplate" ref="rm.jdbcTemplate" />
@@ -137,161 +114,37 @@
<property name="jdbcTemplate" ref="rm.jdbcTemplate" />
</bean>
- <bean id="vpeLockDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.VpeLockDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- </bean>
-
- <bean id="parameterDao" class="org.onap.ccsdk.sli.adaptors.ra.rule.dao.ParameterDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- </bean>
-
- <!-- Service DAO Configuration -->
-
- <bean id="serviceResourceDao" class="org.onap.ccsdk.sli.adaptors.ra.service.dao.ServiceResourceDaoImpl">
- <property name="jdbcTemplate" ref="rm.jdbcTemplate" />
- </bean>
-
- <!-- ResourceAllocator Configuration -->
-
- <bean id="allocationRequestBuilder" class="org.onap.ccsdk.sli.adaptors.ra.rule.comp.AllocationRequestBuilderImpl">
- <property name="resourceRuleDao" ref="resourceRuleDao" />
- <property name="rangeRuleDao" ref="rangeRuleDao" />
- </bean>
+ <!-- ResourceAllocator Configuration -->
<bean id="resourceAllocator" class="org.onap.ccsdk.sli.adaptors.ra.ResourceAllocator">
- <property name="speedUtil" ref="speedUtil" />
- <property name="parameterDao" ref="parameterDao" />
- <property name="serverDao" ref="serverDao" />
- <property name="vpePortDao" ref="vpePortDao" />
- <property name="vplspePortDao" ref="vplspePortDao" />
- <property name="maxPortSpeedDao" ref="maxPortSpeedDao" />
- <property name="maxServerSpeedDao" ref="maxServerSpeedDao" />
- <property name="serviceResourceDao" ref="serviceResourceDao" />
- <property name="allocationRequestBuilder" ref="allocationRequestBuilder" />
<property name="resourceManager" ref="resourceManager" />
<property name="endPointAllocator" ref="endPointAllocator" />
+ <property name="speedUtil" ref="speedUtil" />
</bean>
- <!-- EndPointAllocator Configuration -->
+
+ <bean id="speedUtil" class="org.onap.ccsdk.sli.adaptors.util.speed.SpeedUtil" />
+
+ <!-- EndPointAllocator Configuration -->
<bean id="endPointAllocator" class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocatorImpl">
<property name="resourceManager" ref="resourceManager" />
- <property name="endPointAllocationDefinitionMap">
+ <property name="allocationRuleMap">
<map>
- <entry key="L3AVPN-PORT">
+ <entry key="DEFAULT">
<list>
- <bean class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocationDefinition">
- <property name="serviceModel" value="L3AVPN-PORT" />
- <property name="endPointPosition" value="VPE-Cust" />
- <property name="equipmentReader" ref="vpePortReader" />
- <property name="equipmentCheckList">
- <list>
- <ref bean="provStatusCheck" />
- <ref bean="excludeVpeCheck" />
- <ref bean="anyVrfPresentCheck" />
- </list>
- </property>
- <property name="preferenceRuleList">
- <list>
- <ref bean="affinityLinkPref" />
- </list>
- </property>
- <property name="allocationRuleList">
- <list>
- <ref bean="dbAllocationRule" />
- <ref bean="affinityAllocationRule" />
- </list>
- </property>
- </bean>
- </list>
- </entry>
- <entry key="L3AVPN-EVC">
- <list>
- <bean class="org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocationDefinition">
- <property name="serviceModel" value="L3AVPN-EVC" />
- <property name="endPointPosition" value="VPE-Cust" />
- <property name="equipmentReader" ref="vpePortReader" />
- <property name="equipmentCheckList">
- <list>
- <ref bean="provStatusCheck" />
- <ref bean="excludeVpeCheck" />
- <ref bean="vpeLockCheck" />
- <ref bean="anyVrfPresentCheck" />
- <ref bean="oneMVrfCheck" />
- <ref bean="hubWithRgCheck" />
- </list>
- </property>
- <property name="preferenceRuleList">
- <list>
- <ref bean="affinityLinkPref" />
- </list>
- </property>
- <property name="allocationRuleList">
- <list>
- <ref bean="dbAllocationRule" />
- <ref bean="vrfAllocationRule" />
- <ref bean="servingSiteAllocationRule" />
- <ref bean="affinityAllocationRule" />
- </list>
- </property>
- </bean>
+ <ref bean="dbAllocationRule" />
</list>
</entry>
</map>
</property>
</bean>
- <!-- Equipment Readers Configuration -->
-
- <bean id="vpePortReader" class="org.onap.ccsdk.sli.adaptors.ra.reader.VpePortReader">
- <property name="vpePortDao" ref="vpePortDao" />
- </bean>
-
- <!-- Equipment Checks Configuration -->
-
- <bean id="provStatusCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.ProvStatusCheck">
- </bean>
-
- <bean id="excludeVpeCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.ExcludeVpeCheck">
- </bean>
-
- <bean id="vpeLockCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.VpeLockCheck">
- <property name="vpeLockDao" ref="vpeLockDao" />
- <property name="resourceManager" ref="resourceManager" />
- </bean>
-
- <bean id="anyVrfPresentCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.AnyVrfPresentCheck">
- <property name="resourceManager" ref="resourceManager" />
- </bean>
-
- <bean id="oneMVrfCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.OneMVrfCheck">
- <property name="resourceManager" ref="resourceManager" />
- </bean>
-
- <bean id="hubWithRgCheck" class="org.onap.ccsdk.sli.adaptors.ra.check.HubWithRgCheck">
- <property name="resourceManager" ref="resourceManager" />
- </bean>
-
- <!-- Preference Rule Configuration -->
-
- <bean id="affinityLinkPref" class="org.onap.ccsdk.sli.adaptors.ra.pref.AffinityLinkPref">
- <property name="resourceManager" ref="resourceManager" />
- </bean>
-
- <!-- Resource Allocation Rule Configuration -->
+ <!-- Resource Allocation Rule Configuration -->
<bean id="dbAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.DbAllocationRule">
<property name="resourceRuleDao" ref="resourceRuleDao" />
<property name="rangeRuleDao" ref="rangeRuleDao" />
</bean>
- <bean id="vrfAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.VrfAllocationRule">
- </bean>
-
- <bean id="servingSiteAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.ServingSiteAllocationRule">
- </bean>
-
- <bean id="affinityAllocationRule" class="org.onap.ccsdk.sli.adaptors.ra.alloc.AffinityAllocationRule">
- </bean>
-
</beans>