-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the new backend class to life-preserver (for running lpreserver c…
…ommands), and start on the mainUI header file.
- Loading branch information
Ken Moore
committed
Aug 8, 2013
1 parent
3d428ab
commit 86b4b93
Showing
5 changed files
with
175 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#include "LPBackend.h" | ||
|
||
// ============== | ||
// Informational | ||
// ============== | ||
QStringList listDatasets(){ | ||
QString cmd = "lpreserver listcron"; | ||
//Need output, so run this in a QProcess | ||
QProcess *proc = new QProcess; | ||
proc->setProcessChannelMode(QProcess::MergedChannels); | ||
proc->start(cmd); | ||
proc->waitForFinished(); | ||
QStringList out = QString(proc->readAllStandardOutput()).split("\n"); | ||
delete proc; | ||
//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 listSnapshots(QString dataset){ | ||
QString cmd = "lpreserver listsnap "+dataset; | ||
//Need output, so run this in a QProcess | ||
QProcess *proc = new QProcess; | ||
proc->setProcessChannelMode(QProcess::MergedChannels); | ||
proc->start(cmd); | ||
proc->waitForFinished(); | ||
QStringList out = QString(proc->readAllStandardOutput()).split("\n"); | ||
delete proc; | ||
//Now process the output | ||
QStringList list; | ||
for(int i=0; i<out.length(); i++){ | ||
if(out[i].startsWIth(dataset+"@")){ | ||
QString snap = out[i].section("@",1,3).section(" ",0,0).simplified();; | ||
if(!snap.isEmpty()){ list << snap; } | ||
} | ||
} | ||
return list; | ||
} | ||
|
||
QStringList listReplicationTargets(){ | ||
QString cmd = "lpreserver replicate list"; | ||
//Need output, so run this in a QProcess | ||
QProcess *proc = new QProcess; | ||
proc->setProcessChannelMode(QProcess::MergedChannels); | ||
proc->start(cmd); | ||
proc->waitForFinished(); | ||
QStringList out = QString(proc->readAllStandardOutput()).split("\n"); | ||
delete proc; | ||
//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; | ||
} | ||
|
||
// ================== | ||
// Snapshop Management | ||
// ================== | ||
void newSnapshot(QString dataset){ | ||
QString cmd = "lpreserver mksnap "+dataset; | ||
system(cmd.toUtf8()); | ||
} | ||
|
||
void removeSnapshot(QString dataset, QString snapshot){ | ||
QString cmd = "lpreserver rmsnap "+dataset +" "+snapshot; | ||
system(cmd.toUtf8()); | ||
} | ||
|
||
void revertSnapshot(QString dataset, QString snapshot){ | ||
QString cmd = "lpreserver revertsnap "+dataset +" "+snapshot; | ||
system(cmd.toUtf8()); | ||
} | ||
|
||
void browseSnapshot(QString dataset, QString snapshot){ | ||
//Not implemented yet | ||
} | ||
|
||
// ================== | ||
// Replication Management | ||
// ================== | ||
void setupReplication(QString dataset, QString remotehost, QString user, int port, QString remotedataset, int time){ | ||
QString stime = "sync"; //synchronize on snapshot creation | ||
if(time < 0 || time > 24){ | ||
|
||
}else{ 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; | ||
system(cmd.toUtf8()); | ||
} | ||
|
||
void removeReplication(QString dataset){ | ||
QString cmd = "lpreserver replicate remove "+dataset; | ||
system(cmd.toUtf8()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef _LP_BACKEND_H | ||
#define _LP_BACKEND_H | ||
|
||
#include <QProcess> | ||
|
||
//Class of static functions for using the "lpreserver" backend | ||
class LPBackend{ | ||
|
||
public: | ||
//Informational | ||
QStringList listDatasets(); //list all lifepreserver datasets | ||
QStringList listSnapshots(QString dataset); //list all snapshots for a particular dataset | ||
QStringList listReplicationTargets(); //list all datasets with replication enabled | ||
//Snapshop Management | ||
void newSnapshot(QString dataset); | ||
void removeSnapshot(QString dataset, QString snapshot); | ||
void revertSnapshot(QString dataset, QString snapshot); //revert to given snapshot | ||
void browseSnapshot(QString dataset, QString snapshot); | ||
//Replication Management | ||
void setupReplication(QString dataset, QString remotehost, QString user, int port, QString remotedataset, int time); | ||
void removeReplication(QString dataset); | ||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef _LP_MAINUI_H | ||
#define _LP_MAINUI_H | ||
|
||
class mainUI : public QMainWindow{ | ||
Q_OBJECT | ||
|
||
public: | ||
|
||
private: | ||
|
||
private slots: | ||
|
||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters