Changeset 1285
- Timestamp:
- 03/19/10 14:46:43 (4 months ago)
- Files:
-
- 1 modified
-
trunk/tools/datacenter/vzImport.sh (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/datacenter/vzImport.sh
r1284 r1285 3 3 # vzImport.sh 4 4 #PURPOSE 5 # Using vzlist -a output populate the tContainer table 5 # Using vzlist -a output populate the tContainer table. 6 6 #AUTHOR 7 # (C) 2010 Hugo Urquiza for Unixservice, LLC. 7 # (C) 2010 Hugo Urquiza and Gary Wallis for Unixservice, LLC. 8 # GPLv2 license applies. See LICENSE file. 8 9 # 9 10 #NOTES 10 11 # This is a very basic script, written to perform 11 # a migration task. Therefore initially its command 12 # line options and arguments will be replaced by 13 # code variables. 12 # a specific migration task. 14 13 # 15 14 16 uStartVEID=100; 15 #Set these constants, make sure any tables they refer to have the correct data. 17 16 cVEIDStatus="stopped"; 17 uStatus=31;#must match above via tStatus; 18 18 uDatacenter=1; 19 19 uNode=1; 20 20 uNameserver=1; 21 uSkip=1; 21 uSearchdomain=1; 22 uOwner=1; 23 uCreatedBy=1; 22 24 # CTID NPROC STATUS IP_ADDR HOSTNAME 23 25 # 181 48 running 174.121.136.100 ns1.ringcarrier.com … … 25 27 while read cvzlist 26 28 do 27 # if [ "$uSkip"=="1" ]; then 28 # uSkip=0; 29 # continue; 30 # fi 31 29 cVZStatus=`echo $cvzlist | awk -F' ' '{print $3}'`; 30 if [ "$cVZStatus" != "$cVEIDStatus" ]; then 31 continue; 32 fi 32 33 uContainer=`echo $cvzlist | awk -F' ' '{print $1}'`; 33 cStatus=`echo $cvzlist | awk -F' ' '{print $3}'`;34 34 cIP=`echo $cvzlist | awk -F' ' '{print $4}'`; 35 35 cHostname=`echo $cvzlist | awk -F' ' '{print $5}'`; 36 cLabel= =`echo $cHostname | awk -F. '{print $1}'`;36 cLabel=`echo $cHostname | awk -F. '{print $1}'`; 37 37 cOSTemplate=`cat /etc/vz/conf/$uContainer.conf | grep OSTEMPLATE | awk -F= '{print $2}' | awk -F'"' '{print $2}'`; 38 38 cConfig=`cat /etc/vz/conf/$uContainer.conf | grep ORIGIN_SAMPLE | awk -F= '{print $2}' | awk -F'"' '{print $2}'`; 39 uStatus=31; 39 40 41 echo uContainer=$uContainer; 42 echo cLabel=$cLabel; 43 echo cHostname=$cHostname; 44 #uVeth=0; 45 #uIPv4= from select of first available tIP.uIP then we need to mark unavailble in 2nd query. 46 #uOSTemplate from select. Must preload tOSTemplate from mysqldump of source unxsVZ db. 47 echo cOSTemplate=$cOSTemplate; 48 #uConfig from select. Must preload tConfig from mysqldump of source unxsVZ db. 49 echo cConfig=$cConfig; 50 #uNameserver fixed above. tNameserver must have correct info. 51 echo uNameserver=$uNameserver; 52 #uSearchdomain. Same as above. 53 echo uSearchdomain=$uSearchdomain; 54 #uDatacenter. Same as above. 55 echo uDatacenter=$uDatacenter; 56 #uNode. Same as above. 57 echo uNode=$uNode; 58 echo uStatus=$uStatus; 59 echo uOwner=$uOwner; 60 echo uCreatedBy=$uCreatedBy; 61 echo ""; 40 62 41 cQuery="INSERT INTO tContainer SET uContainer=$uContainer,cLabel='$cLabel',uIPv4=(SELECT uIP FROM tIP WHERE cLabel='$cIP'),uOSTemplate=(SELECT uOSTemplate FROM tOSTemplate WHERE cLabel='$cOSTemplate'),uConfig=(SELECT uConfig FROM tConfig WHERE cLabel='$cConfig',uNameserver=$uNameserver,uSearchdomain=(SELECT uSearchdomain FROM tSearchdomain WHERE cLabel='$cSearchdomain',uDatacenter=$uDatacenter,uNode=$uNode,uStatus=$uStatus,uOwner=$uOwner,uCreatedBy=$uCreatedBy,uCreatedDate=UNIX_TIMESTAMP(NOW())";42 echo $cQuery;63 #cQuery="INSERT INTO tContainer SET uContainer=$uContainer,cLabel='$cLabel',uIPv4=(SELECT uIP FROM tIP WHERE cLabel='$cIP'),uOSTemplate=(SELECT uOSTemplate FROM tOSTemplate WHERE cLabel='$cOSTemplate'),uConfig=(SELECT uConfig FROM tConfig WHERE cLabel='$cConfig',uNameserver=$uNameserver,uSearchdomain=(SELECT uSearchdomain FROM tSearchdomain WHERE cLabel='$cSearchdomain',uDatacenter=$uDatacenter,uNode=$uNode,uStatus=$uStatus,uOwner=$uOwner,uCreatedBy=$uCreatedBy,uCreatedDate=UNIX_TIMESTAMP(NOW())"; 64 # echo $cQuery; 43 65 done 44 66
