Ignore:
Timestamp:
Aug 19, 2010, 4:15:44 PM (14 years ago)
Author:
rock
Message:

Modify: Collect host & guest IP/number.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/functions_drbl_virt

    r179 r180  
    5050# [Select Hypervisior(Xen/KVM)]
    5151function VMM_select(){
     52echo ""
    5253if [ $cpu_flag == "yes" ]; then
    5354    while [ "$VMM_select" != "1" -a "$VMM_select" != "2"  ]
     
    5657    done
    5758  if [ $VMM_select == "1"  ]; then
    58     echo "Xen" > $Work_Home/.tmp/hypervisior
     59    echo "Xen" > $Work_Home/etc/hypervisior
    5960  else
    60     echo "KVM" > $Work_Home/.tmp/hypervisior
     61    echo "KVM" > $Work_Home/etc/hypervisior
    6162  fi 
    6263else
     
    6566    echo ""
    6667    VMM_select=1
    67     echo "Xen" > $Work_Home/.tmp/hypervisior
     68    echo "Xen" > $Work_Home/etc/hypervisior
    6869fi 
    6970}   
     
    7374function install_drbl-virt_dir(){
    7475    mkdir -p $Work_Home/.tmp
     76    mkdir -p $Work_Home/etc
    7577}
    7678
     
    7880# [Check Hypervisior]
    7981function check_hypervisior(){
    80     hypervisior=$(cat $Work_Home/.tmp/hypervisior)   
     82    hypervisior=$(cat $Work_Home/etc/hypervisior)   
    8183}
    8284
     
    154156
    155157
     158function get_DRBL_eth(){
     159eths=$(ls /etc/drbl | grep macadr-eth[0-9] | grep [0-9].txt | cut -d "-" -f2 | cut -d "." -f1)
     160eths_nu=$(echo $eths | wc -l)
     161
     162
     163}
     164
    156165function get_Host_IP_range(){
    157 cat /etc/drbl/IP_HOST_TABLE | sed "${Host_first_Line}p"
    158 cat /etc/drbl/IP_HOST_TABLE | sed "${Host_final_Line}p"                   
    159 declare -i Host_first_Line=$(cat -n /etc/drbl/IP_HOST_TABLE  | grep "# Created by DRBL (drblpush), begin" | awk '{print $1}')
    160 Host_first_Line=$((${Host_first_Line}+1))
    161                        
    162 declare -i Host_final_Line=$(cat -n /etc/drbl/IP_HOST_TABLE  | grep "# Created by DRBL (drblpush), end" | awk '{print $1}')
    163 Host_final_Line=$((${Host_final_Line}-1))
    164 #echo "$Host_first_Line"
    165 #echo "$Host_final_Line"
    166                                                                            
    167 Host_first_IP=$(cat /etc/drbl/IP_HOST_TABLE | sed -n "${Host_first_Line}p"| awk '{print $1}')
    168 Host_final_IP=$(cat /etc/drbl/IP_HOST_TABLE | sed -n "${Host_final_Line}p"| awk '{print $1}')
    169 #echo $Host_first_IP                                                                                                                                                 
    170 #echo $Host_final_IP
     166if [ ! -e /usr/bin/ipcalc ] || [ ! -e /opt/drbl/bin/drbl-get-network ] || [ ! -e /opt/drbl/bin/drbl-get-ipadd ]; then
     167    echo "Don't find /usr/bin/ipcalc /opt/drbl/bin/drbl-get-network & /opt/drbl/bin/drbl-get-ipadd"
     168    exit 0
     169fi
     170
     171# get eth network
     172eth_address=$(/opt/drbl/bin/drbl-get-ipadd $1)
     173eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $1)
     174eth_network=$(/opt/drbl/bin/drbl-get-network $eth_address $eth_netmask)
     175eth_network_f3=$(echo $eth_network | cut -d "." -f 1-3)
     176
     177IP_nu=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | wc -l)
     178Host_first_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==1 {print $1}" | awk '{print 1}')
     179Host_last_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==$IP_nu {print $1}"| awk '{print $1}')
     180
    171181}
    172182
    173183function get_VM_IP_range(){
    174 echo ""       
    175 echo "Your drbl client IP range $Host_first_IP ~ $Host_final_IP"
    176 declare -i Host_final_IP_4=$(echo $Host_final_IP | cut -d "." -f4)
    177 Host_final_IP_4=$(($Host_final_IP_4+1))                       
    178 VM_first_IP=$(echo $Host_final_IP | cut -d "." -f 1-3)
    179 VM_first_IP="${VM_first_IP}.${Host_final_IP_4}"       
    180 echo "The VM IP Range will start from $VM_first_IP"   
    181 while [ $jude != "yes" -a $jude != "y" ];             
    182 do             
    183     read "Input your IP range for VM: " VM_IP_range   
    184 done           
    185 echo "VM_first_IP=$VM_first_IP" > $Work_Home/.tmp/IP_VM_TABLE
    186 echo "VM_IP_range=$VM_IP_range" >> $Work_Home/.tmp/IP_VM_TABLE
    187 
    188 }
    189 
    190 # [DRBL Check]
    191 
    192 
    193 
     184echo ""
     185echo "DRBL client IP range -> $1 [$Host_first_IP ~ $Host_last_IP]"
     186
     187declare -i Host_last_IP_4=$(echo $Host_last_IP | cut -d "." -f4)
     188Host_last_IP_4=$(($Host_last_IP_4+1))
     189VM_first_IP=$(echo $Host_last_IP | cut -d "." -f 1-3)
     190VM_first_IP="${VM_first_IP}.${Host_last_IP_4}"
     191
     192echo "The VM IP Range will start from -> [$VM_first_IP]"
     193jude="no"
     194while [ $jude != "yes" -a $jude != "y" ];
     195do
     196    echo ""
     197    echo "Input VM number/IP range in $1 (ex. 40)."
     198    read -p "(If you have 10 PCs(4-core), suggestion is 30): " VM_IP_range
     199    read -p "Is it correct? (yes/no): " jude
     200done
     201
     202#echo "VM_first_IP=$VM_first_IP"
     203#echo "VM_IP_range=$VM_IP_range"
     204}
     205
     206function get_VM_prefix_name(){
     207jude="no"
     208while [ $jude != "yes" -a $jude != "y" ];
     209do
     210    echo ""
     211    read -p "Input Prefix name for VM in $1 (ex. drblvm): " VM_prefix_name
     212    read -p "Is it correct? (yes/no): " jude
     213done
     214#echo "VM_prefix_name=$VM_prefix_name"
     215}
     216
     217function create_VM_IP_table(){
     218#/etc/drbl-virt/etc/IP_VM_eth
     219
     220}
     221
     222
     223
     224
Note: See TracChangeset for help on using the changeset viewer.