Changeset 183 for drbl-virt/sbin
- Timestamp:
- Aug 20, 2010, 12:00:37 PM (14 years ago)
- Location:
- drbl-virt/sbin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
drbl-virt/sbin/drbl_PXE_PV-VM_deploy.sh
r182 r183 12 12 source /opt/drbl-virt/conf/drbl-virt.conf 13 13 source $Work_Path/functions_drbl_virt 14 14 source ./functions_drbl_virt 15 15 # [Main] 16 16 # = 0. Variables setup = … … 32 32 Host_last_IP="" 33 33 get_Host_IP_range 34 34 35 # == Get VM number, IP range & prefix name == 35 36 declare -i VM_IP_range="" 36 37 declare -i Host_last_IP_4="" 38 declare -i VM_Host_totoal_nu="" 37 39 VM_first_IP="" 38 40 VM_last_IP="" … … 41 43 create_VM_IP_table 42 44 43 done 45 # == Generate MAC address == 46 # MAC address [00:16:3e:xx:xx:xx] is for Xen use 47 generate_Xen_MAC_address 48 44 49 45 50 51 done 46 52 47 53 # = 1. Copy VM fs = -
drbl-virt/sbin/functions_drbl_virt
r182 r183 236 236 #/etc/drbl-virt/etc/IP_VM_eth 237 237 VM_prefix_eth=$(echo $eth | sed 's/eth//g') 238 declare -iVM_Host_totoal_nu=$((${Host_last_IP_4}-1+${VM_IP_range}))238 VM_Host_totoal_nu=$((${Host_last_IP_4}-1+${VM_IP_range})) 239 239 if [ -e /opt/drbl-virt/etc/IP_VM_$eth ]; then 240 240 mv /opt/drbl-virt/etc/IP_VM_$eth /opt/drbl-virt/etc/IP_VM_${eth}.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak … … 244 244 declare -i VM_IP_2="" 245 245 declare -i VM_IP_3="" 246 247 246 248 247 # 2 bit … … 268 267 VM_IP_3=$i 269 268 echo "${eth_network_f3}.${VM_IP_3} ${VM_prefix_name}${VM_IP_0}${VM_IP_1}${VM_IP_2}${VM_IP_3}" >> /opt/drbl-virt/etc/IP_VM_$eth 270 elif [ $i - lt 100 ]; then269 elif [ $i -ge 10 ] && [ $i -lt 100 ]; then 271 270 VM_IP_1=0 272 271 VM_IP_2=$i … … 282 281 } 283 282 284 285 286 283 function generate_Xen_MAC_address(){ 284 echo "eth $eth" 285 echo "VM_Host_totoal_nu $VM_Host_totoal_nu" 286 echo "Host_last_IP_4 $Host_last_IP_4" 287 echo "VM_prefix_eth $VM_prefix_eth" 288 289 # /opt/drbl-virt/etc/macadr-VM-ethX.txt 290 # MAC address [00:16:3e:xx:xx:xx] is for Xen use 291 declare -i Xen_MAC_1="0" 292 declare -i Xen_MAC_2="$VM_prefix_eth" 293 declare -i Xen_MAC_3="0" 294 declare -i Xen_MAC_4="0" 295 Xen_MAC_5="" 296 Xen_MAC_6="" 297 298 # backup 299 mv /opt/drbl-virt/etc/macadr-VM-$eth.txt /opt/drbl-virt/etc/macadr-VM-$eth.txt.$(date +%Y-%m-%d-%H-%M-%S).drbl-virt_bak 300 301 # generate MAC 302 for (( i=0 ; i<="$VM_Host_totoal_nu" ; i++ )) 303 do 304 if [ $i -lt 10 ]; then 305 Xen_MAC_5=0 306 Xen_MAC_6=$i 307 echo "00:16:3e:${Xen_MAC_1}${Xen_MAC_2}:${Xen_MAC_3}${Xen_MAC_4}:${Xen_MAC_5}${Xen_MAC_6}" >> /opt/drbl-virt/etc/macadr-VM-$eth.txt 308 elif [ $i -ge 10 ] && [ $i -le 15 ] ; then 309 Xen_MAC_5=0 310 # translate 10(dec) to 16(hex) 311 printf '%X\n' $i > /tmp/drbl-virt_MAC 312 Xen_MAC_6=$(cat /tmp/drbl-virt_MAC) 313 echo "00:16:3e:${Xen_MAC_1}${Xen_MAC_2}:${Xen_MAC_3}${Xen_MAC_4}:${Xen_MAC_5}${Xen_MAC_6}" >> /opt/drbl-virt/etc/macadr-VM-$eth.txt 314 else 315 printf '%X\n' $i > /tmp/drbl-virt_MAC 316 Xen_MAC_5=$(cat /tmp/drbl-virt_MAC) 317 echo "00:16:3e:${Xen_MAC_1}${Xen_MAC_2}:${Xen_MAC_3}${Xen_MAC_4}:${Xen_MAC_5}" >> /opt/drbl-virt/etc/macadr-VM-$eth.txt 318 fi 319 done 320 321 322 } 323 324
Note: See TracChangeset
for help on using the changeset viewer.