summaryrefslogtreecommitdiffstats
path: root/vnfs/vLBMS/apis
diff options
context:
space:
mode:
Diffstat (limited to 'vnfs/vLBMS/apis')
-rw-r--r--vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/pom.xml6
-rw-r--r--vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/health/read/ElementStateCustomizer.java40
-rw-r--r--vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-api/src/main/yang/vlb-business-vnf-onap-plugin.yang21
-rw-r--r--vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/ElementCrudService.java7
-rw-r--r--vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/DnsInstanceManager.java46
-rw-r--r--vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/ElementCustomizer.java13
6 files changed, 82 insertions, 51 deletions
diff --git a/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/pom.xml b/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/pom.xml
index d53b137b..47351339 100644
--- a/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/pom.xml
+++ b/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/pom.xml
@@ -40,6 +40,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onap.demo.vnf.vlb</groupId>
+ <artifactId>vlb-business-vnf-onap-plugin-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<!-- Honeycomb infrastructure-->
<dependency>
<groupId>io.fd.honeycomb</groupId>
diff --git a/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/health/read/ElementStateCustomizer.java b/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/health/read/ElementStateCustomizer.java
index 5486928d..15d0c22a 100644
--- a/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/health/read/ElementStateCustomizer.java
+++ b/vnfs/vLBMS/apis/health-vnf-onap-plugin/health-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/health/read/ElementStateCustomizer.java
@@ -23,6 +23,9 @@ package org.onap.vnf.health.read;
import org.onap.vnf.health.CrudService;
import org.onap.vnf.health.RESTManager;
import org.onap.vnf.health.RESTManager.Pair;
+import org.onap.vnf.vlb.write.DnsInstanceManager;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vlb.business.vnf.onap.plugin.rev160918.vlb.business.vnf.onap.plugin.params.vdns.instances.VdnsInstance;
import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -38,6 +41,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -66,15 +70,18 @@ import org.slf4j.LoggerFactory;
public final class ElementStateCustomizer implements InitializingReaderCustomizer<HealthCheck, HealthCheckBuilder> {
private final CrudService<HealthCheck> crudService;
+ private DnsInstanceManager dnsInstanceManager;
private static final Logger LOG = LoggerFactory.getLogger(ElementStateCustomizer.class);
private final String SCRIPT;
private final String OUTPUT;
private final String VNFC;
private final Boolean PRIMARY;
private static SimpleDateFormat SDF;
+ private String vPktGenIp;
public ElementStateCustomizer(final CrudService<HealthCheck> crudService) throws IOException {
this.crudService = crudService;
+ dnsInstanceManager = DnsInstanceManager.getInstance();
// initialize data format
SDF = new SimpleDateFormat("MM-dd-yyyy:HH.mm.ss");
@@ -89,6 +96,10 @@ public final class ElementStateCustomizer implements InitializingReaderCustomize
VNFC = prop.getProperty("vnfc");
PRIMARY = Boolean.parseBoolean(prop.getProperty("primary"));
prop_file.close();
+
+ if(PRIMARY) {
+ vPktGenIp = readFromFile("/opt/config/oam_vpktgen_ip.txt");
+ }
}
@Override
@@ -110,18 +121,6 @@ public final class ElementStateCustomizer implements InitializingReaderCustomize
@Nonnull final HealthCheckBuilder builder,
@Nonnull final ReadContext ctx) throws ReadFailedException {
- List<String> ipAddr = new ArrayList<String>();
- if(PRIMARY) {
- String ret = readFromFile("/opt/config/oam_vpktgen_ip.txt");
- if(ret != null) {
- ipAddr.add(ret);
- }
- ret = readFromFile("/opt/config/oam_vdns_ip.txt");
- if(ret != null) {
- ipAddr.add(ret);
- }
- }
-
// assess the health status of the local service (try at most three times, otherwise return an error).
String healthStatus;
String [] cmdArgs = {"/bin/bash", "-c", SCRIPT};
@@ -157,13 +156,20 @@ public final class ElementStateCustomizer implements InitializingReaderCustomize
LOG.info("Failed to assess the health status of the local component. Return status = \"unhealthy\"");
}
- // perform read of details of data specified by key of Element in id
- // final HealthCheck data = crudService.readSpecific(id);
-
// check the status of other VNF components, if any
if(PRIMARY) {
- for(int i = 0; i < ipAddr.size(); i++) {
- if(!getRemoteVnfcHealthStatus(ipAddr.get(i))) {
+ // check the vPacketGenerator first
+ if(vPktGenIp != null) {
+ if(!getRemoteVnfcHealthStatus(vPktGenIp)) {
+ healthStatus = "unhealthy";
+ }
+ }
+
+ // check all the vDNS instances
+ Map<String, VdnsInstance> activeVdnsInstances = dnsInstanceManager.getDnsInstancesAsMap();
+ Iterator<String> iter = activeVdnsInstances.keySet().iterator();
+ while(iter.hasNext()){
+ if(!getRemoteVnfcHealthStatus(activeVdnsInstances.get(iter.next()).getOamIpAddr())) {
healthStatus = "unhealthy";
}
}
diff --git a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-api/src/main/yang/vlb-business-vnf-onap-plugin.yang b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-api/src/main/yang/vlb-business-vnf-onap-plugin.yang
index 229ad7a3..583f87e7 100644
--- a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-api/src/main/yang/vlb-business-vnf-onap-plugin.yang
+++ b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-api/src/main/yang/vlb-business-vnf-onap-plugin.yang
@@ -33,21 +33,6 @@ module vlb-business-vnf-onap-plugin {
// curl -u admin:admin http://localhost:8181/restconf/operational/vlb-business-vnf-onap-plugin:vlb-business-vnf-onap-plugin-state
}
-// grouping vlb-business-vnf-onap-plugin-params {
-// list element {
-//
-// key id;
-// leaf id {
-// type uint32;
-// }
-//
-// leaf description {
-// type string;
-// }
-// }
-// }
-
-
grouping vlb-business-vnf-onap-plugin-params {
container vdns-instances {
list vdns-instance {
@@ -57,7 +42,11 @@ module vlb-business-vnf-onap-plugin {
type string;
}
- leaf is-enabled {
+ leaf oam-ip-addr {
+ type string;
+ }
+
+ leaf enabled {
type boolean;
}
}
diff --git a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/ElementCrudService.java b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/ElementCrudService.java
index d17c6c18..2a926036 100644
--- a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/ElementCrudService.java
+++ b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/ElementCrudService.java
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+ /*
+ * Modifications copyright (c) 2018 AT&T Intellectual Property
+ */
+
package org.onap.vnf.vlb;
import io.fd.honeycomb.translate.read.ReadFailedException;
@@ -101,7 +105,8 @@ final class ElementCrudService implements CrudService<VdnsInstance> {
return new VdnsInstanceBuilder()
.setIpAddr(key.getIpAddr())
.setKey(key)
- .setIsEnabled(true)
+ .setOamIpAddr("10.0.80.0")
+ .setEnabled(true)
.build();
}
diff --git a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/DnsInstanceManager.java b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/DnsInstanceManager.java
index dc3e9248..3740076b 100644
--- a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/DnsInstanceManager.java
+++ b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/DnsInstanceManager.java
@@ -22,6 +22,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vlb.business.vnf.onap.plugin.rev160918.vlb.business.vnf.onap.plugin.params.vdns.instances.VdnsInstance;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,26 +49,40 @@ import org.slf4j.LoggerFactory;
public class DnsInstanceManager {
+ private static DnsInstanceManager thisInstance = null;
private static final Logger LOG = LoggerFactory.getLogger(DnsInstanceManager.class);
- private Map<String, Boolean> dnsInstances = new HashMap<String, Boolean>();
+ private Map<String, VdnsInstance> dnsInstances = new HashMap<String, VdnsInstance>();
/*
* Add a new DNS instance to the map and create a GRE tunnel
* towards that instance if isEnabled is set to true.
*/
- void addDnsInstance(String ipAddr, Boolean isEnabled) {
+
+ public static DnsInstanceManager getInstance() {
+ if(thisInstance == null) {
+ thisInstance = new DnsInstanceManager();
+ }
+
+ return thisInstance;
+ }
+
+ private DnsInstanceManager() {
+
+ }
+
+ void addDnsInstance(String ipAddr, VdnsInstance data) {
// Call updateDnsInstance in case the DNS instance already exists.
// This is somewhat redundant because Honeycomb already runs this check.
if(dnsInstances.containsKey(ipAddr)) {
- updateDnsInstance(ipAddr, isEnabled);
+ updateDnsInstance(ipAddr, data);
return;
}
- dnsInstances.put(ipAddr, isEnabled);
- LOG.debug("DNS instance " + ipAddr + " with status isEnabled=" + isEnabled + " has been added.");
+ dnsInstances.put(ipAddr, data);
+ LOG.debug("DNS instance " + ipAddr + " with status isEnabled=" + data.isEnabled() + " has been added.");
// Create a GRE tunnel towards the new DNS instance if isEnabled is true.
- if(isEnabled) {
+ if(data.isEnabled()) {
addGreTunnel(ipAddr);
}
}
@@ -75,14 +91,15 @@ public class DnsInstanceManager {
* Update an existing DNS instance and create or remove a GRE
* tunnel based on the current value of the isEnabled flag.
*/
- void updateDnsInstance(String ipAddr, Boolean isEnabled) {
+ void updateDnsInstance(String ipAddr, VdnsInstance data) {
// This is somewhat redundant because Honeycomb already runs this check.
- if(dnsInstances.get(ipAddr) == isEnabled) {
+ boolean isEnabled = data.isEnabled();
+ if(dnsInstances.get(ipAddr).isEnabled() == isEnabled) {
LOG.debug("DNS instance " + ipAddr + " with status isEnabled=" + isEnabled + " already exists. No update is necessary.");
return;
}
- dnsInstances.put(ipAddr, isEnabled);
+ dnsInstances.put(ipAddr, data);
LOG.debug("DNS instance " + ipAddr + " has been updated with status isEnabled=" + isEnabled + ".");
if(isEnabled) {
@@ -105,7 +122,7 @@ public class DnsInstanceManager {
}
// Remove a GRE tunnel towards this DNS instance if it exists.
- if(dnsInstances.get(ipAddr)) {
+ if(dnsInstances.get(ipAddr).isEnabled()) {
deleteGreTunnel(ipAddr);
}
@@ -139,4 +156,11 @@ public class DnsInstanceManager {
e.printStackTrace();
}
}
-}
+
+ /*
+ * Auxiliary function that returns vDNS instances as map.
+ */
+ public Map<String, VdnsInstance> getDnsInstancesAsMap() {
+ return dnsInstances;
+ }
+} \ No newline at end of file
diff --git a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/ElementCustomizer.java b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/ElementCustomizer.java
index d8da0b5b..10457a60 100644
--- a/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/ElementCustomizer.java
+++ b/vnfs/vLBMS/apis/vlb-business-vnf-onap-plugin/vlb-business-vnf-onap-plugin-impl/src/main/java/org/onap/vnf/vlb/write/ElementCustomizer.java
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+ /*
+ * Modifications copyright (c) 2018 AT&T Intellectual Property
+ */
+
package org.onap.vnf.vlb.write;
import org.onap.vnf.vlb.CrudService;
@@ -24,8 +28,6 @@ import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vlb.business.vnf.onap.plugin.rev160918.vlb.business.vnf.onap.plugin.params.vdns.instances.VdnsInstance;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vlb.business.vnf.onap.plugin.rev160918.vlb.business.vnf.onap.plugin.params.vdns.instances.VdnsInstanceKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Writer for {@link Element} list node from our YANG model.
@@ -34,11 +36,10 @@ public final class ElementCustomizer implements ListWriterCustomizer<VdnsInstanc
private final CrudService<VdnsInstance> crudService;
private DnsInstanceManager dnsInstanceManager;
- private static final Logger LOG = LoggerFactory.getLogger(ElementCustomizer.class);
public ElementCustomizer(@Nonnull final CrudService<VdnsInstance> crudService) {
this.crudService = crudService;
- dnsInstanceManager = new DnsInstanceManager();
+ dnsInstanceManager = DnsInstanceManager.getInstance();
}
@Override
@@ -47,7 +48,7 @@ public final class ElementCustomizer implements ListWriterCustomizer<VdnsInstanc
//perform write of data,or throw exception
//invoked by PUT operation,if provided data doesn't exist in Config data
crudService.writeData(id, dataAfter);
- dnsInstanceManager.addDnsInstance(dataAfter.getIpAddr(), dataAfter.isIsEnabled());
+ dnsInstanceManager.addDnsInstance(dataAfter.getIpAddr(), dataAfter);
}
@Override
@@ -58,7 +59,7 @@ public final class ElementCustomizer implements ListWriterCustomizer<VdnsInstanc
//perform update of data,or throw exception
//invoked by PUT operation,if provided data does exist in Config data
crudService.updateData(id, dataBefore, dataAfter);
- dnsInstanceManager.updateDnsInstance(dataAfter.getIpAddr(), dataAfter.isIsEnabled());
+ dnsInstanceManager.updateDnsInstance(dataAfter.getIpAddr(), dataAfter);
}
@Override