2016-06-30 00:18:46 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
2016-11-04 14:20:11 +00:00
|
|
|
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
2016-06-30 00:18:46 +01:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#include "jobs/createvolumegroupjob.h"
|
|
|
|
|
|
|
|
#include "core/lvmdevice.h"
|
|
|
|
|
|
|
|
#include "util/report.h"
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
/** Creates a new CreateVolumeGroupJob
|
2016-08-12 01:57:34 +01:00
|
|
|
* @param vgName LVM Volume Group name
|
|
|
|
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
|
|
|
* @param peSize LVM Physical Extent size in MiB
|
2016-06-30 00:18:46 +01:00
|
|
|
*/
|
2017-08-31 10:48:10 +01:00
|
|
|
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgName, const QVector<const Partition*>& pvList, const qint32 peSize) :
|
2016-06-30 00:18:46 +01:00
|
|
|
Job(),
|
2016-08-12 01:57:34 +01:00
|
|
|
m_vgName(vgName),
|
|
|
|
m_pvList(pvList),
|
|
|
|
m_PESize(peSize)
|
2016-06-30 00:18:46 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CreateVolumeGroupJob::run(Report& parent)
|
|
|
|
{
|
|
|
|
bool rval = false;
|
|
|
|
|
|
|
|
Report* report = jobStarted(parent);
|
|
|
|
|
2016-07-18 01:06:56 +01:00
|
|
|
rval = LvmDevice::createVG(*report, vgName(), pvList(), peSize());
|
2016-06-30 00:18:46 +01:00
|
|
|
|
|
|
|
jobFinished(*report, rval);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString CreateVolumeGroupJob::description() const
|
|
|
|
{
|
2016-07-03 13:41:20 +01:00
|
|
|
QString tmp = QString();
|
2016-09-18 01:53:42 +01:00
|
|
|
for (const auto &p : pvList()) {
|
2016-11-03 22:08:32 +00:00
|
|
|
tmp += p->deviceNode() + QStringLiteral(", ");
|
2016-07-03 13:41:20 +01:00
|
|
|
}
|
2016-09-18 01:53:42 +01:00
|
|
|
tmp.chop(2);
|
2016-08-26 13:29:24 +01:00
|
|
|
return xi18nc("@info/plain", "Create a new Volume Group: <filename>%1</filename> with PV: %2", vgName(), tmp);
|
2016-06-30 00:18:46 +01:00
|
|
|
}
|