2020-09-29 23:55:11 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2016 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2016-07-09 01:10:57 +01:00
|
|
|
|
|
|
|
#include "jobs/movephysicalvolumejob.h"
|
|
|
|
|
|
|
|
#include "core/lvmdevice.h"
|
|
|
|
|
|
|
|
#include "util/report.h"
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
/** Creates a new MovePhysicalVolumeJob
|
2016-08-12 01:57:34 +01:00
|
|
|
* @param d Device representing LVM Volume Group
|
2016-07-09 01:10:57 +01:00
|
|
|
*/
|
2016-09-18 01:53:42 +01:00
|
|
|
MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& d, const QList <const Partition*>& partList) :
|
2016-07-09 01:10:57 +01:00
|
|
|
Job(),
|
2016-08-12 01:57:34 +01:00
|
|
|
m_Device(d),
|
|
|
|
m_PartList(partList)
|
2016-07-09 01:10:57 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MovePhysicalVolumeJob::run(Report& parent)
|
|
|
|
{
|
|
|
|
bool rval = false;
|
|
|
|
|
|
|
|
Report* report = jobStarted(parent);
|
|
|
|
|
2016-09-08 01:42:04 +01:00
|
|
|
QStringList destinations = device().deviceNodes();
|
2016-09-18 01:53:42 +01:00
|
|
|
for (const auto &p : partList()) {
|
|
|
|
if (destinations.contains(p->partitionPath())) {
|
|
|
|
destinations.removeAll(p->partitionPath());
|
2016-07-11 14:00:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-18 01:53:42 +01:00
|
|
|
for (const auto &p : partList()) {
|
|
|
|
rval = LvmDevice::movePV(*report, p->partitionPath(), destinations);
|
2016-07-09 01:10:57 +01:00
|
|
|
if (rval == false) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jobFinished(*report, rval);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString MovePhysicalVolumeJob::description() const
|
|
|
|
{
|
2016-09-18 01:53:42 +01:00
|
|
|
QString movedPartitions = QString();
|
|
|
|
for (const auto &p : partList())
|
2016-11-04 14:20:11 +00:00
|
|
|
movedPartitions += p->deviceNode() + QStringLiteral(", ");
|
2016-09-18 01:53:42 +01:00
|
|
|
movedPartitions.chop(2);
|
|
|
|
return xi18nc("@info/plain", "Move used PE in %1 on %2 to other available Physical Volumes", movedPartitions, device().name());
|
2016-07-09 01:10:57 +01:00
|
|
|
}
|