Permalink
Browse files

Add the parsing for a cancelled scrub to the lp-gui, and also add in …

…the fully functioning scrub cancellation button.
  • Loading branch information...
1 parent 1d2eb8d commit 3da8c2043a309743d9b80606cdb29cceaf06bacb Ken Moore committed Oct 17, 2013
Showing with 69 additions and 23 deletions.
  1. +3 −0 lp-gui/LPGUtils.cpp
  2. +35 −3 lp-gui/LPMain.cpp
  3. +2 −0 lp-gui/LPMain.h
  4. +29 −3 lp-gui/LPMain.ui
  5. +0 −17 lp-gui/lPreserve.qrc
View
@@ -44,6 +44,9 @@ LPDataset LPGUtils::loadPoolData(QString zpool){
QString timestamp = line.section(" ",9,13,QString::SectionSkipEmpty);
QString numerrors = line.section(" ",6,6,QString::SectionSkipEmpty);
finished << QString(QObject::tr("Scrub Finished: %1 (%2 errors)")).arg(timestamp, numerrors);
+ }else if(line.contains("scrub cancel")){
+ QString timestamp = line.section(" ",3,7,QString::SectionSkipEmpty);
+ finished << QString(QObject::tr("Scrub Cancelled: %1")).arg(timestamp);
}else if(line.contains("scrub")){
QString timestamp = line.section(" ",4,8,QString::SectionSkipEmpty);
running << QString(QObject::tr("Scrub Started: %1")).arg(timestamp);
View
@@ -42,7 +42,9 @@ LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
connect(ui->actionAdd_Disk, SIGNAL(triggered()), this, SLOT(menuAddDisk()) );
connect(ui->menuRemove_Disk, SIGNAL(triggered(QAction*)), this, SLOT(menuRemoveDisk(QAction*)) );
connect(ui->menuSet_Disk_Offline, SIGNAL(triggered(QAction*)), this, SLOT(menuOfflineDisk(QAction*)) );
+ connect(ui->menuSet_Disk_Online, SIGNAL(triggered(QAction*)), this, SLOT(menuOnlineDisk(QAction*)) );
connect(ui->action_startScrub, SIGNAL(triggered()), this, SLOT(menuStartScrub()) );
+ connect(ui->action_stopScrub, SIGNAL(triggered()), this, SLOT(menuStopScrub()) );
connect(ui->action_newSnapshot, SIGNAL(triggered()), this, SLOT(menuNewSnapshot()) );
connect(ui->menuDelete_Snapshot, SIGNAL(triggered(QAction*)), this, SLOT(menuRemoveSnapshot(QAction*)) );
//Update the interface
@@ -133,8 +135,8 @@ void LPMain::viewChanged(){
ui->menubar->addMenu(ui->menuFile);
ui->menubar->addMenu(ui->menuView);
ui->menubar->addMenu(ui->menuClassic_Backups);
- ui->menubar->addMenu(ui->menuDisks);
ui->menubar->addMenu(ui->menuSnapshots);
+ ui->menubar->addMenu(ui->menuDisks);
}
}
@@ -190,11 +192,18 @@ void LPMain::updateTabs(){
//Now update the disk menu items
ui->menuRemove_Disk->clear();
ui->menuSet_Disk_Offline->clear();
+ ui->menuSet_Disk_Online->clear();
for(int i=0; i<POOLDATA.harddisks.length(); i++){
ui->menuRemove_Disk->addAction(POOLDATA.harddisks[i]);
- ui->menuSet_Disk_Offline->addAction(POOLDATA.harddisks[i]);
+ if(POOLDATA.harddiskStatus[i] == "OFFLINE"){
+ ui->menuSet_Disk_Online->addAction(POOLDATA.harddisks[i]);
+ }else{
+ ui->menuSet_Disk_Offline->addAction(POOLDATA.harddisks[i]);
+ }
}
-
+ ui->menuRemove_Disk->setEnabled(!ui->menuRemove_Disk->isEmpty());
+ ui->menuSet_Disk_Offline->setEnabled(!ui->menuSet_Disk_Offline->isEmpty());
+ ui->menuSet_Disk_Online->setEnabled(!ui->menuSet_Disk_Online->isEmpty());
}else{
//No Pool selected
ui->label_numdisks->clear();
@@ -452,6 +461,12 @@ void LPMain::menuOfflineDisk(QAction *act){
}
+void LPMain::menuOnlineDisk(QAction *act){
+ QString disk = act->text();
+ qDebug() << "Set Disk Online:" << disk;
+
+}
+
void LPMain::menuStartScrub(){
QString pool = ui->combo_pools->currentText();
//Verify starting a scrub
@@ -469,6 +484,23 @@ void LPMain::menuStartScrub(){
}
}
+void LPMain::menuStopScrub(){
+ QString pool = ui->combo_pools->currentText();
+ //Verify stopping a scrub
+ if( QMessageBox::Yes != QMessageBox::question(this,tr("Verify Scrub"),QString(tr("Are you sure you want to stop the scrub on %1?")).arg(pool), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
+ return; //cancelled
+ }
+ qDebug() << "Stop Scrub:" << pool;
+ QString cmd = "zpool scrub -s "+pool;
+ int ret = system(cmd.toUtf8());
+ if(ret == 0){
+ //Now let te user know that one has been triggered
+ QMessageBox::information(this,tr("Scrub Stopped"),QString(tr("The scrub on %1 has been stopped.")).arg(pool));
+ }else{
+ QMessageBox::warning(this,tr("Scrub Not Running"), QString(tr("There was no scrub running on %1.")).arg(pool) );
+ }
+}
+
// ==== Snapshots Menu ====
void LPMain::menuNewSnapshot(){
qDebug() << "New Snapshot";
View
@@ -65,7 +65,9 @@ private slots:
void menuAddDisk();
void menuRemoveDisk(QAction*);
void menuOfflineDisk(QAction*);
+ void menuOnlineDisk(QAction*);
void menuStartScrub();
+ void menuStopScrub();
//Snapshots Menu
void menuNewSnapshot();
void menuRemoveSnapshot(QAction*);
View
@@ -423,7 +423,7 @@
</property>
<widget class="QMenu" name="menuRemove_Disk">
<property name="title">
- <string>Remove Disk</string>
+ <string>Detach Disk</string>
</property>
<property name="icon">
<iconset resource="lPreserve.qrc">
@@ -441,12 +441,24 @@
</property>
<addaction name="actionDisks_2"/>
</widget>
+ <widget class="QMenu" name="menuSet_Disk_Online">
+ <property name="title">
+ <string>Set Disk Online</string>
+ </property>
+ <property name="icon">
+ <iconset resource="lPreserve.qrc">
+ <normaloff>:/images/network-wired.png</normaloff>:/images/network-wired.png</iconset>
+ </property>
+ <addaction name="actionDisk"/>
+ </widget>
<addaction name="actionAdd_Disk"/>
<addaction name="menuRemove_Disk"/>
<addaction name="separator"/>
+ <addaction name="menuSet_Disk_Online"/>
<addaction name="menuSet_Disk_Offline"/>
<addaction name="separator"/>
<addaction name="action_startScrub"/>
+ <addaction name="action_stopScrub"/>
</widget>
<widget class="QMenu" name="menuSnapshots">
<property name="title">
@@ -485,8 +497,8 @@
<addaction name="menuFile"/>
<addaction name="menuView"/>
<addaction name="menuClassic_Backups"/>
- <addaction name="menuDisks"/>
<addaction name="menuSnapshots"/>
+ <addaction name="menuDisks"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionClose_Window">
@@ -529,7 +541,7 @@
<normaloff>:/images/list-add.png</normaloff>:/images/list-add.png</iconset>
</property>
<property name="text">
- <string>Add Disk</string>
+ <string>Attach Disk</string>
</property>
</action>
<action name="actionNew_Snapshot">
@@ -615,6 +627,20 @@
<string notr="true">disks</string>
</property>
</action>
+ <action name="actionDisk">
+ <property name="text">
+ <string notr="true">disk</string>
+ </property>
+ </action>
+ <action name="action_stopScrub">
+ <property name="icon">
+ <iconset resource="lPreserve.qrc">
+ <normaloff>:/images/application-exit.png</normaloff>:/images/application-exit.png</iconset>
+ </property>
+ <property name="text">
+ <string>Stop Scrub</string>
+ </property>
+ </action>
</widget>
<resources>
<include location="lPreserve.qrc"/>
View
@@ -24,22 +24,5 @@
<file>images/list-remove.png</file>
<file>images/system-run.png</file>
<file>images/tray-icon-idle.png</file>
- <file>images/tray-icon-active1.png</file>
- <file>images/tray-icon-active2.png</file>
- <file>images/tray-icon-active3.png</file>
- <file>images/tray-icon-active4.png</file>
- <file>images/tray-icon-active5.png</file>
- <file>images/tray-icon-active6.png</file>
- <file>images/tray-icon-active7.png</file>
- <file>images/tray-icon-active8.png</file>
- <file>images/tray-icon-active9.png</file>
- <file>images/tray-icon-active10.png</file>
- <file>images/tray-icon-active11.png</file>
- <file>images/tray-icon-active12.png</file>
- <file>images/tray-icon-active13.png</file>
- <file>images/tray-icon-active14.png</file>
- <file>images/tray-icon-active15.png</file>
- <file>images/tray-icon-active16.png</file>
- <file>images/tray-icon-failed.png</file>
</qresource>
</RCC>

0 comments on commit 3da8c20

Please sign in to comment.