Changeset 50625d0


Ignore:
Timestamp:
04/29/15 06:51:11 (6 days ago)
Author:
Ken Moore <ken@…>
Branches:
master
Children:
c07c45a
Parents:
242ca42
Message:

Finish fixing up the LP GUi so it handles multiple replication targets properly

Location:
src-qt5/life-preserver/lp-gui
Files:
7 edited

Legend:

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

    r2cec0c3 r50625d0  
    298298} 
    299299 
    300 bool LPBackend::replicationInfo(QString dataset, QString& remotehost, QString& user, int& port, QString& remotedataset, int& time){ 
     300QList<LPRepHost> LPBackend::replicationInfo(QString dataset){ 
    301301  QString cmd = "lpreserver replicate list"; 
    302302  QStringList out = LPBackend::getCmdOutput(cmd); 
    303   //Now process the output 
    304   bool ok = false; 
    305   for(int i=0; i<out.length(); i++){ 
    306     if(out[i].contains("->") && out[i].startsWith(dataset)){ 
    307       QString data = out[i].section("->",1,1); 
    308       user = data.section("@",0,0); 
    309       remotehost = data.section("@",1,1).section("[",0,0); 
    310       port = data.section("[",1,1).section("]",0,0).toInt(); 
    311       remotedataset = data.section(":",1,1).section(" Time",0,0); 
     303  //qDebug() << " -- Raw Info:" << out; 
     304  //Now process the info 
     305  QList<LPRepHost> repdata; 
     306  for(int i=0; i<out.length(); i++){ 
     307    //qDebug() << " -- Line:" << out[i]; 
     308    if(out[i].contains(" -> ") && out[i].startsWith(dataset)){ 
     309      //qDebug() << " -- init container"; 
     310      LPRepHost H; 
     311      QString data = out[i].section(" -> ",1,1); 
     312      //qDebug() << " -- Eval Line:" << data; 
     313      H.setUser( data.section("@",0,0) ); 
     314      H.setHost( data.section("@",1,1).section("[",0,0) ); 
     315      H.setPort( data.section("[",1,1).section("]",0,0).toInt() ); 
     316      H.setDataset( data.section(":",1,1).section(" Time",0,0) ); 
    312317      QString synchro = data.section("Time:",1,1).simplified(); 
    313         if(synchro == "sync"){ time = -1; } 
    314         else if(synchro =="manual"){ time = -2; } 
    315         else if(synchro =="hour"){ time = -60; } 
    316         else if(synchro == "30min"){ time = -30; } 
    317         else if(synchro == "10min"){ time = -10; } 
    318         else{ time = synchro.toInt(); } 
    319       ok = true; 
    320       break; 
     318        if(synchro == "sync"){ H.setFreq(-1); } 
     319        else if(synchro =="manual"){ H.setFreq(-2); } 
     320        else if(synchro =="hour"){ H.setFreq(-60); } 
     321        else if(synchro == "30min"){ H.setFreq(-30); } 
     322        else if(synchro == "10min"){ H.setFreq(-10); } 
     323        else{ H.setFreq(synchro.toInt()); } 
     324      repdata << H; //Add this to the output array 
    321325    } 
    322326  }        
    323     
    324   return ok; 
     327  return repdata; 
    325328} 
    326329 
  • src-qt5/life-preserver/lp-gui/LPBackend.h

    r2cec0c3 r50625d0  
    88#include <QDir> 
    99#include <QCoreApplication> 
     10#include <QList> 
     11 
     12#include "LPContainers.h" 
    1013 
    1114//Class of static functions for using the "lpreserver" backend 
     
    3740        static bool setupReplication(QString dataset, QString remotehost, QString user, int port, QString remotedataset, int time); 
    3841        static bool removeReplication(QString dataset, QString remotehost); 
    39         static bool replicationInfo(QString dataset, QString& remotehost, QString& user, int& port, QString& remotedataset, int& time); 
     42        static QList<LPRepHost> replicationInfo(QString dataset); 
     43        // - conveniance replication functions for the new containers 
     44          static bool setupReplication(QString localDataSet, LPRepHost H){ 
     45            return setupReplication(localDataSet,H.host(), H.user(), H.port(), H.dataset(), H.freq()); 
     46          } 
    4047        //SSH Key Management 
    4148        static bool setupSSHKey(QString remoteHost, QString remoteUser, int remotePort); 
  • src-qt5/life-preserver/lp-gui/LPConfig.cpp

    r9332363 r50625d0  
    99  scrubChanged = false; 
    1010  remoteChanged = false; 
     11  cRepHost = -1; //internal flag 
    1112  //Variables that will be changed when loading the dataset properties 
    1213         
     
    1415  connect(ui->tool_apply,SIGNAL(clicked()), this,SLOT(slotApplyChanges()) ); 
    1516  connect(ui->tool_cancel,SIGNAL(clicked()), this, SLOT(slotCancelConfig()) ); 
    16   connect(ui->push_scanNetwork, SIGNAL(clicked()), this, SLOT(autoDetectReplicationTargets()) ); 
    1717  connect(ui->groupScrub, SIGNAL(toggled(bool)), this, SLOT(UpdateScrubUI()) ); 
    1818  connect(ui->combo_scrub_schedule, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateScrubUI()) ); 
     19  connect(ui->combo_rep_hosts, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateRepHostInfo()) ); 
     20  connect(ui->tool_rep_remhost, SIGNAL(clicked()), this, SLOT(RemRepHost()) ); 
     21  connect(ui->tool_rep_addhost, SIGNAL(clicked()), this, SLOT(AddRepHost()) ); 
    1922} 
    2023 
     
    3235// ========== 
    3336void LPConfig::loadDatasetConfiguration(QString dataset, bool replicated, bool scrubsched){ 
    34   qDebug() <<" - Loading dataset configuration:" << dataset; 
     37  qDebug() <<" - Loading dataset configuration:" << dataset << replicated << scrubsched; 
    3538  //Load the dataset values 
    3639  isReplicated = replicated; 
    3740  isScrubSched = scrubsched; 
    3841  // - Local settings 
     42  //qDebug() << " - Local Info"; 
    3943  if( !LPBackend::datasetInfo(dataset, localSchedule, localSnapshots) ){ 
    4044    localSchedule = 1; //daily at 1 AM 
     
    4246  }        
    4347  // - Scrub Settings 
     48  //qDebug() << " - Scrub Info"; 
    4449  bool ok=false; 
    4550  if(isScrubSched){ 
     
    4954    isScrubSched = false; 
    5055  } 
     56  //qDebug() << " - Replication Info"; 
    5157  // - Replication settings 
    52   ok=false; 
    5358  if(isReplicated){ 
    54     ok = LPBackend::replicationInfo(dataset, remoteHost, remoteUser, remotePort, remoteDataset, remoteFreq); 
    55   } 
    56   if(!ok){ 
    57     isReplicated = false; 
    58     remotePort = 22; 
    59     remoteFreq = -1; //sync 
    60     remoteHost = ""; 
    61     remoteUser = ""; 
    62     remoteDataset = ""; 
    63   } 
     59    remoteHosts = LPBackend::replicationInfo(dataset); 
     60  } 
     61   //qDebug() << " - Load UI"; 
    6462  //Now put the values into the UI 
    6563  // - local settings 
     
    10199   
    102100  // - Replication settings 
    103   ui->groupReplicate->setChecked(isReplicated); 
    104   ui->lineHostName->setText(remoteHost); 
    105   ui->lineUserName->setText(remoteUser); 
    106   ui->lineRemoteDataset->setText(remoteDataset); 
    107   ui->spinPort->setValue(remotePort); 
    108   if(remoteFreq >=0 && remoteFreq < 24){ 
    109     ui->combo_remote_schedule->setCurrentIndex(1); //Daily @ 
    110     ui->time_replicate->setTime( QTime(remoteFreq,0) ); 
    111   }else if(remoteFreq == -60){ 
    112     ui->combo_remote_schedule->setCurrentIndex(2); //Hourly 
    113   }else if(remoteFreq == -30){ 
    114     ui->combo_remote_schedule->setCurrentIndex(3); // 30 minutes 
    115   }else if(remoteFreq == -10){ 
    116     ui->combo_remote_schedule->setCurrentIndex(4); // 10 minutes 
    117   }else if(remoteFreq == -2){ 
    118     ui->combo_remote_schedule->setCurrentIndex(5); // Manual mode 
    119   }else{ 
    120     remoteFreq = -999; //just to make sure it is the "other" case 
    121     ui->combo_remote_schedule->setCurrentIndex(0); // Sync 
    122   } 
     101  ui->combo_rep_hosts->clear(); 
     102  origHosts.clear(); 
     103  for(int i=0; i<remoteHosts.length(); i++){ 
     104    ui->combo_rep_hosts->addItem(remoteHosts[i].host()); 
     105    origHosts << remoteHosts[i].host(); //save this for comparison later 
     106  } 
     107 
    123108  //Now update the visibility of items appropriately 
    124109  on_combo_local_schedule_currentIndexChanged(ui->combo_local_schedule->currentIndex()); 
    125   on_combo_remote_schedule_currentIndexChanged(ui->combo_remote_schedule->currentIndex()); 
     110  UpdateRepHostInfo(); 
     111  //on_combo_remote_schedule_currentIndexChanged(ui->combo_remote_schedule->currentIndex()); 
    126112  UpdateScrubUI(); 
    127113} 
     
    132118  localChanged = false; 
    133119  scrubChanged = false; 
    134   remoteChanged = false; 
     120  //remoteChanged = false; 
    135121 
    136122  //Local Settings 
     
    190176 
    191177  //Replication Settings 
    192   bool updateSSHKey = false; 
    193   if(isReplicated != ui->groupReplicate->isChecked()){ 
    194     remoteChanged = true; 
    195   } 
    196   isReplicated = ui->groupReplicate->isChecked(); 
    197   if(isReplicated && remoteChanged){ updateSSHKey = true; } 
    198   QString tmp = ui->lineHostName->text().simplified(); 
    199   //Only change the backend remoteHost value if the replication is still enabled (so de-activation will work properly) 
    200   if( tmp != remoteHost && isReplicated){ remoteChanged = true; remoteHost = tmp; updateSSHKey=true;} 
    201   tmp = ui->lineUserName->text().simplified(); 
    202   if( tmp != remoteUser ){ remoteChanged = true; remoteUser = tmp; updateSSHKey=true;} 
    203   tmp = ui->lineRemoteDataset->text().simplified(); 
    204   if( tmp != remoteDataset ){ remoteChanged = true; remoteDataset = tmp; } 
    205   if( ui->spinPort->value() != remotePort){ remoteChanged = true; remotePort = ui->spinPort->value(); updateSSHKey=true;} 
     178  UpdateRepHostInfo(); //catch any changes in the UI that have not been saved yet 
    206179   
    207   int nFreq = ui->combo_remote_schedule->currentIndex(); 
    208   if(nFreq == 0){ 
    209     nFreq = -999; //Sync 
    210   }else if(nFreq==5){ 
    211     nFreq = -2; // Manual mode 
    212   }else if(nFreq==1){ 
    213     nFreq = ui->time_replicate->time().hour(); //Daily @ 
    214   }else if(nFreq==2){ 
    215     nFreq = -60; //Hourly 
    216   }else if(nFreq==3){ 
    217     nFreq = -30; //30 minutes 
    218   }else{ 
    219     nFreq = -10; //10 minutes 
    220   } 
    221   if( nFreq != remoteFreq ){ remoteChanged = true; remoteFreq = nFreq; } 
     180  //Compile the lists of new/removed hosts 
     181  newHosts.clear(); remHosts.clear(); 
     182  for(int i=0; i<origHosts.length(); i++){ 
     183    bool found = false; 
     184    for(int j=0; j<remoteHosts.length(); j++){ 
     185      if( origHosts[i] == remoteHosts[j].host() ){ found = true; break;} 
     186    } 
     187    if(!found){ remHosts << origHosts[i]; } //Was removed 
     188  } 
     189  for(int j=0; j<remoteHosts.length(); j++){ 
     190    if( !origHosts.contains(remoteHosts[j].host()) ){ newHosts << remoteHosts[j].host(); } 
     191  } 
     192  newHosts.removeDuplicates(); 
    222193   
    223   if(updateSSHKey && isReplicated && remoteChanged){ 
    224     //Prompt for the SSH key generation 
    225     LPBackend::setupSSHKey(remoteHost, remoteUser, remotePort); 
    226   } 
     194  /*for(int i=0; i<newHosts.length(); i++){ 
     195    //Get the settings for this new host 
     196    for(int j=0; j<remoteHosts.length(); j++){ 
     197      if(remoteHosts[j].host()==newHosts[i]){ 
     198        //Prompt for the SSH key generation 
     199        LPBackend::setupSSHKey(remoteHosts[j].host(), remoteHosts[j].user(), remoteHosts[j].port()); 
     200      } 
     201    } 
     202  }*/ 
     203   
    227204} 
    228205 
     
    286263} 
    287264 
    288 void LPConfig::autoDetectReplicationTargets(){ 
     265/*void LPConfig::autoDetectReplicationTargets(){ 
    289266  QStringList targs = LPGUtils::scanNetworkSSH(); // <name>:::<address>:::<port> 
    290267  if(targs.isEmpty()){ 
     
    308285    } 
    309286  } 
    310 } 
     287}*/ 
     288 
     289void LPConfig::UpdateRepHostInfo(){ 
     290  if(cRepHost>=0 && cRepHost < ui->combo_rep_hosts->count() ){ 
     291    //Also Verify that the array host matches the UI host 
     292    int index = -1; 
     293    for(int i=0; i<remoteHosts.length(); i++){ 
     294      if(remoteHosts[i].host() == ui->combo_rep_hosts->itemText(cRepHost)){ 
     295        index = i; 
     296        break; 
     297      } 
     298    } 
     299    //Save the current info into the array first 
     300    if(remoteHosts[index].user() != ui->lineUserName->text()){ 
     301      remoteHosts[index].setUser( ui->lineUserName->text() ); remoteChanged = true; 
     302    } 
     303    if(remoteHosts[index].dataset() != ui->lineRemoteDataset->text()){ 
     304      remoteHosts[index].setDataset( ui->lineRemoteDataset->text() ); remoteChanged = true; 
     305    } 
     306    if(remoteHosts[index].port() != ui->spinPort->value()){ 
     307      remoteHosts[index].setPort( ui->spinPort->value() ); remoteChanged = true; 
     308    } 
     309    int freq = ui->combo_remote_schedule->currentIndex(); 
     310    if(freq==0){ freq = -1; } //Sync 
     311    else if(freq==1){ freq  = ui->time_replicate->time().hour(); } //daily 
     312    else if(freq==2){ freq = -60; } //hourly 
     313    else if(freq==3){ freq = -30; } //30 minutes 
     314    else if(freq==4){ freq = -10; } //10 minutes 
     315    else{ freq = -2; } //manual 
     316    if(remoteHosts[index].freq() != freq){ 
     317      remoteHosts[index].setFreq(freq); remoteChanged = true; 
     318    } 
     319  } 
     320   
     321  int index = -1; 
     322  if( ui->combo_rep_hosts->currentIndex()>=0){ 
     323    for(int i=0; i<remoteHosts.length(); i++){ 
     324       if(remoteHosts[i].host() == ui->combo_rep_hosts->currentText()){ 
     325         index = i; 
     326         break; 
     327       } 
     328    } 
     329  } 
     330  ui->groupReplicate->setEnabled(index>=0); 
     331  if(index>=0){ 
     332    //Now display the info for the selected host 
     333    ui->lineUserName->setText(remoteHosts[index].user()); 
     334    ui->lineRemoteDataset->setText(remoteHosts[index].dataset()); 
     335    ui->spinPort->setValue(remoteHosts[index].port()); 
     336    if(remoteHosts[index].freq() >=0 && remoteHosts[index].freq() < 24){ 
     337      ui->combo_remote_schedule->setCurrentIndex(1); //Daily @ 
     338      ui->time_replicate->setTime( QTime(remoteHosts[index].freq(),0) ); 
     339    }else if(remoteHosts[index].freq() == -60){ 
     340      ui->combo_remote_schedule->setCurrentIndex(2); //Hourly 
     341    }else if(remoteHosts[index].freq() == -30){ 
     342      ui->combo_remote_schedule->setCurrentIndex(3); // 30 minutes 
     343    }else if(remoteHosts[index].freq() == -10){ 
     344      ui->combo_remote_schedule->setCurrentIndex(4); // 10 minutes 
     345    }else if(remoteHosts[index].freq() == -2){ 
     346      ui->combo_remote_schedule->setCurrentIndex(5); // Manual mode 
     347    }else{ 
     348      ui->combo_remote_schedule->setCurrentIndex(0); // Sync 
     349    } 
     350    //make sure the time widget is visible appropriately 
     351    on_combo_remote_schedule_currentIndexChanged(ui->combo_remote_schedule->currentIndex()); 
     352  } 
     353  cRepHost = ui->combo_rep_hosts->currentIndex(); //save this flag for later 
     354} 
     355 
     356void LPConfig::AddRepHost(){ 
     357  QStringList targs = LPGUtils::scanNetworkSSH(); // <name>:::<address>:::<port> 
     358  //Ask the user to select a target 
     359  QStringList targets; 
     360  for(int i=0; i<targs.length(); i++){ 
     361    targets << targs[i].section(":::",0,0); 
     362  } 
     363  if(targets.isEmpty()){ targets << ""; } 
     364  bool ok; 
     365  QString target = QInputDialog::getItem(this, tr("Identify Replication Target"), tr("Detected Hostname or custom IP:"), targets, 0, true, &ok); 
     366  if(!ok || target.isEmpty() ){ return; } //cancelled 
     367  //Now look for that target in the list of info 
     368  LPRepHost H; 
     369  for(int i=0; i<targs.length(); i++){ 
     370    if(targs[i].startsWith(target+":::")){ 
     371      H.setHost( targs[i].section(":::",1,1) ); 
     372      H.setPort( targs[i].section(":::",2,2).toInt() ); 
     373      break; 
     374    } 
     375  } 
     376  if(H.host().isEmpty()){  
     377    H.setHost( target ); //custom host selected 
     378    H.setPort( 22 ); //Default SSH port on most systems 
     379  } 
     380  H.setFreq( -1 ); //Set to the "Sync" frequency by default 
     381  //Add this host to the info 
     382  remoteHosts << H; 
     383  ui->combo_rep_hosts->addItem( H.host() ); 
     384  ui->combo_rep_hosts->setCurrentIndex( ui->combo_rep_hosts->count()-1 ); //go to the new item 
     385} 
     386 
     387void LPConfig::RemRepHost(){ 
     388  QString host = ui->combo_rep_hosts->currentText(); 
     389  bool found = false; 
     390  for(int i=0; i<remoteHosts.length(); i++){ 
     391    if(remoteHosts[i].host() == host){ 
     392      remoteHosts.removeAt(i); 
     393      found = true; 
     394      break; 
     395    } 
     396  } 
     397  if(!found){ return; } //did not do anything 
     398  cRepHost = -1; //Make sure we don't save any of the settings being removed 
     399  ui->combo_rep_hosts->removeItem(ui->combo_rep_hosts->currentIndex()); 
     400} 
     401 
  • src-qt5/life-preserver/lp-gui/LPConfig.h

    r9332363 r50625d0  
    1010#include "LPBackend.h" 
    1111#include "LPGUtils.h" 
     12#include "LPContainers.h" 
    1213 
    1314namespace Ui{ 
     
    2526        //Output variables 
    2627        bool localChanged, scrubChanged, remoteChanged, isReplicated, isScrubSched; 
    27         int localSchedule, localSnapshots, remotePort, remoteFreq, scrubTime, scrubDay; 
    28         QString remoteHost, remoteUser, remoteDataset, scrubSchedule; 
     28        int localSchedule, localSnapshots, scrubTime, scrubDay, cRepHost; 
     29        QList<LPRepHost> remoteHosts; 
     30        QStringList newHosts, remHosts; 
     31        QString scrubSchedule; 
    2932 
    3033private: 
     
    3437        void setLocalKeepNumber(); 
    3538 
     39        QStringList origHosts; //the original hosts when starting the config 
     40 
    3641private slots: 
    3742        void slotApplyChanges(); 
     
    4045        void UpdateScrubUI(); 
    4146        void on_combo_remote_schedule_currentIndexChanged(int index); 
    42         void autoDetectReplicationTargets(); 
     47        //void autoDetectReplicationTargets(); 
     48 
     49        void UpdateRepHostInfo(); 
     50        void AddRepHost(); 
     51        void RemRepHost(); 
    4352}; 
    4453 
  • src-qt5/life-preserver/lp-gui/LPConfig.ui

    r9332363 r50625d0  
    77    <x>0</x> 
    88    <y>0</y> 
    9     <width>372</width> 
    10     <height>385</height> 
     9    <width>354</width> 
     10    <height>346</height> 
    1111   </rect> 
    1212  </property> 
     
    182182      <layout class="QVBoxLayout" name="verticalLayout_2"> 
    183183       <item> 
     184        <layout class="QHBoxLayout" name="horizontalLayout_13"> 
     185         <item> 
     186          <widget class="QComboBox" name="combo_rep_hosts"/> 
     187         </item> 
     188         <item> 
     189          <widget class="QToolButton" name="tool_rep_addhost"> 
     190           <property name="text"> 
     191            <string>...</string> 
     192           </property> 
     193           <property name="icon"> 
     194            <iconset resource="lPreserve.qrc"> 
     195             <normaloff>:/images/list-add.png</normaloff>:/images/list-add.png</iconset> 
     196           </property> 
     197          </widget> 
     198         </item> 
     199         <item> 
     200          <widget class="QToolButton" name="tool_rep_remhost"> 
     201           <property name="text"> 
     202            <string>...</string> 
     203           </property> 
     204           <property name="icon"> 
     205            <iconset resource="lPreserve.qrc"> 
     206             <normaloff>:/images/list-remove.png</normaloff>:/images/list-remove.png</iconset> 
     207           </property> 
     208          </widget> 
     209         </item> 
     210        </layout> 
     211       </item> 
     212       <item> 
    184213        <widget class="QGroupBox" name="groupReplicate"> 
    185214         <property name="title"> 
    186           <string>Replicate on a Remote System</string> 
     215          <string>Replication Settings</string> 
    187216         </property> 
    188217         <property name="checkable"> 
    189           <bool>true</bool> 
     218          <bool>false</bool> 
    190219         </property> 
    191220         <property name="checked"> 
     
    193222         </property> 
    194223         <layout class="QVBoxLayout" name="verticalLayout_3"> 
    195           <item> 
    196            <layout class="QHBoxLayout" name="horizontalLayout_9"> 
    197             <item> 
    198              <spacer name="horizontalSpacer_5"> 
    199               <property name="orientation"> 
    200                <enum>Qt::Horizontal</enum> 
    201               </property> 
    202               <property name="sizeHint" stdset="0"> 
    203                <size> 
    204                 <width>40</width> 
    205                 <height>20</height> 
    206                </size> 
    207               </property> 
    208              </spacer> 
    209             </item> 
    210             <item> 
    211              <widget class="QPushButton" name="push_scanNetwork"> 
    212               <property name="text"> 
    213                <string>&amp;Scan Network</string> 
    214               </property> 
    215               <property name="icon"> 
    216                <iconset resource="lPreserve.qrc"> 
    217                 <normaloff>:/images/network-wired.png</normaloff>:/images/network-wired.png</iconset> 
    218               </property> 
    219              </widget> 
    220             </item> 
    221             <item> 
    222              <spacer name="horizontalSpacer_4"> 
    223               <property name="orientation"> 
    224                <enum>Qt::Horizontal</enum> 
    225               </property> 
    226               <property name="sizeHint" stdset="0"> 
    227                <size> 
    228                 <width>40</width> 
    229                 <height>20</height> 
    230                </size> 
    231               </property> 
    232              </spacer> 
    233             </item> 
    234            </layout> 
    235           </item> 
    236           <item> 
    237            <layout class="QHBoxLayout" name="horizontalLayout_8"> 
    238             <item> 
    239              <widget class="QLabel" name="label_9"> 
    240               <property name="text"> 
    241                <string>Host Name</string> 
    242               </property> 
    243              </widget> 
    244             </item> 
    245             <item> 
    246              <widget class="QLineEdit" name="lineHostName"/> 
    247             </item> 
    248            </layout> 
    249           </item> 
    250224          <item> 
    251225           <layout class="QHBoxLayout" name="horizontalLayout_7"> 
     
    337311             <string>Frequency</string> 
    338312            </property> 
     313            <property name="alignment"> 
     314             <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> 
     315            </property> 
    339316            <layout class="QGridLayout" name="gridLayout_3"> 
     317             <property name="leftMargin"> 
     318              <number>2</number> 
     319             </property> 
     320             <property name="topMargin"> 
     321              <number>2</number> 
     322             </property> 
     323             <property name="rightMargin"> 
     324              <number>2</number> 
     325             </property> 
     326             <property name="bottomMargin"> 
     327              <number>2</number> 
     328             </property> 
    340329             <item row="0" column="0"> 
    341330              <layout class="QHBoxLayout" name="horizontalLayout_6"> 
  • src-qt5/life-preserver/lp-gui/LPContainers.h

    rb0f0453 r50625d0  
    55#include <QStringList> 
    66#include <QString> 
    7  
    87 
    98class LPDataset{ 
     
    4140}; 
    4241 
     42class LPRepHost : private QStringList{ 
     43public: 
     44        LPRepHost() : QStringList(){ 
     45          //Always 5 elements 
     46          for(int i=0; i<5; i++){ this->append(""); } 
     47          //pre-define the numbers 
     48          this->replace(3,"22"); //port 
     49          this->replace(4, "-1"); //freq 
     50        } 
     51        ~LPRepHost(){} 
     52                 
     53        //INTERNAL FORMAT  
     54        // [0] host, [1] user, [2] dataset, [3] port, [4] freq 
     55                 
     56        //Getters 
     57        QString host(){ return this->at(0); } 
     58        QString user(){ return this->at(1); } 
     59        QString dataset(){ return this->at(2); } 
     60        int port(){ return this->at(3).toInt(); } 
     61        int freq(){ return this->at(4).toInt(); } 
     62         
     63        //Setters 
     64        void setHost(QString txt){ this->replace(0,txt); } 
     65        void setUser(QString txt){ this->replace(1,txt); } 
     66        void setDataset(QString txt){ this->replace(2,txt); } 
     67        void setPort(int num){ this->replace(3,QString::number(num)); } 
     68        void setFreq(int num){ this->replace(4,QString::number(num)); } 
     69         
     70}; 
    4371#endif 
  • src-qt5/life-preserver/lp-gui/LPMain.cpp

    r1b702e0 r50625d0  
    431431  QString ds = ui->combo_pools->currentText(); 
    432432  if(ds.isEmpty()){ return; } 
     433  qDebug() << "Opening Config UI:"; 
    433434  LPConfig CFG(this); 
     435  qDebug() << " - Loading Datasets"; 
    434436  CFG.loadDataset(ds, LPBackend::listReplicationTargets().contains(ds), LPBackend::listScrubs().contains(ds)); 
     437  qDebug() << " - Exec"; 
    435438  CFG.exec(); 
    436439  //Now check for return values and update appropriately 
     
    460463  if(CFG.remoteChanged){ 
    461464    change = true; 
    462     if(CFG.isReplicated){ 
    463       ui->statusbar->showMessage(QString(tr("Configuring replication: %1")).arg(ds),0); 
    464       qDebug() << "Setting up Replication:" << ds << " Frequency:" << CFG.remoteFreq; 
    465       LPBackend::setupReplication(ds, CFG.remoteHost, CFG.remoteUser, CFG.remotePort, CFG.remoteDataset, CFG.remoteFreq); 
    466       QMessageBox::information(this,tr("Reminder"),tr("Don't forget to save your SSH key to a USB stick so that you can restore your system from the remote host later!!")); 
    467     }else{ 
    468       ui->statusbar->showMessage(QString(tr("Removing replication: %1")).arg(ds),0); 
    469       qDebug() << "Removing Replication:" << ds; 
    470       LPBackend::removeReplication(ds, CFG.remoteHost); 
    471     } 
    472     ui->statusbar->clearMessage(); 
    473   } 
     465    ui->statusbar->showMessage(QString(tr("Configuring replication settings: %1")).arg(ds),0); 
     466    QApplication::processEvents(); 
     467      //First setup any existing/new replication hosts 
     468      for(int i=0; i<CFG.remoteHosts.length(); i++){ 
     469        qDebug() << "Setting up Replication:" << ds << "Host:" << CFG.remoteHosts[i].host() << " Frequency:" << CFG.remoteHosts[i].freq(); 
     470        if(CFG.newHosts.contains(CFG.remoteHosts[i].host())){ 
     471          //This is a brand new host - setup the SSH key first 
     472          bool ok = LPBackend::setupSSHKey(CFG.remoteHosts[i].host(), CFG.remoteHosts[i].user(), CFG.remoteHosts[i].port()); 
     473          if(!ok){ continue; } //cancelled for some reason - move on to the next host 
     474          else{ QMessageBox::information(this,tr("Reminder"),tr("Don't forget to save your SSH key to a USB stick so that you can restore your system from the remote host later!!")); } 
     475        } 
     476        LPBackend::setupReplication(ds, CFG.remoteHosts[i]); 
     477      } 
     478      //Now remove any old hosts 
     479      for(int i=0; i<CFG.remHosts.length(); i++){ 
     480        ui->statusbar->showMessage(QString(tr("Removing replication: %1, Host: %2")).arg(ds, CFG.remHosts[i]),0); 
     481        QApplication::processEvents(); 
     482        qDebug() << "Removing Replication:" << ds << "Host:" << CFG.remHosts[i]; 
     483        LPBackend::removeReplication(ds, CFG.remHosts[i]); 
     484      } 
     485  } 
     486  ui->statusbar->clearMessage(); 
     487 
    474488  //Now update the UI if appropriate 
    475489  if(change){ 
     
    541555        ui->statusbar->showMessage(QString(tr("%1: Disabling Replication")).arg(ds),0); 
    542556        showWaitBox(tr("Disabling Replication")); 
    543         //Need the replication host 
    544         QString rhost, junk1,junk3; 
    545         int junk2, junk4; 
    546         LPBackend::replicationInfo(ds, rhost, junk1, junk2, junk3, junk4); 
    547         LPBackend::removeReplication(ds,rhost);  
     557        //Need the replication host(s) 
     558        QList<LPRepHost> rhosts = LPBackend::replicationInfo(ds); 
     559        for(int i=0; i<rhosts.length(); i++){ 
     560          LPBackend::removeReplication(ds,rhosts[i].host());  
     561        } 
    548562        ui->statusbar->clearMessage();       
    549563      } 
Note: See TracChangeset for help on using the changeset viewer.