Permalink
Browse files

Remove the lp-gui and lp-tray from the projects tree, it is in the ma…

…in src-qt4 tree now.
  • Loading branch information...
1 parent eb30fda commit 541f93150f1a9e583916e09826424e246d98cdbf Ken Moore committed Oct 22, 2013
Showing with 0 additions and 49,718 deletions.
  1. +0 −357 lp-gui/LPBackend.cpp
  2. +0 −53 lp-gui/LPBackend.h
  3. +0 −171 lp-gui/LPConfig.cpp
  4. +0 −39 lp-gui/LPConfig.h
  5. +0 −397 lp-gui/LPConfig.ui
  6. +0 −33 lp-gui/LPContainers.h
  7. +0 −254 lp-gui/LPGUtils.cpp
  8. +0 −28 lp-gui/LPGUtils.h
  9. +0 −671 lp-gui/LPMain.cpp
  10. +0 −84 lp-gui/LPMain.h
  11. +0 −654 lp-gui/LPMain.ui
  12. +0 −58 lp-gui/LPWizard.cpp
  13. +0 −35 lp-gui/LPWizard.h
  14. +0 −627 lp-gui/LPWizard.ui
  15. +0 −439 lp-gui/i18n/LifePreserver_af.ts
  16. +0 −439 lp-gui/i18n/LifePreserver_ar.ts
  17. +0 −439 lp-gui/i18n/LifePreserver_az.ts
  18. +0 −439 lp-gui/i18n/LifePreserver_bg.ts
  19. +0 −439 lp-gui/i18n/LifePreserver_bn.ts
  20. +0 −439 lp-gui/i18n/LifePreserver_bs.ts
  21. +0 −439 lp-gui/i18n/LifePreserver_ca.ts
  22. +0 −439 lp-gui/i18n/LifePreserver_cs.ts
  23. +0 −439 lp-gui/i18n/LifePreserver_cy.ts
  24. +0 −439 lp-gui/i18n/LifePreserver_da.ts
  25. +0 −439 lp-gui/i18n/LifePreserver_de.ts
  26. +0 −439 lp-gui/i18n/LifePreserver_el.ts
  27. +0 −439 lp-gui/i18n/LifePreserver_en_GB.ts
  28. +0 −439 lp-gui/i18n/LifePreserver_en_US.ts
  29. +0 −439 lp-gui/i18n/LifePreserver_en_ZA.ts
  30. +0 −439 lp-gui/i18n/LifePreserver_es.ts
  31. +0 −439 lp-gui/i18n/LifePreserver_et.ts
  32. +0 −439 lp-gui/i18n/LifePreserver_eu.ts
  33. +0 −439 lp-gui/i18n/LifePreserver_fa.ts
  34. +0 −439 lp-gui/i18n/LifePreserver_fi.ts
  35. +0 −439 lp-gui/i18n/LifePreserver_fr.ts
  36. +0 −439 lp-gui/i18n/LifePreserver_fr_CA.ts
  37. +0 −439 lp-gui/i18n/LifePreserver_fur.ts
  38. +0 −439 lp-gui/i18n/LifePreserver_gl.ts
  39. +0 −439 lp-gui/i18n/LifePreserver_he.ts
  40. +0 −439 lp-gui/i18n/LifePreserver_hi.ts
  41. +0 −439 lp-gui/i18n/LifePreserver_hr.ts
  42. +0 −439 lp-gui/i18n/LifePreserver_hu.ts
  43. +0 −439 lp-gui/i18n/LifePreserver_id.ts
  44. +0 −439 lp-gui/i18n/LifePreserver_is.ts
  45. +0 −439 lp-gui/i18n/LifePreserver_it.ts
  46. +0 −439 lp-gui/i18n/LifePreserver_ja.ts
  47. +0 −439 lp-gui/i18n/LifePreserver_ka.ts
  48. +0 −439 lp-gui/i18n/LifePreserver_ko.ts
  49. +0 −439 lp-gui/i18n/LifePreserver_lt.ts
  50. +0 −439 lp-gui/i18n/LifePreserver_lv.ts
  51. +0 −439 lp-gui/i18n/LifePreserver_mk.ts
  52. +0 −439 lp-gui/i18n/LifePreserver_mn.ts
  53. +0 −439 lp-gui/i18n/LifePreserver_ms.ts
  54. +0 −439 lp-gui/i18n/LifePreserver_mt.ts
  55. +0 −439 lp-gui/i18n/LifePreserver_nb.ts
  56. +0 −439 lp-gui/i18n/LifePreserver_ne.ts
  57. +0 −439 lp-gui/i18n/LifePreserver_nl.ts
  58. +0 −439 lp-gui/i18n/LifePreserver_pa.ts
  59. +0 −439 lp-gui/i18n/LifePreserver_pl.ts
  60. +0 −439 lp-gui/i18n/LifePreserver_pt.ts
  61. +0 −439 lp-gui/i18n/LifePreserver_pt_BR.ts
  62. +0 −439 lp-gui/i18n/LifePreserver_ro.ts
  63. +0 −439 lp-gui/i18n/LifePreserver_ru.ts
  64. +0 −439 lp-gui/i18n/LifePreserver_sa.ts
  65. +0 −439 lp-gui/i18n/LifePreserver_sk.ts
  66. +0 −439 lp-gui/i18n/LifePreserver_sl.ts
  67. +0 −439 lp-gui/i18n/LifePreserver_sr.ts
  68. +0 −439 lp-gui/i18n/LifePreserver_sv.ts
  69. +0 −439 lp-gui/i18n/LifePreserver_sw.ts
  70. +0 −439 lp-gui/i18n/LifePreserver_ta.ts
  71. +0 −439 lp-gui/i18n/LifePreserver_tg.ts
  72. +0 −439 lp-gui/i18n/LifePreserver_th.ts
  73. +0 −439 lp-gui/i18n/LifePreserver_tr.ts
  74. +0 −439 lp-gui/i18n/LifePreserver_uk.ts
  75. +0 −439 lp-gui/i18n/LifePreserver_uz.ts
  76. +0 −439 lp-gui/i18n/LifePreserver_vi.ts
  77. +0 −439 lp-gui/i18n/LifePreserver_zh_CN.ts
  78. +0 −439 lp-gui/i18n/LifePreserver_zh_HK.ts
  79. +0 −439 lp-gui/i18n/LifePreserver_zh_TW.ts
  80. +0 −439 lp-gui/i18n/LifePreserver_zu.ts
  81. +0 −4 lp-gui/images/.directory
  82. BIN lp-gui/images/application-exit.png
  83. BIN lp-gui/images/backup-failed.png
  84. BIN lp-gui/images/backup-ok.png
  85. BIN lp-gui/images/box_add.png
  86. BIN lp-gui/images/box_extract.png
  87. BIN lp-gui/images/camera_add.png
  88. BIN lp-gui/images/configure.png
  89. BIN lp-gui/images/copy.png
  90. BIN lp-gui/images/drive-removable-media.png
  91. BIN lp-gui/images/folder.png
  92. BIN lp-gui/images/key.png
  93. BIN lp-gui/images/lifepreserver.png
  94. BIN lp-gui/images/list-add.png
  95. BIN lp-gui/images/list-remove.png
  96. BIN lp-gui/images/network-wired-red.png
  97. BIN lp-gui/images/network-wired.png
  98. BIN lp-gui/images/next.png
  99. BIN lp-gui/images/previous.png
  100. BIN lp-gui/images/refresh.png
  101. BIN lp-gui/images/system-run.png
  102. BIN lp-gui/images/tray-icon-error.png
  103. BIN lp-gui/images/tray-icon-failed.png
  104. BIN lp-gui/images/tray-icon-idle.png
  105. BIN lp-gui/images/tray-icon-working.png
  106. BIN lp-gui/images/upload.png
  107. BIN lp-gui/images/view.png
  108. +0 −29 lp-gui/lPreserve.qrc
  109. +0 −105 lp-gui/life-preserver.pro
  110. +0 −42 lp-gui/main.cpp
  111. +0 −46 lp-gui/scripts/setup-ssh-keys.sh
  112. +0 −95 lp-tray/LPMessages.cpp
  113. +0 −38 lp-tray/LPMessages.h
  114. +0 −150 lp-tray/LPMessages.ui
  115. +0 −172 lp-tray/LPTray.cpp
  116. +0 −38 lp-tray/LPTray.h
  117. +0 −580 lp-tray/LPWatcher.cpp
  118. +0 −68 lp-tray/LPWatcher.h
  119. +0 −237 lp-tray/i18n/LifePreserverTray_af.ts
  120. +0 −237 lp-tray/i18n/LifePreserverTray_ar.ts
  121. +0 −237 lp-tray/i18n/LifePreserverTray_az.ts
  122. +0 −237 lp-tray/i18n/LifePreserverTray_bg.ts
  123. +0 −237 lp-tray/i18n/LifePreserverTray_bn.ts
  124. +0 −237 lp-tray/i18n/LifePreserverTray_bs.ts
  125. +0 −237 lp-tray/i18n/LifePreserverTray_ca.ts
  126. +0 −237 lp-tray/i18n/LifePreserverTray_cs.ts
  127. +0 −237 lp-tray/i18n/LifePreserverTray_cy.ts
  128. +0 −237 lp-tray/i18n/LifePreserverTray_da.ts
  129. +0 −237 lp-tray/i18n/LifePreserverTray_de.ts
  130. +0 −237 lp-tray/i18n/LifePreserverTray_el.ts
  131. +0 −237 lp-tray/i18n/LifePreserverTray_en_GB.ts
  132. +0 −237 lp-tray/i18n/LifePreserverTray_en_US.ts
  133. +0 −237 lp-tray/i18n/LifePreserverTray_en_ZA.ts
  134. +0 −237 lp-tray/i18n/LifePreserverTray_es.ts
  135. +0 −237 lp-tray/i18n/LifePreserverTray_et.ts
  136. +0 −237 lp-tray/i18n/LifePreserverTray_eu.ts
  137. +0 −237 lp-tray/i18n/LifePreserverTray_fa.ts
  138. +0 −237 lp-tray/i18n/LifePreserverTray_fi.ts
  139. +0 −237 lp-tray/i18n/LifePreserverTray_fr.ts
  140. +0 −237 lp-tray/i18n/LifePreserverTray_fr_CA.ts
  141. +0 −237 lp-tray/i18n/LifePreserverTray_fur.ts
  142. +0 −237 lp-tray/i18n/LifePreserverTray_gl.ts
  143. +0 −237 lp-tray/i18n/LifePreserverTray_he.ts
  144. +0 −237 lp-tray/i18n/LifePreserverTray_hi.ts
  145. +0 −237 lp-tray/i18n/LifePreserverTray_hr.ts
  146. +0 −237 lp-tray/i18n/LifePreserverTray_hu.ts
  147. +0 −237 lp-tray/i18n/LifePreserverTray_id.ts
  148. +0 −237 lp-tray/i18n/LifePreserverTray_is.ts
  149. +0 −237 lp-tray/i18n/LifePreserverTray_it.ts
  150. +0 −237 lp-tray/i18n/LifePreserverTray_ja.ts
  151. +0 −237 lp-tray/i18n/LifePreserverTray_ka.ts
  152. +0 −237 lp-tray/i18n/LifePreserverTray_ko.ts
  153. +0 −237 lp-tray/i18n/LifePreserverTray_lt.ts
  154. +0 −237 lp-tray/i18n/LifePreserverTray_lv.ts
  155. +0 −237 lp-tray/i18n/LifePreserverTray_mk.ts
  156. +0 −237 lp-tray/i18n/LifePreserverTray_mn.ts
  157. +0 −237 lp-tray/i18n/LifePreserverTray_ms.ts
  158. +0 −237 lp-tray/i18n/LifePreserverTray_mt.ts
  159. +0 −237 lp-tray/i18n/LifePreserverTray_nb.ts
  160. +0 −237 lp-tray/i18n/LifePreserverTray_ne.ts
  161. +0 −237 lp-tray/i18n/LifePreserverTray_nl.ts
  162. +0 −237 lp-tray/i18n/LifePreserverTray_pa.ts
  163. +0 −237 lp-tray/i18n/LifePreserverTray_pl.ts
  164. +0 −237 lp-tray/i18n/LifePreserverTray_pt.ts
  165. +0 −237 lp-tray/i18n/LifePreserverTray_pt_BR.ts
  166. +0 −237 lp-tray/i18n/LifePreserverTray_ro.ts
  167. +0 −237 lp-tray/i18n/LifePreserverTray_ru.ts
  168. +0 −237 lp-tray/i18n/LifePreserverTray_sa.ts
  169. +0 −237 lp-tray/i18n/LifePreserverTray_sk.ts
  170. +0 −237 lp-tray/i18n/LifePreserverTray_sl.ts
  171. +0 −237 lp-tray/i18n/LifePreserverTray_sr.ts
  172. +0 −237 lp-tray/i18n/LifePreserverTray_sv.ts
  173. +0 −237 lp-tray/i18n/LifePreserverTray_sw.ts
  174. +0 −237 lp-tray/i18n/LifePreserverTray_ta.ts
  175. +0 −237 lp-tray/i18n/LifePreserverTray_tg.ts
  176. +0 −237 lp-tray/i18n/LifePreserverTray_th.ts
  177. +0 −237 lp-tray/i18n/LifePreserverTray_tr.ts
  178. +0 −237 lp-tray/i18n/LifePreserverTray_uk.ts
  179. +0 −237 lp-tray/i18n/LifePreserverTray_uz.ts
  180. +0 −237 lp-tray/i18n/LifePreserverTray_vi.ts
  181. +0 −237 lp-tray/i18n/LifePreserverTray_zh_CN.ts
  182. +0 −237 lp-tray/i18n/LifePreserverTray_zh_HK.ts
  183. +0 −237 lp-tray/i18n/LifePreserverTray_zh_TW.ts
  184. +0 −237 lp-tray/i18n/LifePreserverTray_zu.ts
  185. +0 −4 lp-tray/images/.directory
  186. BIN lp-tray/images/application-exit.png
  187. BIN lp-tray/images/backup-failed.png
  188. BIN lp-tray/images/backup-ok.png
  189. BIN lp-tray/images/configure.png
  190. BIN lp-tray/images/lifepreserver.png
  191. BIN lp-tray/images/list-add.png
  192. BIN lp-tray/images/list-remove.png
  193. BIN lp-tray/images/refresh.png
  194. BIN lp-tray/images/tray-icon-error.png
  195. BIN lp-tray/images/tray-icon-failed.png
  196. BIN lp-tray/images/tray-icon-idle.png
  197. BIN lp-tray/images/tray-icon-working.png
  198. +0 −16 lp-tray/lPreserve.qrc
  199. +0 −102 lp-tray/lifepreserver.desktop
  200. +0 −105 lp-tray/lp-tray.pro
  201. +0 −47 lp-tray/main.cpp
