diff --git a/src/jobs/CMakeLists.txt b/src/jobs/CMakeLists.txt index a0184ee..908ea9e 100644 --- a/src/jobs/CMakeLists.txt +++ b/src/jobs/CMakeLists.txt @@ -8,6 +8,8 @@ set(JOBS_SRC jobs/createpartitiontablejob.cpp jobs/createvolumegroupjob.cpp jobs/removevolumegroupjob.cpp + jobs/deactivatevolumegroupjob.cpp + jobs/deactivatelogicalvolumejob.cpp jobs/resizevolumegroupjob.cpp jobs/movephysicalvolumejob.cpp jobs/setfilesystemlabeljob.cpp diff --git a/src/jobs/deactivatelogicalvolumejob.cpp b/src/jobs/deactivatelogicalvolumejob.cpp new file mode 100644 index 0000000..ddc52c1 --- /dev/null +++ b/src/jobs/deactivatelogicalvolumejob.cpp @@ -0,0 +1,63 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * 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 .* + *************************************************************************/ + +#include "jobs/deactivatelogicalvolumejob.h" + +#include "core/lvmdevice.h" +#include "core/partition.h" +#include "core/partitiontable.h" + +#include "util/report.h" + +#include + +/** Creates a new DeactivateLogicalVolumeJob + @param vgname + @parem pvList +*/ +DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(VolumeManagerDevice& dev, QStringList lvPaths) : + Job(), + m_Device(dev), + m_LVList(lvPaths) +{ +} + +bool DeactivateLogicalVolumeJob::run(Report& parent) +{ + bool rval = true; + + Report* report = jobStarted(parent); + + if (device().type() == Device::LVM_Device) { + foreach (Partition* part, device().partitionTable()->children()) { + if (!part->roles().has(PartitionRole::Unallocated)) { + if (!LvmDevice::deactivateLV(*report, dynamic_cast(device()), *part)) { + rval = false; + } + } + } + } + + jobFinished(*report, rval); + + return rval; +} + +QString DeactivateLogicalVolumeJob::description() const +{ + return xi18nc("@info/plain", "Deactivate Logical Volumes: %1", device().prettyDeviceNodeList()); +} diff --git a/src/jobs/deactivatelogicalvolumejob.h b/src/jobs/deactivatelogicalvolumejob.h new file mode 100644 index 0000000..2224f58 --- /dev/null +++ b/src/jobs/deactivatelogicalvolumejob.h @@ -0,0 +1,56 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * 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 .* + *************************************************************************/ + +#if !defined(DEACTIVATELOGICALVOLUMEJOB_H) + +#define DEACTIVATELOGICALVOLUMEJOB_H + +#include "jobs/job.h" + +class VolumeManagerDevice; +class Partition; +class Report; + +class QString; + +class DeactivateLogicalVolumeJob : public Job +{ +public: + DeactivateLogicalVolumeJob(VolumeManagerDevice& dev, QStringList lvPaths = {}); + +public: + bool run(Report& parent) override; + QString description() const override; + +protected: + VolumeManagerDevice& device() { + return m_Device; + } + const VolumeManagerDevice& device() const { + return m_Device; + } + + QStringList LVList() const { + return m_LVList; + } + +private: + VolumeManagerDevice& m_Device; + QStringList m_LVList; +}; + +#endif diff --git a/src/jobs/deactivatevolumegroupjob.cpp b/src/jobs/deactivatevolumegroupjob.cpp new file mode 100644 index 0000000..fe5b907 --- /dev/null +++ b/src/jobs/deactivatevolumegroupjob.cpp @@ -0,0 +1,54 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * 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 .* + *************************************************************************/ + +#include "jobs/deactivatevolumegroupjob.h" + +#include "core/lvmdevice.h" + +#include "util/report.h" + +#include + +/** Deactivate LVM Volume Group + @param vgname + @parem pvList +*/ +DeactivateVolumeGroupJob::DeactivateVolumeGroupJob(VolumeManagerDevice& dev) : + Job(), + m_Device(dev) +{ +} + +bool DeactivateVolumeGroupJob::run(Report& parent) +{ + bool rval = false; + + Report* report = jobStarted(parent); + + if (device().type() == Device::LVM_Device) { + rval = LvmDevice::deactivateVG(*report, dynamic_cast(device())); + } + + jobFinished(*report, rval); + + return rval; +} + +QString DeactivateVolumeGroupJob::description() const +{ + return xi18nc("@info/plain", "Deactivate Volume Group: %1", device().name()); +} diff --git a/src/jobs/deactivatevolumegroupjob.h b/src/jobs/deactivatevolumegroupjob.h new file mode 100644 index 0000000..1222a45 --- /dev/null +++ b/src/jobs/deactivatevolumegroupjob.h @@ -0,0 +1,51 @@ +/************************************************************************* + * Copyright (C) 2016 by Chantara Tith * + * * + * 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 .* + *************************************************************************/ + +#if !defined(DEACTIVATEVOLUMEGROUPJOB_H) + +#define DEACTIVATEVOLUMEGROUPJOB_H + +#include "jobs/job.h" + +class VolumeManagerDevice; +class Partition; +class Report; + +class QString; + +class DeactivateVolumeGroupJob : public Job +{ +public: + DeactivateVolumeGroupJob(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