[PC-BSD Commits] r17696 - pcbsd/current/src-qt4/warden-gui

svn at pcbsd.org svn at pcbsd.org
Mon Jul 9 11:56:30 PDT 2012


Author: kris
Date: 2012-07-09 18:56:30 +0000 (Mon, 09 Jul 2012)
New Revision: 17696

Modified:
   pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
   pcbsd/current/src-qt4/warden-gui/dialogwarden.h
   pcbsd/current/src-qt4/warden-gui/dialogwarden.ui
Log:

Add initial GUI layout for clone support, and list mounted / cloned snaps



Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2012-07-09 18:52:04 UTC (rev 17695)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp	2012-07-09 18:56:30 UTC (rev 17696)
@@ -1135,6 +1135,7 @@
       return;
 
    groupSnaps->setEnabled(false); 
+   groupClones->setEnabled(false); 
    labelSnap->setText(tr("Loading snapshots..."));
 
    QString IP = listJails->currentItem()->text(0);
@@ -1178,20 +1179,88 @@
      sliderSnaps->setEnabled(false);
      pushRestoreSnap->setEnabled(false);
      pushRemoveSnap->setEnabled(false);
+     pushAddClone->setEnabled(false);
+     pushRemoveClone->setEnabled(false);
      return;
    }
 
    // List snapshots
-   labelSnap->setText(tr("No snapshots available. You may create one below."));
    sliderSnaps->setRange(0, snapshotList.count() - 1 );
    sliderSnaps->setValue(snapshotList.count() -1 );
-   labelSnap->setText(getSnapDateReadable(snapshotList.at(snapshotList.count()-1)));
+   tmp="";
+   if ( hasClone(snapshotList.at(snapshotList.count()-1)) )
+      tmp = tr("(Cloned)");
+ 
+   labelSnap->setText(getSnapDateReadable(snapshotList.at(snapshotList.count()-1)) + " " + tmp);
+   sliderSnaps->setEnabled(true);
    groupSnaps->setEnabled(true); 
-   sliderSnaps->setEnabled(true);
    pushRestoreSnap->setEnabled(true);
    pushRemoveSnap->setEnabled(true);
+
+   slotLoadClones();
 }
 
+bool dialogWarden::hasClone(QString snap)
+{
+   for (int i = 0; i < cloneList.size(); ++i)
+     if ( cloneList.at(i) == snap )
+        return true;
+
+   return false;
+}
+
+void dialogWarden::slotLoadClones()
+{
+   if ( ! listJails->currentItem() )
+      return;
+
+   labelClone->setText(tr("Loading clones..."));
+
+   QString IP = listJails->currentItem()->text(0);
+
+   // Grab the ZFS clone list
+   QProcess m;
+   m.start(QString("warden"), QStringList() << "zfslistclone" << IP );
+   while(m.state() == QProcess::Starting || m.state() == QProcess::Running) {
+      m.waitForFinished(200);
+      QCoreApplication::processEvents();
+   }
+
+   // Check if the user changed jails before we finished loading snaps
+   if ( ! listJails->currentItem() )
+      return;
+   if ( IP != listJails->currentItem()->text(0))
+     return;
+
+   cloneList.clear();
+   QString tmp;
+   bool ok, ok2;
+
+   qDebug() << "Getting ZFS clones for " + IP;
+
+   // Get output of ZFS Clones
+   while (m.canReadLine()) {
+      tmp = m.readLine().simplified();
+      tmp.section("-", 0, 0).toInt(&ok);
+      tmp.section("-", 1, 1).toInt(&ok2);
+      if (ok && ok2) {
+         cloneList << tmp.section("-", 0, 1);
+      }
+   }
+
+   qDebug() << "Available Clones:" << cloneList;
+
+   groupClones->setEnabled(true); 
+
+   if ( snapshotList.count() <= 0 ) {
+     pushRemoveClone->setEnabled(false);
+     pushAddClone->setEnabled(false);
+   } else
+     slotSnapSliderChanged(snapshotList.count()-1);
+   return;
+
+}
+
 QString dialogWarden::getSnapDateReadable(QString time)
 {
    QDate date = QDate::fromString(time.section("-", 0, 0), "yyyyMMdd");
@@ -1439,8 +1508,23 @@
 
 
 void dialogWarden::slotSnapSliderChanged(int newVal)
-{
-   labelSnap->setText(getSnapDateReadable(snapshotList.at(newVal)));
+{  
+   QString IP = listJails->currentItem()->text(0);
+   QString tmp;
+   if ( hasClone(snapshotList.at(newVal)) ) {
+      tmp = tr("(Cloned)");
+      pushAddClone->setEnabled(false);
+      pushRemoveClone->setEnabled(true);
+
+      // List the clone
+      labelClone->setText(tr("Mounted on: ") + "/usr/jails/clones/" + IP + "-" + cloneList.at(cloneList.count()-1) );
+
+   } else {
+      labelClone->setText(tr("Snapshot not mounted"));
+      pushAddClone->setEnabled(true);
+      pushRemoveClone->setEnabled(false);
+   }
+   labelSnap->setText(getSnapDateReadable(snapshotList.at(newVal)) + " " + tmp);
 }
 
 void dialogWarden::slotShowDialogCloseButton()

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.h	2012-07-09 18:52:04 UTC (rev 17695)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.h	2012-07-09 18:56:30 UTC (rev 17696)
@@ -79,10 +79,12 @@
     void slotCreateSnap();
     void slotRestoreSnap();
     void slotRemoveSnap();
+    void slotLoadClones();
 
 private:
     void refreshJailDetailsView();
     void runCommand( QString command );
+    bool hasClone(QString);
     QString getSnapDateReadable(QString time);
     QString ProgDir;
     QString WorldSrc;
@@ -130,6 +132,7 @@
     metaWidget *pkgWidget;
     QList<QStringList> jailDetails;
     QStringList snapshotList;
+    QStringList cloneList;
     dialogEditIP *dIP;
 
 signals:

Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.ui
===================================================================
(Binary files differ)



More information about the Commits mailing list