Repository: cloudstack Updated Branches: refs/heads/4.5 488625b19 -> 294503a02
CLOUDSTACK-8331: savepassword should try all IPs on eth0 The logic is same as passwd_server_ip script which runs password server on all IPs on eth0 interface. Signed-off-by: Rohit Yadav <rohit.ya...@shapeblue.com> Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/294503a0 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/294503a0 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/294503a0 Branch: refs/heads/4.5 Commit: 294503a0251a1305c61a83bf4a094c1af8030a4c Parents: 488625b Author: Rohit Yadav <rohit.ya...@shapeblue.com> Authored: Tue Mar 17 14:21:48 2015 +0530 Committer: Rohit Yadav <rohit.ya...@shapeblue.com> Committed: Tue Mar 17 14:21:48 2015 +0530 ---------------------------------------------------------------------- .../patches/debian/config/opt/cloud/bin/passwd_server_ip.py | 5 +++-- systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/294503a0/systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py b/systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py index 097d4fb..7476666 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py @@ -39,6 +39,7 @@ from SocketServer import ThreadingMixIn #, ForkingMixIn passMap = {} secureToken = None +listeningAddress = '127.0.0.1' lock = threading.RLock() def getTokenFile(): @@ -133,7 +134,7 @@ class PasswordRequestHandler(BaseHTTPRequestHandler): self.send_response(200) self.end_headers() clientAddress = self.client_address[0] - if clientAddress not in ['localhost', '127.0.0.1']: + if clientAddress not in ['localhost', '127.0.0.1', listeningAddress]: syslog.syslog('serve_password: non-localhost IP trying to save password: %s' % clientAddress) self.send_response(403) return @@ -162,7 +163,7 @@ class PasswordRequestHandler(BaseHTTPRequestHandler): def serve(HandlerClass = PasswordRequestHandler, ServerClass = ThreadedHTTPServer): - listeningAddress = '127.0.0.1' + global listeningAddress if len(sys.argv) > 1: listeningAddress = sys.argv[1] http://git-wip-us.apache.org/repos/asf/cloudstack/blob/294503a0/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh ---------------------------------------------------------------------- diff --git a/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh b/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh index 4a870fb..7fdc99f 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh @@ -30,7 +30,6 @@ do ;; esac done -SERVER_IP=$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') TOKEN_FILE="/tmp/passwdsrvrtoken" TOKEN="" if [ -f $TOKEN_FILE ]; then @@ -39,5 +38,9 @@ fi ps aux | grep passwd_server_ip.py |grep -v grep 2>&1 > /dev/null if [ $? -eq 0 ] then - curl --header "DomU_Request: save_password" "http://$SERVER_IP:8080/" -F "ip=$VM_IP" -F "password=$PASSWORD" -F "token=$TOKEN" + ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}') + for ip in $ips; do + server_ip=$(echo $ip | awk -F'/' '{print $1}') + curl --header "DomU_Request: save_password" "http://$server_ip:8080/" -F "ip=$VM_IP" -F "password=$PASSWORD" -F "token=$TOKEN" >/dev/null 2>/dev/null & + done fi