File indexing completed on 2024-04-28 05:45:53

0001 /*
0002     SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
0003     SPDX-FileCopyrightText: 2016-2017 Andrius Štikonas <andrius@stikonas.eu>
0004 
0005     SPDX-License-Identifier: GPL-3.0-or-later
0006 */
0007 
0008 #include "jobs/createvolumegroupjob.h"
0009 
0010 #include "core/lvmdevice.h"
0011 
0012 #include "util/report.h"
0013 
0014 #include <KLocalizedString>
0015 
0016 /** Creates a new CreateVolumeGroupJob
0017  * @param vgName LVM Volume Group name
0018  * @param pvList List of LVM Physical Volumes used to create Volume Group
0019  * @param peSize LVM Physical Extent size in MiB
0020 */
0021 CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgName, const QVector<const Partition*>& pvList, const qint32 peSize) :
0022     Job(),
0023     m_vgName(vgName),
0024     m_pvList(pvList),
0025     m_PESize(peSize)
0026 {
0027 }
0028 
0029 bool CreateVolumeGroupJob::run(Report& parent)
0030 {
0031     bool rval = false;
0032 
0033     Report* report = jobStarted(parent);
0034 
0035     rval = LvmDevice::createVG(*report, vgName(), pvList(), peSize());
0036 
0037     jobFinished(*report, rval);
0038 
0039     return rval;
0040 }
0041 
0042 QString CreateVolumeGroupJob::description() const
0043 {
0044     QString tmp = QString();
0045     for (const auto &p : pvList()) {
0046         tmp += p->deviceNode() + QStringLiteral(", ");
0047     }
0048     tmp.chop(2);
0049     return xi18nc("@info/plain", "Create a new Volume Group: <filename>%1</filename> with PV: %2", vgName(), tmp);
0050 }