Ignore:
Timestamp:
Oct 21, 2013 8:12:00 AM (6 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
4bf853e
Parents:
dca28eb
Message:

Remove the old life-preserver from the src-qt4/life-preserver dir, and replace it with src-qt4/life-preserver/lp-tray and src-qt4/life-preserver/lp-gui.

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src-qt4/life-preserver/lp-gui/LPBackend.cpp

    rea627be r6a2483b  
    6464  //Now process the output 
    6565  QStringList list; 
    66   for(int i=out.length()-1; i>=0; i--){ //go in reverse order for proper time format (newest first) 
     66  for(int i=0; i<out.length(); i++){ //oldest ->newest 
    6767    if(out[i].startsWith(dataset+"@")){ 
    6868      QString snap = out[i].section("@",1,3).section(" ",0,0).simplified();; 
     
    185185} 
    186186 
    187 QString LPBackend::revertSnapshotFile(QString dsmountpoint, QString snapshot, QString filepath){ 
    188   //Copy the given file from the snapshot back into the main dataset 
    189   // -- filepath: full path to the file in the snapshot directory 
    190   //qDebug() << " - Revert file:" << filepath; 
    191   filepath.replace("~",QDir::homePath()); 
    192   //Check that the file path is complete and the file exists 
    193   if(!QFile::exists(filepath)){ 
    194     //invalid file given 
    195     return ""; 
    196   } 
    197   //Generate the new file path 
    198   QString newfilepath = filepath.replace(dsmountpoint+"/.zfs/snapshot/"+snapshot, dsmountpoint);         
    199   if( QFile::exists(newfilepath) ){ 
    200     //get the file extension 
    201     QString filename = newfilepath.section("/",-1); 
    202     QString ext = filename.section(".",-1); 
    203     if( !ext.isEmpty() && !filename.startsWith("."+ext) && ext!=filename){ 
    204       newfilepath.chop(ext.length()+1); 
    205       newfilepath.append("-reversion."+ext); 
    206       int i=1; 
    207       //append a number to the end if a reversion file already exists 
    208       while(QFile::exists(newfilepath)){ 
    209         newfilepath.chop(ext.length()+1); 
    210         newfilepath.append(QString::number(i)+"."+ext); 
    211       i  ++; 
    212       } 
    213     }else{ 
    214       //File without an extension - just append a number 
    215       newfilepath.append("-reversion"); 
    216       int i=1;  
    217       QString npath = newfilepath; 
    218       while(QFile::exists(npath)){ 
    219         npath = newfilepath.append(QString::number(i)); 
    220         i++; 
    221       } 
    222       newfilepath = npath; 
    223     } 
    224   } 
    225   //perform the copy 
    226   qDebug() <<  " - File Reversion:" << filepath << newfilepath; 
    227   bool ok = QFile::copy(filepath,newfilepath); 
    228   //return the path to the new file if the copy was successful 
    229   if(ok){  
    230     //reset the permissions on the reverted file to match the original 
    231     QFile::setPermissions(newfilepath, QFile::permissions(filepath)); 
    232     return newfilepath; 
    233   }else{ return ""; } 
    234 } 
    235  
    236187// ================== 
    237188//    Replication Management 
     
    319270 
    320271// ====================== 
    321 //          Device Management 
     272//        USB Device Management 
    322273// ====================== 
    323274QStringList LPBackend::listDevices(){ 
     
    337288 
    338289bool LPBackend::isMounted(QString device){ 
    339   qDebug() << "Device mount check not implemented yet"; 
     290  qDebug() << "Device mount check not implemented yet:" << device; 
    340291  return false; 
    341292} 
    342293 
    343294bool LPBackend::unmountDevice(QString device){ 
    344   qDebug() << "Device unmounting not implemented yet"; 
     295  qDebug() << "Device unmounting not implemented yet:" << device; 
    345296  return false; 
     297} 
     298 
     299// ====================== 
     300//        ZPOOL Disk Management 
     301// ====================== 
     302bool LPBackend::attachDisk(QString pool, QString disk){ 
     303  if( !disk.startsWith("/dev/") ){ disk.prepend("/dev/"); } //make sure it is the full disk path 
     304  if( !QFile::exists(disk) ){ return false; } //make sure the disk exists 
     305  QString cmd = "lpreserver zpool attach "+pool+" "+disk; 
     306  //Run the command 
     307  int ret = LPBackend::runCmd(cmd); 
     308  return (ret ==0); 
     309} 
     310 
     311bool LPBackend::detachDisk(QString pool, QString disk){ 
     312  QString cmd = "lpreserver zpool detach "+pool+" "+disk; 
     313  //Run the command 
     314  int ret = LPBackend::runCmd(cmd); 
     315  return (ret ==0);      
     316} 
     317 
     318bool LPBackend::setDiskOnline(QString pool, QString disk){ 
     319  QString cmd = "lpreserver zpool online "+pool+" "+disk; 
     320  //Run the command 
     321  int ret = LPBackend::runCmd(cmd); 
     322  return (ret ==0);      
     323} 
     324 
     325bool LPBackend::setDiskOffline(QString pool, QString disk){ 
     326  QString cmd = "lpreserver zpool offline "+pool+" "+disk; 
     327  //Run the command 
     328  int ret = LPBackend::runCmd(cmd); 
     329  return (ret ==0);      
    346330} 
    347331 
Note: See TracChangeset for help on using the changeset viewer.