Changeset 1285

Show
Ignore:
Timestamp:
03/19/10 14:46:43 (4 months ago)
Author:
Gary
Message:

unxsVZ datacenter/vzImport.sh save commit work in progress.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/tools/datacenter/vzImport.sh

    r1284 r1285  
    33#       vzImport.sh 
    44#PURPOSE 
    5 #       Using vzlist -a output populate the tContainer table 
     5#       Using vzlist -a output populate the tContainer table. 
    66#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. 
    89# 
    910#NOTES 
    1011#       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. 
    1413#        
    1514 
    16 uStartVEID=100; 
     15#Set these constants, make sure any tables they refer to have the correct data. 
    1716cVEIDStatus="stopped"; 
     17uStatus=31;#must match above via tStatus; 
    1818uDatacenter=1;   
    1919uNode=1; 
    2020uNameserver=1; 
    21 uSkip=1; 
     21uSearchdomain=1; 
     22uOwner=1; 
     23uCreatedBy=1; 
    2224#      CTID      NPROC STATUS  IP_ADDR         HOSTNAME                         
    2325#       181         48 running 174.121.136.100 ns1.ringcarrier.com   
     
    2527while read cvzlist 
    2628do 
    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 
    3233        uContainer=`echo $cvzlist | awk -F' ' '{print $1}'`; 
    33         cStatus=`echo $cvzlist | awk -F' ' '{print $3}'`; 
    3434        cIP=`echo $cvzlist | awk -F' ' '{print $4}'`; 
    3535        cHostname=`echo $cvzlist | awk -F' ' '{print $5}'`; 
    36         cLabel==`echo $cHostname | awk -F. '{print $1}'`; 
     36        cLabel=`echo $cHostname | awk -F. '{print $1}'`; 
    3737        cOSTemplate=`cat /etc/vz/conf/$uContainer.conf | grep OSTEMPLATE | awk -F= '{print $2}' | awk -F'"' '{print $2}'`; 
    3838        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 ""; 
    4062         
    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; 
    4365done 
    4466