foreman_snapshot_management 1.5.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +200 -2
- data/Rakefile +9 -2
- data/app/controllers/api/v2/snapshots_controller.rb +39 -7
- data/app/controllers/concerns/foreman/controller/parameters/snapshot.rb +2 -0
- data/app/controllers/foreman_snapshot_management/snapshots_controller.rb +10 -7
- data/app/helpers/concerns/foreman_snapshot_management/hosts_helper_extension.rb +2 -0
- data/app/helpers/foreman_snapshot_management/snapshot_helper.rb +2 -0
- data/app/models/concerns/fog_extensions/proxmox/snapshots/mock.rb +24 -0
- data/app/models/concerns/fog_extensions/vsphere/snapshots/mock.rb +2 -0
- data/app/models/concerns/fog_extensions/vsphere/snapshots/real.rb +4 -2
- data/app/models/foreman_snapshot_management/proxmox_extensions.rb +101 -0
- data/app/models/foreman_snapshot_management/snapshot.rb +36 -30
- data/app/models/foreman_snapshot_management/vmware_extensions.rb +42 -13
- data/app/views/api/v2/snapshots/base.json.rabl +4 -0
- data/app/views/api/v2/snapshots/create.json.rabl +2 -0
- data/app/views/api/v2/snapshots/destroy.json.rabl +2 -0
- data/app/views/api/v2/snapshots/index.json.rabl +2 -0
- data/app/views/api/v2/snapshots/main.json.rabl +4 -2
- data/app/views/api/v2/snapshots/revert.json.rabl +2 -0
- data/app/views/api/v2/snapshots/show.json.rabl +2 -0
- data/app/views/api/v2/snapshots/update.json.rabl +2 -0
- data/app/views/foreman_snapshot_management/snapshots/_index.html.erb +12 -74
- data/app/views/{foreman_snapshot_management/hosts/_snapshots_tab_content.html.erb → hosts/_snapshots_tab.html.erb} +8 -0
- data/config/routes.rb +2 -0
- data/lib/foreman_snapshot_management.rb +2 -0
- data/lib/foreman_snapshot_management/engine.rb +56 -17
- data/lib/foreman_snapshot_management/version.rb +3 -1
- data/lib/tasks/foreman_snapshot_management_tasks.rake +31 -10
- data/locale/de/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
- data/locale/de/foreman_snapshot_management.po +195 -0
- data/locale/en/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
- data/locale/en/foreman_snapshot_management.edit.po +0 -0
- data/locale/en/foreman_snapshot_management.po +179 -11
- data/locale/foreman_snapshot_management.pot +259 -8
- data/locale/gemspec.rb +3 -1
- data/package.json +46 -0
- data/test/controllers/api/v2/snapshots_test.rb +252 -39
- data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +63 -9
- data/test/factories/proxmox_factory.rb +18 -0
- data/test/test_plugin_helper.rb +5 -0
- data/webpack/components/SnapshotManagement/SnapshotManagement.js +84 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementActions.js +212 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementConstants.js +9 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementReducer.js +100 -0
- data/webpack/components/SnapshotManagement/SnapshotManagementSelectors.js +8 -0
- data/webpack/components/SnapshotManagement/__tests__/SnapshotManagementActions.test.js +123 -0
- data/webpack/components/SnapshotManagement/__tests__/SnapshotManagementReducer.test.js +157 -0
- data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementActions.test.js.snap +314 -0
- data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementReducer.test.js.snap +214 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +118 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormConstants.js +5 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js +26 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +476 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/index.js +19 -0
- data/webpack/components/SnapshotManagement/components/SnapshotForm/snapshotForm.scss +3 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js +37 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModalConstants.js +1 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js +19 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap +19 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/index.js +12 -0
- data/webpack/components/SnapshotManagement/components/SnapshotFormModal/useSnapshotFormModal.js +7 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js +314 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js +70 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js +88 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap +1081 -0
- data/webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss +13 -0
- data/webpack/components/SnapshotManagement/index.js +33 -0
- data/webpack/components/SnapshotManagement/snapshotManagement.scss +5 -0
- data/webpack/global_index.js +7 -0
- data/webpack/global_test_setup.js +11 -0
- data/webpack/index.js +8 -0
- data/webpack/reducers.js +7 -0
- data/webpack/test_setup.js +17 -0
- metadata +52 -54
- data/app/overrides/hosts/add_tab_to_host_overview.rb +0 -11
- data/app/views/foreman_snapshot_management/hosts/_snapshots_tab.html.erb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b21ddce3f89248da10faf11e3c9ed617c68b9500be5ef2f0a4557462e670912c
|
4
|
+
data.tar.gz: e345def34460802d4491dded6341ff0089c733cbeb1ce7b925e321f0c8be8caf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70868762e401d992c5aeeda419491ccbe294f57c20bd87c4eab30c9bb7299da128f6f50a8ab640fcf83058fd62018c1aecd851ccde34b372656fb72b40e3179e
|
7
|
+
data.tar.gz: 2542bb32f1efb8ba220b8a63342313e73994990336252529a5496dc3f95dd8e5c8e41da322042042b617bb8f46bd213141821d94ea1cbfc19fdbd0c7b3210de1
|
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
[![
|
1
|
+
[![React Testing](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/react.yml/badge.svg)](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/react.yml)
|
2
|
+
[![Ruby Testing](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/ruby.yml/badge.svg)](https://github.com/ATIX-AG/foreman_snapshot_management/actions/workflows/ruby.yml)
|
2
3
|
|
3
4
|
# ForemanSnapshotManagement
|
4
5
|
|
5
6
|
ForemanSnapshotManagement is a Foreman plugin to manage snapshots.
|
6
|
-
As Hypervisor
|
7
|
+
As Hypervisor the following systems are supported:
|
8
|
+
- VMware vSphere
|
9
|
+
- [Proxmox](https://www.proxmox.com/)
|
7
10
|
|
8
11
|
## Features
|
9
12
|
|
@@ -20,10 +23,205 @@ See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wi
|
|
20
23
|
|
21
24
|
| Foreman Version | Plugin Version |
|
22
25
|
| --------------- | -------------- |
|
26
|
+
| 2.3 | >= 2.0.0 |
|
27
|
+
| 1.24 | >= 1.7.0 |
|
28
|
+
| 1.23 | >= 1.7.0 |
|
29
|
+
| 1.22 | >= 1.6.0 |
|
30
|
+
| 1.21 | >= 1.5.0 |
|
31
|
+
| 1.20 | >= 1.5.0 |
|
23
32
|
| 1.19 | >= 1.5.0 |
|
24
33
|
| 1.18 | >= 1.5.0 |
|
25
34
|
| 1.17 | >= 1.5.0 |
|
26
35
|
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
You will get a new tab named "Snapshots" in the hosts page in Foreman.
|
39
|
+
|
40
|
+
Following rights are required to view snapshots:
|
41
|
+
|
42
|
+
- Snapshot Viewer
|
43
|
+
- Viewer
|
44
|
+
|
45
|
+
Following **additional** rights are required for creating, modifying, deleting and rollback:
|
46
|
+
|
47
|
+
- Snapshot Manger
|
48
|
+
- Site Manager
|
49
|
+
|
50
|
+
## API usage examples
|
51
|
+
|
52
|
+
Documentation for the api v2 endpoints provided by this Plugin can be found at `https://<your.foreman.installation>/apidoc/v2/snapshots.html`.
|
53
|
+
Some examples using `curl` and `jq` are given here.
|
54
|
+
|
55
|
+
The api user requires the same rights as a normal one.
|
56
|
+
|
57
|
+
### Environment
|
58
|
+
|
59
|
+
Environment variables used in this examples, edit to your needs.
|
60
|
+
|
61
|
+
```bash
|
62
|
+
FOREMAN="foreman.example.lan" # fqdn or ip to foreman
|
63
|
+
AUTH="snapper:mysupersecretpassword123" # foreman user
|
64
|
+
HOST="vm001.example.lan" # the servers name or id
|
65
|
+
```
|
66
|
+
|
67
|
+
### List all snapshots
|
68
|
+
|
69
|
+
```bash
|
70
|
+
curl -s -u "$AUTH" \
|
71
|
+
-H 'Accept: application/json' \
|
72
|
+
"https://${FOREMAN}/api/v2/hosts/${HOST}/snapshots" \
|
73
|
+
| jq
|
74
|
+
```
|
75
|
+
|
76
|
+
```json
|
77
|
+
{
|
78
|
+
"total": 2,
|
79
|
+
"subtotal": 2,
|
80
|
+
"page": 1,
|
81
|
+
"per_page": 30,
|
82
|
+
"search": null,
|
83
|
+
"sort": {
|
84
|
+
"by": null,
|
85
|
+
"order": null
|
86
|
+
},
|
87
|
+
"results": [
|
88
|
+
{
|
89
|
+
"description": "",
|
90
|
+
"id": "snapshot-646",
|
91
|
+
"name": "clean",
|
92
|
+
"created_at": "2018-10-08 08:07:30 UTC",
|
93
|
+
"parent_id": null,
|
94
|
+
"children_ids": [
|
95
|
+
"snapshot-658"
|
96
|
+
]
|
97
|
+
},
|
98
|
+
{
|
99
|
+
"description": "test",
|
100
|
+
"id": "snapshot-658",
|
101
|
+
"name": "test",
|
102
|
+
"created_at": "2018-10-18 09:50:03 UTC",
|
103
|
+
"parent_id": null,
|
104
|
+
"children_ids": []
|
105
|
+
}
|
106
|
+
]
|
107
|
+
}
|
108
|
+
```
|
109
|
+
|
110
|
+
### Show a snapshot
|
111
|
+
|
112
|
+
```bash
|
113
|
+
curl -s -u "$AUTH" \
|
114
|
+
-H 'Accept: application/json' \
|
115
|
+
"https://${FOREMAN}/api/v2/hosts/${HOST}/snapshots/${SNAP_ID}" \
|
116
|
+
| jq
|
117
|
+
```
|
118
|
+
|
119
|
+
```json
|
120
|
+
{
|
121
|
+
"description": "test",
|
122
|
+
"id": "snapshot-658",
|
123
|
+
"name": "test",
|
124
|
+
"created_at": "2018-10-18 09:50:03 UTC",
|
125
|
+
"parent_id": null,
|
126
|
+
"children_ids": []
|
127
|
+
}
|
128
|
+
```
|
129
|
+
|
130
|
+
### Create a snapshot
|
131
|
+
|
132
|
+
```bash
|
133
|
+
curl -s -u "$AUTH" \
|
134
|
+
-X POST \
|
135
|
+
-H 'Accept: application/json' \
|
136
|
+
-H 'Content-Type: application/json' \
|
137
|
+
--data "{ \"name\": \"${SNAP_NAME}\", \"description\": \"${DESCRIPTION}\" }" \
|
138
|
+
"https://${FOREMAN}/api/v2/hosts/${HOST}/snapshots" \
|
139
|
+
| jq
|
140
|
+
```
|
141
|
+
|
142
|
+
```json
|
143
|
+
{
|
144
|
+
"description": "A wonderful snapshot.",
|
145
|
+
"id": null,
|
146
|
+
"name": "wonderful",
|
147
|
+
"created_at": null,
|
148
|
+
"parent_id": null,
|
149
|
+
"children_ids": []
|
150
|
+
}
|
151
|
+
```
|
152
|
+
|
153
|
+
### Delete a snashot
|
154
|
+
|
155
|
+
```bash
|
156
|
+
curl -s -u "$AUTH" \
|
157
|
+
-X DELETE \
|
158
|
+
-H 'Accept: application/json' \
|
159
|
+
-H 'Content-Type: application/json' \
|
160
|
+
"https://${FOREMAN}/api/v2/hosts/${HOST}/snapshots/${SNAP_ID}" \
|
161
|
+
| jq
|
162
|
+
```
|
163
|
+
|
164
|
+
```json
|
165
|
+
{
|
166
|
+
"description": "A wonderful snapshot.",
|
167
|
+
"id": null,
|
168
|
+
"name": "wonderful",
|
169
|
+
"created_at": "2018-10-19 07:03:37 UTC",
|
170
|
+
"parent_id": null,
|
171
|
+
"children_ids": []
|
172
|
+
}
|
173
|
+
```
|
174
|
+
|
175
|
+
### Update a snapshot
|
176
|
+
|
177
|
+
This updates only name and description, not the data.
|
178
|
+
|
179
|
+
```bash
|
180
|
+
curl -s -u "$AUTH" \
|
181
|
+
-X PUT \
|
182
|
+
-H 'Accept: application/json' \
|
183
|
+
-H 'Content-Type: application/json' \
|
184
|
+
--data "{ \"name\": \"${SNAP_NAME}\", \"description\": \"${DESCRIPTION}\" }" \
|
185
|
+
"https://${FOREMAN}/api/v2/hosts/${HOST}/snapshots/${SNAP_ID}" \
|
186
|
+
| jq
|
187
|
+
```
|
188
|
+
|
189
|
+
```json
|
190
|
+
{
|
191
|
+
"description": "An exceptional snapshot.",
|
192
|
+
"id": "snapshot-666",
|
193
|
+
"name": "exceptional",
|
194
|
+
"created_at": "2018-10-19 07:11:24 UTC",
|
195
|
+
"parent_id": null,
|
196
|
+
"children_ids": []
|
197
|
+
}
|
198
|
+
```
|
199
|
+
|
200
|
+
### Revert a snapshot
|
201
|
+
|
202
|
+
This request will block until the snapshot is reverted. Make sure to check your timeouts.
|
203
|
+
|
204
|
+
```bash
|
205
|
+
curl -s -u "$AUTH" \
|
206
|
+
--max-time 600 \
|
207
|
+
-X PUT \
|
208
|
+
-H 'Content-Type: application/json' \
|
209
|
+
-H 'Accept: application/json' \
|
210
|
+
"https://${FOREMAN}/api/v2/hosts/${HOST}/snapshots/${SNAP_ID}/revert" \
|
211
|
+
| jq
|
212
|
+
```
|
213
|
+
|
214
|
+
```json
|
215
|
+
{
|
216
|
+
"description": "test",
|
217
|
+
"id": "snapshot-658",
|
218
|
+
"name": "test",
|
219
|
+
"created_at": "2018-10-18 09:50:03 UTC",
|
220
|
+
"parent_id": null,
|
221
|
+
"children_ids": []
|
222
|
+
}
|
223
|
+
```
|
224
|
+
|
27
225
|
## Contributing
|
28
226
|
|
29
227
|
Fork and send a Pull Request. Thanks!
|
data/Rakefile
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
begin
|
3
5
|
require 'bundler/setup'
|
4
6
|
rescue LoadError
|
@@ -12,6 +14,13 @@ rescue LoadError
|
|
12
14
|
RDoc::Task = Rake::RDocTask
|
13
15
|
end
|
14
16
|
|
17
|
+
begin
|
18
|
+
require 'rubocop/rake_task'
|
19
|
+
RuboCop::RakeTask.new
|
20
|
+
rescue StandardError => _e
|
21
|
+
puts 'Rubocop not loaded.'
|
22
|
+
end
|
23
|
+
|
15
24
|
RDoc::Task.new(:rdoc) do |rdoc|
|
16
25
|
rdoc.rdoc_dir = 'rdoc'
|
17
26
|
rdoc.title = 'ForemanSnapshotManagement'
|
@@ -20,6 +29,4 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
20
29
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
30
|
end
|
22
31
|
|
23
|
-
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
24
|
-
|
25
32
|
Bundler::GemHelper.install_tasks
|
@@ -1,17 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Api
|
2
4
|
module V2
|
3
5
|
class SnapshotsController < V2::BaseController
|
4
6
|
include Api::Version2
|
5
7
|
include Foreman::Controller::Parameters::Snapshot
|
6
8
|
|
7
|
-
before_action :
|
9
|
+
before_action :find_host
|
8
10
|
before_action :check_snapshot_capability
|
9
11
|
before_action :find_resource, :only => %w[show update destroy revert]
|
10
12
|
|
11
13
|
api :GET, '/hosts/:host_id/snapshots', N_('List all snapshots')
|
12
14
|
param :host_id, :identifier_dottable, :required => true
|
15
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
16
|
+
meta :search => [{ :name => 'name', :type => 'string' }]
|
13
17
|
def index
|
14
|
-
|
18
|
+
if params[:search]
|
19
|
+
search = params[:search].match(/^\s*name\s*=\s*(\w+)\s*$/) || params[:search].match(/^\s*name\s*=\s*\"([^"]+)\"\s*$/)
|
20
|
+
raise "Field '#{params[:search]}' not recognized for searching!" unless search
|
21
|
+
|
22
|
+
snapshot = resource_class.find_for_host_by_name(@host, search[1])
|
23
|
+
@snapshots = if snapshot
|
24
|
+
[snapshot].paginate(paginate_options)
|
25
|
+
else
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
else
|
29
|
+
@snapshots = resource_scope_for_index
|
30
|
+
end
|
15
31
|
end
|
16
32
|
|
17
33
|
api :GET, '/hosts/:host_id/snapshots/:id', 'Show a snapshot'
|
@@ -33,7 +49,7 @@ module Api
|
|
33
49
|
param_group :snapshot, :as => :create
|
34
50
|
|
35
51
|
def create
|
36
|
-
@snapshot = resource_class.new(snapshot_params.to_h.merge(host: @
|
52
|
+
@snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge(include_ram: params[:include_ram]))
|
37
53
|
process_response @snapshot.create
|
38
54
|
end
|
39
55
|
|
@@ -43,7 +59,7 @@ module Api
|
|
43
59
|
param_group :snapshot
|
44
60
|
|
45
61
|
def update
|
46
|
-
process_response @snapshot.
|
62
|
+
process_response @snapshot.update(snapshot_params)
|
47
63
|
end
|
48
64
|
|
49
65
|
api :DELETE, '/hosts/:host_id/snapshots/:id', N_('Delete a snapshot')
|
@@ -64,9 +80,25 @@ module Api
|
|
64
80
|
|
65
81
|
private
|
66
82
|
|
83
|
+
# Find Host
|
84
|
+
#
|
85
|
+
# This method is responsible that methods of the controller know the current host.
|
86
|
+
def find_host
|
87
|
+
host_id = params[:host_id]
|
88
|
+
if host_id.blank?
|
89
|
+
not_found
|
90
|
+
return false
|
91
|
+
end
|
92
|
+
@host = Host.authorized("#{action_permission}_snapshots".to_sym, Host).friendly.find(host_id)
|
93
|
+
return @host if @host
|
94
|
+
|
95
|
+
not_found
|
96
|
+
false
|
97
|
+
end
|
98
|
+
|
67
99
|
def resource_scope(_options = {})
|
68
100
|
# TODO: Ask host for snapshots
|
69
|
-
@resource_scope ||= resource_class.all_for_host(@
|
101
|
+
@resource_scope ||= resource_class.all_for_host(@host)
|
70
102
|
end
|
71
103
|
|
72
104
|
def resource_scope_for_index
|
@@ -78,12 +110,12 @@ module Api
|
|
78
110
|
end
|
79
111
|
|
80
112
|
def find_resource
|
81
|
-
@snapshot = resource_class.find_for_host(@
|
113
|
+
@snapshot = resource_class.find_for_host(@host, params[:id])
|
82
114
|
not_found unless @snapshot
|
83
115
|
end
|
84
116
|
|
85
117
|
def check_snapshot_capability
|
86
|
-
not_found unless @
|
118
|
+
not_found unless @host.compute_resource&.capabilities&.include?(:snapshots)
|
87
119
|
end
|
88
120
|
|
89
121
|
def action_permission
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ForemanSnapshotManagement
|
2
4
|
class SnapshotsController < ApplicationController
|
3
5
|
include Foreman::Controller::ActionPermissionDsl
|
@@ -64,7 +66,7 @@ module ForemanSnapshotManagement
|
|
64
66
|
#
|
65
67
|
# This method renames a Snapshot from a given host.
|
66
68
|
def update
|
67
|
-
if @snapshot.
|
69
|
+
if @snapshot.update(snapshot_params)
|
68
70
|
render json: { name: @snapshot.name, description: @snapshot.description }
|
69
71
|
else
|
70
72
|
msg = _('Failed to update Snapshot: %s') % @snapshot.errors.full_messages.to_sentence
|
@@ -87,8 +89,8 @@ module ForemanSnapshotManagement
|
|
87
89
|
errors << [h.name, s.errors.full_messages.to_sentence]
|
88
90
|
end
|
89
91
|
end
|
90
|
-
error _('Error occurred while creating Snapshot for
|
91
|
-
if snapshots_created
|
92
|
+
error _('Error occurred while creating Snapshot for:%s') % "<br /><dl>#{errors.map { |e| "<dt>#{e[0]}</dt><dd>#{e[1]}</dd>" }.join('<br />')}</dl>" unless errors.empty?
|
93
|
+
if snapshots_created.positive?
|
92
94
|
msg = _('Created %{snapshots} for %{num} %{hosts}') % {
|
93
95
|
snapshots: n_('Snapshot', 'Snapshots', snapshots_created),
|
94
96
|
num: snapshots_created,
|
@@ -122,6 +124,7 @@ module ForemanSnapshotManagement
|
|
122
124
|
end
|
123
125
|
@host = Host.authorized("#{action_permission}_snapshots".to_sym, Host).friendly.find(host_id)
|
124
126
|
return @host if @host
|
127
|
+
|
125
128
|
not_found
|
126
129
|
false
|
127
130
|
end
|
@@ -140,10 +143,10 @@ module ForemanSnapshotManagement
|
|
140
143
|
end
|
141
144
|
|
142
145
|
@hosts
|
143
|
-
rescue StandardError =>
|
144
|
-
message = _('Something went wrong while selecting hosts - %s') %
|
146
|
+
rescue StandardError => e
|
147
|
+
message = _('Something went wrong while selecting hosts - %s') % e
|
145
148
|
error(message)
|
146
|
-
Foreman::Logging.exception(message,
|
149
|
+
Foreman::Logging.exception(message, e)
|
147
150
|
redirect_to hosts_path
|
148
151
|
false
|
149
152
|
end
|
@@ -168,7 +171,7 @@ module ForemanSnapshotManagement
|
|
168
171
|
end
|
169
172
|
|
170
173
|
def check_snapshot_capability
|
171
|
-
not_found unless @host.compute_resource
|
174
|
+
not_found unless @host.compute_resource&.capabilities&.include?(:snapshots)
|
172
175
|
end
|
173
176
|
|
174
177
|
def enumerate_snapshots
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module FogExtensions
|
4
|
+
module Proxmox
|
5
|
+
module Snapshots
|
6
|
+
module Mock
|
7
|
+
def status_task(_node, _upid)
|
8
|
+
{
|
9
|
+
'type' => 'qmsnapshot',
|
10
|
+
'starttime' => 1_580_720_848,
|
11
|
+
'pstart' => 1_864_464_143,
|
12
|
+
'node' => 'proxmox',
|
13
|
+
'upid' => 'UPID:proxmox:00003E13:6F21770F:5E37E2D0:qmsnapshot:100:root@pam:',
|
14
|
+
'user' => 'root@pam',
|
15
|
+
'exitstatus' => 'OK',
|
16
|
+
'status' => 'stopped',
|
17
|
+
'id' => '100',
|
18
|
+
'pid' => 15_891
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|