Index: /drbl-virt/sbin/check_drbl_client.sh
===================================================================
--- /drbl-virt/sbin/check_drbl_client.sh	(revision 195)
+++ /drbl-virt/sbin/check_drbl_client.sh	(revision 195)
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Program:
+#   Check DRBL client status
+# Author: 
+#   Jazz, Rock {jazz, rock}@nchc.org.tw
+# Version:
+#    1.0
+# History:                                                                                          
+#   2010/08/29  Rock    First release (1.0) 
+
+source /opt/drbl-virt/conf/drbl-virt.conf
+source $Work_Path/functions_drbl_virt
+
+
+# [Varliables]
+client_IPs=$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | awk '{print $1}')
+drbl_client_file="/tmp/drbl_client_status.$$"
+drbl_client_top_file="/tmp/drbl_client_top.$$"
+
+
+# [Main] 
+for client_IP in $client_IPs
+do
+    # local variables
+    client_hostname="$(cat $Work_Home/etc/IP_HOST_TABLE | grep -v "#" | awk '{print $2}')"
+    IP_status="online"
+    client_CPU_core=""
+    client_Ram=""
+    client_idle_CPU=""
+    client_unused_Ram=""
+    # check network status
+    ping -c1 -w1 $client_IP > /dev/null 2>&1 || IP_status="offline"
+
+    if [ $IP_status == "online" ]; then
+        # check CPU core
+        client_CPU_core=$(ssh -o StrictHostKeyChecking=no $client_IP "cat /proc/cpuinfo |grep processor | wc -l")
+        # check top information
+        ssh -o StrictHostKeyChecking=no $client_IP "top -b -n1" > $drbl_client_top_file
+        client_idle_CPU=$(cat $drbl_client_top_file | grep ^Cpu | sed 's/^.*ni,//' | sed 's/id,.*$//'  | awk '{print $1}')
+        client_Ram=$(cat $drbl_client_top_file | grep ^Mem | sed 's/total.*$//' | sed 's/^Mem://' | awk '{print $1}')
+        client_unused_Ram=$(cat $drbl_client_top_file | grep ^Mem | sed 's/^.*used,//' | sed 's/free.*$//' | awk '{print $1}')
+    fi
+
+echo "$client_hostname $client_IP $IP_status CPU_Core=$client_CPU_core Ram=$client_Ram idle_CPU=$client_idle_CPU unused_Ram=$client_unused_Ram"
+echo "$client_hostname $client_IP $IP_status $client_CPU_core $client_Ram $client_idle_CPU $client_unused_Ram" >> $drbl_client_file
+
+done
+
+
Index: /drbl-virt/sbin/drbl_PXE_PV-VM_create.sh
===================================================================
--- /drbl-virt/sbin/drbl_PXE_PV-VM_create.sh	(revision 194)
+++ /drbl-virt/sbin/drbl_PXE_PV-VM_create.sh	(revision 195)
@@ -11,6 +11,6 @@
 # [Source]
 source /opt/drbl-virt/conf/drbl-virt.conf
-#source $Work_Path/functions_drbl_PXE_PV-VM_create
-source ./functions_drbl_PXE_PV-VM_create
+source $Work_Path/functions_drbl_virt
+#source ./functions_drbl_PXE_PV-VM_create
 
 
@@ -28,8 +28,8 @@
 echo "Usage: drbl_PXE_PV-VM_create.sh options"
 echo "Options: "
-echo "-v    vm name"
-echo "-c    cpu number"
-echo "-r    ram size"
-echo "-h    deploy vm to which host"
+echo "-v|--vm      vm name"
+echo "-c|--cpu     cpu number"
+echo "-r|--ram     ram size"
+echo "-h|--host    deploy vm to which host"
 echo "Examples: "
 echo "drbl_PXE_PV-VM_create.sh options -v drbl110 -c 2 -r 512 -h drbl101"
