Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Get all the disk operations (detach/online/offline) operational (stil…

…l needs testing). Also clean up the tray icons that we don't need anymore.
  • Loading branch information...
commit 81e5a7303a9f7a132577aaf763f607a25f427be1 1 parent d4b29ff
@beanpole135 beanpole135 authored
View
39 lp-gui/LPBackend.cpp
@@ -269,7 +269,7 @@ bool LPBackend::copySSHKey(QString mountPath, QString localHost){
}
// ======================
-// Device Management
+// USB Device Management
// ======================
QStringList LPBackend::listDevices(){
//Scan the system for all valid da* and ada* devices (USB/SCSI, SATA)
@@ -287,15 +287,48 @@ QStringList LPBackend::listDevices(){
}
bool LPBackend::isMounted(QString device){
- qDebug() << "Device mount check not implemented yet";
+ qDebug() << "Device mount check not implemented yet:" << device;
return false;
}
bool LPBackend::unmountDevice(QString device){
- qDebug() << "Device unmounting not implemented yet";
+ qDebug() << "Device unmounting not implemented yet:" << device;
return false;
}
+// ======================
+// ZPOOL Disk Management
+// ======================
+bool LPBackend::attachDisk(QString pool, QString disk){
+ if( !disk.startsWith("/dev/") ){ disk.prepend("/dev/"); } //make sure it is the full disk path
+ if( !QFile::exists(disk) ){ return false; } //make sure the disk exists
+ QString cmd = "lpreserver zpool attach "+pool+" "+disk;
+ //Run the command
+ int ret = LPBackend::runCmd(cmd);
+ return (ret ==0);
+}
+
+bool LPBackend::detachDisk(QString pool, QString disk){
+ QString cmd = "lpreserver zpool detach "+pool+" "+disk;
+ //Run the command
+ int ret = LPBackend::runCmd(cmd);
+ return (ret ==0);
+}
+
+bool LPBackend::setDiskOnline(QString pool, QString disk){
+ QString cmd = "lpreserver zpool online "+pool+" "+disk;
+ //Run the command
+ int ret = LPBackend::runCmd(cmd);
+ return (ret ==0);
+}
+
+bool LPBackend::setDiskOffline(QString pool, QString disk){
+ QString cmd = "lpreserver zpool offline "+pool+" "+disk;
+ //Run the command
+ int ret = LPBackend::runCmd(cmd);
+ return (ret ==0);
+}
+
// =========================
// PRIVATE FUNCTIONS
// =========================
View
9 lp-gui/LPBackend.h
@@ -36,12 +36,15 @@ class LPBackend{
static bool setupSSHKey(QString remoteHost, QString remoteUser, int remotePort);
static QStringList findValidUSBDevices();
static bool copySSHKey(QString mountPath, QString localHost);
- //Device Management
+ //USB Device Management
static QStringList listDevices();
static bool isMounted(QString device);
static bool unmountDevice(QString device);
- //Mirroring Management
-
+ //Zpool disk Management
+ static bool attachDisk(QString pool, QString disk);
+ static bool detachDisk(QString pool, QString disk);
+ static bool setDiskOnline(QString pool, QString disk);
+ static bool setDiskOffline(QString pool, QString disk);
//General utility functions
static QStringList getCmdOutput(QString);
static int runCmd(QString);
View
62 lp-gui/LPMain.cpp
@@ -445,26 +445,70 @@ void LPMain::menuExtractHomeDir(){
// ==== Disks Menu ====
void LPMain::menuAddDisk(){
- qDebug() << "Add Disk";
-
+ QString pool = ui->combo_pools->currentText();
+ //Find a disk that can be added to the system
+ QString disk = "";
+ qDebug() << "Add disk not implemented yet:" << pool;
+ return;
+ qDebug() << "Add Disk:" << disk << pool;
+ bool ok = LPBackend::attachDisk(pool, disk);
+ if(ok){
+ QMessageBox::information(this,tr(""),tr(""));
+ QTimer::singleShot(0,this,SLOT(updateTabs()) );
+ }else{
+ QMessageBox::warning(this,tr(""),tr(""));
+ }
}
void LPMain::menuRemoveDisk(QAction *act){
QString disk = act->text();
- qDebug() << "Remove Disk:" << disk;
-
+ QString pool = ui->combo_pools->currentText();
+ //Verify action
+ if(QMessageBox::Yes != QMessageBox::question(this,tr("Verify Disk Removal"),QString(tr("Are you sure that you want to remove %1 from %2?")).arg(disk,pool) + "\n\n" + tr("CAUTION: This disk can only be re-attached later as a brand new disk"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
+ return; //cancelled
+ }
+ qDebug() << "Remove Disk:" << disk << pool;
+ bool ok = LPBackend::detachDisk(pool, disk);
+ if(ok){
+ QMessageBox::information(this,tr("Disk Removal Success"),QString(tr("Success: %1 was removed from %2")).arg(disk, pool) );
+ QTimer::singleShot(0,this,SLOT(updateTabs()) );
+ }else{
+ QMessageBox::warning(this,tr("Disk Removal Failure"),QString(tr("Failure: %1 could not be removed from %2 at this time.")).arg(disk, pool) );
+ }
}
void LPMain::menuOfflineDisk(QAction *act){
QString disk = act->text();
- qDebug() << "Set Disk Offline:" << disk;
-
+ QString pool = ui->combo_pools->currentText();
+ //Verify action
+ if(QMessageBox::Yes != QMessageBox::question(this,tr("Verify Disk Offline"),QString(tr("Are you sure you wish to set %1 offline?")).arg(disk), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
+ return; //cancelled
+ }
+ qDebug() << "Offline Disk:" << disk << pool;
+ bool ok = LPBackend::detachDisk(pool, disk);
+ if(ok){
+ QMessageBox::information(this,tr("Disk Offline Success"),QString(tr("Success: %1 has been taken offline.")).arg(disk) );
+ QTimer::singleShot(0,this,SLOT(updateTabs()) );
+ }else{
+ QMessageBox::warning(this,tr("Disk Offline Failure"),QString(tr("Failure: %1 could not be taken offline at this time.")).arg(disk) );
+ }
}
void LPMain::menuOnlineDisk(QAction *act){
QString disk = act->text();
- qDebug() << "Set Disk Online:" << disk;
-
+ QString pool = ui->combo_pools->currentText();
+ //Verify action
+ if(QMessageBox::Yes != QMessageBox::question(this,tr("Verify Disk Online"),QString(tr("Are you sure you wish to set %1 online?")).arg(disk), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) ){
+ return; //cancelled
+ }
+ qDebug() << "Online Disk:" << disk << pool;
+ bool ok = LPBackend::detachDisk(pool, disk);
+ if(ok){
+ QMessageBox::information(this,tr("Disk Online Success"),QString(tr("Success: %1 has been set online.")).arg(disk) );
+ QTimer::singleShot(0,this,SLOT(updateTabs()) );
+ }else{
+ QMessageBox::warning(this,tr("Disk Online Failure"),QString(tr("Failure: %1 could not be set online at this time.")).arg(disk) );
+ }
}
void LPMain::menuStartScrub(){
@@ -479,6 +523,7 @@ void LPMain::menuStartScrub(){
if(ret == 0){
//Now let te user know that one has been triggered
QMessageBox::information(this,tr("Scrub Started"),QString(tr("A scrub has just been started on %1")).arg(pool));
+ QTimer::singleShot(0,this,SLOT(updateTabs()) );
}else{
QMessageBox::warning(this,tr("Scrub Not Started"), QString(tr("A scrub on %1 could not be started at this time.")).arg(pool) + "\n"+tr("Please wait until any current resilvering or scrubs are finished before trying again.") );
}
@@ -496,6 +541,7 @@ void LPMain::menuStopScrub(){
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));
+ QTimer::singleShot(0,this,SLOT(updateTabs()) );
}else{
QMessageBox::warning(this,tr("Scrub Not Running"), QString(tr("There was no scrub running on %1.")).arg(pool) );
}
View
1  lp-gui/LPMain.h
@@ -12,6 +12,7 @@
#include <QFileSystemModel>
#include <QInputDialog>
#include <QDateTime>
+#include <QTimer>
#include "LPBackend.h"
#include "LPContainers.h"
View
6 lp-gui/LPMain.ui
@@ -437,7 +437,7 @@
</property>
<property name="icon">
<iconset resource="lPreserve.qrc">
- <normaloff>:/images/network-wired.png</normaloff>:/images/network-wired.png</iconset>
+ <normaloff>:/images/network-wired-red.png</normaloff>:/images/network-wired-red.png</iconset>
</property>
<addaction name="actionDisks_2"/>
</widget>
@@ -623,6 +623,10 @@
</property>
</action>
<action name="actionDisks_2">
+ <property name="icon">
+ <iconset resource="lPreserve.qrc">
+ <normaloff>:/images/network-wired-red.png</normaloff>:/images/network-wired-red.png</iconset>
+ </property>
<property name="text">
<string notr="true">disks</string>
</property>
View
BIN  lp-gui/images/network-wired-red.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  lp-gui/images/tray-icon-active1.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active10.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active11.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active12.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active13.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active14.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active15.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active16.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active2.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active3.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active4.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active5.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active6.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active7.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active8.png
Deleted file not rendered
View
BIN  lp-gui/images/tray-icon-active9.png
Deleted file not rendered
View
1  lp-gui/lPreserve.qrc
@@ -1,5 +1,6 @@
<RCC>
<qresource>
+ <file>images/network-wired-red.png</file>
<file>images/refresh.png</file>
<file>images/box_add.png</file>
<file>images/box_extract.png</file>
Please sign in to comment.
Something went wrong with that request. Please try again.