LVM support #6
|
@ -6,6 +6,7 @@ set(JOBS_SRC
|
|||
jobs/shredfilesystemjob.cpp
|
||||
jobs/createpartitionjob.cpp
|
||||
jobs/createpartitiontablejob.cpp
|
||||
jobs/createvolumegroupjob.cpp
|
||||
jobs/setfilesystemlabeljob.cpp
|
||||
jobs/deletepartitionjob.cpp
|
||||
jobs/restorefilesystemjob.cpp
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
/*************************************************************************
|
||||
* 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/createvolumegroupjob.h"
|
||||
|
||||
#include "core/lvmdevice.h"
|
||||
|
||||
#include "util/report.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new CreateVolumeGroupJob
|
||||
@param vgname
|
||||
@parem pvList
|
||||
*/
|
||||
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgname, const QList<Partition*> pvlist) :
|
||||
Job(),
|
||||
m_vgName(vgname),
|
||||
m_pvList(pvlist)
|
||||
{
|
||||
}
|
||||
|
||||
bool CreateVolumeGroupJob::run(Report& parent)
|
||||
{
|
||||
bool rval = false;
|
||||
|
||||
Report* report = jobStarted(parent);
|
||||
|
||||
rval = LvmDevice::createVG(*report, vgName(), pvList());
|
||||
|
||||
jobFinished(*report, rval);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
QString CreateVolumeGroupJob::description() const
|
||||
{
|
||||
return xi18nc("@info/plain", "Create new Volume Group named <filename>%1</filename>", vgName());
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/*************************************************************************
|
||||
* 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(CREATEVOLUMEGROUPJOB_H)
|
||||
|
||||
#define CREATEVOLUMEGROUPJOB_H
|
||||
|
||||
#include "jobs/job.h"
|
||||
|
||||
class LvmDevice;
|
||||
class Partition;
|
||||
class Report;
|
||||
|
||||
class QString;
|
||||
|
||||
class CreateVolumeGroupJob : public Job
|
||||
{
|
||||
public:
|
||||
CreateVolumeGroupJob(const QString& vgname, const QList<Partition*> pvlist);
|
||||
|
||||
public:
|
||||
bool run(Report& parent) override;
|
||||
QString description() const override;
|
||||
|
||||
protected:
|
||||
QString vgName() {
|
||||
return m_vgName;
|
||||
}
|
||||
const QString vgName() const {
|
||||
return m_vgName;
|
||||
}
|
||||
QList<Partition*> pvList() {
|
||||
return m_pvList;
|
||||
}
|
||||
const QList<Partition*> pvList() const {
|
||||
return m_pvList;
|
||||
}
|
||||
|
||||
private:
|
||||
QString m_vgName;
|
||||
QList<Partition*> m_pvList;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -6,6 +6,7 @@ set(OPS_SRC
|
|||
ops/newoperation.cpp
|
||||
ops/createfilesystemoperation.cpp
|
||||
ops/createpartitiontableoperation.cpp
|
||||
ops/createvolumegroupoperation.cpp
|
||||
ops/setfilesystemlabeloperation.cpp
|
||||
ops/setpartflagsoperation.cpp
|
||||
ops/checkoperation.cpp
|
||||
|
@ -19,6 +20,7 @@ set(OPS_LIB_HDRS
|
|||
ops/copyoperation.h
|
||||
ops/createfilesystemoperation.h
|
||||
ops/createpartitiontableoperation.h
|
||||
ops/createvolumegroupoperation.h
|
||||
ops/deleteoperation.h
|
||||
ops/newoperation.h
|
||||
ops/operation.h
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*************************************************************************
|
||||
* 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/createvolumegroupoperation.h"
|
||||
|
||||
#include "core/lvmdevice.h"
|
||||
|
||||
#include "jobs/createvolumegroupjob.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
/** Creates a new CreateVolumeGroupOperation.
|
||||
@param d the Device to create the new PartitionTable on
|
||||
@param t the type for the new PartitionTable
|
||||
*/
|
||||
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgname, const QList<Partition*> pvlist) :
|
||||
Operation(),
|
||||
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgname, pvlist))
|
||||
{
|
||||
addJob(createVolumeGroupJob());
|
||||
}
|
||||
|
||||
bool CreateVolumeGroupOperation::canCreate()
|
||||
{
|
||||
//TODO: return true if there is any free PV
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CreateVolumeGroupOperation::description() const
|
||||
{
|
||||
return xi18nc("@info/plain", "Create a new LVM volume group.");
|
||||
}
|
||||
|
||||
bool CreateVolumeGroupOperation::targets(const Device&) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CreateVolumeGroupOperation::targets(const Partition& part) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreateVolumeGroupOperation::preview()
|
||||
{
|
||||
}
|
||||
|
||||
void CreateVolumeGroupOperation::undo()
|
||||
{
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*************************************************************************
|
||||
* 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(CREATEVOLUMEGROUPOPERATION_H)
|
||||
|
||||
#define CREATEVOLUMEGROUPOPERATION_H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "ops/operation.h"
|
||||
|
||||
#include "core/lvmdevice.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
class CreateVolumeGroupJob;
|
||||
class OperationStack;
|
||||
|
||||
class LIBKPMCORE_EXPORT CreateVolumeGroupOperation : public Operation
|
||||
{
|
||||
Q_DISABLE_COPY(CreateVolumeGroupOperation)
|
||||
|
||||
friend class OperationStack;
|
||||
|
||||
public:
|
||||
CreateVolumeGroupOperation(const QString& vgname, const QList<Partition*> pvlist);
|
||||
|
||||
public:
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("document-new");
|
||||
}
|
||||
|
||||
QString description() const override;
|
||||
|
||||
virtual bool targets(const Device&) const override;
|
||||
virtual bool targets(const Partition&) const override;
|
||||
|
||||
virtual void preview() override;
|
||||
virtual void undo() override;
|
||||
|
||||
static bool canCreate();
|
||||
|
||||
protected:
|
||||
CreateVolumeGroupJob* createVolumeGroupJob() {
|
||||
return m_CreateVolumeGroupJob;
|
||||
}
|
||||
|
||||
private:
|
||||
CreateVolumeGroupJob* m_CreateVolumeGroupJob;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue