Show
Ignore:
Timestamp:
03/20/10 09:16:51 (2 years ago)
Author:
Gary
Message:

unxsVZ tools/datacenter/vzImport.sh corrected during extensive tests.

Files:
1 modified

Legend:

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

    r1288 r1289  
    1414#       The first step was faking the new node on the source system 
    1515#       and running clone wizard after setting up the ssh stuff. 
     16# 
     17#TODO 
     18#       We need to get the actual MySQL query results to determine 
     19#       if something wrong or unexpected happened. 
    1620#        
    1721 
     
    6569        echo ""; 
    6670 
    67         #this is a nested read see do above 
    68         read -e -p "Commit $cHostname [y/n/s/q]?: " cReply < /dev/tty; 
    69         if [ "$cReply" == "n" ];then 
    70                 echo "Aborting commit and exiting $0"; 
    71                 exit 0; 
    72         fi       
    73         if [ "$cReply" == "s" ];then 
    74                 echo "Skipping $cHostname"; 
    75                 echo ""; 
    76                 continue; 
    77         fi       
    78         if [ "$cReply" != "y" ];then 
    79                 echo "Aborting commit and exiting $0"; 
    80                 exit 0; 
    81         fi       
    82  
    83         echo "Commiting to tContainer"; 
    84  
    8571        cQuery="SELECT uIP FROM tIP WHERE cLabel='$cIP' AND uAvailable=1"; 
    8672        uIPv4=`echo $cQuery | /usr/bin/mysql -pwsxedc -u unxsvz unxsvz | tail -n 1 | awk -F' ' '{print $1}'`; 
     
    10894 
    10995        cQuery="SELECT uContainer FROM tContainer WHERE cLabel='$cLabel' AND uDatacenter=$uDatacenter AND uNode=$uNode"; 
    110         uContainer=`echo $cQuery | /usr/bin/mysql -pwsxedc -u unxsvz unxsvz | tail -n 1 | awk -F' ' '{print $1}'`; 
     96        uCheckContainer=`echo $cQuery | /usr/bin/mysql -pwsxedc -u unxsvz unxsvz | tail -n 1 | awk -F' ' '{print $1}'`; 
    11197        if [ $? != 0 ];then 
    11298                echo "$cQuery failed"; 
    11399                exit 1; 
    114100        fi 
    115         echo uContainer=$uContainer; 
     101        echo uCheckContainer=$uCheckContainer; 
    116102 
    117         if [ "$uContainer" != "" ];then 
     103        if [ "$uCheckContainer" != "" ];then 
    118104                echo "Skipping container cLabel=$cLabel cHostname=$cHostname already in tContainer"; 
    119105                echo ""; 
     
    121107        fi 
    122108 
    123         #debug only 
    124         #echo ""; 
    125         #continue; 
     109        #this is a nested read see do above 
     110        read -e -p "Commit $cHostname [y/n/s/q]?: " cReply < /dev/tty; 
     111        if [ "$cReply" == "n" ];then 
     112                echo "Aborting commit and exiting $0"; 
     113                exit 0; 
     114        fi       
     115        if [ "$cReply" == "s" ];then 
     116                echo "Skipping $cHostname"; 
     117                echo ""; 
     118                continue; 
     119        fi       
     120        if [ "$cReply" != "y" ];then 
     121                echo "Aborting commit and exiting $0"; 
     122                exit 0; 
     123        fi       
     124 
     125        echo "Commiting to tContainer"; 
    126126 
    127127        cQuery="INSERT INTO tContainer SET uContainer=$uContainer,cLabel='$cLabel',cHostname='$cHostname',uIPv4=$uIPv4,uOSTemplate=$uOSTemplate,uConfig=$uConfig,uNameserver=$uNameserver,uSearchdomain=$uSearchdomain,uDatacenter=$uDatacenter,uNode=$uNode,uStatus=$uStatus,uOwner=$uOwner,uCreatedBy=$uCreatedBy,uCreatedDate=UNIX_TIMESTAMP(NOW())"; 
     
    133133        echo $cResult; 
    134134 
    135         cQuery="UPDATE tIP SET uAvailable=0 WHERE uIPv4=$uIPv4"; 
     135        cQuery="UPDATE tIP SET uAvailable=0 WHERE uIP=$uIPv4"; 
    136136        cResult=`echo $cQuery | /usr/bin/mysql -pwsxedc -u unxsvz unxsvz | tail -n 1`; 
    137137        if [ $? != 0 ];then 
     
    140140        fi 
    141141        echo $cResult; 
    142         echo "Commited"; 
     142        echo "Commit attempted"; 
    143143        echo ""; 
    144144done