@@ -46,5 +46,5 @@
 while [ $# -gt 0 ]; do
     case "$1" in
-        -v)
+        -v|--vm)
             shift
             if [ -z "$(echo $1 |grep ^-.)" ]; then
@@ -58,5 +58,5 @@
             fi
             ;;
-        -c)
+        -c|--cpu)
             shift
             if [ -z "$(echo $1 |grep ^-.)" ]; then
@@ -70,5 +70,5 @@
             fi
             ;;
-        -r)
+        -r|--ram)
             shift 
             if [ -z "$(echo $1 |grep ^-.)" ]; then
@@ -82,5 +82,5 @@
             fi 
             ;;  
-        -h)
+        -h|--host)
             shift 
             if [ -z "$(echo $1 |grep ^-.)" ]; then
@@ -138,5 +138,5 @@
 fi
 
-vm_cfg=${vm_dir}/${vm_name}.cfg
+vm_cfg=${vm_dir}/${vm_name}_PXE_PV-VM.cfg
 
 if [ -e $vm_cfg ]; then
Index: /drbl-virt/sbin/drbl_xen_repush.sh
===================================================================
--- /drbl-virt/sbin/drbl_xen_repush.sh	(revision 194)
+++ /drbl-virt/sbin/drbl_xen_repush.sh	(revision 195)
@@ -30,6 +30,8 @@
     cp /etc/drbl/IP_HOST_TABLE /etc/drbl/IP_HOST_TABLE.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak
     cp -f /etc/drbl/IP_HOST_TABLE.drbl-virt_bak /etc/drbl/IP_HOST_TABLE
+    cp -f /etc/drbl/IP_HOST_TABLE.drbl-virt_bak /opt/drbl-virt/etc/IP_HOST_TABLE
 else
     cp /etc/drbl/IP_HOST_TABLE /etc/drbl/IP_HOST_TABLE.drbl-virt_bak
+    cp /etc/drbl/IP_HOST_TABLE /opt/drbl-virt/etc/IP_HOST_TABLE
 fi  
 
Index: bl-virt/sbin/functions_drbl_PXE_PV-VM_create
===================================================================
--- /drbl-virt/sbin/functions_drbl_PXE_PV-VM_create	(revision 194)
+++ 	(revision )
@@ -1,38 +1,0 @@
-#!/bin/bash
-# Program:
-#   Function for drbl_PXE_PV-VM_create.sh 
-# Author: 
-#   Jazz, Rock {jazz, rock}@nchc.org.tw
-# Version:
-#    1.0
-# History:
-#   2010/07/20  Rock    First release (1.0)
-
-# [Variable Declation]
-
-# [Check Root]
-function check_root(){      
-  if [ $USER != "root" ]; then
-    echo -e "Please change root to run it!"
-    exit
-  fi
-} 
-
-
-function check_root_run(){
-    if [ $USER != "root" ]; then
-    echo -e "Please change root to run it!"
-    sudo su -c ~/"$0" "$@"
-    exit
-fi
-}
-
-# [Check Parameter]
-#function check_parameters(){
-#echo "fun $1"
-#if [ -z $(echo $1) ]; then
-#Usage && exit 2
-#fi
-#
-#}
-
Index: /drbl-virt/sbin/functions_drbl_virt
===================================================================
--- /drbl-virt/sbin/functions_drbl_virt	(revision 194)
+++ /drbl-virt/sbin/functions_drbl_virt	(revision 195)
@@ -16,4 +16,5 @@
 VMM_select=""
 
+
 # [Check Root]
 function check_root(){      
@@ -24,4 +25,5 @@
 } 
 
+# [Change root to run]
 function check_root_run(){
     if [ $USER != "root" ]; then
@@ -41,4 +43,5 @@
 }
 
+
 # [Check System Version]
 function check_systemInfo(){
@@ -47,4 +50,5 @@
 Linux_Version=$(lsb_release -r | awk '{print $2}')
 }
