Changeset 180 for drbl-virt/sbin
- Timestamp:
- Aug 19, 2010, 4:15:44 PM (14 years ago)
- Location:
- drbl-virt/sbin
- Files:
-
- 1 added
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/drbl_PXE_PV-VM_deploy.sh
r179 r180 15 15 # [Main] 16 16 # = 0. Variables setup = 17 # == Get Host IP range/number == # 18 Host_first_IP="" 19 Host_final_IP="" 20 get_Host_IP_range 21 # == Get VM IP range/number == # 22 VM_IP_range="" 23 VM_first_IP="" 24 VM_final_IP="" 25 get_VM_IP_range 26 # == Get VM IP prefix hostname == # 17 # == Get DRBL eth == 18 eths="" 19 declare -i eth_nu="" 20 get_DRBL_eth 21 22 if [ $eth_nu -gt "1" ]; then 23 echo "" 24 echo "DRBL environment has muiltpule netwrok card(NIC)." 25 fi 26 27 for eth in $eths 28 do 29 30 # == Get Host IP range/number == 31 Host_first_IP="" 32 Host_last_IP="" 33 get_Host_IP_range $eth 34 # == Get VM number & IP range == 35 VM_IP_range="" 36 VM_first_IP="" 37 VM_last_IP="" 38 get_VM_IP_range $eth 39 # == Get VM IP prefix hostname == 40 VM_prefix_name="" 41 get_VM_prefix_name $eth 42 43 done 27 44 28 45 29 46 # = 1. Copy VM fs = 47 # Kernel & initrd -> /home/domains 48 30 49 31 50 # = 2. Add NFS config = -
drbl-virt/sbin/functions_drbl_virt
r179 r180 50 50 # [Select Hypervisior(Xen/KVM)] 51 51 function VMM_select(){ 52 echo "" 52 53 if [ $cpu_flag == "yes" ]; then 53 54 while [ "$VMM_select" != "1" -a "$VMM_select" != "2" ] … … 56 57 done 57 58 if [ $VMM_select == "1" ]; then 58 echo "Xen" > $Work_Home/ .tmp/hypervisior59 echo "Xen" > $Work_Home/etc/hypervisior 59 60 else 60 echo "KVM" > $Work_Home/ .tmp/hypervisior61 echo "KVM" > $Work_Home/etc/hypervisior 61 62 fi 62 63 else … … 65 66 echo "" 66 67 VMM_select=1 67 echo "Xen" > $Work_Home/ .tmp/hypervisior68 echo "Xen" > $Work_Home/etc/hypervisior 68 69 fi 69 70 } … … 73 74 function install_drbl-virt_dir(){ 74 75 mkdir -p $Work_Home/.tmp 76 mkdir -p $Work_Home/etc 75 77 } 76 78 … … 78 80 # [Check Hypervisior] 79 81 function check_hypervisior(){ 80 hypervisior=$(cat $Work_Home/ .tmp/hypervisior)82 hypervisior=$(cat $Work_Home/etc/hypervisior) 81 83 } 82 84 … … 154 156 155 157 158 function get_DRBL_eth(){ 159 eths=$(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 162 163 } 164 156 165 function 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 166 if [ ! -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 169 fi 170 171 # get eth network 172 eth_address=$(/opt/drbl/bin/drbl-get-ipadd $1) 173 eth_netmask=$(/opt/drbl/bin/drbl-get-netmask $1) 174 eth_network=$(/opt/drbl/bin/drbl-get-network $eth_address $eth_netmask) 175 eth_network_f3=$(echo $eth_network | cut -d "." -f 1-3) 176 177 IP_nu=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | wc -l) 178 Host_first_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==1 {print $1}" | awk '{print 1}') 179 Host_last_IP=$(cat /etc/drbl/IP_HOST_TABLE | grep $eth_network_f3 | awk "NR==$IP_nu {print $1}"| awk '{print $1}') 180 171 181 } 172 182 173 183 function 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 184 echo "" 185 echo "DRBL client IP range -> $1 [$Host_first_IP ~ $Host_last_IP]" 186 187 declare -i Host_last_IP_4=$(echo $Host_last_IP | cut -d "." -f4) 188 Host_last_IP_4=$(($Host_last_IP_4+1)) 189 VM_first_IP=$(echo $Host_last_IP | cut -d "." -f 1-3) 190 VM_first_IP="${VM_first_IP}.${Host_last_IP_4}" 191 192 echo "The VM IP Range will start from -> [$VM_first_IP]" 193 jude="no" 194 while [ $jude != "yes" -a $jude != "y" ]; 195 do 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 200 done 201 202 #echo "VM_first_IP=$VM_first_IP" 203 #echo "VM_IP_range=$VM_IP_range" 204 } 205 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 $1 (ex. drblvm): " VM_prefix_name 212 read -p "Is it correct? (yes/no): " jude 213 done 214 #echo "VM_prefix_name=$VM_prefix_name" 215 } 216 217 function 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.