View
@@ -1,357 +0,0 @@
-#include "LPBackend.h"
-
-// ==============
-// Informational
-// ==============
-QStringList LPBackend::listPossibleDatasets(){
- QString cmd = "zpool list -H -o name";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output (one dataset per line - no headers)
- QStringList list;
- for(int i=0; i<out.length(); i++){
- QString ds = out[i].section("/",0,0).simplified();
- if(!ds.isEmpty()){ list << ds; }
- }
- list.removeDuplicates();
-
- return list;
-}
-
-QStringList LPBackend::listDatasets(){
- QString cmd = "lpreserver listcron";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- QStringList list;
- for(int i=2; i<out.length(); i++){ //skip the first two lines (headers)
- QString ds = out[i].section(" - ",0,0).simplified();
- if(!ds.isEmpty()){ list << ds; }
- }
-
- return list;
-}
-
-QStringList LPBackend::listDatasetSubsets(QString dataset){
- QString cmd = "zfs list -H -t filesystem -o name,mountpoint,mounted";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output (one dataset per line - no headers)
- QStringList list;
- for(int i=0; i<out.length(); i++){
- if(out[i].startsWith(dataset+"/")){
- if(out[i].section("\t",2,2,QString::SectionSkipEmpty).simplified() == "yes"){
- QString ds = out[i].section("\t",1,1).simplified(); //save the mountpoint
- if(!ds.isEmpty()){ list << ds; }
- }
- }
- }
- list.removeDuplicates();
-
- return list;
-}
-
-QStringList LPBackend::listSnapshots(QString dsmountpoint){
- //List all the snapshots available for the given dataset mountpoint
- QDir dir(dsmountpoint+"/.zfs/snapshot");
- QStringList list;
- if(dir.exists()){
- list = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Time | QDir::Reversed);
- }
- return list;
-}
-
-QStringList LPBackend::listLPSnapshots(QString dataset){
- QString cmd = "lpreserver listsnap "+dataset;
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- QStringList list;
- for(int i=0; i<out.length(); i++){ //oldest ->newest
- if(out[i].startsWith(dataset+"@")){
- QString snap = out[i].section("@",1,3).section(" ",0,0).simplified();;
- if(!snap.isEmpty()){ list << snap; }
- }
- }
-
- return list;
-}
-
-QStringList LPBackend::listReplicationTargets(){
- QString cmd = "lpreserver replicate list";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- QStringList list;
- for(int i=0; i<out.length(); i++){
- if(out[i].contains("->")){
- QString ds = out[i].section("->",0,0).simplified();
- if(!ds.isEmpty()){ list << ds; }
- }
- }
-
- return list;
-}
-
-QStringList LPBackend::listCurrentStatus(){
- QString cmd = "lpreserver status";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- QStringList list;
- for(int i=2; i<out.length(); i++){ //first 2 lines are headers
- //Format: <dataset>:::<lastsnapshot | NONE>:::<lastreplication | NONE>
- if(out[i].isEmpty()){ continue; }
- QString ds = out[i].section(" - ",0,0).simplified();
- QString snap = out[i].section(" - ",1,1).simplified();
- QString rep = out[i].section(" - ",2,2).simplified();
- if(snap == "NONE"){ snap = "-"; }
- if(rep == "NONE"){ rep = "-"; }
- list << ds +":::"+ snap+":::"+rep;
- }
-
- return list;
-}
-
-// ==================
-// Dataset Management
-// ==================
-bool LPBackend::setupDataset(QString dataset, int time, int numToKeep){
- //Configure inputs
- QString freq;
- if(time == -30){ freq = "30min"; }
- else if(time == -10){ freq = "10min"; }
- else if(time == -5){ freq = "5min"; }
- else if(time >= 0 && time < 24){ freq = "daily@"+QString::number(time); }
- else{ freq = "hourly"; }
-
- //Create the command
- QString cmd = "lpreserver cronsnap "+dataset+" start "+freq+" "+QString::number(numToKeep);
- int ret = LPBackend::runCmd(cmd);
-
- return (ret == 0);
-}
-
-bool LPBackend::removeDataset(QString dataset){
- QString cmd = "lpreserver cronsnap "+dataset+" stop";
- int ret = LPBackend::runCmd(cmd);
-
- return (ret == 0);
-}
-
-bool LPBackend::datasetInfo(QString dataset, int& time, int& numToKeep){
- QString cmd = "lpreserver listcron";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- bool ok = false;
- for(int i=0; i<out.length(); i++){
- if(out[i].section(" - ",0,0).simplified() == dataset){
- //Get time schedule (in integer format)
- QString sch = out[i].section(" - ",1,1).simplified();
- if(sch.startsWith("daily@")){ time = sch.section("@",1,1).simplified().toInt(); }
- else if(sch=="5min"){time = -5;}
- else if(sch=="10min"){time = -10;}
- else if(sch=="30min"){time = -30;}
- else{ time = -60; } //hourly
- //Get total snapshots
- numToKeep = out[i].section("- total:",1,1).simplified().toInt();
- ok=true;
- break;
- }
- }
- //qDebug() << "lpreserver cronsnap:\n" << out << QString::number(time) << QString::number(numToKeep);
-
- return ok;
-}
-
-// ==================
-// Snapshop Management
-// ==================
-void LPBackend::newSnapshot(QString dataset, QString snapshotname){
- //This needs to run externally - since the snapshot is simply added to the queue, and the replication
- // afterwards may take a long time.
- QString cmd = "lpreserver mksnap --replicate "+dataset+" "+snapshotname;
- QProcess::startDetached(cmd);
-
- return;
-}
-
-bool LPBackend::removeSnapshot(QString dataset, QString snapshot){
- QString cmd = "lpreserver rmsnap "+dataset +" "+snapshot;
- int ret = LPBackend::runCmd(cmd);
-
- return (ret == 0);
-}
-
-bool LPBackend::revertSnapshot(QString dataset, QString snapshot){
- QString cmd = "lpreserver revertsnap "+dataset +" "+snapshot;
- int ret = LPBackend::runCmd(cmd);
-
- return (ret == 0);
-}
-
-// ==================
-// Replication Management
-// ==================
-bool LPBackend::setupReplication(QString dataset, QString remotehost, QString user, int port, QString remotedataset, int time){
- QString stime = "sync"; //synchronize on snapshot creation (default)
- if(time >= 0 && time < 24){ stime = QString::number(time); } //daily at a particular hour (24 hour notation)
-
-
- QString cmd = "lpreserver replicate add "+remotehost+" "+user+" "+ QString::number(port)+" "+dataset+" "+remotedataset+" "+stime;
- int ret = LPBackend::runCmd(cmd);
-
- return (ret == 0);
-}
-
-bool LPBackend::removeReplication(QString dataset){
- QString cmd = "lpreserver replicate remove "+dataset;
- int ret = LPBackend::runCmd(cmd);
-
- return (ret == 0);
-}
-
-bool LPBackend::replicationInfo(QString dataset, QString& remotehost, QString& user, int& port, QString& remotedataset, int& time){
- QString cmd = "lpreserver replicate list";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- bool ok = false;
- for(int i=0; i<out.length(); i++){
- if(out[i].contains("->") && out[i].startsWith(dataset)){
- QString data = out[i].section("->",1,1);
- user = data.section("@",0,0);
- remotehost = data.section("@",1,1).section("[",0,0);
- port = data.section("[",1,1).section("]",0,0).toInt();
- remotedataset = data.section(":",1,1).section(" Time",0,0);
- QString synchro = data.section("Time:",1,1).simplified();
- if(synchro == "sync"){ time = -1; }
- else{ time = synchro.toInt(); }
- ok = true;
- break;
- }
- }
-
- return ok;
-}
-
-// ======================
-// SSH Key Management
-// ======================
-bool LPBackend::setupSSHKey(QString remoteHost, QString remoteUser, int remotePort){
- QString LPPATH = "/usr/local/share/lifePreserver";
- QString cmd = "xterm -e \""+LPPATH+"/scripts/setup-ssh-keys.sh "+remoteUser+" "+remoteHost+" "+QString::number(remotePort)+"\"";
- int ret = LPBackend::runCmd(cmd);
- return (ret == 0);
-}
-
-QStringList LPBackend::findValidUSBDevices(){
- //Return format: "<mountpoint> (<device node>")
- QString cmd = "mount";
- QStringList out = LPBackend::getCmdOutput(cmd);
- //Now process the output
- QStringList list;
- for(int i=0; i<out.length(); i++){
- if(out[i].startsWith("/dev/da") && out[i].contains("(msdosfs,")){
- QString mountpoint = out[i].section(" on ",1,1).section("(",0,0).simplified();
- QString devnode = out[i].section(" on ",0,0).section("/",-1).simplified();
- list << mountpoint +" ("+devnode+")";
- }
- }
- return list;
-}
-
-bool LPBackend::copySSHKey(QString mountPath, QString localHost){
- QString publicKey = "/root/.ssh/id_rsa";
- //copy the file onto the designated USB stick
- if(!mountPath.endsWith("/")){ mountPath.append("/"); }
- QDir lDir=mountPath + "lpreserver";
- if ( ! lDir.exists() )
- lDir.mkdir(lDir.path());
-
- mountPath.append("lpreserver/"+localHost+"-id_rsa");
-
- bool ok = QFile::copy(publicKey, mountPath);
- return ok;
-}
-
-// ======================
-// USB Device Management
-// ======================
-QStringList LPBackend::listDevices(){
- //Scan the system for all valid da* and ada* devices (USB/SCSI, SATA)
- //Return format: "<device node> (<device information>)"
- QDir devDir("/dev");
- QStringList devs = devDir.entryList(QStringList() << "da*"<<"ada*", QDir::System | QDir::NoSymLinks, QDir::Name);
- QStringList camOut = LPBackend::getCmdOutput("camcontrol devlist");
- QStringList output, flist;
- for(int i=0; i<devs.length(); i++){
- flist = camOut.filter("("+devs[i]+",");
- //still need to add an additional device filter to weed out devices currently in use.
- if(!flist.isEmpty()){ output << devs[i] + " ("+flist[0].section(">",0,0).remove("<").simplified()+")"; }
- }
- return output;
-}
-
-bool LPBackend::isMounted(QString device){
- qDebug() << "Device mount check not implemented yet:" << device;
- return false;
-}
-
-bool LPBackend::unmountDevice(QString device){
- 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
-// =========================
-QStringList LPBackend::getCmdOutput(QString cmd){
- QProcess *proc = new QProcess;
- proc->setProcessChannelMode(QProcess::MergedChannels);
- proc->start(cmd);
- while(!proc->waitForFinished(300)){
- QCoreApplication::processEvents();
- }
- QStringList out = QString(proc->readAllStandardOutput()).split("\n");
- delete proc;
- return out;
-}
-
-int LPBackend::runCmd(QString cmd){
- QProcess *proc = new QProcess;
- proc->setProcessChannelMode(QProcess::MergedChannels);
- proc->start(cmd);
- while(!proc->waitForFinished(300)){
- QCoreApplication::processEvents();
- }
- int ret = proc->exitCode();
- delete proc;
- return ret;
-}
Oops, something went wrong.

0 comments on commit 541f931

Please sign in to comment.