Skip to content

Commit b819211

Browse files
committed
CLOUDSTACK-8331: have savepassword try all interfaces
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 3262b0b commit b819211

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎systemvm/patches/debian/config/opt/cloud/bin/passwd_server_ip.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ def getTokenFile():
4646
return '/tmp/passwdsrvrtoken'
4747

4848
def getPasswordFile():
49-
return '/var/cache/cloud/passwords'
49+
return '/var/cache/cloud/passwords-%s' % listeningAddress
5050

5151
def initToken():
5252
global secureToken
53-
secureToken = binascii.hexlify(os.urandom(16))
54-
with open(getTokenFile(), 'w') as f:
55-
f.write(secureToken)
53+
if os.path.exists(getTokenFile()):
54+
with open(getTokenFile(), 'r') as f:
55+
secureToken = f.read()
56+
if not secureToken:
57+
secureToken = binascii.hexlify(os.urandom(16))
58+
with open(getTokenFile(), 'w') as f:
59+
f.write(secureToken)
5660

5761
def checkToken(token):
5862
return token == secureToken
@@ -152,6 +156,7 @@ def do_POST(self):
152156
if not ip or not password:
153157
syslog.syslog('serve_password: empty ip/password[%s/%s] received from savepassword' % (ip, password))
154158
return
159+
syslog.syslog('serve_password: password saved for VM IP %s' % ip)
155160
setPassword(ip, password)
156161
savePasswordFile()
157162
return

‎systemvm/patches/debian/config/opt/cloud/bin/savepassword.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fi
3838
ps aux | grep passwd_server_ip.py |grep -v grep 2>&1 > /dev/null
3939
if [ $? -eq 0 ]
4040
then
41-
ips=$(ip addr show dev eth0 | grep inet | grep eth0 | awk '{print $2}')
41+
ips=$(ip addr show | grep inet | awk '{print $2}')
4242
for ip in $ips; do
4343
server_ip=$(echo $ip | awk -F'/' '{print $1}')
4444
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 &

0 commit comments

Comments
 (0)