-
Notifications
You must be signed in to change notification settings - Fork 736
Az integration #3924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Parent:
Availability Zones
+1,587
−332
Merged
Az integration #3924
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
cad30f2
[az] make vms and vm factories aware of zones
andrei-toterman a6156f6
[az] add az implementation
andrei-toterman adfaccd
[az] add az manager implementation
andrei-toterman c70fc1f
[daemon] integrate zones in daemon
andrei-toterman c06bfa8
[tests] make stub az classes and put them where they are needed
andrei-toterman 34f009c
[az] add default zone names to constants
andrei-toterman c0455f4
[az] inject az manager into vm factory constructors
andrei-toterman 7756997
[az] move az from vm to base vm
andrei-toterman 4ed63d3
[az] handle az not found in daemon
andrei-toterman c6a7954
[tests] make tests compile with azs
andrei-toterman 386e689
[utils] introduce util to read json object from file
andrei-toterman 76140b4
[az] refactor base az implementation
andrei-toterman 84852c4
[az] refactor base az manager implementation
andrei-toterman a49db32
[az] Address review comments
Sploder12 c975740
[az] add test coverage for base az and manager files
levkropp 9edb236
apply code review suggestions
levkropp ac7055b
[az] Fix mock naming
Sploder12 4aca32a
[az] Address some review comments
Sploder12 8d42803
[az] Address more review comments
Sploder12 dc5b45d
[az] Integrate Windows
Sploder12 a9be08a
[az] Integrate macOS
Sploder12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,61 @@ | ||
| /* | ||
| * 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_BASE_AVAILABILITY_ZONE_H | ||
| #define MULTIPASS_BASE_AVAILABILITY_ZONE_H | ||
|
|
||
| #include "availability_zone.h" | ||
|
|
||
| #include <filesystem> | ||
| #include <mutex> | ||
| #include <string> | ||
| #include <vector> | ||
|
|
||
| namespace multipass | ||
| { | ||
| class BaseAvailabilityZone : public AvailabilityZone | ||
| { | ||
| public: | ||
| BaseAvailabilityZone(const std::string& name, const std::filesystem::path& az_directory); | ||
|
|
||
| const std::string& get_name() const override; | ||
| const std::string& get_subnet() const override; | ||
| bool is_available() const override; | ||
| void set_available(bool new_available) override; | ||
| void add_vm(VirtualMachine& vm) override; | ||
| void remove_vm(VirtualMachine& vm) override; | ||
|
|
||
| private: | ||
| void serialize() const; | ||
|
|
||
| // we store all the data in one struct so that it can be created from one function call in the initializer list | ||
| struct data | ||
| { | ||
| const std::string name{}; | ||
| const std::filesystem::path file_path{}; | ||
| const std::string subnet{}; | ||
| bool available{}; | ||
| std::vector<std::reference_wrapper<VirtualMachine>> vms{}; | ||
| // we don't have designated initializers, so mutex remains last so it doesn't need to be manually initialized | ||
| mutable std::recursive_mutex mutex{}; | ||
| } m; | ||
|
|
||
| static data read_from_file(const std::string& name, const std::filesystem::path& file_path); | ||
| }; | ||
| } // namespace multipass | ||
|
|
||
| #endif // MULTIPASS_BASE_AVAILABILITY_ZONE_H | ||
This file contains hidden or 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,78 @@ | ||
| /* | ||
| * 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_BASE_AVAILABILITY_ZONE_MANAGER_H | ||
| #define MULTIPASS_BASE_AVAILABILITY_ZONE_MANAGER_H | ||
|
|
||
| #include "availability_zone_manager.h" | ||
|
|
||
| #include <multipass/constants.h> | ||
|
|
||
| #include <array> | ||
| #include <filesystem> | ||
| #include <mutex> | ||
| #include <shared_mutex> | ||
|
|
||
| namespace multipass | ||
| { | ||
| class BaseAvailabilityZoneManager final : public AvailabilityZoneManager | ||
ricab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| public: | ||
| explicit BaseAvailabilityZoneManager(const std::filesystem::path& data_dir); | ||
|
|
||
| AvailabilityZone& get_zone(const std::string& name) override; | ||
| std::vector<std::reference_wrapper<const AvailabilityZone>> get_zones() override; | ||
| std::string get_automatic_zone_name() override; | ||
| std::string get_default_zone_name() const override; | ||
|
|
||
| private: | ||
| void serialize() const; | ||
|
|
||
| class ZoneCollection | ||
| { | ||
| public: | ||
| static constexpr size_t size = default_zone_names.size(); | ||
| using ZoneArray = std::array<AvailabilityZone::UPtr, size>; | ||
| static_assert(size > 0); | ||
|
|
||
| const ZoneArray zones{}; | ||
|
|
||
| ZoneCollection(ZoneArray&& zones, std::string last_used); | ||
| [[nodiscard]] std::string next_available(); | ||
| [[nodiscard]] std::string last_used() const; | ||
|
|
||
| private: | ||
| ZoneArray::const_iterator automatic_zone; | ||
| mutable std::shared_mutex mutex{}; | ||
| }; | ||
|
|
||
| // we store all the data in one struct so that it can be created from one function call in the initializer list | ||
| struct data | ||
| { | ||
| const std::filesystem::path file_path{}; | ||
| ZoneCollection zone_collection; | ||
| // we don't have designated initializers, so mutex remains last so it doesn't need to be manually initialized | ||
| mutable std::recursive_mutex mutex{}; | ||
| } m; | ||
|
|
||
| [[nodiscard]] const ZoneCollection::ZoneArray& zones() const; | ||
|
|
||
| static data read_from_file(const std::filesystem::path& file_path, const std::filesystem::path& zones_directory); | ||
ricab marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
| } // namespace multipass | ||
|
|
||
| #endif // MULTIPASS_BASE_AVAILABILITY_ZONE_MANAGER_H | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.