Changeset 182


Ignore:
Timestamp:
Aug 20, 2010, 10:29:05 AM (14 years ago)
Author:
rock
Message:

Modify: The smae

Location:
drbl-virt/sbin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • drbl-virt/sbin/drbl_PXE_PV-VM_deploy.sh

    r181 r182  
    3232    Host_last_IP=""
    3333    get_Host_IP_range
    34     # == Get VM number & IP range ==
     34    # == Get VM number, IP range & prefix name ==
    3535    declare -i VM_IP_range=""
    3636    declare -i Host_last_IP_4=""
    3737    VM_first_IP=""
    3838    VM_last_IP=""
    39     get_VM_IP_range
    40     # == Get VM IP prefix hostname  ==
    4139    VM_prefix_name=""
    42     get_VM_prefix_name
    43    
     40    get_VM_IP_range_and_prefix_name
     41    create_VM_IP_table
    4442
    4543done
  • drbl-virt/sbin/functions_drbl_virt

    r181 r182  
    158158function get_DRBL_eth(){
    159159eths=$(ls /etc/drbl | grep macadr-eth[0-9] | grep [0-9].txt$ | cut -d "-" -f2 | cut -d "." -f1)
    160 eths_nu=$(echo $eths | wc -l)
    161 
     160eths_nu=$(echo $eths | wc -w)
     161
     162if [ $eths_nu -gt 1 ]; then
     163    echo ""
     164    echo "There are multiple eth for DRBL environment: "
     165    echo "$eths"
     166fi
    162167
    163168}
     
    181186}
    182187
    183 function get_VM_IP_range(){
     188function get_VM_IP_range_and_prefix_name(){
     189
    184190echo ""
    185 echo "DRBL client IP range -> $eth [$Host_first_IP ~ $Host_last_IP]"
    186 
    187 declare -i Host_last_IP_4=$(echo $Host_last_IP | cut -d "." -f4)
     191echo "DRBL client IP range -> $eth: [$Host_first_IP ~ $Host_last_IP]"
     192
     193Host_last_IP_4=$(echo $Host_last_IP | cut -d "." -f4)
    188194Host_last_IP_4=$(($Host_last_IP_4+1))
    189195VM_first_IP=$(echo $Host_last_IP | cut -d "." -f 1-3)
     
    195201do
    196202    echo ""
    197     echo "Input VM number/IP range in $eth (ex. 40)."
    198     read -p "(If you have 10 PCs(4-core), suggestion is 30): " VM_IP_range
     203    echo "Input VM number/IP range for $eth (ex. 40)."
     204
     205    jude_2="no"
     206    while [ $jude_2 != "yes" -a $jude_2 != "y" ]
     207    do
     208        jude_2="yes"
     209        read -p "(If you have 10 PCs(4-core), suggestion is 30): " VM_IP_range
     210        if [ $((${VM_IP_range}+${Host_last_IP_4})) -ge 254 ]; then
     211            echo "range can't greater than 254"
     212            jude_2="no"
     213        fi
     214    done
     215
     216    read -p "Input Prefix name for VM for $eth (ex. drblvm): " VM_prefix_name
    199217    read -p "Is it correct? (yes/no): " jude
    200218done
     
    204222}
    205223
    206 function get_VM_prefix_name(){
    207 jude="no"
    208 while [ $jude != "yes" -a $jude != "y" ];
    209 do
    210     echo ""
    211     read -p "Input Prefix name for VM in $eth (ex. drblvm): " VM_prefix_name
    212     read -p "Is it correct? (yes/no): " jude
    213 done
     224#function get_VM_prefix_name(){
     225#jude="no"
     226#while [ $jude != "yes" -a $jude != "y" ];
     227#do
     228#    echo ""
     229#    read -p "Input Prefix name for VM for $eth (ex. drblvm): " VM_prefix_name
     230#    read -p "Is it correct? (yes/no): " jude
     231#done
    214232#echo "VM_prefix_name=$VM_prefix_name"
    215 }
     233#}
    216234
    217235function create_VM_IP_table(){
     
    230248# 2 bit
    231249if [ $VM_Host_totoal_nu -lt 100 ]; then
    232     for (( i=$Host_last_IP_4 ; i<="$VM_IP_range" ; i++ ))
     250    for (( i=$Host_last_IP_4 ; i<="$VM_Host_totoal_nu" ; i++ ))
    233251    do
    234252        if [ $i -lt 10 ]; then
     
    238256        else
    239257            VM_IP_1=$i
    240             echo "${eth_network_f3}.$VM_IP_1 ${VM_prefix_name}${VM_IP_0}${VM_IP_1}" >> /opt/drbl-virt/etc/IP_VM_$et
     258            echo "${eth_network_f3}.$VM_IP_1 ${VM_prefix_name}${VM_IP_0}${VM_IP_1}" >> /opt/drbl-virt/etc/IP_VM_$eth
    241259        fi
    242260    done
    243261# 3 bit
    244262elif [ $VM_Host_totoal_nu -ge 100 ] && [ $VM_Host_totoal_nu -lt 254 ]; then
    245     for (( i=$Host_last_IP_4 ; i<=$VM_IP_range ; i++ ))
     263    for (( i=$Host_last_IP_4 ; i<=$VM_Host_totoal_nu ; i++ ))
    246264    do
    247265        if [ $i -lt 10 ]; then
Note: See TracChangeset for help on using the changeset viewer.