[PC-BSD Commits] r15973 - in pcbsd/current/src-qt4/warden: bin conf scripts/backend src

svn at pcbsd.org svn at pcbsd.org
Fri Mar 23 00:15:19 PDT 2012


Author: kris
Date: 2012-03-23 07:15:19 +0000 (Fri, 23 Mar 2012)
New Revision: 15973

Added:
   pcbsd/current/src-qt4/warden/scripts/backend/details.sh
Modified:
   pcbsd/current/src-qt4/warden/bin/warden
   pcbsd/current/src-qt4/warden/conf/warden.conf
   pcbsd/current/src-qt4/warden/src/dialogwarden.cpp
   pcbsd/current/src-qt4/warden/src/dialogwarden.h
   pcbsd/current/src-qt4/warden/src/dialogwarden.ui
Log:

Add some basic details to warden GUI, add new backend "details" option to 
grab usage stats as well



Modified: pcbsd/current/src-qt4/warden/bin/warden
===================================================================
--- pcbsd/current/src-qt4/warden/bin/warden	2012-03-23 06:10:26 UTC (rev 15972)
+++ pcbsd/current/src-qt4/warden/bin/warden	2012-03-23 07:15:19 UTC (rev 15973)
@@ -41,6 +41,7 @@
     auto - Toggles the autostart flag for a jail
   chroot - Launches chroot into a jail 
   create - Creates a new jail 
+ details - Display usage details about a jail
   delete - Deletes a jail
   export - Exports a jail to a .wdn file
   inload - Install an inmate package into a jail
@@ -134,7 +135,24 @@
 "
 };
 
+help_details()
+{
+ title
+ echo "Help details
 
+View usage details about a jail
+
+Usage:
+
+  warden details <IP>
+
+Example:
+
+  warden details 192.168.0.5
+"
+};
+
+
 help_type()
 {
  title
@@ -363,6 +381,7 @@
            start) help_start ;;
            stop) help_stop ;;
            delete) help_delete ;;
+           details) help_details ;;
            chroot) help_chroot ;;
            list) help_list ;;
            export) help_export ;;
@@ -378,21 +397,30 @@
 
 
     pkgs) IP="${2}"
-
-         if [ -z "${IP}" ]
-         then
+         if [ -z "${IP}" ]; then
           echo "ERROR: No IP specified!"
           exit 1
          fi
 
-         if [ ! -e "${JDIR}/${IP}" ]
-         then
+         if [ ! -e "${JDIR}/${IP}" ]; then
            echo "ERROR: No such jail!"
            exit 1
          fi
 
          ${PROGDIR}/scripts/backend/listpkgs.sh "${IP}" 
+         ;;
+details) IP="${2}"
+         if [ -z "${IP}" ]; then
+          echo "ERROR: No IP specified!"
+          exit 1
+         fi
 
+         if [ ! -e "${JDIR}/${IP}" ]; then
+           echo "ERROR: No such jail!"
+           exit 1
+         fi
+
+         ${PROGDIR}/scripts/backend/details.sh "${IP}" 
          ;;
     set) require_root
 	 OPT="${2}" 

Modified: pcbsd/current/src-qt4/warden/conf/warden.conf
===================================================================
--- pcbsd/current/src-qt4/warden/conf/warden.conf	2012-03-23 06:10:26 UTC (rev 15972)
+++ pcbsd/current/src-qt4/warden/conf/warden.conf	2012-03-23 07:15:19 UTC (rev 15973)
@@ -3,7 +3,7 @@
 ######################################################################
 
 # Network Interface for the jails to use
-NIC: re0
+NIC: em0
 
 # Directory to use for compressing / decompressing files 
 WTMP: /tmp

Index: pcbsd/current/src-qt4/warden/scripts/backend/details.sh
===================================================================
--- pcbsd/current/src-qt4/warden/scripts/backend/details.sh	2012-03-23 06:10:26 UTC (rev 15972)
+++ pcbsd/current/src-qt4/warden/scripts/backend/details.sh	2012-03-23 07:15:19 UTC (rev 15973)

