-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2993: Snapshots r=townsend2010 a=ricab Fixes #208 Co-authored-by: Ricardo Abreu <[email protected]> Co-authored-by: ScottH <[email protected]>
- Loading branch information
Showing
122 changed files
with
7,228 additions
and
1,442 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright (C) Canonical, Ltd. | ||
* | ||
* 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; version 3. | ||
* | ||
* 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/>. | ||
* | ||
*/ | ||
|
||
#ifndef MULTIPASS_FILE_OPEN_FAILED_EXCEPTION_H | ||
#define MULTIPASS_FILE_OPEN_FAILED_EXCEPTION_H | ||
|
||
#include <cerrno> | ||
#include <cstring> | ||
#include <stdexcept> | ||
|
||
namespace multipass | ||
{ | ||
class FileOpenFailedException : public std::runtime_error | ||
{ | ||
public: | ||
explicit FileOpenFailedException(const std::string& name) | ||
: std::runtime_error(fmt::format("failed to open file '{}': {}({})", name, strerror(errno), errno)) | ||
{ | ||
} | ||
}; | ||
} // namespace multipass | ||
|
||
#endif // MULTIPASS_FILE_OPEN_FAILED_EXCEPTION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) Canonical, Ltd. | ||
* | ||
* 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; version 3. | ||
* | ||
* 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/>. | ||
* | ||
*/ | ||
|
||
#ifndef MULTIPASS_SNAPSHOT_EXCEPTIONS_H | ||
#define MULTIPASS_SNAPSHOT_EXCEPTIONS_H | ||
|
||
#include <stdexcept> | ||
#include <string> | ||
|
||
#include <multipass/format.h> | ||
|
||
namespace multipass | ||
{ | ||
class SnapshotNameTakenException : public std::runtime_error | ||
{ | ||
public: | ||
SnapshotNameTakenException(const std::string& vm_name, const std::string& snapshot_name) | ||
: std::runtime_error{fmt::format("Snapshot already exists: {}.{}", vm_name, snapshot_name)} | ||
{ | ||
} | ||
}; | ||
|
||
class NoSuchSnapshotException : public std::runtime_error | ||
{ | ||
public: | ||
NoSuchSnapshotException(const std::string& vm_name, const std::string& snapshot_name) | ||
: std::runtime_error{fmt::format("No such snapshot: {}.{}", vm_name, snapshot_name)} | ||
{ | ||
} | ||
}; | ||
} // namespace multipass | ||
|
||
#endif // MULTIPASS_SNAPSHOT_EXCEPTIONS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,29 @@ | |
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Authored by: Alberto Aguirre <[email protected]> | ||
* | ||
*/ | ||
|
||
#ifndef MULTIPASS_JSON_UTILS_H | ||
#define MULTIPASS_JSON_UTILS_H | ||
|
||
#include <string> | ||
#include "singleton.h" | ||
|
||
#include <QJsonObject> | ||
#include <QString> | ||
|
||
#include <string> | ||
|
||
#define MP_JSONUTILS multipass::JsonUtils::instance() | ||
|
||
namespace multipass | ||
{ | ||
void write_json(const QJsonObject& root, QString file_name); | ||
std::string json_to_string(const QJsonObject& root); | ||
} | ||
class JsonUtils : public Singleton<JsonUtils> | ||
{ | ||
public: | ||
explicit JsonUtils(const Singleton<JsonUtils>::PrivatePass&) noexcept; | ||
|
||
virtual void write_json(const QJsonObject& root, QString file_name) const; // transactional; creates parent dirs | ||
virtual std::string json_to_string(const QJsonObject& root) const; | ||
}; | ||
} // namespace multipass | ||
#endif // MULTIPASS_JSON_UTILS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.