2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2018-06-26 05:38:52 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2018-06-26 05:38:52 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2018-06-26 05:38:52 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ResizeVolumeGroupJob.h"
|
|
|
|
|
|
|
|
// KPMcore
|
|
|
|
#include <kpmcore/core/lvmdevice.h>
|
|
|
|
#include <kpmcore/core/partition.h>
|
|
|
|
#include <kpmcore/ops/resizevolumegroupoperation.h>
|
|
|
|
#include <kpmcore/util/report.h>
|
|
|
|
|
|
|
|
ResizeVolumeGroupJob::ResizeVolumeGroupJob( LvmDevice* device, QVector< const Partition* >& partitionList )
|
|
|
|
: m_device( device )
|
|
|
|
, m_partitionList( partitionList )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
ResizeVolumeGroupJob::prettyName() const
|
|
|
|
{
|
|
|
|
return tr( "Resize volume group named %1 from %2 to %3." )
|
2020-04-07 11:36:40 +02:00
|
|
|
.arg( m_device->name() )
|
|
|
|
.arg( currentPartitions() )
|
|
|
|
.arg( targetPartitions() );
|
2018-06-26 05:38:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
ResizeVolumeGroupJob::prettyDescription() const
|
|
|
|
{
|
|
|
|
return tr( "Resize volume group named <strong>%1</strong> from <strong>%2</strong> to <strong>%3</strong>." )
|
2020-04-07 11:36:40 +02:00
|
|
|
.arg( m_device->name() )
|
|
|
|
.arg( currentPartitions() )
|
|
|
|
.arg( targetPartitions() );
|
2018-06-26 05:38:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
ResizeVolumeGroupJob::prettyStatusMessage() const
|
|
|
|
{
|
|
|
|
return tr( "Resize volume group named %1 from %2 to %3." )
|
2020-04-07 11:36:40 +02:00
|
|
|
.arg( m_device->name() )
|
|
|
|
.arg( currentPartitions() )
|
|
|
|
.arg( targetPartitions() );
|
2018-06-26 05:38:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Calamares::JobResult
|
|
|
|
ResizeVolumeGroupJob::exec()
|
|
|
|
{
|
|
|
|
Report report( nullptr );
|
|
|
|
|
|
|
|
ResizeVolumeGroupOperation op( *m_device, m_partitionList );
|
|
|
|
|
|
|
|
op.setStatus( Operation::OperationStatus::StatusRunning );
|
|
|
|
|
|
|
|
QString message = tr( "The installer failed to resize a volume group named '%1'." ).arg( m_device->name() );
|
|
|
|
if ( op.execute( report ) )
|
2020-04-07 11:36:40 +02:00
|
|
|
{
|
2018-06-26 05:38:52 +02:00
|
|
|
return Calamares::JobResult::ok();
|
2020-04-07 11:36:40 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
|
|
|
|
return Calamares::JobResult::error( message, report.toText() );
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
ResizeVolumeGroupJob::currentPartitions() const
|
|
|
|
{
|
|
|
|
QString result;
|
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
for ( const Partition* p : m_device->physicalVolumes() )
|
|
|
|
{
|
2018-06-26 05:38:52 +02:00
|
|
|
result += p->deviceNode() + ", ";
|
2020-04-07 11:36:40 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
result.chop( 2 );
|
2018-06-26 05:38:52 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString
|
|
|
|
ResizeVolumeGroupJob::targetPartitions() const
|
|
|
|
{
|
|
|
|
QString result;
|
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
for ( const Partition* p : m_partitionList )
|
|
|
|
{
|
2018-06-26 05:38:52 +02:00
|
|
|
result += p->deviceNode() + ", ";
|
2020-04-07 11:36:40 +02:00
|
|
|
}
|
2018-06-26 05:38:52 +02:00
|
|
|
|
2020-04-07 11:36:40 +02:00
|
|
|
result.chop( 2 );
|
2018-06-26 05:38:52 +02:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|