From 8eaeb5111ca20f630cdbf524599ee1d433b5cccc Mon Sep 17 00:00:00 2001 From: edison Date: Thu, 2 Sep 2010 19:58:49 -0700 Subject: [PATCH] Backport from master, to make sure console-proxy always gets correct public.network.device --- .../bindir/cloud-setup-console-proxy.in | 11 ++++++----- console-proxy/libexec/console-proxy-runner.in | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/console-proxy/bindir/cloud-setup-console-proxy.in b/console-proxy/bindir/cloud-setup-console-proxy.in index 6ce89909cc4..d0bcce6f1bd 100755 --- a/console-proxy/bindir/cloud-setup-console-proxy.in +++ b/console-proxy/bindir/cloud-setup-console-proxy.in @@ -188,9 +188,6 @@ newhost = raw_input().strip() if newhost: host = newhost confopts["host"] = host -confopts["private.network.device"] = dev -confopts["public.network.device"] = dev - for opt,val in confopts.items(): line = "=".join([opt,val]) if opt not in confposes: lines.append(line) @@ -204,12 +201,16 @@ stderr("") stderr("Cloud Console Proxy setup completed successfully") stderr("Starting the Cloud Console Proxy") +try: + m = service("@PACKAGE@-console-proxy","stop") + print m.stdout + m.stderr +except CalledProcessError,e: + print e.stdout + e.stderr + try: m = service("@PACKAGE@-console-proxy","start") print m.stdout + m.stderr except CalledProcessError,e: print e.stdout + e.stderr bail(E_CPFAILEDTOSTART,"@PACKAGE@-console-proxy failed to start") - - # FIXMES: 1) nullify networkmanager on ubuntu (asking the user first) and enable the networking service permanently diff --git a/console-proxy/libexec/console-proxy-runner.in b/console-proxy/libexec/console-proxy-runner.in index a95b7200bd7..c1eb4d224eb 100755 --- a/console-proxy/libexec/console-proxy-runner.in +++ b/console-proxy/libexec/console-proxy-runner.in @@ -23,6 +23,20 @@ cd "@CPLIBDIR@" echo Current directory is "$PWD" echo CLASSPATH to run the agent: "$CLASSPATH" +export PATH=/sbin:/usr/sbin:"$PATH" +SERVICEARGS= +for x in private public ; do + configuration=`grep -q "^$x.network.device" "@CPSYSCONFDIR@"/agent.properties || true` + if [ -n "$CONFIGURATION" ] ; then + echo "Using manually-configured network device $CONFIGURATION" + else + defaultroute=`ip route | grep ^default | cut -d ' ' -f 5` + test -n "$defaultroute" + echo "Using auto-discovered network device $defaultroute which is the default route" + SERVICEARGS="$SERVICEARGS $x.network.device="$defaultroute + fi +done + function termagent() { if [ "$agentpid" != "" ] ; then echo Killing VMOps Console Proxy "(PID $agentpid)" with SIGTERM >&2 @@ -38,7 +52,7 @@ function termagent() { trap termagent TERM while true ; do - java -Xms128M -Xmx384M -cp "$CLASSPATH" "$@" com.cloud.agent.AgentShell & + java -Xms128M -Xmx384M -cp "$CLASSPATH" "$@" com.cloud.agent.AgentShell $SERVICEARGS & agentpid=$! echo "Console Proxy started. PID: $!" >&2 wait $agentpid