Repository: cloudstack Updated Branches: refs/heads/master ce2b2a1fc -> ae0cb8279
Both scripts should be able to use the data-server introduced in 4.4 Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ae0cb827 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ae0cb827 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ae0cb827 Branch: refs/heads/master Commit: ae0cb8279225db0b6d0f642a546792ba6f3f1117 Parents: ce2b2a1 Author: Hugo Trippaers <[email protected]> Authored: Fri Nov 28 14:08:47 2014 +0100 Committer: Hugo Trippaers <[email protected]> Committed: Mon Dec 1 14:56:58 2014 +0100 ---------------------------------------------------------------------- setup/bindir/cloud-set-guest-password.in | 69 +++++++++++++-------------- setup/bindir/cloud-set-guest-sshkey.in | 36 ++++++-------- 2 files changed, 48 insertions(+), 57 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0cb827/setup/bindir/cloud-set-guest-password.in ---------------------------------------------------------------------- diff --git a/setup/bindir/cloud-set-guest-password.in b/setup/bindir/cloud-set-guest-password.in index 4c7c575..2c7304b 100755 --- a/setup/bindir/cloud-set-guest-password.in +++ b/setup/bindir/cloud-set-guest-password.in @@ -40,45 +40,44 @@ for DHCP_FILE in $DHCP_FOLDERS; do if [ -n "$PASSWORD_SERVER_IP" ]; then logger -t "cloud" "Found password server IP $PASSWORD_SERVER_IP in $DHCP_FILE" - logger -t "cloud" "Sending request to password server at $PASSWORD_SERVER_IP" - - password=$(wget -q -t 3 -T 20 -O - --header "DomU_Request: send_my_password" $PASSWORD_SERVER_IP:$PASSWORD_SERVER_PORT) - - if [ $? -eq 0 ]; then - password=$(echo $password | tr -d '\r') - logger -t "cloud" "Got response from server at $PASSWORD_SERVER_IP" - - case $password in - "") - logger -t "cloud" "Password server at $PASSWORD_SERVER_IP did not have any password for the VM" - continue - ;; - "bad_request") - logger -t "cloud" "VM sent an invalid request to password server at $PASSWORD_SERVER_IP" - error_count=$((error_count+1)) - continue - ;; - "saved_password") - logger -t "cloud" "VM has already saved a password from the password server at $PASSWORD_SERVER_IP" - continue - ;; - *) - logger -t "cloud" "VM got a valid password from server at $PASSWORD_SERVER_IP" - password_received=1 - break - ;; - esac - else - logger -t "cloud" "Failed to send request to password server at $PASSWORD_SERVER_IP" - error_count=$((error_count+1)) - fi - else - logger -t "cloud" "Could not find password server IP in $DHCP_FILE" - error_count=$((error_count+1)) + break fi fi done +if [ -z "$PASSWORD_SERVER_IP" ] ; then + logger -t "cloud" "Unable to determine the password server, falling back to data-server" + PASSWORD_SERVER_IP=data-server +fi + +logger -t "cloud" "Sending request to password server at $PASSWORD_SERVER_IP" +password=$(wget -q -t 3 -T 20 -O - --header "DomU_Request: send_my_password" http://$PASSWORD_SERVER_IP:$PASSWORD_SERVER_PORT) +if [ $? -eq 0 ]; then + password=$(echo $password | tr -d '\r') + logger -t "cloud" "Got response from server at $PASSWORD_SERVER_IP" + + case $password in + "") + logger -t "cloud" "Password server at $PASSWORD_SERVER_IP did not have any password for the VM" + ;; + "bad_request") + logger -t "cloud" "VM sent an invalid request to password server at $PASSWORD_SERVER_IP" + error_count=$((error_count+1)) + ;; + "saved_password") + logger -t "cloud" "VM has already saved a password from the password server at $PASSWORD_SERVER_IP" + ;; + *) + logger -t "cloud" "VM got a valid password from server at $PASSWORD_SERVER_IP" + password_received=1 + ;; + esac +else + logger -t "cloud" "Failed to send request to password server at $PASSWORD_SERVER_IP" + error_count=$((error_count+1)) +fi + + if [ "$password_received" == "0" ]; then if [ "$error_count" == "$file_count" ]; then logger -t "cloud" "Failed to get password from any server" http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ae0cb827/setup/bindir/cloud-set-guest-sshkey.in ---------------------------------------------------------------------- diff --git a/setup/bindir/cloud-set-guest-sshkey.in b/setup/bindir/cloud-set-guest-sshkey.in index 4955dea..0472a7c 100755 --- a/setup/bindir/cloud-set-guest-sshkey.in +++ b/setup/bindir/cloud-set-guest-sshkey.in @@ -37,32 +37,24 @@ for DHCP_FILE in $DHCP_FOLDERS; do SSHKEY_SERVER_IP=$(grep dhcp-server-identifier $DHCP_FILE | tail -1 | awk '{print $NF}' | tr -d '\;') if [ -n "$SSHKEY_SERVER_IP" ]; then - logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP" - - publickey=$(wget -q -t 3 -T 20 -O - http://$SSHKEY_SERVER_IP/latest/public-keys) - - if [ $? -eq 0 ]; then - logger -t "cloud" "Got response from server at $SSHKEY_SERVER_IP" - keys_received=1 - break - fi + logger -t "cloud" "Found ssh key server at $SSHKEY_SERVER_IP" + break else - logger -t "cloud" "Could not find ssh key server IP in $DHCP_FILE trying with the name data-server " + logger -t "cloud" "Could not find ssh key server IP in $DHCP_FILE" fi fi done -if [ "$keys_received" == "0" ]; then - SSHKEY_SERVER_IP=$(nslookup data-server | grep Address |tr '\n' ' '| awk '{print $4}') - logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP" - publickey=$(wget -q -t 3 -T 20 -O - http://data-server/latest/public-keys) - if [ $? -eq 0 ] - then - logger -t "cloud" "Got response from server at $SSHKEY_SERVER_IP" - keys_received=1 - else - logger -t "cloud" "Could not resolve the name data-server" - fi +if [ -z "$SSHKEY_SERVER_IP" ]; then + logger -t "cloud" "Unable to determine the password server, falling back to data-server" + SSHKEY_SERVER_IP=data-server +fi + +logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP" +publickey=$(wget -q -t 3 -T 20 -O - http://$SSHKEY_SERVER_IP/latest/public-keys) +if [ $? -eq 0 ]; then + logger -t "cloud" "Got response from server at $SSHKEY_SERVER_IP" + keys_received=1 fi if [ "$keys_received" == "0" ]; then @@ -94,4 +86,4 @@ echo "$publickey" >> $authorized which restorecon && restorecon -R -v $sshdir -exit 0 \ No newline at end of file +exit 0
