From efa34361df72e351cdc1f719a5dba705eab771ef Mon Sep 17 00:00:00 2001 From: wilderrodrigues Date: Fri, 3 Jul 2015 14:29:57 +0200 Subject: [PATCH] CLOUDSTACK-8607 - Changed update script to return exit code based on the result - Changed location of the update_host_passwd script - Updated the patch files for XenServer - Updated the script path on LibvirtComputing class - Removed the hostIP from the LibvirtUpdateHostPasswordCommandWrapper execute() method --- .../resource/LibvirtComputingResource.java | 2 +- ...bvirtUpdateHostPasswordCommandWrapper.java | 3 +-- ...itrixUpdateHostPasswordCommandWrapper.java | 1 + .../{kvm => }/update_host_passwd.sh | 10 +++++--- .../xenserver/update_host_passwd.sh | 24 ------------------- scripts/vm/hypervisor/xenserver/xcposs/patch | 1 + .../vm/hypervisor/xenserver/xcpserver/patch | 2 +- .../vm/hypervisor/xenserver/xenserver56/patch | 2 +- .../hypervisor/xenserver/xenserver56fp1/patch | 2 +- .../vm/hypervisor/xenserver/xenserver60/patch | 2 +- .../vm/hypervisor/xenserver/xenserver62/patch | 2 +- .../vm/hypervisor/xenserver/xenserver65/patch | 2 +- .../cloud/resource/ResourceManagerImpl.java | 2 +- 13 files changed, 18 insertions(+), 37 deletions(-) rename scripts/vm/hypervisor/{kvm => }/update_host_passwd.sh (80%) delete mode 100755 scripts/vm/hypervisor/xenserver/update_host_passwd.sh diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 782ea2864b4..5419a602b2a 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -523,7 +523,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv } protected String getDefaultHypervisorScriptsDir() { - return "scripts/vm/hypervisor/kvm"; + return "scripts/vm/hypervisor"; } protected String getDefaultKvmScriptsDir() { diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpdateHostPasswordCommandWrapper.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpdateHostPasswordCommandWrapper.java index 7ed827d8969..4d7d2347e3e 100644 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpdateHostPasswordCommandWrapper.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtUpdateHostPasswordCommandWrapper.java @@ -36,12 +36,11 @@ public final class LibvirtUpdateHostPasswordCommandWrapper extends CommandWrappe @Override public Answer execute(final UpdateHostPasswordCommand command, final LibvirtComputingResource libvirtComputingResource) { - final String hostIp = command.getHostIp(); final String username = command.getUsername(); final String newPassword = command.getNewPassword(); final Script script = new Script(libvirtComputingResource.getUpdateHostPasswdPath(), TIMEOUT, s_logger); - script.add(hostIp, username, newPassword); + script.add(username, newPassword); final String result = script.execute(); if (result != null) { diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixUpdateHostPasswordCommandWrapper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixUpdateHostPasswordCommandWrapper.java index 7d0c99abaa3..d5a530b41e3 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixUpdateHostPasswordCommandWrapper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/CitrixUpdateHostPasswordCommandWrapper.java @@ -43,6 +43,7 @@ public final class CitrixUpdateHostPasswordCommandWrapper extends CommandWrapper final String newPassword = command.getNewPassword(); final StringBuffer cmdLine = new StringBuffer(); + cmdLine.append("sh /opt/cloud/bin/"); cmdLine.append(VRScripts.UPDATE_HOST_PASSWD); cmdLine.append(' '); cmdLine.append(username); diff --git a/scripts/vm/hypervisor/kvm/update_host_passwd.sh b/scripts/vm/hypervisor/update_host_passwd.sh similarity index 80% rename from scripts/vm/hypervisor/kvm/update_host_passwd.sh rename to scripts/vm/hypervisor/update_host_passwd.sh index 39e4a3b8642..9dfc5a900f1 100755 --- a/scripts/vm/hypervisor/kvm/update_host_passwd.sh +++ b/scripts/vm/hypervisor/update_host_passwd.sh @@ -18,7 +18,11 @@ username=$1 new_passwd=$2 +expected="successfully." +result=`echo -e "$new_passwd\n$new_passwd" | passwd --stdin $username | grep successfully | awk '{ print $6 }'` -echo -e "$new_passwd\n$new_passwd" | passwd --stdin $username - -return $?; \ No newline at end of file +if [ $result = $expected ]; then + exit 0 +else + exit 1 +fi \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/update_host_passwd.sh b/scripts/vm/hypervisor/xenserver/update_host_passwd.sh deleted file mode 100755 index 39e4a3b8642..00000000000 --- a/scripts/vm/hypervisor/xenserver/update_host_passwd.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -username=$1 -new_passwd=$2 - -echo -e "$new_passwd\n$new_passwd" | passwd --stdin $username - -return $?; \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xcposs/patch b/scripts/vm/hypervisor/xenserver/xcposs/patch index 561d7b683b0..d3c5db05245 100644 --- a/scripts/vm/hypervisor/xenserver/xcposs/patch +++ b/scripts/vm/hypervisor/xenserver/xcposs/patch @@ -58,3 +58,4 @@ router_proxy.sh=../../../../network/domr/,0755,/opt/cloud/bin cloudstack_plugins.conf=..,0644,/etc/xensource cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins cloudlog=..,0644,/etc/logrotate.d +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xcpserver/patch b/scripts/vm/hypervisor/xenserver/xcpserver/patch index 62e15e31356..862aa2e9c11 100644 --- a/scripts/vm/hypervisor/xenserver/xcpserver/patch +++ b/scripts/vm/hypervisor/xenserver/xcpserver/patch @@ -59,4 +59,4 @@ add_to_vcpus_params_live.sh=..,0755,/opt/cloud/bin cloudstack_plugins.conf=..,0644,/etc/xensource cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins cloudlog=..,0644,/etc/logrotate.d -update_host_passwd.sh=..,0755,/opt/cloud/bin \ No newline at end of file +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xenserver56/patch b/scripts/vm/hypervisor/xenserver/xenserver56/patch index 2145b315eec..23da0f37172 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56/patch @@ -63,4 +63,4 @@ add_to_vcpus_params_live.sh=..,0755,/opt/cloud/bin cloudstack_plugins.conf=..,0644,/etc/xensource cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins cloudlog=..,0644,/etc/logrotate.d -update_host_passwd.sh=..,0755,/opt/cloud/bin \ No newline at end of file +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch index 60404dcbb47..a67224f8306 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver56fp1/patch @@ -62,4 +62,4 @@ add_to_vcpus_params_live.sh=..,0755,/opt/cloud/bin cloudstack_plugins.conf=..,0644,/etc/xensource cloudstack_pluginlib.py=..,0755,/etc/xapi.d/plugins cloudlog=..,0644,/etc/logrotate.d -update_host_passwd.sh=..,0755,/opt/cloud/bin \ No newline at end of file +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xenserver60/patch b/scripts/vm/hypervisor/xenserver/xenserver60/patch index c22d469777e..cf2f03e0f3c 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver60/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver60/patch @@ -68,4 +68,4 @@ ovs-pvlan-cleanup.sh=../../../network,0755,/opt/cloud/bin ovs-get-dhcp-iface.sh=..,0755,/opt/cloud/bin ovs-get-bridge.sh=..,0755,/opt/cloud/bin cloudlog=..,0644,/etc/logrotate.d -update_host_passwd.sh=..,0755,/opt/cloud/bin \ No newline at end of file +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xenserver62/patch b/scripts/vm/hypervisor/xenserver/xenserver62/patch index 090192443a5..11d979de9c4 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver62/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver62/patch @@ -64,4 +64,4 @@ ovs-pvlan-cleanup.sh=../../../network,0755,/opt/cloud/bin ovs-get-dhcp-iface.sh=..,0755,/opt/cloud/bin ovs-get-bridge.sh=..,0755,/opt/cloud/bin cloudlog=..,0644,/etc/logrotate.d -update_host_passwd.sh=..,0755,/opt/cloud/bin \ No newline at end of file +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/scripts/vm/hypervisor/xenserver/xenserver65/patch b/scripts/vm/hypervisor/xenserver/xenserver65/patch index 090192443a5..11d979de9c4 100644 --- a/scripts/vm/hypervisor/xenserver/xenserver65/patch +++ b/scripts/vm/hypervisor/xenserver/xenserver65/patch @@ -64,4 +64,4 @@ ovs-pvlan-cleanup.sh=../../../network,0755,/opt/cloud/bin ovs-get-dhcp-iface.sh=..,0755,/opt/cloud/bin ovs-get-bridge.sh=..,0755,/opt/cloud/bin cloudlog=..,0644,/etc/logrotate.d -update_host_passwd.sh=..,0755,/opt/cloud/bin \ No newline at end of file +update_host_passwd.sh=../..,0755,/opt/cloud/bin \ No newline at end of file diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index e9825ff0af8..b777de92d58 100644 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -2265,7 +2265,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, if (shouldUpdateHostPasswd) { final boolean isUpdated = doUpdateHostPassword(host.getId()); if (!isUpdated) { - throw new CloudRuntimeException("CloudStack failed to update the password of the Host with UUID/ID ==> " + host.getUuid() + "/" + host.getId() + ". Please make sure you are still able to connect to your hosts."); + throw new CloudRuntimeException("CloudStack failed to update the password of the Host with UUID / ID ==> " + host.getUuid() + " / " + host.getId() + ". Please make sure you are still able to connect to your hosts."); } } }