diff options
11 files changed, 310 insertions, 90 deletions
diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/ResourceAllocator.java index 944429a3c..c51b03846 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 @@ -28,6 +28,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import org.onap.ccsdk.sli.adaptors.ra.comp.AllocationData; import org.onap.ccsdk.sli.adaptors.ra.comp.EndPointAllocator; import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceData; import org.onap.ccsdk.sli.adaptors.ra.comp.ResourceEntity; @@ -124,7 +125,9 @@ public class ResourceAllocator implements SvcLogicResource { } else if (resourceTargetId != null && resourceTargetType != null && resourceName != null) { ResourceData rd = endPointAllocator.getResource(resourceTargetType, resourceTargetId, resourceName, resourceEntityTypeFilter, resourceEntityIdFilter, resourceShareGroupFilter); - setResourceDataInContext(ctx, prefix, Collections.singletonList(rd)); + if (rd != null) { + setResourceDataInContext(ctx, prefix, Collections.singletonList(rd)); + } } else if ((resourceTargetTypeFilter != null || resourceTargetIdFilter != null) && resourceName != null) { List<ResourceData> rdlist = endPointAllocator.getResourcesForTarget(resourceTargetTypeFilter, resourceTargetIdFilter, resourceName); @@ -157,6 +160,10 @@ public class ResourceAllocator implements SvcLogicResource { } private void setResourceDataInContext(SvcLogicContext ctx, String prefix, List<ResourceData> rdlist) { + if (rdlist == null || rdlist.isEmpty()) { + return; + } + prefix = prefix == null ? "" : prefix + '.'; setAttr(ctx, prefix + "resource-list_length", String.valueOf(rdlist.size())); @@ -170,7 +177,6 @@ public class ResourceAllocator implements SvcLogicResource { 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); @@ -180,6 +186,28 @@ public class ResourceAllocator implements SvcLogicResource { setAttr(ctx, pp + kk, value); } } + + if (rd.allocationDataList != null && !rd.allocationDataList.isEmpty()) { + + setAttr(ctx, pp + "allocation-data-list_length", String.valueOf(rd.allocationDataList.size())); + + for (int j = 0; j < rd.allocationDataList.size(); j++) { + AllocationData ad = rd.allocationDataList.get(j); + + String ppp = pp + "allocation-data-list[" + j + "]."; + + setAttr(ctx, ppp + "resource-entity-type", ad.resourceEntityType); + setAttr(ctx, ppp + "resource-entity-id", ad.resourceEntityId); + setAttr(ctx, ppp + "resource-entity-version", ad.resourceEntityVersion); + + if (ad.data != null && !ad.data.isEmpty()) { + for (String kk : ad.data.keySet()) { + String value = String.valueOf(ad.data.get(kk)); + setAttr(ctx, ppp + kk, value); + } + } + } + } } } diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationData.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationData.java new file mode 100644 index 000000000..3e0e6b140 --- /dev/null +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/AllocationData.java @@ -0,0 +1,11 @@ +package org.onap.ccsdk.sli.adaptors.ra.comp; + +import java.util.Map; + +public class AllocationData { + + public String resourceEntityType; + public String resourceEntityId; + public String resourceEntityVersion; + public Map<String, String> data; +} 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 d188429ea..ab73dab1b 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 @@ -224,40 +224,8 @@ public class EndPointAllocatorImpl implements EndPointAllocator { log.info("ResourceName:" + r.resourceKey.resourceName + " assetId:" + r.resourceKey.assetId); - ResourceData rd = new ResourceData(); + ResourceData rd = getResourceData(r); 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 (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); - - } else if (r instanceof LimitResource) { - LimitResource lr = (LimitResource) r; - - log.info("lr.used: " + lr.used); - rd.data.put("allocated", String.valueOf(lr.used)); - } } return rdlist; @@ -266,7 +234,6 @@ public class EndPointAllocatorImpl implements EndPointAllocator { @Override public ResourceData getResource(String resourceTargetType, String resourceTargetId, String resourceName, String resourceEntityTypeFilter, String resourceEntityIdFilter, String resourceShareGroupFilter) { - ResourceData rd = new ResourceData(); String assetId = resourceTargetType + "::" + resourceTargetId; String resourceUnionFilter = null; @@ -288,36 +255,87 @@ public class EndPointAllocatorImpl implements EndPointAllocator { 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); + ResourceData rd = getResourceData(r); + return rd; + } - 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; + return null; + } + + private ResourceData getResourceData(Resource r) { + ResourceData rd = new ResourceData(); + + 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<>(); + rd.data = new HashMap<>(); + + 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); + + } else if (r instanceof LimitResource) { + LimitResource lr = (LimitResource) r; + + log.info("lr.used: " + lr.used); + rd.data.put("allocated", String.valueOf(lr.used)); + } + + rd.allocationDataList = new ArrayList<>(); + + if (r.allocationItems != null) { + for (AllocationItem ai : r.allocationItems) { + AllocationData ad = new AllocationData(); + rd.allocationDataList.add(ad); + + i1 = ai.resourceUnionId.indexOf("::"); + if (i1 > 0) { + ad.resourceEntityType = ai.resourceUnionId.substring(0, i1); + ad.resourceEntityId = ai.resourceUnionId.substring(i1 + 2); + } else { + ad.resourceEntityType = ""; + ad.resourceEntityId = ai.resourceUnionId; + } - if (r instanceof RangeResource) { - RangeResource rr = (RangeResource) r; + i1 = ai.resourceSetId.lastIndexOf("::"); + if (i1 > 0) { + ad.resourceEntityVersion = ai.resourceSetId.substring(i1 + 2); + } else { + ad.resourceEntityVersion = ""; + } + + ad.data = new HashMap<>(); + + if (ai instanceof RangeAllocationItem) { + RangeAllocationItem rai = (RangeAllocationItem) ai; - log.info("rr.used: " + rr.used); - String ss = String.valueOf(rr.used); - ss = ss.substring(1, ss.length() - 1); - rd.data.put("allocated", ss); + log.info("rr.used: " + rai.used); + String ss = String.valueOf(rai.used); + ss = ss.substring(1, ss.length() - 1); + ad.data.put("allocated", ss); - } else if (r instanceof LimitResource) { - LimitResource lr = (LimitResource) r; + } else if (ai instanceof LimitAllocationItem) { + LimitAllocationItem lai = (LimitAllocationItem) ai; - log.info("lr.used: " + lr.used); - rd.data.put("allocated", String.valueOf(lr.used)); + log.info("lr.used: " + lai.used); + ad.data.put("allocated", String.valueOf(lai.used)); + } } } diff --git a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java index a5881b957..a20c01d79 100644 --- a/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java +++ b/resource-assignment/provider/src/main/java/org/onap/ccsdk/sli/adaptors/ra/comp/ResourceData.java @@ -21,6 +21,7 @@ package org.onap.ccsdk.sli.adaptors.ra.comp; +import java.util.List; import java.util.Map; public class ResourceData { @@ -29,7 +30,8 @@ public class ResourceData { public String resourceTargetId; public String resourceTargetValue; public String resourceTargetType; + public String endPointPosition; public String status; public Map<String, String> data; - public String endPointPosition; + public List<AllocationData> allocationDataList; } diff --git a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java index 4be985b2a..f31a3859a 100644 --- a/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java +++ b/resource-assignment/provider/src/test/java/jtest/org/onap/ccsdk/sli/adaptors/ra/TestQueryResource.java @@ -85,6 +85,27 @@ public class TestQueryResource { Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].resource-target-type"), "Port"); Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].resource-target-id"), "TESTPORT-1-2"); Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocated"), "0, 1, 2, 3, 4"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list_length"), "5"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[0].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[0].resource-entity-id"), "TEST-0-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[0].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[0].allocated"), "0"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[1].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[1].resource-entity-id"), "TEST-1-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[1].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[1].allocated"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[2].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[2].resource-entity-id"), "TEST-2-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[2].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[2].allocated"), "2"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[3].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[3].resource-entity-id"), "TEST-3-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[3].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[3].allocated"), "3"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[4].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[4].resource-entity-id"), "TEST-4-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[4].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[1].allocation-data-list[4].allocated"), "4"); } @Test @@ -111,5 +132,26 @@ public class TestQueryResource { Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-type"), "Port"); Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].resource-target-id"), "TESTPORT-1-1"); Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocated"), "1500"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list_length"), "5"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[0].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[0].resource-entity-id"), "TEST-0-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[0].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[0].allocated"), "100"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[1].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[1].resource-entity-id"), "TEST-1-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[1].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[1].allocated"), "200"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[2].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[2].resource-entity-id"), "TEST-2-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[2].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[2].allocated"), "300"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[3].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[3].resource-entity-id"), "TEST-3-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[3].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[3].allocated"), "400"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[4].resource-entity-type"), "EVC"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[4].resource-entity-id"), "TEST-4-1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[4].resource-entity-version"), "1"); + Assert.assertEquals(ctx.getAttribute("ra-output.resource-list[0].allocation-data-list[4].allocated"), "500"); } } diff --git a/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml b/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml index cca279cdf..d92aa49e4 100644 --- a/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml +++ b/saltstack-adapter/saltstack-adapter-features/src/main/resources/features.xml @@ -35,8 +35,6 @@ <feature version="${odl.mdsal.version}">odl-mdsal-broker</feature> <feature>sdnc-sli</feature> <bundle dependency="true">mvn:org.apache.sshd/sshd-core/0.12.0</bundle> - <bundle dependency="true">mvn:org.onap.appc/appc-common/1.3.0</bundle> - <bundle dependency="true">mvn:org.onap.appc/appc-ssh-adapter-api/1.3.0</bundle> <bundle dependency="true">mvn:org.apache.commons/commons-io/1.3.2</bundle> <bundle>mvn:org.onap.ccsdk.sli.adaptors/saltstack-adapter-provider/${project.version}</bundle> </feature> diff --git a/saltstack-adapter/saltstack-adapter-provider/pom.xml b/saltstack-adapter/saltstack-adapter-provider/pom.xml index 5fee5cdcf..8134fe033 100644 --- a/saltstack-adapter/saltstack-adapter-provider/pom.xml +++ b/saltstack-adapter/saltstack-adapter-provider/pom.xml @@ -78,18 +78,18 @@ <version>0.12.0</version> </dependency> - <dependency> - <groupId>org.onap.appc</groupId> - <artifactId>appc-common</artifactId> - <version>1.3.0</version> - </dependency> - - <dependency> - <groupId>org.onap.appc</groupId> - <artifactId>appc-ssh-adapter-api</artifactId> - <version>1.3.0</version> - <scope>provided</scope> - </dependency> + <!--<dependency>--> + <!--<groupId>org.onap.appc</groupId>--> + <!--<artifactId>appc-common</artifactId>--> + <!--<version>1.3.0</version>--> + <!--</dependency>--> + + <!--<dependency>--> + <!--<groupId>org.onap.appc</groupId>--> + <!--<artifactId>appc-ssh-adapter-api</artifactId>--> + <!--<version>1.3.0</version>--> + <!--<scope>provided</scope>--> + <!--</dependency>--> <!-- Needed to run test cases --> diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java index 25a15fcca..9f1799821 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/ConnectionBuilder.java @@ -26,16 +26,13 @@ package org.onap.ccsdk.sli.adaptors.saltstack.impl; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; -import org.onap.appc.adapter.ssh.SshException; +import org.onap.ccsdk.sli.adaptors.saltstack.model.SshException; import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackResult; import org.onap.ccsdk.sli.adaptors.saltstack.model.SaltstackResultCodes; import java.io.ByteArrayOutputStream; import java.io.IOException; -//import org.onap.appc.adapter.ssh.SshConnection; -//import org.onap.appc.adapter.ssh.SshAdapter; - /** * Returns a custom SSH client * - based on options diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java index 988183fc1..eb45ead50 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/impl/SshConnection.java @@ -34,11 +34,8 @@ import org.apache.sshd.client.future.AuthFuture; import org.apache.sshd.client.future.OpenFuture; import org.apache.sshd.common.KeyPairProvider; import org.apache.sshd.common.keyprovider.FileKeyPairProvider; -import org.onap.appc.adapter.ssh.Constants; -import org.onap.appc.adapter.ssh.SshException; -import org.onap.appc.configuration.Configuration; -import org.onap.appc.configuration.ConfigurationFactory; -import org.onap.appc.encryption.EncryptionTool; +import org.onap.ccsdk.sli.adaptors.saltstack.model.Constants; +import org.onap.ccsdk.sli.adaptors.saltstack.model.SshException; import java.io.OutputStream; import java.security.KeyPair; @@ -52,7 +49,6 @@ class SshConnection { private static final long AUTH_TIMEOUT = 60000; private static final long EXEC_TIMEOUT = 120000; - private static final Configuration configuration = ConfigurationFactory.getConfiguration(); private String host; private int port; private String username; @@ -83,9 +79,9 @@ class SshConnection { sshClient.start(); try { clientSession = - sshClient.connect(EncryptionTool.getInstance().decrypt(username), host, port).await().getSession(); + sshClient.connect(username, host, port).await().getSession(); if (password != null) { - clientSession.addPasswordIdentity(EncryptionTool.getInstance().decrypt(password)); + clientSession.addPasswordIdentity(password); } else if (keyFile != null) { KeyPairProvider keyPairProvider = new FileKeyPairProvider(new String[]{ keyFile @@ -114,10 +110,8 @@ class SshConnection { int retryCount; int retryDelay; int retriesLeft; - retryCount = configuration.getIntegerProperty(Constants.CONNECTION_RETRY_COUNT, - Constants.DEFAULT_CONNECTION_RETRY_COUNT); - retryDelay = configuration.getIntegerProperty(Constants.CONNECTION_RETRY_DELAY, - Constants.DEFAULT_CONNECTION_RETRY_DELAY); + retryCount = Constants.DEFAULT_CONNECTION_RETRY_COUNT; + retryDelay = Constants.DEFAULT_CONNECTION_RETRY_DELAY; retriesLeft = retryCount + 1; do { try { diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/Constants.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/Constants.java new file mode 100644 index 000000000..a1826c4e1 --- /dev/null +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/Constants.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.adaptors.saltstack.model; + +public class Constants { + public static final String NETCONF_SCHEMA = "sdnctl"; + public static final String SDNCTL_SCHEMA = "sdnctl"; + public static final String DEVICE_AUTHENTICATION_TABLE_NAME = "DEVICE_AUTHENTICATION"; + public static final String CONFIGFILES_TABLE_NAME = "CONFIGFILES"; + public static final String DEVICE_INTERFACE_LOG_TABLE_NAME = "DEVICE_INTERFACE_LOG"; + public static final String FILE_CONTENT_TABLE_FIELD_NAME = "FILE_CONTENT"; + public static final String FILE_NAME_TABLE_FIELD_NAME = "FILE_NAME"; + public static final String USER_NAME_TABLE_FIELD_NAME = "USER_NAME"; + public static final String PASSWORD_TABLE_FIELD_NAME = "PASSWORD"; + public static final String PORT_NUMBER_TABLE_FIELD_NAME = "PORT_NUMBER"; + public static final String VNF_TYPE_TABLE_FIELD_NAME = "VNF_TYPE"; + public static final String SERVICE_INSTANCE_ID_FIELD_NAME = "SERVICE_INSTANCE_ID"; + public static final String REQUEST_ID_FIELD_NAME = "REQUEST_ID"; + public static final String CREATION_DATE_FIELD_NAME = "CREATION_DATE"; + public static final String LOG_FIELD_NAME = "LOG"; + public static final String SDC_ARTIFACTS_TABLE_NAME = "ASDC_ARTIFACTS"; + public static final String PAYLOAD = "payload"; + public static final String CONNECTION_RETRY_DELAY = "org.onap.appc.ssh.connection.retry.delay"; + public static final String CONNECTION_RETRY_COUNT = "org.onap.appc.ssh.connection.retry.count"; + public static final int DEFAULT_CONNECTION_RETRY_DELAY = 60; + public static final int DEFAULT_CONNECTION_RETRY_COUNT = 5; + public static final int DEFAULT_SSH_COMMAND_RETRY_COUNT = 3; + public static final int DEFAULT_CHECKACTIVE_RETRY_COUNT = 3; + public static final int DEFAULT_CHECKACTIVE_RETRY_DELAY = 30; + public static final int DEFAULT_STOP_RETRY_COUNT = 3; + public static final int DEFAULT_STOP_RETRY_DELAY = 30; + public static final String PARAM_IN_CONNECTION_DETAILS = "connection-details"; + public static final String PARAM_IN_NODE_NAME = "node-name"; + public static final String PARAM_IN_NODE_STATUS = "node-status"; + public static final String PARAM_IN_VM_URL = "vm-url"; + public static final String SKIP_EXECUTION_INSTALLER_BIN_FILE = "Skip-execution-installer-bin-file"; + public static final String SKIP_DEPLOY = "Skip-deploy"; + public static final String UPGRADE_VERSION = "upgrade-version"; + public static final String STATE_COMMAND = "/opt/jnetx/skyfall-scp/asp-state.sh | grep -o UP | wc -l"; + public static final String VNFC_STATE_COMMAND = "/opt/jnetx/skyfall-scp/asp-state.sh"; + public static final String RESTART_NODE_COMMAND = "/opt/jnetx/skyfall-scp/asp-stop.sh --restart -f --nodes"; + public static final String START_NODE_COMMAND = "/opt/jnetx/skyfall-scp/asp-start.sh -f --nodes"; + public static final String STOP_NODE_COMMAND = "/opt/jnetx/skyfall-scp/asp-stop.sh -f --nodes"; + public static final int STATE_COMMAND_RESULT = 18; + public static final String FE_STATE_TRUE_TEST_COMMAND = "ssh -t -q fe1 /opt/omni/bin/swmml -e display-platform-status | grep -o TRUE | wc -l"; + public static final int FE_STATE_TRUE_TEST_RESULT = 22; + public static final String FE_STATE_FALSE_TEST_COMMAND = "ssh -t -q fe1 /opt/omni/bin/swmml -e display-platform-status | grep -o FALSE | wc -l"; + public static final int FE_STATE_FALSE_TEST_RESULT = 2; + public static final String FE_OPERATIONAL_TEST_COMMAND = "ssh -t -q fe1 /opt/omni/bin/swmml -e display-platform-status | grep -o 'NOT FULLY OPERATIONAL' | wc -l"; + public static final int FE_OPERATIONAL_TEST_RESULT = 2; + public static final String SMP_CHECK_ACTIVE_STATE_COMMAND = "cat skyfall-scp/runtime/SCP_SMP_*/smp/log/system.log| grep SSS | tail -1"; + public static final String SMP_STATE_ACTIVE = "SMP is active"; + public static final String SMP_STATE_INACTIVE = "SMP is not active"; + public static final String RSYNC_COMMAND = "yes n | /opt/jnetx/skyfall-scp/asp-rsync.sh --check | grep -o 'is active' | wc -l"; + public static final int RSYNC_COMMAND_RESULT = 9; + public static final String PARAM_IN_TIMEOUT = "timeout"; + public static final String PARAM_IN_FILE_URL = "source-file-url"; + public static final String DOWNLOAD_COMMAND = "wget -N %s"; + public static final String[] VM_NAMES = new String[]{"fe1", "fe2", "be1", "be2", "be3", "be4", "be5", "smp1", "smp2"}; + public static final String DEFAULT_DISK_SPACE = "10240000"; + public static final String DF_COMMAND_TEMPLATE = "ssh %s df | grep vda1 | grep -v grep | tr -s ' '|cut -d ' ' -f4"; + public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message"; + public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message"; + public static final String CONNECTION_DETAILS_FIELD_NAME = "connection-details"; + public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address"; + public static final String VNF_HOST_IP2_ADDRESS_FIELD_NAME = "vnf-host-ip2-address"; + public static final String DG_ERROR_FIELD_NAME = "org.openecom.appc.dg.error"; + + private Constants() { + } +} diff --git a/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SshException.java b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SshException.java new file mode 100644 index 000000000..037a1e891 --- /dev/null +++ b/saltstack-adapter/saltstack-adapter-provider/src/main/java/org/onap/ccsdk/sli/adaptors/saltstack/model/SshException.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.sli.adaptors.saltstack.model; + +public class SshException extends RuntimeException { + private static final long serialVersionUID = 1L; + + public SshException(String message) { + super(message); + } + + public SshException(String message, Throwable cause) { + super(message, cause); + } +}
\ No newline at end of file |