Skip to content

Commit 3c8be55

Browse files
author
Sheng Yang
committed
CLOUDSTACK-2792: Call savepassword.sh inside VR for Xen
Also only set password when password service is running, thus avoid setting for redundant router BACKUP router.
1 parent 93188b4 commit 3c8be55

7 files changed

Lines changed: 79 additions & 76 deletions

File tree

‎core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -549,13 +549,14 @@ protected Answer execute(final SavePasswordCommand cmd) {
549549
final String vmIpAddress = cmd.getVmIpAddress();
550550
final String local = vmName;
551551

552-
// Run save_password_to_domr.sh
553-
final String result = savePassword(routerPrivateIPAddress, vmIpAddress, password, local);
552+
String args = "-v " + vmIpAddress;
553+
args += " -p " + password;
554+
555+
String result = routerProxy("savepassword.sh", routerPrivateIPAddress, args);
554556
if (result != null) {
555557
return new Answer(cmd, false, "Unable to save password to DomR.");
556-
} else {
557-
return new Answer(cmd);
558558
}
559+
return new Answer(cmd);
559560
}
560561

561562
protected Answer execute (final DhcpEntryCommand cmd) {
@@ -1169,11 +1170,6 @@ public boolean configure(final String name, final Map<String, Object> params) th
11691170
throw new ConfigurationException("Unable to find the call_loadbalancer.sh");
11701171
}
11711172

1172-
_savepasswordPath = findScript("save_password_to_domr.sh");
1173-
if(_savepasswordPath == null) {
1174-
throw new ConfigurationException("Unable to find save_password_to_domr.sh");
1175-
}
1176-
11771173
_dhcpEntryPath = findScript("dhcp_entry.sh");
11781174
if(_dhcpEntryPath == null) {
11791175
throw new ConfigurationException("Unable to find dhcp_entry.sh");
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# Copyright 2012 Citrix Systems, Inc. Licensed under the
3+
# Apache License, Version 2.0 (the "License"); you may not use this
4+
# file except in compliance with the License. Citrix Systems, Inc.
5+
# reserves all rights not expressly granted by the License.
6+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
#
13+
# Automatically generated by addcopyright.py at 04/03/2012
14+
15+
16+
17+
18+
19+
# Usage
20+
# save_password -v <user VM IP> -p <password>
21+
22+
source /root/func.sh
23+
24+
lock="passwdlock"
25+
#default timeout value is 30 mins as password reset command is not synchronized on agent side any more,
26+
#and multiple commands can be sent to the same VR at a time
27+
locked=$(getLockFile $lock 1800)
28+
if [ "$locked" != "1" ]
29+
then
30+
exit 1
31+
fi
32+
33+
PASSWD_FILE=/var/cache/cloud/passwords
34+
35+
while getopts 'v:p:' OPTION
36+
do
37+
case $OPTION in
38+
v) VM_IP="$OPTARG"
39+
;;
40+
p)
41+
ENCODEDPASSWORD="$OPTARG"
42+
PASSWORD=$(echo $ENCODEDPASSWORD | tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]')
43+
;;
44+
?) echo "Incorrect usage"
45+
unlock_exit 1 $lock $locked
46+
;;
47+
esac
48+
done
49+
50+
[ -f $PASSWD_FILE ] || touch $PASSWD_FILE
51+
52+
sed -i /$VM_IP/d $PASSWD_FILE
53+
54+
ps aux | grep serve_password.sh |grep -v grep 2>&1 > /dev/null
55+
if [ $? -eq 0 ]
56+
then
57+
echo "$VM_IP=$PASSWORD" >> $PASSWD_FILE
58+
else
59+
echo "$VM_IP=saved_password" >> $PASSWD_FILE
60+
fi
61+
62+
unlock_exit $? $lock $locked