+
 
 # [Select Hypervisior(Xen/KVM)]
@@ -70,4 +74,5 @@
 }   
 
+
 # [Check Hypervisior]
 function check_hypervisior(){
@@ -140,4 +145,5 @@
 
 
+# [Tunning Debain env for Xen]
 function debain-lenny_xen_patch(){
 echo xen.independent_wallclock=1 >> /etc/sysctl.conf
@@ -148,4 +154,5 @@
 
 
+# [Get ethX for DRBL environment usage ]
 function get_DRBL_eth(){
 eths=$(ls /etc/drbl | grep macadr-eth[0-9] | grep [0-9].txt$ | cut -d "-" -f2 | cut -d "." -f1)
@@ -160,4 +167,6 @@
 }
 
+
+# [Get DRBL client IP range]
 function get_Host_IP_range(){
 if [ ! -e /usr/bin/ipcalc ] || [ ! -e /opt/drbl/bin/drbl-get-network ] || [ ! -e /opt/drbl/bin/drbl-get-ipadd ]; then
@@ -175,6 +184,7 @@
 }
 
+
+# [Input VM IP range]
 function get_VM_IP_range_and_prefix_name(){
-
 echo ""
 echo "DRBL client IP range -> $eth: [$Host_first_IP ~ $Host_last_IP]"
@@ -213,4 +223,5 @@
 
 
+# [Get VM prefix name]
 #function get_VM_prefix_name(){ 
 #jude="no"
@@ -224,4 +235,6 @@
 #}
 
+
+# [Create VM IP table]
 function create_VM_IP_table(){
 #/etc/drbl-virt/etc/IP_VM_eth
@@ -271,4 +284,6 @@
 }
 
+
+# [Creat VM Mac table]
 function generate_Xen_MAC_address(){
 #echo "eth $eth"
@@ -312,4 +327,5 @@
 }
 
+
 #function add_VM_dhcpd_conf(){
 ## backup dhcpd.conf
@@ -353,2 +369,36 @@
 }  
 
+
+# [create ssh key amd cpoy to client]
+function drbl_sshkey(){
+# The reasone we do not to use $HOME is that sudo will not change
+# environmental variable $HOME, but it will change the $USER
+# we need to know who is really running this after applying sudo.
+# say, sudo echo "$HOME", it will show user's home, instead of root's home,
+REALHOME=$(LC_ALL=C grep -Ew "^$USER" /etc/passwd | cut -d":" -f6)
+drblroot="/tftpboot/nodes"
+
+if [ ! -f $REALHOME/.ssh/id_rsa ]; then
+  ssh-keygen -t rsa -q -f $REALHOME/.ssh/id_rsa -N ""
+fi
+
+# Put authorized_keys for the user. 2 cases:
+# (1). It is root running drbl-doit.
+# (2). It is normal user running drbl-doit.
+# For root, we will NOT copy authorized_keys in server, since the root in the client should not share the same authorized_keys with that in server. We only put them in the client. (Note! Every client has its own root directory in $ihost/root/)
+# For normal user, we let user can ssh login back to server and other machine without password (Note! This is NFS-based home, so we just have to copy id_rsa.pub as authorized_keys in user's home, then no matter which machine user logins, it will use this key).
+if [ "$UID" = "0" ]; then
+  # for root, copy id_rsa.pub as authorized_keys in clients.
+  for ihost in $drblroot/*; do
+    if [ -f "$REALHOME/.ssh/id_rsa.pub" ]; then
+      mkdir -p $ihost/root/.ssh
+      cp -af $REALHOME/.ssh/id_rsa.pub $ihost/root/.ssh/authorized_keys
+    fi
+  done
+else
+  if [ -f "$REALHOME/.ssh/id_rsa.pub" ]; then
+    cp -af $REALHOME/.ssh/id_rsa.pub $REALHOME/.ssh/authorized_keys
+  fi
+fi
+
+}
