Simon Hunt
Committed by Gerrit Code Review

CORD GUI - Define runtime properties 'headnodeip' and 'headnodeport'.

- put scripts (pullwar.sh, run.me, stop.me) under revision control.

Change-Id: I58078e8134d643d976271b60fe80ff28f9458ca9
...@@ -64,7 +64,7 @@ public class CordModelCache extends JsonFactory { ...@@ -64,7 +64,7 @@ public class CordModelCache extends JsonFactory {
64 */ 64 */
65 CordModelCache() { 65 CordModelCache() {
66 log.info("Initialize model cache"); 66 log.info("Initialize model cache");
67 - subscriberId = XosManager.INSTANCE.initDemoSubscriber(); 67 + subscriberId = XosManager.INSTANCE.initXosSubscriber();
68 currentBundle = new Bundle(BundleFactory.BASIC_BUNDLE); 68 currentBundle = new Bundle(BundleFactory.BASIC_BUNDLE);
69 initUsers(); 69 initUsers();
70 } 70 }
......
...@@ -38,17 +38,22 @@ public class XosManager { ...@@ -38,17 +38,22 @@ public class XosManager {
38 38
39 private static final ObjectMapper MAPPER = new ObjectMapper(); 39 private static final ObjectMapper MAPPER = new ObjectMapper();
40 40
41 - private static final String TEST_XOS_SERVER_ADDRESS = "10.254.1.22"; 41 + private static final String HEAD_NODE_IP = "headnodeip";
42 + private static final String HEAD_NODE_PORT = "headnodeport";
43 + private static final int PORT_MIN = 1025;
44 + private static final int PORT_MAX = 65535;
45 +
46 + private static final String TEST_XOS_SERVER_IP = "10.254.1.22";
47 + private static final String TEST_XOS_SERVER_PORT_STR = "8000";
42 private static final int TEST_XOS_SERVER_PORT = 8000; 48 private static final int TEST_XOS_SERVER_PORT = 8000;
43 private static final String URI_RS = "/rs/"; 49 private static final String URI_RS = "/rs/";
44 private static final String URI_SUBSCRIBER = "/rs/subscriber/%d/"; 50 private static final String URI_SUBSCRIBER = "/rs/subscriber/%d/";
45 private static final String BUNDLE_URI_FORMAT = "services/%s/%s/"; 51 private static final String BUNDLE_URI_FORMAT = "services/%s/%s/";
46 52
47 53
48 - private final XosManagerRestUtils xosUtilsRs = 54 + private String xosServerIp;
49 - new XosManagerRestUtils(TEST_XOS_SERVER_ADDRESS, 55 + private int xosServerPort;
50 - TEST_XOS_SERVER_PORT, URI_RS); 56 + private XosManagerRestUtils xosUtilsRs;
51 -
52 private XosManagerRestUtils xosUtils; 57 private XosManagerRestUtils xosUtils;
53 58
54 59
...@@ -59,11 +64,38 @@ public class XosManager { ...@@ -59,11 +64,38 @@ public class XosManager {
59 */ 64 */
60 XosManager() {} 65 XosManager() {}
61 66
67 + private String getXosServerIp() {
68 + return System.getProperty(HEAD_NODE_IP, TEST_XOS_SERVER_IP);
69 + }
70 +
71 + private int getXosServerPort() {
72 + String p = System.getProperty(HEAD_NODE_PORT, TEST_XOS_SERVER_PORT_STR);
73 + int port;
74 + try {
75 + port = Integer.valueOf(p);
76 + } catch (NumberFormatException e) {
77 + port = TEST_XOS_SERVER_PORT;
78 + log.warn("Could not parse port number [{}], using {}", p, port);
79 + }
80 + if (port < PORT_MIN || port > PORT_MAX) {
81 + log.warn("Bad port number [{}], using {}", port, TEST_XOS_SERVER_PORT);
82 + port = TEST_XOS_SERVER_PORT;
83 + }
84 + return port;
85 + }
86 +
62 /** 87 /**
63 * Queries XOS for the Demo Subscriber ID and caches it for future calls. 88 * Queries XOS for the Demo Subscriber ID and caches it for future calls.
64 */ 89 */
65 - public int initDemoSubscriber() { 90 + public int initXosSubscriber() {
66 log.info("intDemoSubscriber() called"); 91 log.info("intDemoSubscriber() called");
92 + xosServerIp = getXosServerIp();
93 + xosServerPort = getXosServerPort();
94 + log.info("Using XOS server at {}:{}", xosServerIp, xosServerPort);
95 +
96 + xosUtilsRs = new XosManagerRestUtils(xosServerIp, xosServerPort, URI_RS);
97 +
98 + // ask XOS for the subscriber ID of the canned Demo account...
67 String result = xosUtilsRs.getRest("initdemo/"); 99 String result = xosUtilsRs.getRest("initdemo/");
68 log.info("from XOS: {}", result); 100 log.info("from XOS: {}", result);
69 101
...@@ -80,8 +112,7 @@ public class XosManager { ...@@ -80,8 +112,7 @@ public class XosManager {
80 log.info("Using DEMO subscriber ID {}.", demoId); 112 log.info("Using DEMO subscriber ID {}.", demoId);
81 113
82 String uri = String.format(URI_SUBSCRIBER, demoId); 114 String uri = String.format(URI_SUBSCRIBER, demoId);
83 - xosUtils = new XosManagerRestUtils(TEST_XOS_SERVER_ADDRESS, 115 + xosUtils = new XosManagerRestUtils(xosServerIp, xosServerPort, uri);
84 - TEST_XOS_SERVER_PORT, uri);
85 return demoId; 116 return demoId;
86 } 117 }
87 118
......
1 +cp $ONOS_ROOT/apps/demo/cord-gui/target/cord-gui-1.2.0-SNAPSHOT.war .
1 +#######------------------------------------------------------------
2 +# CORD Demo
3 +# =========
4 +
5 +export JETTY="-jar jetty-runner.jar"
6 +export CORD=./cord-gui-1.2.0-SNAPSHOT.war
7 +export LOGDBG=-Dorg.onosproject.cord.gui.LEVEL=DEBUG
8 +export DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n"
9 +export LOG=cord.log
10 +
11 +IP="$1"
12 +PORT="$2"
13 +
14 +if [ ! -z "$IP" ]
15 +then
16 + PARAM1="-Dheadnodeip=$IP"
17 +else
18 + PARAM1=""
19 +fi
20 +
21 +if [ ! -z "$PORT" ]
22 +then
23 + PARAM2="-Dheadnodeport=$PORT"
24 +else
25 + PARAM2=""
26 +fi
27 +
28 +java $PARAM1 $PARAM2 $LOGDBG $JETTY $CORD >$LOG 2>&1 &
29 +#java $PARAM1 $PARAM2 $LOGDBG $DEBUG $JETTY $CORD >$LOG 2>&1 &
30 +
31 +echo jetty-runner started {$PARAM1:$PARAM2}
32 +echo .. logging to $LOG
1 +# script to stop the cord gui server
2 +#
3 +PID=$(ps | grep jetty-runner | grep -v grep | cut -c1-5)
4 +if [ -z "$PID" ]
5 +then
6 + echo jetty-runner not running
7 + exit 0
8 +fi
9 +kill $PID
10 +sleep 1
11 +
12 +PID=$(ps | grep jetty-runner | grep -v grep | cut -c1-5)
13 +if [ ! -z "$PID" ]
14 +then
15 + echo jetty-runner still running ?
16 +else
17 + echo jetty-runner stopped
18 +fi