cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yas...@apache.org
Subject git commit: updated refs/heads/master to 35d20d1
Date Thu, 08 Aug 2013 17:41:43 GMT
Updated Branches:
  refs/heads/master 9807f8661 -> 35d20d163


CLOUDSTACK-4138: keep the existing changes in cloud-set-guest-sshkey.in to make sure we do
not break the backward compatibility

Signed-off-by: Sheng Yang <sheng.yang@citrix.com>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/35d20d16
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/35d20d16
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/35d20d16

Branch: refs/heads/master
Commit: 35d20d163dd74fa56324bbe3ebda52a33285f001
Parents: 9807f86
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Wed Aug 7 16:04:08 2013 +0530
Committer: Sheng Yang <sheng.yang@citrix.com>
Committed: Thu Aug 8 10:41:36 2013 -0700

----------------------------------------------------------------------
 setup/bindir/cloud-set-guest-sshkey.in | 49 +++++++++++++++++++++++------
 1 file changed, 40 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35d20d16/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 9436b03..68a209f 100755
--- a/setup/bindir/cloud-set-guest-sshkey.in
+++ b/setup/bindir/cloud-set-guest-sshkey.in
@@ -26,17 +26,48 @@
 # Modify this line to specify the user (default is root)
 user=root
 
-SSHKEY_SERVER_IP=$(nslookup data-server | grep Server | awk '{print $2}')
-logger -t "cloud" "Sending request to ssh key server at $SSHKEY_SERVER_IP"
+# Add your DHCP lease folders here
+DHCP_FOLDERS="/var/lib/dhclient/* /var/lib/dhcp3/*"
+keys_received=0
+file_count=0
+
+for DHCP_FILE in $DHCP_FOLDERS
+do
+    if [ -f $DHCP_FILE ]
+    then
+        file_count=$((file_count+1))
+        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 -t 3 -T 20 -O - http://$SSHKEY_SERVER_IP/latest/public-keys
2>/dev/null)
+
+            if [ $? -eq 0 ]
+            then
+                logger -t "cloud" "Got response from server at $SSHKEY_SERVER_IP"
+                keys_received=1
+                break
+            fi
+        else
+            logger -t "cloud" "Could not find ssh key server IP in $DHCP_FILE trying with
the name data-server "
+        fi
+    fi
+done
 
-publickey=$(wget -t 3 -T 20 -O - http://data-server/latest/public-keys 2>/dev/null)
-
-if [ $? -eq 0 ]
+if [ "$keys_received" == "0" ]
 then
-     logger -t "cloud" "Got response from server at $SSHKEY_SERVER_IP"
-     keys_received=1
-else
-     logger -t "cloud" "Could not find ssh key server IP in $DHCP_FILE"
+    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 -t 3 -T 20 -O - http://data-server/latest/public-keys 2>/dev/null)
+     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
 fi
 
 # did we find the keys anywhere?


Mime
View raw message