Property changes on: pcbsd/current/src-qt4/warden/scripts/backend/details.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
Modified: pcbsd/current/src-qt4/warden/src/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden/src/dialogwarden.cpp	2012-03-23 06:10:26 UTC (rev 15972)
+++ pcbsd/current/src-qt4/warden/src/dialogwarden.cpp	2012-03-23 07:15:19 UTC (rev 15973)
@@ -75,12 +75,15 @@
 
 void dialogWarden::refreshJails()
 {
-   QString AutoStart;
+   QString AutoStart, jType, jIPs;
+   QStringList jD;
  
-   if ( widgetPackages->layout() )
+   if ( widgetPackages->layout() == 0 )
      delete widgetPackages->layout();
+   update();
     
    listJails->clear();
+   jailDetails.clear();
    
    // Check our JailDir and see what we have
    QDir d(JailDir);
@@ -89,37 +92,62 @@
    for ( unsigned int i = 0; i < d.count(); i++ ) {
        
        // Traverse our directories, looking for jails
-       if ( d[i] != "." && d[i] != ".." ) {
+       if ( d[i] == "." || d[i] == ".." )
+          continue;
+
+       jD.clear();
 	   
-            // Check for the hostname of this jail
-            QFile file( JailDir + "/" + d[i] + "/etc/warden/host" );
-            if ( file.exists() ) {
-	if ( file.open( QIODevice::ReadOnly ) ) {
-	    QTextStream stream( &file );
-	    QString host;
+       // Check for the hostname of this jail
+       QFile file( JailDir + "/" + d[i] + "/etc/warden/host" );
+       if ( ! file.exists() )
+          continue;
+       if ( ! file.open( QIODevice::ReadOnly ) )
+          continue;
+
+       QTextStream stream( &file );
+       QString host;
         
-	    while ( !stream.atEnd() ) {
-		host = stream.readLine(); // line of text excluding '\n'
-	    }
+       while ( !stream.atEnd() )
+          host = stream.readLine(); // line of text excluding '\n'
+       file.close();
 	    
-	          // Check if this jail is set to autostart
-	          AutoStart = "Disabled";
-	          QFile file2(JailDir + "/" + d[i] + "/etc/warden/autostart" );
-	          if ( file2.exists() )
-	          {
-		     AutoStart = "Enabled";  
-	          }
-	           QStringList cols;
-		   if ( radioIPSort->isChecked() )	
-                     cols << d[i] << d[i] << host;
-		   else
-                     cols << d[i] << d[i] << host;
-	           (void) new QTreeWidgetItem( listJails, cols );
-                  }
-	}
-        }
+       // Check if this jail is set to autostart
+       AutoStart = "Disabled";
+       QFile file2(JailDir + "/" + d[i] + "/etc/warden/autostart" );
+       if ( file2.exists() )
+          AutoStart = "Enabled";  
+
+       // Check for additional IPs in this jail
+       jIPs = "";
+       QFile fileip(JailDir + "/" + d[i] + "/etc/warden/ip-extra" );
+       if ( fileip.exists() ) {
+         if (fileip.open( QIODevice::ReadOnly ) ) {
+            QTextStream stream2( &fileip );
+            while ( !stream2.atEnd() )
+              jIPs = jIPs + stream2.readLine() + " "; // line of text excluding '\n'
+	 }
+         fileip.close();
+       }
+
+       // Check the type of jail
+       jType = tr("Standard");
+       QFile file3(JailDir + "/" + d[i] + "/etc/warden/xjail" );
+       if ( file3.exists() )
+         jType = tr("X Jail");
+
+       // Display the jail in the tree widget now
+       QStringList cols;
+       if ( radioIPSort->isChecked() )	
+          cols << d[i] << d[i] << host;
+       else
+          cols << d[i] << d[i] << host;
+       (void) new QTreeWidgetItem( listJails, cols );
+
+       // Save additional jail details into list
+       jD << d[i] << "Pending" << jType << jIPs;
+       jailDetails << jD;
    
-   }
+   } // end of loop
    
    listJails->sortByColumn(1, Qt::AscendingOrder);
    
@@ -776,6 +804,29 @@
    groupJailTab->setTitle(tr("Working on jail:") + " " + listJails->currentItem()->text(0));
    groupJailTab->setEnabled(true);
 
+   // Load the details for this jail
+   for (int i=0; i < jailDetails.count(); ++i) {
+     if ( jailDetails.at(i).at(0) != listJails->currentItem()->text(0) )
+        continue;
+
+     // Load the details now
+     labelType->setText(jailDetails.at(i).at(2));
+     labelIPs->setText(jailDetails.at(i).at(3));
+
+     // Not all details available, stop here
+     if ( jailDetails.at(i).at(1) == "Pending" )
+        break;
+
+
+     // Done loading all details
+     break;
+
+   }
+
+   // Stop any pkg widget activity
+   if ( widgetPackages->layout() != 0 )
+     pkgWidget->stop();
+
    pkgWidget = new metaWidget();
    pkgWidget->init(QString("/usr/jails/" + listJails->currentItem()->text(0)));
    QVBoxLayout *mWLayout = new QVBoxLayout();

Modified: pcbsd/current/src-qt4/warden/src/dialogwarden.h
===================================================================
--- pcbsd/current/src-qt4/warden/src/dialogwarden.h	2012-03-23 06:10:26 UTC (rev 15972)
+++ pcbsd/current/src-qt4/warden/src/dialogwarden.h	2012-03-23 07:15:19 UTC (rev 15973)
@@ -99,6 +99,7 @@
     QProcess *loadInmateProc;
     QProcess *toggleAutoProc;
     metaWidget *pkgWidget;