‎patches/systemvm/debian/config/root/redundant_router/check_heartbeat.sh.templ‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ then
2525
if [ $diff -lt 30 ]
2626
then
2727
echo Keepalived process is dead! >> [RROUTER_LOG]
28+
[RROUTER_BIN_PATH]/services.sh stop >> [RROUTER_LOG] 2>&1
29+
[RROUTER_BIN_PATH]/disable_pubip.sh >> [RROUTER_LOG] 2>&1
30+
[RROUTER_BIN_PATH]/primary-backup.sh fault >> [RROUTER_LOG] 2>&1
2831
service keepalived stop >> [RROUTER_LOG] 2>&1
2932
service conntrackd stop >> [RROUTER_LOG] 2>&1
3033
pkill -9 keepalived >> [RROUTER_LOG] 2>&1
31-
[RROUTER_BIN_PATH]/disable_pubip.sh >> [RROUTER_LOG] 2>&1
34+
pkill -9 conntrackd >> [RROUTER_LOG] 2>&1
3235
echo Status: FAULT \(keepalived process is dead\) >> [RROUTER_LOG]
3336
exit
3437
fi

‎patches/systemvm/debian/config/root/redundant_router/fault.sh.templ‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ fi
2727

2828
echo To fault called >> [RROUTER_LOG]
2929
[RROUTER_BIN_PATH]/disable_pubip.sh >> [RROUTER_LOG] 2>&1
30+
echo Disable public ip >> [RROUTER_LOG]
31+
[RROUTER_BIN_PATH]/services.sh stop >> [RROUTER_LOG] 2>&1
32+
echo Stop services $? >> [RROUTER_LOG]
3033
[RROUTER_BIN_PATH]/primary-backup.sh fault >> [RROUTER_LOG] 2>&1
34+
echo Switch conntrackd mode fault $? >> [RROUTER_LOG]
3135
echo Status: FAULT >> [RROUTER_LOG]
3236

3337
releaseLockFile $lock $locked

‎patches/systemvm/debian/config/root/savepassword.sh‎

Lines changed: 0 additions & 58 deletions
This file was deleted.

‎plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,15 +2084,15 @@ protected Answer execute(SavePasswordCommand cmd) {
20842084
String args = " -v " + vmIpAddress;
20852085

20862086
if (s_logger.isDebugEnabled()) {
2087-
s_logger.debug("Run command on domain router " + controlIp + ", /root/savepassword.sh " + args + " -p " + StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
2087+
s_logger.debug("Run command on domain router " + controlIp + ", /opt/cloud/bin/savepassword.sh " + args + " -p " + StringUtils.getMaskedPasswordForDisplay(cmd.getPassword()));
20882088
}
20892089

20902090
args += " -p " + password;
20912091

20922092

20932093
try {
20942094
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
2095-
Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/root/savepassword.sh " + args);
2095+
Pair<Boolean, String> result = SshHelper.sshExecute(controlIp, DEFAULT_DOMR_SSHPORT, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/savepassword.sh " + args);
20962096

20972097
if (!result.first()) {
20982098
s_logger.error("savepassword command on domain router " + controlIp + " failed, message: " + result.second());

‎plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,16 +2229,12 @@ protected Answer execute(final SavePasswordCommand cmd) {
22292229
Connection conn = getConnection();
22302230
final String password = cmd.getPassword();
22312231
final String routerPrivateIPAddress = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
2232-
final String vmName = cmd.getVmName();
22332232
final String vmIpAddress = cmd.getVmIpAddress();
2234-
final String local = vmName;
22352233

2236-
// Run save_password_to_domr.sh
2237-
String args = "-r " + routerPrivateIPAddress;
2234+
String args = "savepassword.sh " + routerPrivateIPAddress;
22382235
args += " -v " + vmIpAddress;
22392236
args += " -p " + password;
2240-
args += " " + local;
2241-
String result = callHostPlugin(conn, "vmops", "savePassword", "args", args);
2237+
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
22422238

22432239
if (result == null || result.isEmpty()) {
22442240
return new Answer(cmd, false, "savePassword failed");

0 commit comments

Comments
 (0)