[partition] Adding resizing, deactivating and removing procedures for LVM VGs.

This commit is contained in:
Caio Carvalho 2018-06-26 00:38:52 -03:00
parent 98a158c6e5
commit 295e14530e
18 changed files with 738 additions and 41 deletions

View file

@ -51,6 +51,7 @@ if ( KPMcore_FOUND )
gui/PartitionSplitterWidget.cpp
gui/PartitionViewStep.cpp
gui/PrettyRadioButton.cpp
gui/ResizeVolumeGroupDialog.cpp
gui/ScanningDialog.cpp
gui/ReplaceWidget.cpp
gui/VolumeGroupBaseDialog.cpp
@ -59,11 +60,14 @@ if ( KPMcore_FOUND )
jobs/CreatePartitionJob.cpp
jobs/CreatePartitionTableJob.cpp
jobs/CreateVolumeGroupJob.cpp
jobs/DeactivateVolumeGroupJob.cpp
jobs/DeletePartitionJob.cpp
jobs/FillGlobalStorageJob.cpp
jobs/FormatPartitionJob.cpp
jobs/PartitionJob.cpp
jobs/RemoveVolumeGroupJob.cpp
jobs/ResizePartitionJob.cpp
jobs/ResizeVolumeGroupJob.cpp
jobs/SetPartitionFlagsJob.cpp
UI
gui/ChoicePage.ui

View file