+    QList<QStringList> jailDetails;
 
 signals:
 } ;

Modified: pcbsd/current/src-qt4/warden/src/dialogwarden.ui
===================================================================
--- pcbsd/current/src-qt4/warden/src/dialogwarden.ui	2012-03-23 06:10:26 UTC (rev 15972)
+++ pcbsd/current/src-qt4/warden/src/dialogwarden.ui	2012-03-23 07:15:19 UTC (rev 15973)
@@ -194,7 +194,7 @@
           <attribute name="title">
            <string>Info</string>
           </attribute>
-          <layout class="QGridLayout" name="gridLayout_12">
+          <layout class="QGridLayout" name="gridLayout_9">
            <item row="0" column="0">
             <widget class="QGroupBox" name="groupBox_4">
              <property name="title">
@@ -254,69 +254,86 @@
              <property name="title">
               <string>Network Information</string>
              </property>
-             <layout class="QGridLayout" name="gridLayout_9">
+             <layout class="QGridLayout" name="gridLayout_8">
               <item row="0" column="0">
-               <layout class="QGridLayout" name="gridLayout_8">
-                <item row="0" column="0">
-                 <widget class="QLabel" name="label_3">
-                  <property name="text">
-                   <string>Active Connections:</string>
-                  </property>
-                 </widget>
-                </item>
-                <item row="0" column="1">
-                 <widget class="QLabel" name="labelConnections">
-                  <property name="text">
-                   <string/>
-                  </property>
-                 </widget>
-                </item>
-                <item row="1" column="0">
+               <widget class="QLabel" name="label_3">
+                <property name="text">
+                 <string>Active Connections:</string>
+                </property>
+               </widget>
+              </item>
+              <item row="0" column="1">
+               <widget class="QLabel" name="labelConnections">
+                <property name="text">
+                 <string/>
+                </property>
+               </widget>
+              </item>
+              <item row="1" column="0">
+               <layout class="QHBoxLayout" name="horizontalLayout_6">
+                <item>
                  <widget class="QLabel" name="label_7">
                   <property name="text">
-                   <string>Assigned IP Addresses:</string>
+                   <string>Additional IPs:</string>
                   </property>
                  </widget>
                 </item>
-                <item row="1" column="1">
-                 <widget class="QLabel" name="labelIPs">
-                  <property name="text">
-                   <string/>
+                <item>
+                 <widget class="QLabel" name="labelIPEdit">
+                  <property name="cursor">
+                   <cursorShape>PointingHandCursor</cursorShape>
                   </property>
-                 </widget>
-                </item>
-                <item row="2" column="0">
-                 <widget class="QLabel" name="label_9">
                   <property name="text">
-                   <string>Listening on Ports:</string>
+                   <string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" text-decoration: underline; color:#0000ff;">(edit)</span></p></body></html></string>
                   </property>
                  </widget>
                 </item>
-                <item row="2" column="1">
-                 <widget class="QLabel" name="labelPorts">
-                  <property name="text">
-                   <string/>
-                  </property>
-                 </widget>
-                </item>
                </layout>
               </item>
-              <item row="0" column="1">
-               <spacer name="horizontalSpacer_8">
-                <property name="orientation">
-                 <enum>Qt::Horizontal</enum>
+              <item row="1" column="1">
+               <widget class="QLabel" name="labelIPs">
+                <property name="text">
+                 <string/>
                 </property>
-                <property name="sizeHint" stdset="0">
-                 <size>
-                  <width>40</width>
-                  <height>20</height>
-                 </size>
+                <property name="wordWrap">
+                 <bool>true</bool>
                 </property>
-               </spacer>
+               </widget>
               </item>
+              <item row="2" column="0">
+               <widget class="QLabel" name="label_9">
+                <property name="text">
+                 <string>Listening on Ports:</string>
+                </property>
+               </widget>
+              </item>
+              <item row="2" column="1">
+               <widget class="QLabel" name="labelPorts">
+                <property name="text">
+                 <string/>
+                </property>
+               </widget>
+              </item>
              </layout>
             </widget>
            </item>
+           <item row="1" column="1">
+            <spacer name="horizontalSpacer_8">
+             <property name="orientation">
+              <enum>Qt::Horizontal</enum>
+             </property>
+             <property name="sizeHint" stdset="0">
+              <size>
+               <width>246</width>
+               <height>20</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
            <item row="2" column="0">
             <spacer name="verticalSpacer_2">
              <property name="orientation">



More information about the Commits mailing list