-
Notifications
You must be signed in to change notification settings - Fork 785
Expand file tree
/
Copy pathbase_image_host.cpp
More file actions
83 lines (71 loc) · 2.41 KB
/
base_image_host.cpp
File metadata and controls
83 lines (71 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* 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/>.
*
*/
#include <multipass/format.h>
#include <multipass/image_host/base_image_host.h>
#include <multipass/logging/log.h>
#include <multipass/platform.h>
namespace mp = multipass;
namespace mpl = multipass::logging;
namespace
{
constexpr auto category = "VMImageHost";
}
mp::BaseVMImageHost::BaseVMImageHost(URLDownloader* downloader) : url_downloader(downloader)
{
}
auto mp::BaseVMImageHost::info_for(const Query& query) const -> std::optional<VMImageInfo>
{
std::shared_lock lock{manifest_mutex};
return info_for_impl(query);
}
auto mp::BaseVMImageHost::all_info_for(const Query& query) const
-> std::vector<std::pair<std::string, VMImageInfo>>
{
std::shared_lock lock{manifest_mutex};
return all_info_for_impl(query);
}
auto mp::BaseVMImageHost::info_for_full_hash(const std::string& full_hash) const -> VMImageInfo
{
std::shared_lock lock{manifest_mutex};
return info_for_full_hash_impl(full_hash);
}
auto mp::BaseVMImageHost::all_images_for(const std::string& remote_name,
const bool allow_unsupported) const
-> std::vector<VMImageInfo>
{
std::shared_lock lock{manifest_mutex};
return all_images_for_impl(remote_name, allow_unsupported);
}
void mp::BaseVMImageHost::for_each_entry_do(const Action& action) const
{
std::shared_lock lock{manifest_mutex};
for_each_entry_do_impl(action);
}
void mp::BaseVMImageHost::update_manifests(const bool force_update)
{
std::lock_guard lock{manifest_mutex};
clear();
fetch_manifests(force_update);
}
void mp::BaseVMImageHost::on_manifest_empty(const std::string& details)
{
mpl::log_message(mpl::Level::info, category, details);
}
void mp::BaseVMImageHost::on_manifest_update_failure(const std::string& details)
{
mpl::warn(category, "Could not update manifest: {}", details);
}