@ -34,10 +34,13 @@
#include "jobs/CreatePartitionJob.h"
#include "jobs/CreatePartitionTableJob.h"
#include "jobs/CreateVolumeGroupJob.h"
#include "jobs/DeactivateVolumeGroupJob.h"
#include "jobs/DeletePartitionJob.h"
#include "jobs/FillGlobalStorageJob.h"
#include "jobs/FormatPartitionJob.h"
#include "jobs/RemoveVolumeGroupJob.h"
#include "jobs/ResizePartitionJob.h"
#include "jobs/ResizeVolumeGroupJob.h"
#include "jobs/SetPartitionFlagsJob.h"
#include "Typedefs.h"
@ -65,6 +68,7 @@ PartitionCoreModule::DeviceInfo::DeviceInfo( Device* _device )
: device( _device )
, partitionModel( new PartitionModel )
, immutableDevice( new Device( *_device ) )
, isAvailable( true )
{}
PartitionCoreModule::DeviceInfo::~DeviceInfo()
@ -298,6 +302,48 @@ PartitionCoreModule::createVolumeGroup( QString &vgName,
refresh();
}
void
PartitionCoreModule::resizeVolumeGroup( LvmDevice *device, QVector< const Partition* >& pvList )
{
DeviceInfo* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
ResizeVolumeGroupJob* job = new ResizeVolumeGroupJob( device, pvList );
deviceInfo->jobs << Calamares::job_ptr( job );
refresh();
}
void
PartitionCoreModule::deactivateVolumeGroup( LvmDevice *device )
{
DeviceInfo* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
deviceInfo->isAvailable = false;
DeactivateVolumeGroupJob* job = new DeactivateVolumeGroupJob( device );
// DeactivateVolumeGroupJob needs to be immediately called
job->exec();
refresh();
}
void
PartitionCoreModule::removeVolumeGroup( LvmDevice *device )
{
DeviceInfo* deviceInfo = infoForDevice( device );
Q_ASSERT( deviceInfo );
RemoveVolumeGroupJob* job = new RemoveVolumeGroupJob( device );
deviceInfo->jobs << Calamares::job_ptr( job );
refresh();
}
void
PartitionCoreModule::deletePartition( Device* device, Partition* partition )
{
@ -596,16 +642,40 @@ PartitionCoreModule::scanForLVMPVs()
{
m_lvmPVs.clear();
QList< Device* > devices;
QList< Device* > physicalDevices;
QList< LvmDevice* > vgDevices;
for ( DeviceInfo* deviceInfo : m_deviceInfos )
devices << deviceInfo->device.data();
{
if ( deviceInfo->device.data()->type() == Device::Type::Disk_Device)
physicalDevices << deviceInfo->device.data();
else if ( deviceInfo->device.data()->type() == Device::Type::LVM_Device )
{
LvmDevice* device = dynamic_cast<LvmDevice*>(deviceInfo->device.data());
LvmDevice::scanSystemLVM( devices );
// Restoring physical volume list
device->physicalVolumes().clear();
vgDevices << device;
}
}
// Update LVM::pvList
LvmDevice::scanSystemLVM( physicalDevices );
for ( auto p : LVM::pvList )
{
m_lvmPVs << p.partition().data();
for ( LvmDevice* device : vgDevices )
if ( p.vgName() == device->name() )
{
// Adding scanned VG to PV list
device->physicalVolumes() << p.partition();
break;
}
}
for ( DeviceInfo* d : m_deviceInfos )
{
for ( auto job : d->jobs )
@ -693,21 +763,26 @@ PartitionCoreModule::revertAllDevices()
for ( auto it = m_deviceInfos.begin(); it != m_deviceInfos.end(); )
{
// In new VGs device info, there will be always a CreateVolumeGroupJob as the first job in jobs list
if ( dynamic_cast<LvmDevice*>( ( *it )->device.data() ) && !( *it )->jobs.empty() )
if ( dynamic_cast<LvmDevice*>( ( *it )->device.data() ) )
{
CreateVolumeGroupJob* vgJob = dynamic_cast<CreateVolumeGroupJob*>( ( *it )->jobs[0].data() );
( *it )->isAvailable = true;
if ( vgJob )
if ( !( *it )->jobs.empty() )
{
vgJob->undoPreview();
CreateVolumeGroupJob* vgJob = dynamic_cast<CreateVolumeGroupJob*>( ( *it )->jobs[0].data() );
( *it )->forgetChanges();
if ( vgJob )
{
vgJob->undoPreview();
m_deviceModel->removeDevice( ( *it )->device.data() );
( *it )->forgetChanges();
it = m_deviceInfos.erase( it );
m_deviceModel->removeDevice( ( *it )->device.data() );
continue;
it = m_deviceInfos.erase( it );
continue;
}
}
}
@ -736,8 +811,13 @@ PartitionCoreModule::revertDevice( Device* dev )
m_deviceModel->swapDevice( dev, newDev );
QList< Device* > devices;
foreach ( auto info, m_deviceInfos )
devices.append( info->device.data() );
for ( auto info : m_deviceInfos )
{
if ( info->device.data()->type() != Device::Type::Disk_Device )
continue;
else
devices.append( info->device.data() );
}
m_bootLoaderModel->init( devices );
@ -777,6 +857,16 @@ PartitionCoreModule::isDirty()
return m_isDirty;
}
bool
PartitionCoreModule::isVGdeactivated( LvmDevice *device )
{
for ( DeviceInfo* deviceInfo : m_deviceInfos )
if ( device == deviceInfo->device.data() && !deviceInfo->isAvailable )
return true;
return false;
}
QList< PartitionCoreModule::SummaryInfo >
PartitionCoreModule::createSummaryInfo() const
{

View file

@ -114,6 +114,12 @@ public:
void createVolumeGroup( QString &vgName, QVector< const Partition* > pvList, qint32 peSize );
void resizeVolumeGroup( LvmDevice* device, QVector< const Partition* >& pvList );
void deactivateVolumeGroup( LvmDevice* device );
void removeVolumeGroup( LvmDevice* device );
void deletePartition( Device* device, Partition* partition );
void formatPartition( Device* device, Partition* partition );
@ -160,6 +166,8 @@ public:
bool isDirty(); // true if there are pending changes, otherwise false
bool isVGdeactivated( LvmDevice* device );
/**
* To be called when a partition has been altered, but only for changes
* which do not affect its size, because changes which affect the partition size
@ -198,6 +206,9 @@ private:
const QScopedPointer< Device > immutableDevice;
QList< Calamares::job_ptr > jobs;
// To check if LVM VGs are deactivated
bool isAvailable;
void forgetChanges();
bool isDirty() const;
};

View file

@ -28,13 +28,16 @@
CreateVolumeGroupDialog::CreateVolumeGroupDialog( QString& vgName,
QVector< const Partition* >& selectedPVs,
QVector< const Partition* > pvList,
qint32& peSize,
qint64& pSize,
QWidget* parent )
: VolumeGroupBaseDialog( vgName, pvList, peSize, parent )
: VolumeGroupBaseDialog( vgName, pvList, parent )
, m_selectedPVs( selectedPVs )
, m_peSize( pSize )
{
setWindowTitle( "Create Volume Group" );
peSize()->setValue( pSize );
vgType()->setEnabled( false );
}
@ -46,7 +49,7 @@ CreateVolumeGroupDialog::accept()
m_selectedPVs << checkedItems();
qint32& pe = peSizeValue();
qint64& pe = m_peSize;
pe = peSize()->value();
QDialog::accept();

View file

@ -27,13 +27,15 @@ public:
CreateVolumeGroupDialog( QString& vgName,
QVector< const Partition* >& selectedPVs,
QVector< const Partition* > pvList,
qint32& peSize,
qint64& pSize,
QWidget* parent );
void accept() override;
private:
QVector< const Partition* >& m_selectedPVs;
qint64& m_peSize;
};
#endif // CREATEVOLUMEGROUPDIALOG_H

View file

@ -30,6 +30,7 @@
#include "gui/CreatePartitionDialog.h"
#include "gui/CreateVolumeGroupDialog.h"
#include "gui/EditExistingPartitionDialog.h"
#include "gui/ResizeVolumeGroupDialog.h"
#include "gui/ScanningDialog.h"
#include "ui_PartitionPage.h"
@ -43,6 +44,8 @@
// KPMcore
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/ops/deactivatevolumegroupoperation.h>
#include <kpmcore/ops/removevolumegroupoperation.h>
// Qt
#include <QDebug>
@ -101,6 +104,9 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
connect( m_ui->partitionTreeView, &QAbstractItemView::doubleClicked, this, &PartitionPage::onPartitionViewActivated );
connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
connect( m_ui->newVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onNewVolumeGroupClicked );
connect( m_ui->resizeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onResizeVolumeGroupClicked );
connect( m_ui->deactivateVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onDeactivateVolumeGroupClicked );
connect( m_ui->removeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onRemoveVolumeGroupClicked );
connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
@ -121,7 +127,8 @@ PartitionPage::~PartitionPage()
void
PartitionPage::updateButtons()
{
bool create = false, createTable = false, edit = false, del = false;
bool create = false, createTable = false, edit = false, del = false, currentDeviceIsVG = false, isDeactivable = false;
bool isRemovable = false, isVGdeactivated = false;
QModelIndex index = m_ui->partitionTreeView->currentIndex();
if ( index.isValid() )
@ -152,12 +159,28 @@ PartitionPage::updateButtons()
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
if ( m_core->deviceModel()->deviceForIndex( deviceIndex )->type() != Device::Type::LVM_Device )
createTable = true;
else
{
currentDeviceIsVG = true;
LvmDevice* lvmDevice = dynamic_cast<LvmDevice*>(m_core->deviceModel()->deviceForIndex( deviceIndex ));
isDeactivable = DeactivateVolumeGroupOperation::isDeactivatable( lvmDevice );
isRemovable = RemoveVolumeGroupOperation::isRemovable( lvmDevice );
isVGdeactivated = m_core->isVGdeactivated( lvmDevice );
m_ui->revertButton->setEnabled( isVGdeactivated );
}
}
m_ui->createButton->setEnabled( create );
m_ui->editButton->setEnabled( edit );
m_ui->deleteButton->setEnabled( del );
m_ui->newPartitionTableButton->setEnabled( createTable );
m_ui->resizeVolumeGroupButton->setEnabled( currentDeviceIsVG && !isVGdeactivated );
m_ui->deactivateVolumeGroupButton->setEnabled( currentDeviceIsVG && isDeactivable && !isVGdeactivated );
m_ui->removeVolumeGroupButton->setEnabled( currentDeviceIsVG && isRemovable );
}
void
@ -188,7 +211,7 @@ PartitionPage::onNewVolumeGroupClicked()
{
QString vgName;
QVector< const Partition* > selectedPVs;
qint32 peSize = 4;
qint64 peSize = 4;
QVector< const Partition* > availablePVs;
@ -238,6 +261,59 @@ PartitionPage::onNewVolumeGroupClicked()
delete dlg;
}
void
PartitionPage::onResizeVolumeGroupClicked()
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
QVector< const Partition* > availablePVs;
QVector< const Partition* > selectedPVs;
for ( const Partition* p : m_core->lvmPVs() )
if ( !m_core->isInVG( p ) )
availablePVs << p;
QPointer< ResizeVolumeGroupDialog > dlg = new ResizeVolumeGroupDialog( device,
availablePVs,
selectedPVs,
this );
if ( dlg->exec() == QDialog::Accepted )
m_core->resizeVolumeGroup( device, selectedPVs );
delete dlg;
}
void
PartitionPage::onDeactivateVolumeGroupClicked()
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
m_core->deactivateVolumeGroup( device );
updateFromCurrentDevice();
PartitionModel* model = m_core->partitionModelForDevice( device );
model->update();
}
void
PartitionPage::onRemoveVolumeGroupClicked()
{
QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );
Q_ASSERT( device && device->type() == Device::Type::LVM_Device );
m_core->removeVolumeGroup( device );
}
void
PartitionPage::onCreateClicked()
{

View file

@ -51,6 +51,9 @@ private:
void updateButtons();
void onNewPartitionTableClicked();
void onNewVolumeGroupClicked();
void onResizeVolumeGroupClicked();
void onDeactivateVolumeGroupClicked();
void onRemoveVolumeGroupClicked();
void onCreateClicked();
void onEditClicked();
void onDeleteClicked();

View file

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>655</width>
<width>684</width>
<height>304</height>
</rect>
</property>
@ -88,13 +88,6 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="newVolumeGroupButton">
<property name="text">
<string>New Volume Group</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -131,6 +124,51 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="newVolumeGroupButton">
<property name="text">
<string>New Volume Group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resizeVolumeGroupButton">
<property name="text">
<string>Resize Volume Group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deactivateVolumeGroupButton">
<property name="text">
<string>Deactivate Volume Group</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeVolumeGroupButton">
<property name="text">
<string>Remove Volume Group</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View file

@ -0,0 +1,62 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ResizeVolumeGroupDialog.h"
#include "gui/ListPhysicalVolumeWidgetItem.h"
#include <kpmcore/core/lvmdevice.h>
#include <kpmcore/util/capacity.h>
#include <QComboBox>
#include <QLineEdit>
#include <QListWidgetItem>
#include <QSpinBox>
ResizeVolumeGroupDialog::ResizeVolumeGroupDialog( LvmDevice *device,
QVector< const Partition* > availablePVs,
QVector< const Partition* >& selectedPVs,
QWidget* parent )
: VolumeGroupBaseDialog( device->name(), device->physicalVolumes(), parent )
, m_selectedPVs( selectedPVs )
{
setWindowTitle( "Resize Volume Group" );
for ( int i = 0; i < pvList()->count(); i++ )
pvList()->item(i)->setCheckState( Qt::Checked );
for ( const Partition* p : availablePVs )
pvList()->addItem( new ListPhysicalVolumeWidgetItem( p, false ) );
peSize()->setValue( device->peSize() / Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB) );
vgName()->setEnabled( false );
peSize()->setEnabled( false );
vgType()->setEnabled( false );
setUsedSizeValue( device->allocatedPE() * device->peSize() );
setLVQuantity( device->partitionTable()->children().count() );
}
void
ResizeVolumeGroupDialog::accept()
{
m_selectedPVs << checkedItems();
QDialog::accept();
}

View file

@ -0,0 +1,40 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RESIZEVOLUMEGROUPDIALOG_H
#define RESIZEVOLUMEGROUPDIALOG_H
#include "gui/VolumeGroupBaseDialog.h"
class LvmDevice;
class ResizeVolumeGroupDialog : public VolumeGroupBaseDialog
{
public:
ResizeVolumeGroupDialog( LvmDevice *device,
QVector< const Partition* > availablePVs,
QVector< const Partition* >& selectedPVs,
QWidget* parent );
void accept() override;
private:
QVector< const Partition* >& m_selectedPVs;
};
#endif // RESIZEVOLUMEGROUPDIALOG_H

View file

@ -32,12 +32,10 @@
VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName,
QVector< const Partition* > pvList,
qint32& peSize,
QWidget *parent )
: QDialog(parent)
, ui(new Ui::VolumeGroupBaseDialog)
, m_vgNameValue(vgName)
, m_peSizeValue(peSize)
, m_totalSizeValue(0)
, m_usedSizeValue(0)
{
@ -53,8 +51,6 @@ VolumeGroupBaseDialog::VolumeGroupBaseDialog( QString& vgName,
ui->vgName->setValidator( new QRegularExpressionValidator( re, this ) );
ui->vgName->setText( m_vgNameValue );
ui->peSize->setValue( m_peSizeValue );
updateOkButton();
updateTotalSize();
@ -111,6 +107,20 @@ VolumeGroupBaseDialog::updateOkButton()
ui->peSize->value() > 0);
}
void
VolumeGroupBaseDialog::setUsedSizeValue( qint64 usedSize )
{
m_usedSizeValue = usedSize;
ui->usedSize->setText( Capacity::formatByteSize(m_usedSizeValue) );
}
void
VolumeGroupBaseDialog::setLVQuantity( qint32 lvQuantity )
{
ui->lvQuantity->setText( QString::number( lvQuantity ) );
}
void
VolumeGroupBaseDialog::updateTotalSize()
{
@ -143,12 +153,6 @@ VolumeGroupBaseDialog::vgNameValue() const
return m_vgNameValue;
}
qint32&
VolumeGroupBaseDialog::peSizeValue() const
{
return m_peSizeValue;
}
QLineEdit*
VolumeGroupBaseDialog::vgName() const
{

View file

@ -39,13 +39,16 @@ class VolumeGroupBaseDialog : public QDialog
public:
explicit VolumeGroupBaseDialog( QString& vgName,
QVector< const Partition* > pvList,
qint32& peSize,
QWidget* parent = nullptr );
~VolumeGroupBaseDialog();
protected:
virtual void updateOkButton();
void setUsedSizeValue( qint64 usedSize );
void setLVQuantity( qint32 lvQuantity );
void updateTotalSize();
void updateTotalSectors();
@ -56,8 +59,6 @@ protected:
QString& vgNameValue() const;
qint32& peSizeValue() const;
QLineEdit* vgName() const;
QComboBox* vgType() const;
@ -72,7 +73,6 @@ private:
Ui::VolumeGroupBaseDialog* ui;
QString& m_vgNameValue;
qint32& m_peSizeValue;
qint64 m_totalSizeValue;
qint64 m_usedSizeValue;

View file

@ -0,0 +1,69 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DeactivateVolumeGroupJob.h"
#include <kpmcore/core/lvmdevice.h>
#include <kpmcore/ops/deactivatevolumegroupoperation.h>
#include <kpmcore/util/report.h>
DeactivateVolumeGroupJob::DeactivateVolumeGroupJob( LvmDevice* device )
: m_device( device )
{
}
QString
DeactivateVolumeGroupJob::prettyName() const
{
return tr( "Deactivate volume group named %1." )
.arg( m_device->name() );
}
QString
DeactivateVolumeGroupJob::prettyDescription() const
{
return tr( "Deactivate volume group named <strong>%1</strong>." )
.arg( m_device->name() );
}
QString
DeactivateVolumeGroupJob::prettyStatusMessage() const
{
return tr( "Deactivate volume group named %1." )
.arg( m_device->name() );
}
Calamares::JobResult
DeactivateVolumeGroupJob::exec()
{
Report report( nullptr );
DeactivateVolumeGroupOperation op( *m_device );
op.setStatus( Operation::OperationStatus::StatusRunning );
QString message = tr( "The installer failed to deactivate a volume group named %1." ).arg( m_device->name() );
if ( op.execute( report ) )
{
op.preview();
return Calamares::JobResult::ok();
}
return Calamares::JobResult::error(message, report.toText());
}

View file

@ -0,0 +1,40 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef DEACTIVATEVOLUMEGROUPJOB_H
#define DEACTIVATEVOLUMEGROUPJOB_H
#include "Job.h"
class LvmDevice;
class DeactivateVolumeGroupJob : public Calamares::Job
{
public:
DeactivateVolumeGroupJob( LvmDevice* device );
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;
Calamares::JobResult exec() override;
private:
LvmDevice* m_device;
};
#endif // DEACTIVATEVOLUMEGROUPJOB_H

View file

@ -0,0 +1,66 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "RemoveVolumeGroupJob.h"
#include <kpmcore/core/lvmdevice.h>
#include <kpmcore/ops/removevolumegroupoperation.h>
#include <kpmcore/util/report.h>
RemoveVolumeGroupJob::RemoveVolumeGroupJob( LvmDevice* device )
: m_device( device )
{
}
QString
RemoveVolumeGroupJob::prettyName() const
{
return tr( "Remove Volume Group named %1." )
.arg( m_device->name() );
}
QString
RemoveVolumeGroupJob::prettyDescription() const
{
return tr( "Remove Volume Group named <strong>%1</strong>.")
.arg( m_device->name() );
}
QString
RemoveVolumeGroupJob::prettyStatusMessage() const
{
return tr( "Remove Volume Group named %1." )
.arg( m_device->name() );
}
Calamares::JobResult
RemoveVolumeGroupJob::exec()
{
Report report( nullptr );
RemoveVolumeGroupOperation op( *m_device );
op.setStatus( Operation::OperationStatus::StatusRunning );
QString message = tr( "The installer failed to remove a volume group named '%1'." ).arg( m_device->name() );
if ( op.execute( report ) )
return Calamares::JobResult::ok();
return Calamares::JobResult::error(message, report.toText());
}

View file

@ -0,0 +1,40 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef REMOVEVOLUMEGROUPJOB_H
#define REMOVEVOLUMEGROUPJOB_H
#include <Job.h>
class LvmDevice;
class RemoveVolumeGroupJob : public Calamares::Job
{
public:
RemoveVolumeGroupJob( LvmDevice* device );
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;
Calamares::JobResult exec() override;
private:
LvmDevice* m_device;
};
#endif // REMOVEVOLUMEGROUPJOB_H

View file

@ -0,0 +1,101 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#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." )
.arg( m_device->name() )
.arg( currentPartitions() )
.arg( targetPartitions() );
}
QString
ResizeVolumeGroupJob::prettyDescription() const
{
return tr( "Resize volume group named <strong>%1</strong> from <strong>%2</strong> to <strong>%3</strong>." )
.arg( m_device->name() )
.arg( currentPartitions() )
.arg( targetPartitions() );
}
QString
ResizeVolumeGroupJob::prettyStatusMessage() const
{
return tr( "Resize volume group named %1 from %2 to %3." )
.arg( m_device->name() )
.arg( currentPartitions() )
.arg( targetPartitions() );
}
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 ) )
return Calamares::JobResult::ok();
return Calamares::JobResult::error( message, report.toText() );
}
QString
ResizeVolumeGroupJob::currentPartitions() const
{
QString result;
for ( const Partition *p : m_device->physicalVolumes() )
result += p->deviceNode() + ", ";
result.chop(2);
return result;
}
QString
ResizeVolumeGroupJob::targetPartitions() const
{
QString result;
for ( const Partition *p : m_partitionList )
result += p->deviceNode() + ", ";
result.chop(2);
return result;
}

View file

@ -0,0 +1,48 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* Copyright 2018, Caio Jordão Carvalho <caiojcarvalho@gmail.com>
*
* Calamares 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.
*
* Calamares 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 Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RESIZEVOLUMEGROUPJOB_H
#define RESIZEVOLUMEGROUPJOB_H
#include <Job.h>
#include <QVector>
class LvmDevice;
class Partition;
class ResizeVolumeGroupJob : public Calamares::Job
{
public:
ResizeVolumeGroupJob( LvmDevice* device, QVector< const Partition* >& partitionList );
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;
Calamares::JobResult exec() override;
private:
QString currentPartitions() const;
QString targetPartitions() const;
private:
LvmDevice* m_device;
QVector< const Partition* > m_partitionList;
};
#endif // RESIZEVOLUMEGROUPJOB_H