Ignore:
Timestamp:
04/15/13 10:35:21 (17 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.1-release, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
9bf0d71
Parents:
90a056e
Message:
  • Number of changes to Warden GUI to work with updated backend
    • Allow IP & IPV6 address to be set during creation
    • Enable option to disable boot-strapping PKGNG / PCBSD-Utils
    • Fix up main dialog to understand new "jails" format
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/warden-gui/dialogwarden.cpp

    r0cfe72f rf66423f  
    4343   listJails->setAllColumnsShowFocus(TRUE); 
    4444 
     45   // Run this a single time, just to be sure we did any jail import / migration 
     46   // from legacy jails 
     47   system("warden list"); 
     48 
    4549   // Hide the identifier column / host column 
    4650   listJails->setColumnHidden(0, true); 
     
    130134void dialogWarden::refreshJails() 
    131135{ 
    132    QString jType, jIPs, jZFS; 
     136   QString jType, jName, jZFS; 
    133137   QStringList jD; 
    134138   QStringList mountOut; 
     
    166170 
    167171       qDebug() << "Checking:" << d[i]; 
     172 
     173       jName = d[i].replace(".meta", "").remove(0, 1); 
    168174            
    169        // Check for the IP of this jail 
    170        QFile fileIP( JailDir + "/" + d[i] + "/ip" ); 
    171        if ( ! fileIP.exists() ) 
    172           continue; 
    173        if ( ! fileIP.open( QIODevice::ReadOnly ) ) 
    174           continue; 
    175        QTextStream streamip( &fileIP ); 
    176        QString jIP; 
    177        while ( !streamip.atEnd() ) 
    178           jIP = streamip.readLine(); // line of text excluding '\n' 
    179        fileIP.close(); 
    180  
    181175       // Check if this jail is created on ZFS 
    182176       jZFS="NO"; 
    183177       for (int z = 0; z < mountOut.size(); ++z) 
    184           if ( mountOut.at(z).indexOf("on " + JailDir + "/" + jIP) != -1 && mountOut.at(z).indexOf("(zfs,") != -1 ) 
     178          if ( mountOut.at(z).indexOf("on " + JailDir + "/" + jName) != -1 && mountOut.at(z).indexOf("(zfs,") != -1 ) 
    185179             jZFS="YES"; 
    186  
    187180 
    188181       // Check for the hostname of this jail 
     
    198191       file.close(); 
    199192             
    200        // Check for additional IPs in this jail 
    201        jIPs = ""; 
    202        QFile fileip(JailDir + "/" + d[i] + "/ip-extra" ); 
    203        if ( fileip.exists() ) { 
    204          if (fileip.open( QIODevice::ReadOnly ) ) { 
    205             QTextStream stream2( &fileip ); 
    206             while ( !stream2.atEnd() ) 
    207               jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n' 
    208          } 
    209          fileip.close(); 
     193       // Build list of IPs for this jail 
     194       QString jIPs = ""; 
     195       QStringList ipFiles; 
     196       ipFiles << "ipv4" << "ipv6"; 
     197       for (int f = 0; f < ipFiles.size(); ++f) { 
     198         QFile fileip(JailDir + "/" + d[i] + "/" + ipFiles.at(f) ); 
     199         if ( fileip.exists() ) { 
     200           if (fileip.open( QIODevice::ReadOnly ) ) { 
     201              QTextStream stream2( &fileip ); 
     202              while ( !stream2.atEnd() ) 
     203                jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n' 
     204           } 
     205           fileip.close(); 
     206         } 
    210207       } 
     208       qDebug() << jIPs; 
    211209 
    212210       // Check the type of jail 
     
    221219       // Display the jail in the tree widget now 
    222220       QStringList cols; 
    223        cols << jIP << jIP << host; 
     221       cols << jName << host; 
    224222 
    225223       QTreeWidgetItem *curItem = new QTreeWidgetItem( listJails, cols ); 
     
    228226 
    229227       // Save additional jail details into list 
    230        jD << jIP << "Pending" << jType << jIPs << "" << "" << "" << jZFS; 
     228       jD << jName << "Pending" << jType << jIPs << "" << "" << "" << jZFS; 
    231229       jailDetails << jD; 
    232230    
     
    305303    } 
    306304 
    307     // Check for additional IPs in this jail 
    308     QString jIPs; 
    309     QFile fileip(JailDir + "/." + currentDetailsWorkingJail + ".meta/ip-extra" ); 
    310     if ( fileip.exists() ) { 
    311       if (fileip.open( QIODevice::ReadOnly ) ) { 
    312          QTextStream stream2( &fileip ); 
    313          while ( !stream2.atEnd() ) 
    314            jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n' 
     305    // Build list of IPs for this jail 
     306    QString jIPs = ""; 
     307    QStringList ipFiles; 
     308    ipFiles << "ipv4" << "ipv6"; 
     309    for (int f = 0; f < ipFiles.size(); ++f) { 
     310       QFile fileip(JailDir + "/." + currentDetailsWorkingJail + ".meta/" + ipFiles.at(f) ); 
     311       if ( fileip.exists() ) { 
     312         if (fileip.open( QIODevice::ReadOnly ) ) { 
     313            QTextStream stream2( &fileip ); 
     314            while ( !stream2.atEnd() ) 
     315             jIPs = jIPs + stream2.readLine().simplified() + " "; // line of text excluding '\n' 
     316         } 
    315317         fileip.close(); 
    316       } 
    317     } 
     318       } 
     319    } 
     320    qDebug() << "Found IPS:" << jIPs; 
    318321 
    319322    // Save the new jail IPs 
     
    582585                running = true; 
    583586                (*it)->setIcon(1, QIcon(":running.png")); 
    584                 (*it)->setText(3, "Running"); 
     587                (*it)->setText(2, "Running"); 
    585588            } else { 
    586589                running = false; 
    587590                (*it)->setIcon(1, QIcon(":stopped.png")); 
    588                 (*it)->setText(3, "Not Running"); 
     591                (*it)->setText(2, "Not Running"); 
    589592            } 
    590593 
     
    625628    if ( listJails->currentItem()) { 
    626629          popupip = listJails->currentItem()->text(0); 
    627           Status = listJails->currentItem()->text(3); 
    628           Updates = listJails->currentItem()->text(4); 
     630          Status = listJails->currentItem()->text(2); 
     631          Updates = listJails->currentItem()->text(3); 
    629632          popup = new QMenu(); 
    630633          if ( Status == "Running" ) 
     
    687690 
    688691        // If jail is running, lets stop it 
    689         if ( listJails->currentItem()->text(3) == "Running" ) { 
     692        if ( listJails->currentItem()->text(2) == "Running" ) { 
    690693           slotStopJail(); 
    691694           return; 
     
    898901      newJailWizard->setHostIPUsed(uH, uI); 
    899902       
    900       connect( newJailWizard, SIGNAL(create(const QString &, const QString &, bool, const QString &, bool, bool, bool, bool, const QString &)), this, SLOT(slotCreateNewJail(const QString &, const QString &, bool, const QString &, bool, bool, bool, bool, const QString &) ) ); 
     903      connect( newJailWizard, SIGNAL(create(const QString &, const QString &, const QString &, bool, bool, const QString &, bool, bool, bool, bool, const QString &)), this, SLOT(slotCreateNewJail(const QString &, const QString &, const QString &, bool, bool, const QString &, bool, bool, bool, bool, const QString &) ) ); 
    901904      newJailWizard->show(); 
    902905} 
    903906 
    904907 
    905 void dialogWarden::slotCreateNewJail( const QString &IP, const QString &host, bool tradjail, const QString &rootpw, bool src, bool ports, bool autostart, bool linuxJail, const QString &linuxScript ) 
     908void dialogWarden::slotCreateNewJail( const QString &IP, const QString &IP6, const QString &host, bool tradjail, bool PCUtils, const QString &rootpw, bool src, bool ports, bool autostart, bool linuxJail, const QString &linuxScript ) 
    906909{ 
    907910    if ( tradjail || linuxJail ) 
     
    910913      newRootPW=""; 
    911914     
    912     newIP=IP; 
     915    newHost=host; 
    913916 
    914917    /*********************************************************************************************************************** 
     
    927930      QString program = "warden"; 
    928931      QStringList args; 
    929       args << "create" << IP << host; 
     932      args << "create" << host; 
    930933 
    931934      // Set our optional flags 
     935      if ( ! IP.isEmpty() ) { 
     936        args << "--ipv4"; 
     937        args << IP; 
     938      } 
     939 
     940      if ( ! IP6.isEmpty() ) { 
     941        args << "--ipv6"; 
     942        args << IP6; 
     943      } 
     944 
     945      if ( tradjail && ! PCUtils ) 
     946        args << "--vanilla"; 
     947 
    932948      if ( ! tradjail && ! linuxJail ) 
    933949        args << "--portjail"; 
     
    944960      if ( autostart ) 
    945961        args << "--startauto"; 
    946        
     962 
    947963      // Connect the exited signal and start the process  
    948964      createJailProc->setProcessChannelMode(QProcess::MergedChannels); 
     
    976992    QString program = ProgDir + "/scripts/backend/setupusers.sh"; 
    977993    QStringList args; 
    978     args << newIP << newRootPW; 
     994    args << newHost << newRootPW; 
    979995       
    980996    // Connect the exited signal and start the process  
     
    13641380   //pushStart->setEnabled(false); 
    13651381 
    1366    if ( listJails->currentItem()->text(3) == "Running" ) { 
     1382   if ( listJails->currentItem()->text(2) == "Running" ) { 
    13671383     //pushStart->setEnabled(true); 
    13681384     pushTerminal->setEnabled(true); 
     
    13711387     pushStart->setToolTip(tr("Stop the selected jail")); 
    13721388   } 
    1373    if ( listJails->currentItem()->text(3) == "Not Running" ) { 
     1389   if ( listJails->currentItem()->text(2) == "Not Running" ) { 
    13741390     //pushStart->setEnabled(true); 
    13751391     pushTerminal->setEnabled(false); 
Note: See TracChangeset for help on using the changeset viewer.