-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cda34e3
commit 557933a
Showing
12 changed files
with
440 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
onap-demo.web/src/main/java/org/onap/demo/integration/WSContent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
onap-demo.web/src/main/java/org/onap/demo/integration/WSController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() + "!"); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
onap-demo.web/src/main/java/org/onap/demo/integration/WSMessage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
onap-demo.web/src/main/java/org/onap/demo/integration/WebSocketConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
onap-demo.web/src/main/java/org/onap/demo/sbi/ExternalProcessEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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")); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ping vid | ||
#cd /Users/michaelobrien/wse_onap/onap | ||
#source admin.rc | ||
#openstack port list |
Oops, something went wrong.