Changeset 1860

Show
Ignore:
Timestamp:
02/01/12 07:07:07 (4 months ago)
Author:
Dylan
Message:

unxsVZ minor extensions to datacenter and container tabs.

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/tcontainerfunc.h

    r1854 r1860  
    27962796                { 
    27972797                        ProcesstContainerVars(entries,x); 
    2798                         if(uStatus==uACTIVE && uAllowMod(uOwner,uCreatedBy)) 
     2798                        if( (uStatus==uACTIVE||uStatus==uSTOPPED) && uAllowMod(uOwner,uCreatedBy)) 
    27992799                        { 
    28002800                                guMode=0; 
     
    28142814                { 
    28152815                        ProcesstContainerVars(entries,x); 
    2816                         if(uStatus==uACTIVE && uAllowMod(uOwner,uCreatedBy)) 
     2816                        if( (uStatus==uACTIVE||uStatus==uSTOPPED) && uAllowMod(uOwner,uCreatedBy)) 
    28172817                        { 
    28182818                                unsigned uTargetDatacenter=0; 
     
    28592859                                        tContainer("<blink>Error:</blink> Create job for unxsBind," 
    28602860                                                                " but no cunxsBindARecordJobZone"); 
     2861 
     2862                                //label-cloneN and hostname.cloneN mess change to new format 
     2863                                // new hostname is based on source cLabel and cHostname 
     2864                                char cPrevHostname[100]={""}; 
     2865                                if(uSource) 
     2866                                { 
     2867                                        char cSourceHostname[100]={""}; 
     2868                                        char cWizLabel[33]={""}; 
     2869                                        char cNewLabel[33]={""}; 
     2870                                        char *cp=NULL; 
     2871                                        unsigned uWizLabelLoop=1; 
     2872                                        unsigned uWizLabelSuffix=0; 
     2873 
     2874                                        sprintf(cPrevHostname,"%s",cHostname); 
     2875 
     2876                                        sprintf(cLabel,"%.25s",ForeignKey("tContainer","cLabel",uSource)); 
     2877                                        //Get first available <cLabel>-clone<uNum> 
     2878                                        while(uWizLabelLoop) 
     2879                                        { 
     2880                                                uWizLabelSuffix++; 
     2881                                                if(uWizLabelSuffix>9) tContainer("<blink>Error:</blink> Clone limit reached"); 
     2882                                                sprintf(cWizLabel,"%.25s-clone%u",cLabel,uWizLabelSuffix); 
     2883                                                sprintf(gcQuery,"SELECT uContainer FROM tContainer WHERE cLabel='%s'",cWizLabel); 
     2884                                                mysql_query(&gMysql,gcQuery); 
     2885                                                if(mysql_errno(&gMysql)) 
     2886                                                        htmlPlainTextError(mysql_error(&gMysql)); 
     2887                                                res=mysql_store_result(&gMysql); 
     2888                                                uWizLabelLoop=mysql_num_rows(res); 
     2889                                                mysql_free_result(res); 
     2890                                        } 
     2891                                        sprintf(cNewLabel,"%.25s-clone%u",cLabel,uWizLabelSuffix); 
     2892                                        sprintf(cLabel,"%.32s",cNewLabel); 
     2893 
     2894                                        sprintf(cSourceHostname,"%.99s",ForeignKey("tContainer","cHostname",uSource)); 
     2895                                        if((cp=strchr(cSourceHostname,'.'))) 
     2896                                        { 
     2897                                                sprintf(cHostname,"%.32s.%.64s",cLabel,cp+1); 
     2898                                        } 
     2899                                } 
     2900 
    28612901                                uHostnameLen=strlen(cHostname); 
    28622902                                if(!strstr(cHostname+(uHostnameLen-strlen(cunxsBindARecordJobZone)-1),cunxsBindARecordJobZone)) 
    2863                                         tContainer("<blink>Error:</blink> cHostname must end with cunxsBindARecordJobZone"); 
     2903                                                tContainer("<blink>Error:</blink> cHostname must end with cunxsBindARecordJobZone"); 
     2904                                if(uSource) 
     2905                                { 
     2906                                        sprintf(gcQuery,"UPDATE tContainer SET cHostname='%s',cLabel='%s'" 
     2907                                                                " WHERE uContainer=%u",cHostname,cLabel,uContainer); 
     2908                                        mysql_query(&gMysql,gcQuery); 
     2909                                        if(mysql_errno(&gMysql)) 
     2910                                                htmlPlainTextError(mysql_error(&gMysql)); 
     2911                                } 
    28642912 
    28652913                                guMode=0; 
     
    28942942                                        if(!cIPOld[0]) 
    28952943                                                htmlPlainTextError("Unexpected !cIPOld"); 
    2896                                         //Note that job is for new node 
     2944 
     2945                                        //Note that these jobs are for new node 
    28972946                                        //Then this job must run after migration. 
    2898                                         if(IPContainerJob(uTargetDatacenter,uTargetNode,uContainer,uOwner,guLoginClient,cIPOld)) 
    2899  
     2947                                        IPContainerJob(uTargetDatacenter,uTargetNode,uContainer,uOwner,guLoginClient,cIPOld); 
    29002948                                        //Create unxsBind DNS 
    29012949                                        CreateDNSJob(uWizIPv4,uOwner,NULL,cHostname,uDatacenter,guLoginClient); 
     2950 
     2951                                        //Create change hostname job 
     2952                                        if(uSource) 
     2953                                                HostnameContainerJob(uTargetDatacenter,uTargetNode,uContainer,cPrevHostname); 
    29022954 
    29032955                                        sscanf(ForeignKey("tContainer","uModDate",uContainer),"%lu",&uModDate); 
     
    39814033                                { 
    39824034                                        htmlHealth(uContainer,3); 
    3983                                         printf("<p><input title='Migrate container to another datacenter node'" 
    3984                                         " type=submit class=largeButton" 
    3985                                         " name=gcCommand value='Remote Migration'><br>\n"); 
    39864035                                        if(!strstr(cLabel,"-clone")) 
    3987                                         printf("<input title='Clone a container to this or another hardware node." 
     4036                                        printf("<p><input title='Clone a container to this or another hardware node." 
    39884037                                        " The clone will be an online container with another IP and hostname." 
    39894038                                        " It will be kept updated via rsync on a configurable basis.'" 
     
    40334082                                        " type=submit class=largeButton" 
    40344083                                        " name=gcCommand value='Migration Wizard'><br>\n"); 
     4084                                        printf("<input title='Migrate container to another datacenter node'" 
     4085                                        " type=submit class=largeButton" 
     4086                                        " name=gcCommand value='Remote Migration'><br>\n"); 
    40354087                                        printf("<input title='Change current container name and hostname'" 
    40364088                                        " type=submit class=largeButton" 
  • trunk/tdatacenterfunc.h

    r1855 r1860  
    705705        mysql_free_result(res); 
    706706 
     707        //4b-. Last 5 min top diff talkers 
     708        if(uTargetNode) 
     709                sprintf(gcQuery,"SELECT ABS(CONVERT(t2.cValue,SIGNED)-CONVERT(t1.cValue,SIGNED)),t1.uKey,t1.uKey FROM" 
     710                        " tProperty AS t1, tProperty AS t2 WHERE" 
     711                        " t1.uKey IN (SELECT uContainer from tContainer where uStatus=%u AND uDatacenter=%u AND uNode=%u) AND" 
     712                        " t1.uKey=t2.uKey AND t1.uType=3 AND t1.cName='Venet0.luInDelta' AND" 
     713                        " t2.uKey=t2.uKey AND t2.uType=3 AND t2.cName='Venet0.luOutDelta'" 
     714                        " ORDER BY ABS(CONVERT(t2.cValue,SIGNED)-CONVERT(t1.cValue,SIGNED)) DESC LIMIT 10",uACTIVE,uDatacenter,uTargetNode); 
     715        else 
     716                sprintf(gcQuery,"SELECT ABS(CONVERT(t2.cValue,SIGNED)-CONVERT(t1.cValue,SIGNED)),t1.uKey,t1.uKey FROM" 
     717                        " tProperty AS t1, tProperty AS t2 WHERE" 
     718                        " t1.uKey IN (SELECT uContainer from tContainer where uStatus=%u AND uDatacenter=%u) AND" 
     719                        " t1.uKey=t2.uKey AND t1.uType=3 AND t1.cName='Venet0.luInDelta' AND" 
     720                        " t2.uKey=t2.uKey AND t2.uType=3 AND t2.cName='Venet0.luOutDelta'" 
     721                        " ORDER BY ABS(CONVERT(t2.cValue,SIGNED)-CONVERT(t1.cValue,SIGNED)) DESC LIMIT 10",uACTIVE,uDatacenter); 
     722        mysql_query(&gMysql,gcQuery); 
     723        if(mysql_errno(&gMysql)) 
     724        { 
     725                printf("<p><u>tDatacenterHealth</u><br>\n"); 
     726                printf("5-. %s",mysql_error(&gMysql)); 
     727                return; 
     728        } 
     729        res=mysql_store_result(&gMysql); 
     730        if(mysql_num_rows(res)) 
     731        {        
     732                printf("<p><u>Last 5min top diff</u><br>\n"); 
     733 
     734                while((field=mysql_fetch_row(res))) 
     735                        printf("<a class=darkLink href=unxsVZ.cgi?gcFunction=tContainer&uContainer=%s>" 
     736                                "%s %sB/s</a><br>\n",field[1],field[2],field[0]); 
     737        } 
     738        mysql_free_result(res); 
     739 
    707740        //4-. Top talkers 
    708741        if(uTargetNode)