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 747666607f9..91dec24e9ae 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 @@ -46,13 +46,17 @@ def getTokenFile(): return '/tmp/passwdsrvrtoken' def getPasswordFile(): - return '/var/cache/cloud/passwords' + return '/var/cache/cloud/passwords-%s' % listeningAddress def initToken(): global secureToken - secureToken = binascii.hexlify(os.urandom(16)) - with open(getTokenFile(), 'w') as f: - f.write(secureToken) + if os.path.exists(getTokenFile()): + with open(getTokenFile(), 'r') as f: + secureToken = f.read() + if not secureToken: + secureToken = binascii.hexlify(os.urandom(16)) + with open(getTokenFile(), 'w') as f: + f.write(secureToken) def checkToken(token): return token == secureToken @@ -152,6 +156,7 @@ class PasswordRequestHandler(BaseHTTPRequestHandler): if not ip or not password: syslog.syslog('serve_password: empty ip/password[%s/%s] received from savepassword' % (ip, password)) return + syslog.syslog('serve_password: password saved for VM IP %s' % ip) setPassword(ip, password) savePasswordFile() return diff --git a/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh b/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh index 7fdc99f6328..079b26f1b9e 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh @@ -38,7 +38,7 @@ fi ps aux | grep passwd_server_ip.py |grep -v grep 2>&1 > /dev/null if [ $? -eq 0 ] then - ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}') + ips=$(ip addr show | grep inet | 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 &