[PC-BSD Commits] r17704 - pcbsd/current/src-qt4/warden-gui
svn at pcbsd.org
svn at pcbsd.org
Tue Jul 10 09:21:10 PDT 2012
Author: kris
Date: 2012-07-10 16:21:10 +0000 (Tue, 10 Jul 2012)
New Revision: 17704
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:
Finish up the support in the Warden GUI for "mounting/cloning" a snapshot,
and unmounting/removing said clone.
While here, do some UI enhancements, fix some text with reverting snapshots,
and make sure when we do clone operations, stay selected on the same snapshot.
Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp 2012-07-10 15:34:57 UTC (rev 17703)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.cpp 2012-07-10 16:21:10 UTC (rev 17704)
@@ -90,7 +90,9 @@
connect( pushStart, SIGNAL(clicked()), this, SLOT(slotStartJail() ) );
connect( pushStop, SIGNAL(clicked()), this, SLOT(slotStopJail() ) );
- // Snapshot support
+ // Snapshot / Clone support
+ connect( pushAddClone, SIGNAL(clicked()), this, SLOT(slotAddClone() ) );
+ connect( pushRemoveClone, SIGNAL(clicked()), this, SLOT(slotRemoveClone() ) );
connect( pushCreateSnap, SIGNAL(clicked()), this, SLOT(slotCreateSnap() ) );
connect( pushRestoreSnap, SIGNAL(clicked()), this, SLOT(slotRestoreSnap() ) );
connect( pushRemoveSnap, SIGNAL(clicked()), this, SLOT(slotRemoveSnap() ) );
@@ -1135,7 +1137,6 @@
return;
groupSnaps->setEnabled(false);
- groupClones->setEnabled(false);
labelSnap->setText(tr("Loading snapshots..."));
QString IP = listJails->currentItem()->text(0);
@@ -1193,7 +1194,6 @@
labelSnap->setText(getSnapDateReadable(snapshotList.at(snapshotList.count()-1)) + " " + tmp);
sliderSnaps->setEnabled(true);
- groupSnaps->setEnabled(true);
pushRestoreSnap->setEnabled(true);
pushRemoveSnap->setEnabled(true);
@@ -1250,15 +1250,20 @@
qDebug() << "Available Clones:" << cloneList;
- groupClones->setEnabled(true);
-
if ( snapshotList.count() <= 0 ) {
pushRemoveClone->setEnabled(false);
pushAddClone->setEnabled(false);
} else
slotSnapSliderChanged(snapshotList.count()-1);
- return;
+ // If we did something and want to show the same snapshot
+ if ( currentSnapshot != -1 ) {
+ sliderSnaps->setValue(currentSnapshot );
+ slotSnapSliderChanged(currentSnapshot);
+ }
+
+
+ groupSnaps->setEnabled(true);
}
QString dialogWarden::getSnapDateReadable(QString time)
@@ -1285,6 +1290,8 @@
pushStop->setEnabled(false);
return;
}
+
+ currentSnapshot = -1;
pushStart->setEnabled(false);
pushStop->setEnabled(false);
@@ -1411,11 +1418,67 @@
slotCurrentJailChanged();
}
+void dialogWarden::slotAddClone()
+{
+ if ( ! listJails->currentItem() )
+ return;
+
+ // Update status
+ groupSnaps->setEnabled(false);
+ labelSnap->setText(tr("Cloning snapshot... Please wait..."));
+
+ QString IP = listJails->currentItem()->text(0);
+
+ // Now start the script to stop this jail
+ createJailProc = new QProcess( this );
+ QString program = "warden";
+ QStringList args;
+ args << "zfsclonesnap" << IP << snapshotList.at(sliderSnaps->value());
+
+ // Connect the exited signal and start the process
+ createJailProc->setProcessChannelMode(QProcess::MergedChannels);
+ createJailProc->setReadChannel(QProcess::StandardOutput);
+ connect( createJailProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotLoadSnapshots() ) );
+ createJailProc->start(program, args);
+
+ currentSnapshot = sliderSnaps->value();
+
+}
+
+void dialogWarden::slotRemoveClone()
+{
+ if ( ! listJails->currentItem() )
+ return;
+
+ // Update status
+ groupSnaps->setEnabled(false);
+ labelSnap->setText(tr("Removing clone... Please wait..."));
+
+ QString IP = listJails->currentItem()->text(0);
+
+ // Now start the script to stop this jail
+ createJailProc = new QProcess( this );
+ QString program = "warden";
+ QStringList args;
+ args << "zfsrmclone" << IP << snapshotList.at(sliderSnaps->value());
+
+ // Connect the exited signal and start the process
+ createJailProc->setProcessChannelMode(QProcess::MergedChannels);
+ createJailProc->setReadChannel(QProcess::StandardOutput);
+ connect( createJailProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotLoadSnapshots() ) );
+ createJailProc->start(program, args);
+
+ currentSnapshot = sliderSnaps->value();
+}
+
+
void dialogWarden::slotCreateSnap()
{
if ( ! listJails->currentItem() )
return;
+ currentSnapshot = -1;
+
// Update status
groupSnaps->setEnabled(false);
labelSnap->setText(tr("Creating new snapshot... Please wait..."));
@@ -1442,10 +1505,12 @@
groupSnaps->setEnabled(false);
labelSnap->setText(tr("Reverting snapshot... Please wait..."));
+ currentSnapshot = -1;
+
QString IP = listJails->currentItem()->text(0);
int ret = QMessageBox::question(this, tr("Warden"),
- tr("Are you sure you want to revert to the snapshot:") + "\n" + getSnapDateReadable(snapshotList.at(sliderSnaps->value() ) ) + "?" + "\n" + tr("Any newer snapshots will be lost, and the jail will be restarted!"),
+ tr("Are you sure you want to revert to the snapshot:") + "\n" + getSnapDateReadable(snapshotList.at(sliderSnaps->value() ) ) + "?" + "\n" + tr("Any newer snapshots and mounted clones will be lost, and the jail will be restarted!"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if ( ret != QMessageBox::Yes )
@@ -1454,8 +1519,8 @@
dialogOutput = new dialogDisplayOutput();
dialogOutput->setModal(true);
dialogOutput->programInit(FALSE);
- dialogOutput->setDialogCaption("Creating Jail: " + IP);
- dialogOutput->setDialogText("");
+ dialogOutput->setDialogCaption(tr("Reverting snapshot"));
+ dialogOutput->setDialogText(tr("Reverting to snapshot:") + " " + getSnapDateReadable(snapshotList.at(sliderSnaps->value() ) ));
dialogOutput->show();
@@ -1481,6 +1546,8 @@
QString IP = listJails->currentItem()->text(0);
+ currentSnapshot = -1;
+
int ret = QMessageBox::question(this, tr("Warden"),
tr("Are you sure you want to remove the snapshot:") + "\n" + getSnapDateReadable(snapshotList.at(sliderSnaps->value() ) ) + "?",
QMessageBox::Yes | QMessageBox::No,
@@ -1511,14 +1578,20 @@
{
QString IP = listJails->currentItem()->text(0);
QString tmp;
+ int cloneId = -1;
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) );
+ for (int i = 0; i < cloneList.size(); ++i)
+ if ( cloneList.at(i) == snapshotList.at(newVal) )
+ cloneId = i;
+ if ( cloneId != -1 )
+ // List the clone
+ labelClone->setText(tr("Mounted on: ") + "/usr/jails/clones/" + IP + "-" + cloneList.at(cloneId) );
+
} else {
labelClone->setText(tr("Snapshot not mounted"));
pushAddClone->setEnabled(true);
Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.h
===================================================================
--- pcbsd/current/src-qt4/warden-gui/dialogwarden.h 2012-07-10 15:34:57 UTC (rev 17703)
+++ pcbsd/current/src-qt4/warden-gui/dialogwarden.h 2012-07-10 16:21:10 UTC (rev 17704)
@@ -80,6 +80,8 @@
void slotRestoreSnap();
void slotRemoveSnap();
void slotLoadClones();
+ void slotAddClone();
+ void slotRemoveClone();
private:
void refreshJailDetailsView();
@@ -134,6 +136,7 @@
QStringList snapshotList;
QStringList cloneList;
dialogEditIP *dIP;
+ int currentSnapshot;
signals:
} ;
Modified: pcbsd/current/src-qt4/warden-gui/dialogwarden.ui
===================================================================
(Binary files differ)
More information about the Commits
mailing list