diff --git a/onap-demo.web/.project b/onap-demo.web/.project
index fd40426..f819a11 100644
--- a/onap-demo.web/.project
+++ b/onap-demo.web/.project
@@ -26,12 +26,12 @@
- org.eclipse.m2e.core.maven2Builder
+ org.springframework.ide.eclipse.core.springbuilder
- org.springframework.ide.eclipse.core.springbuilder
+ org.eclipse.m2e.core.maven2Builder
diff --git a/onap-demo.web/pom.xml b/onap-demo.web/pom.xml
index c338314..679e650 100644
--- a/onap-demo.web/pom.xml
+++ b/onap-demo.web/pom.xml
@@ -140,6 +140,38 @@
genson
1.1
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+ org.webjars
+ webjars-locator
+
+
+ org.webjars
+ sockjs-client
+ 1.0.2
+
+
+ org.webjars
+ stomp-websocket
+ 2.3.3
+
+
+ org.webjars
+ bootstrap
+ 3.3.7
+
+
+ org.webjars
+ jquery
+ 3.1.0
+
+
diff --git a/onap-demo.web/src/main/java/org/onap/demo/ApiController.java b/onap-demo.web/src/main/java/org/onap/demo/ApiController.java
index 4977281..51c9da2 100644
--- a/onap-demo.web/src/main/java/org/onap/demo/ApiController.java
+++ b/onap-demo.web/src/main/java/org/onap/demo/ApiController.java
@@ -3,6 +3,7 @@
import java.util.concurrent.atomic.AtomicLong;
import org.onap.demo.integration.JAXRSClient;
+import org.onap.demo.sbi.ExternalProcessEndpoint;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -16,22 +17,20 @@ public class ApiController {
private final AtomicLong counter = new AtomicLong();
@RequestMapping(method=RequestMethod.GET)
- public @ResponseBody Api sayHello(@RequestParam(value="name", required=true, defaultValue="undefined") String name) {
+ public @ResponseBody Api process(@RequestParam(value="name", required=true, defaultValue="undefined") String name) {
String message = null;
// external call
- message = getState(name);
+ message = externalAPICall(name);
Api api = new Api(
counter.incrementAndGet(), //String.format(template, name));
message);
return api;
}
- private String getState(String id) {
+ private String externalAPICall(String id) {
String content = null;
JAXRSClient client = new JAXRSClient();
- //String sec = client.run(false, "http://" + Configuration.get("coll-ip") + ":3904/events/unauthenticated.SEC_MEASUREMENT_OUTPUT/group3/sub1?timeout=9000","","");
-
-
+
switch(id) {
case "sec_mo":
content = client.run(false, Configuration.get("iad", "coll-ip"), "3904", "events/unauthenticated.SEC_MEASUREMENT_OUTPUT/group3/sub1?timeout=9000", null, null, null);
@@ -40,6 +39,31 @@ private String getState(String id) {
// will get a 4000 on customers/customer but not customers at demo init state
content = client.run(true, Configuration.get("iad", "aai-ip"), "8443", "aai/v8/business/customers/customer", "AAI", "AAI", "AAI");
break;
+ case "initial-config":
+ ExternalProcessEndpoint ep_ic = new ExternalProcessEndpoint();
+ content = ep_ic.runExternal("openstack_port_list.sh","network", "list");
+ break;
+ case "service-creation":
+ ExternalProcessEndpoint ep_sc = new ExternalProcessEndpoint();
+ content = ep_sc.runExternal("openstack_port_list.sh","network", "list");
+ break;
+ case "vnf-creation":
+ ExternalProcessEndpoint ep_vc = new ExternalProcessEndpoint();
+ content = ep_vc.runExternal("openstack_port_list.sh","network", "list");
+ break;
+ case "vfm-preload":
+ ExternalProcessEndpoint ep_mp = new ExternalProcessEndpoint();
+ content = ep_mp.runExternal("openstack_port_list.sh","network", "list");
+ break;
+ case "vfm-creation":
+ ExternalProcessEndpoint ep_mc = new ExternalProcessEndpoint();
+ content = ep_mc.runExternal("openstack_port_list.sh","network", "list");
+ break;
+ case "closed-loop":
+ ExternalProcessEndpoint ep_cl = new ExternalProcessEndpoint();
+ content = ep_cl.runExternal("openstack_port_list.sh","network", "list");
+ break;
+
}
return content;
diff --git a/onap-demo.web/src/main/java/org/onap/demo/Configuration.java b/onap-demo.web/src/main/java/org/onap/demo/Configuration.java
index 980e7ac..9787e88 100644
--- a/onap-demo.web/src/main/java/org/onap/demo/Configuration.java
+++ b/onap-demo.web/src/main/java/org/onap/demo/Configuration.java
@@ -3,15 +3,34 @@
import java.util.HashMap;
import java.util.Map;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.PropertySource;
+
+//@PropertySource(ignoreResourceNotFound=true, value="classpath:jdbc-${spring.profiles.active}.properties")
+@PropertySource(ignoreResourceNotFound=true, value="classpath:onap-dev.properties")
public class Configuration {
+ public static final String DDC = "dfw";
+ public static final String VDC = "iad";
+ public static final String LOCAL = "local";
+
+ @Value("${script.dir}") // TODO: use typesafe
+ private String scriptDir;
+
+ public String getScriptDir() {
+ return scriptDir;
+ }
+
+
private static Map> map = new HashMap<>();
static {
- map.put("dfw", new HashMap<>());
- map.put("iad", new HashMap<>());
- Map dMap = map.get("dfw");
- Map iMap = map.get("iad");
+ map.put(DDC, new HashMap<>());
+ map.put(VDC, new HashMap<>());
+ map.put(LOCAL, new HashMap<>());
+ Map dMap = map.get(DDC);
+ Map vMap = map.get(VDC);
+ Map iMap = map.get(LOCAL);
dMap.put("robot-ip", "23.253.125.166");
dMap.put("aai-ip", "172.99.115.238");
dMap.put("appc-ip", "67.192.246.90");
@@ -29,22 +48,25 @@ public class Configuration {
dMap.put("coll-ip", "162.242.235.75");
dMap.put("pstg-ip", "104.239.240.7");
- iMap.put("robot-ip", "104.130.13.93");
- iMap.put("aai-ip", "146.20.65.216");
- iMap.put("appc-ip", "162.242.219.48");
- iMap.put("dcae-ip", "172.99.67.156");
- iMap.put("message-router-ip", "162.209.124.37");
- iMap.put("mso-ip", "162.242.218.100");
- iMap.put("policy-ip", "104.239.234.15");
- iMap.put("portal-ip", "104.130.31.44");
- iMap.put("sdc-ip", "104.239.234.11");
- iMap.put("sdnc-ip", "162.242.218.219");
- iMap.put("vid-ip", "104.130.169.38");
- iMap.put("cdap0-ip", "104.239.175.196");
- iMap.put("cdap1-ip", "104.130.239.149");
- iMap.put("cdap2-ip", "172.99.68.155");
- iMap.put("coll-ip", "162.242.235.75");
- iMap.put("pstg-ip", "104.239.168.49");
+ vMap.put("robot-ip", "104.130.13.93");
+ vMap.put("aai-ip", "146.20.65.216");
+ vMap.put("appc-ip", "162.242.219.48");
+ vMap.put("dcae-ip", "172.99.67.156");
+ vMap.put("message-router-ip", "162.209.124.37");
+ vMap.put("mso-ip", "162.242.218.100");
+ vMap.put("policy-ip", "104.239.234.15");
+ vMap.put("portal-ip", "104.130.31.44");
+ vMap.put("sdc-ip", "104.239.234.11");
+ vMap.put("sdnc-ip", "162.242.218.219");
+ vMap.put("vid-ip", "104.130.169.38");
+ vMap.put("cdap0-ip", "104.239.175.196");
+ vMap.put("cdap1-ip", "104.130.239.149");
+ vMap.put("cdap2-ip", "172.99.68.155");
+ vMap.put("coll-ip", "162.242.235.75");
+ vMap.put("pstg-ip", "104.239.168.49");
+
+ // local config
+ iMap.put("script-dir","/opt/");
}
public static String get(String region, String key) {
@@ -55,5 +77,5 @@ public static void put(String region, String key, String value) {
map.get(region).put(key, value);
}
-
+ // curl http://healthcheck:zb\!XztG34@policy:6969/healthcheck
}
diff --git a/onap-demo.web/src/main/java/org/onap/demo/integration/JAXRSClient.java b/onap-demo.web/src/main/java/org/onap/demo/integration/JAXRSClient.java
index 4213828..088a18b 100644
--- a/onap-demo.web/src/main/java/org/onap/demo/integration/JAXRSClient.java
+++ b/onap-demo.web/src/main/java/org/onap/demo/integration/JAXRSClient.java
@@ -1,19 +1,11 @@
package org.onap.demo.integration;
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
-import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
-import javax.ws.rs.core.Response;
import org.glassfish.jersey.SslConfigurator;
import org.onap.demo.oss.Authenticator;
@@ -59,25 +51,5 @@ record = rootTarget.request()
}
return record;
}
-
- //public static void main(String[] args) {
- //JAXRSClient client = new JAXRSClient();
- //client.run(false, "http://67.192.246.187:8080/asdc/properties/encrypt/ecomp-dev/", "", "aa3871669d893c7fb8abbcda31b88b4f");
- // https://developer.openstack.org/api-guide/quick-start/api-quick-start.html
- /*try {
- ProcessBuilder processBuilder = new ProcessBuilder("/Users/michaelobrien/wse_onap/onap/openstack_port_list.sh","network", "list");
- processBuilder.redirectErrorStream(true);
- Process process = processBuilder.start();
- InputStreamReader isr = new InputStreamReader(process.getInputStream());
- BufferedReader buff = new BufferedReader (isr);
- String line;
- while((line = buff.readLine()) != null) {
- System.out.print(line);
- }
- } catch (Exception e) {
- e.printStackTrace();
- }*/
- //}
-
}
diff --git a/onap-demo.web/src/main/java/org/onap/demo/integration/WSContent.java b/onap-demo.web/src/main/java/org/onap/demo/integration/WSContent.java
new file mode 100644
index 0000000..e23b106
--- /dev/null
+++ b/onap-demo.web/src/main/java/org/onap/demo/integration/WSContent.java
@@ -0,0 +1,18 @@
+package org.onap.demo.integration;
+
+public class WSContent {
+
+ private String content;
+
+ public WSContent() {
+ }
+
+ public WSContent(String content) {
+ this.content = content;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+}
diff --git a/onap-demo.web/src/main/java/org/onap/demo/integration/WSController.java b/onap-demo.web/src/main/java/org/onap/demo/integration/WSController.java
new file mode 100644
index 0000000..d87a9a1
--- /dev/null
+++ b/onap-demo.web/src/main/java/org/onap/demo/integration/WSController.java
@@ -0,0 +1,17 @@
+package org.onap.demo.integration;
+
+import org.springframework.messaging.handler.annotation.MessageMapping;
+import org.springframework.messaging.handler.annotation.SendTo;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class WSController {
+
+ @MessageMapping("/ws")
+ @SendTo("/topic/content")
+ public WSContent greeting(WSMessage message) throws Exception {
+ Thread.sleep(1000); // simulated delay
+ return new WSContent("Hello, " + message.getName() + "!");
+ }
+
+}
diff --git a/onap-demo.web/src/main/java/org/onap/demo/integration/WSMessage.java b/onap-demo.web/src/main/java/org/onap/demo/integration/WSMessage.java
new file mode 100644
index 0000000..5d9118d
--- /dev/null
+++ b/onap-demo.web/src/main/java/org/onap/demo/integration/WSMessage.java
@@ -0,0 +1,22 @@
+package org.onap.demo.integration;
+
+public class WSMessage {
+
+ private String name;
+
+ public WSMessage() {
+ }
+
+ public WSMessage(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+}
diff --git a/onap-demo.web/src/main/java/org/onap/demo/integration/WebSocketConfig.java b/onap-demo.web/src/main/java/org/onap/demo/integration/WebSocketConfig.java
new file mode 100644
index 0000000..2bd8b9c
--- /dev/null
+++ b/onap-demo.web/src/main/java/org/onap/demo/integration/WebSocketConfig.java
@@ -0,0 +1,24 @@
+package org.onap.demo.integration;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.messaging.simp.config.MessageBrokerRegistry;
+import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
+import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
+import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
+
+@Configuration
+@EnableWebSocketMessageBroker
+public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
+
+ @Override
+ public void configureMessageBroker(MessageBrokerRegistry config) {
+ config.enableSimpleBroker("/topic");
+ config.setApplicationDestinationPrefixes("/app");
+ }
+
+ @Override
+ public void registerStompEndpoints(StompEndpointRegistry registry) {
+ registry.addEndpoint("/gs-guide-websocket").withSockJS();
+ }
+
+}
diff --git a/onap-demo.web/src/main/java/org/onap/demo/sbi/ExternalProcessEndpoint.java b/onap-demo.web/src/main/java/org/onap/demo/sbi/ExternalProcessEndpoint.java
new file mode 100644
index 0000000..6bc29d1
--- /dev/null
+++ b/onap-demo.web/src/main/java/org/onap/demo/sbi/ExternalProcessEndpoint.java
@@ -0,0 +1,44 @@
+package org.onap.demo.sbi;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.util.concurrent.TimeUnit;
+
+import org.onap.demo.Configuration;
+
+public class ExternalProcessEndpoint {
+
+ public String runExternal(String sh, String op0, String op1) {
+ // https://developer.openstack.org/api-guide/quick-start/api-quick-start.html
+ StringBuffer buffer = new StringBuffer();
+ try {
+ ProcessBuilder processBuilder = new ProcessBuilder(
+ Configuration.get(Configuration.LOCAL, "script-dir") + sh, op0, op1);
+ processBuilder.redirectErrorStream(true);
+ Process process = processBuilder.start();
+ InputStreamReader isr = new InputStreamReader(process.getInputStream());
+ BufferedReader buff = new BufferedReader (isr);
+ String line;
+ //int lineCount = 0;
+ while((line = buff.readLine()) != null) {
+ System.out.println(line);
+ buffer.append(line);
+ //if(lineCount > 2) {
+ // break;
+ //}
+ //lineCount+=1;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ // simulate
+ try { TimeUnit.SECONDS.sleep(35); } catch (InterruptedException ie) { ie.printStackTrace(); }
+ return buffer.toString();
+ }
+ public static void main(String[] args) {
+ ExternalProcessEndpoint ep = new ExternalProcessEndpoint();
+ System.out.println(ep.runExternal("openstack_port_list.sh","network", "list"));
+
+ }
+
+}
diff --git a/onap-demo.web/src/main/openstack_port_list.sh b/onap-demo.web/src/main/openstack_port_list.sh
new file mode 100755
index 0000000..2c63fe7
--- /dev/null
+++ b/onap-demo.web/src/main/openstack_port_list.sh
@@ -0,0 +1,4 @@
+ping vid
+#cd /Users/michaelobrien/wse_onap/onap
+#source admin.rc
+#openstack port list
diff --git a/onap-demo.web/src/main/resources/static/index.html b/onap-demo.web/src/main/resources/static/index.html
index 69ab0f3..7378c46 100644
--- a/onap-demo.web/src/main/resources/static/index.html
+++ b/onap-demo.web/src/main/resources/static/index.html
@@ -8,16 +8,25 @@
body {font-family: Monospace; background-color: #ddd; margin: 0px; overflow: hidden;}
#info {position: absolute; color: #fff; top: 0px; width: 100%; padding: 5px; text-align:center;}
a {color: #fff;}
+ #info {position: absolute; top: 10px; width: 100%; text-align: center; z-index: 100;display:block;}
+
+
+
+
+
- |
+ |
Dashboard |
+ Description
@@ -110,7 +242,7 @@
d2
-
+
@@ -126,7 +258,8 @@