mirror of https://github.com/cutefishos/calamares
[partition] Adding resizing, deactivating and removing procedures for LVM VGs.
parent
98a158c6e5
commit
295e14530e
@ -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();
|
||||
}
|
@ -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
|
@ -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());
|
||||
}
|
@ -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
|
@ -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());
|
||||
}
|
@ -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
|
@ -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;
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue