Add removeVG lvmdevice. And, Change createVG to accpeting QStringList instead.

This commit is contained in:
Chantara Tith 2016-07-03 15:01:49 +07:00
parent 8b48406200
commit 016daaa75d
2 changed files with 13 additions and 4 deletions

View File

@ -321,15 +321,23 @@ bool LvmDevice::insertPV(Report& report, LvmDevice& dev, const QString& pvPath)
return (cmd.run(-1) && cmd.exitCode() == 0); return (cmd.run(-1) && cmd.exitCode() == 0);
} }
bool LvmDevice::createVG(Report& report, const QString vgname, const QList<Partition*> pvlist) bool LvmDevice::createVG(Report& report, const QString vgname, const QStringList pvlist)
{ {
//TODO: check that all the pv in pvlist is lvm2_pv //TODO: check that all the pv in pvlist is lvm2_pv
QStringList args = QStringList(); QStringList args = QStringList();
args << QStringLiteral("vgcreate") << vgname; args << QStringLiteral("vgcreate") << vgname;
foreach (Partition* p, pvlist) { foreach (QString pvnode, pvlist) {
args << p->partitionPath(); args << pvnode;
} }
ExternalCommand cmd(report, QStringLiteral("lvm"), args); ExternalCommand cmd(report, QStringLiteral("lvm"), args);
return (cmd.run(-1) && cmd.exitCode() == 0); return (cmd.run(-1) && cmd.exitCode() == 0);
} }
bool LvmDevice::removeVG(Report& report, const QString vgname)
{
ExternalCommand cmd(report, QStringLiteral("lvm"),
{ QStringLiteral("vgremove"),
vgname });
return (cmd.run(-1) && cmd.exitCode() == 0);
}

View File

@ -68,7 +68,8 @@ public:
static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath); static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath); static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool createVG(Report& report, const QString vgname, const QList<Partition*> pvlist); static bool createVG(Report& report, const QString vgname, const QStringList pvlist);
static bool removeVG(Report& report, const QString vgname);
protected: protected:
void initPartitions(); void initPartitions();