Initial work on removeVolume Operation and Job.
This commit is contained in:
parent
ef7b4003b7
commit
c74a61e513
|
@ -7,6 +7,7 @@ set(JOBS_SRC
|
||||||
jobs/createpartitionjob.cpp
|
jobs/createpartitionjob.cpp
|
||||||
jobs/createpartitiontablejob.cpp
|
jobs/createpartitiontablejob.cpp
|
||||||
jobs/createvolumegroupjob.cpp
|
jobs/createvolumegroupjob.cpp
|
||||||
|
jobs/removevolumegroupjob.cpp
|
||||||
jobs/setfilesystemlabeljob.cpp
|
jobs/setfilesystemlabeljob.cpp
|
||||||
jobs/deletepartitionjob.cpp
|
jobs/deletepartitionjob.cpp
|
||||||
jobs/restorefilesystemjob.cpp
|
jobs/restorefilesystemjob.cpp
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
||||||
|
* *
|
||||||
|
* This program 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. *
|
||||||
|
* *
|
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "jobs/removevolumegroupjob.h"
|
||||||
|
|
||||||
|
#include "core/lvmdevice.h"
|
||||||
|
|
||||||
|
#include "util/report.h"
|
||||||
|
|
||||||
|
#include <KLocalizedString>
|
||||||
|
|
||||||
|
/** Creates a new RemoveVolumeGroupJob
|
||||||
|
@param vgname
|
||||||
|
@parem pvList
|
||||||
|
*/
|
||||||
|
RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& dev) :
|
||||||
|
Job(),
|
||||||
|
m_Device(dev)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoveVolumeGroupJob::run(Report& parent)
|
||||||
|
{
|
||||||
|
bool rval = false;
|
||||||
|
|
||||||
|
Report* report = jobStarted(parent);
|
||||||
|
|
||||||
|
if (device().type() == Device::LVM_Device) {
|
||||||
|
rval = LvmDevice::removeVG(*report, dynamic_cast<LvmDevice&>(device()));
|
||||||
|
}
|
||||||
|
|
||||||
|
jobFinished(*report, rval);
|
||||||
|
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RemoveVolumeGroupJob::description() const
|
||||||
|
{
|
||||||
|
return xi18nc("@info/plain", "Remove Volume Group: <filename>%1</filename>", device().name());
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
||||||
|
* *
|
||||||
|
* This program 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. *
|
||||||
|
* *
|
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(REMOVEVOLUMEGROUPJOB_H)
|
||||||
|
|
||||||
|
#define REMOVEVOLUMEGROUPJOB_H
|
||||||
|
|
||||||
|
#include "jobs/job.h"
|
||||||
|
|
||||||
|
class VolumeManagerDevice;
|
||||||
|
class Partition;
|
||||||
|
class Report;
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
|
||||||
|
class RemoveVolumeGroupJob : public Job
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RemoveVolumeGroupJob(VolumeManagerDevice& dev);
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool run(Report& parent) override;
|
||||||
|
QString description() const override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
VolumeManagerDevice& device() {
|
||||||
|
return m_Device;
|
||||||
|
}
|
||||||
|
const VolumeManagerDevice& device() const {
|
||||||
|
return m_Device;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
VolumeManagerDevice& m_Device;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,6 +7,7 @@ set(OPS_SRC
|
||||||
ops/createfilesystemoperation.cpp
|
ops/createfilesystemoperation.cpp
|
||||||
ops/createpartitiontableoperation.cpp
|
ops/createpartitiontableoperation.cpp
|
||||||
ops/createvolumegroupoperation.cpp
|
ops/createvolumegroupoperation.cpp
|
||||||
|
ops/removevolumegroupoperation.cpp
|
||||||
ops/setfilesystemlabeloperation.cpp
|
ops/setfilesystemlabeloperation.cpp
|
||||||
ops/setpartflagsoperation.cpp
|
ops/setpartflagsoperation.cpp
|
||||||
ops/checkoperation.cpp
|
ops/checkoperation.cpp
|
||||||
|
@ -21,6 +22,7 @@ set(OPS_LIB_HDRS
|
||||||
ops/createfilesystemoperation.h
|
ops/createfilesystemoperation.h
|
||||||
ops/createpartitiontableoperation.h
|
ops/createpartitiontableoperation.h
|
||||||
ops/createvolumegroupoperation.h
|
ops/createvolumegroupoperation.h
|
||||||
|
ops/removevolumegroupoperation.h
|
||||||
ops/deleteoperation.h
|
ops/deleteoperation.h
|
||||||
ops/newoperation.h
|
ops/newoperation.h
|
||||||
ops/operation.h
|
ops/operation.h
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
||||||
|
* *
|
||||||
|
* This program 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. *
|
||||||
|
* *
|
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#include "ops/removevolumegroupoperation.h"
|
||||||
|
#include "jobs/removevolumegroupjob.h"
|
||||||
|
|
||||||
|
#include "core/volumemanagerdevice.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
#include <KLocalizedString>
|
||||||
|
|
||||||
|
/** Creates a new RemoveVolumeGroupOperation.
|
||||||
|
@param d the Device to create the new PartitionTable on
|
||||||
|
@param t the type for the new PartitionTable
|
||||||
|
*/
|
||||||
|
RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& dev) :
|
||||||
|
Operation(),
|
||||||
|
m_RemoveVolumeGroupJob(new RemoveVolumeGroupJob(dev))
|
||||||
|
{
|
||||||
|
addJob(removeVolumeGroupJob());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString RemoveVolumeGroupOperation::description() const
|
||||||
|
{
|
||||||
|
return xi18nc("@info/plain", "Remove a new LVM volume group.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveVolumeGroupOperation::preview()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RemoveVolumeGroupOperation::undo()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RemoveVolumeGroupOperation::canRemove()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
||||||
|
* *
|
||||||
|
* This program 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. *
|
||||||
|
* *
|
||||||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
|
*************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(REMOVEVOLUMEOPERATION_H)
|
||||||
|
|
||||||
|
#define REMOVEVOLUMEGROUPOPERATION_H
|
||||||
|
|
||||||
|
#include "util/libpartitionmanagerexport.h"
|
||||||
|
|
||||||
|
#include "ops/operation.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class RemoveVolumeGroupJob;
|
||||||
|
class VolumeManagerDevice;
|
||||||
|
class OperationStack;
|
||||||
|
|
||||||
|
class LIBKPMCORE_EXPORT RemoveVolumeGroupOperation : public Operation
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(RemoveVolumeGroupOperation)
|
||||||
|
|
||||||
|
friend class OperationStack;
|
||||||
|
|
||||||
|
public:
|
||||||
|
RemoveVolumeGroupOperation(VolumeManagerDevice& dev);
|
||||||
|
|
||||||
|
public:
|
||||||
|
QString iconName() const override {
|
||||||
|
return QStringLiteral("edit-delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
QString description() const override;
|
||||||
|
|
||||||
|
virtual bool targets(const Device&) const override {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
virtual bool targets(const Partition&) const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void preview() override;
|
||||||
|
virtual void undo() override;
|
||||||
|
|
||||||
|
static bool canRemove();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
RemoveVolumeGroupJob* removeVolumeGroupJob() {
|
||||||
|
return m_RemoveVolumeGroupJob;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
RemoveVolumeGroupJob* m_RemoveVolumeGroupJob;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue