foreman_snapshot_management 2.0.1 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/controllers/api/v2/snapshots_controller.rb +1 -1
- data/lib/foreman_snapshot_management/version.rb +1 -1
- data/test/controllers/api/v2/snapshots_test.rb +113 -89
- data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +55 -39
- data/webpack/components/SnapshotManagement/SnapshotManagementActions.js +1 -1
- data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementActions.test.js.snap +12 -12
- data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +7 -6
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 682e7ff61a5f90d7c1e1a07c12d1d27dc40deafb6bbae57e842fcf906e15c30f
|
4
|
+
data.tar.gz: ddf453d479054de2f1f1b7efe78b24ae12977882482db989953125aea0488fd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b92836939d7d8c70f965fa1f1859895412ddc66a8e64a353b60b2fb8a8ad120a737ad39cd1d38ff91eb58f48e057bcee1572c9a00d4e4d988f9902df4bd2c2d7
|
7
|
+
data.tar.gz: 4a0b0488fb4e7642f065b04d15925faa4550dd669129aeb1c40e18bd0a7cbca6a014ab8c16551f2c3d61b13843e7ffe964fd28b60f258ce09baf6dd272455b86
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ module Api
|
|
49
49
|
param_group :snapshot, :as => :create
|
50
50
|
|
51
51
|
def create
|
52
|
-
@snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge(include_ram: params[:include_ram]))
|
52
|
+
@snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge(include_ram: Foreman::Cast.to_bool(params[:include_ram])))
|
53
53
|
process_response @snapshot.create
|
54
54
|
end
|
55
55
|
|
@@ -12,13 +12,17 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
12
12
|
let(:uuid) { '5032c8a5-9c5e-ba7a-3804-832a03e16381' }
|
13
13
|
let(:host) { FactoryBot.create(:host, :managed, :compute_resource => compute_resource, :uuid => uuid) }
|
14
14
|
let(:snapshot_id) { 'snapshot-0101' }
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
|
16
|
+
if defined?(TEST_PROXMOX)
|
17
|
+
let(:vmid) { '100' }
|
18
|
+
let(:proxmox_compute_resource) do
|
19
|
+
cr = FactoryBot.create(:proxmox_cr)
|
20
|
+
ComputeResource.find_by(id: cr.id)
|
21
|
+
end
|
22
|
+
let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => "1_#{vmid}") }
|
23
|
+
let(:proxmox_snapshot) { 'snapshot1' }
|
18
24
|
end
|
19
|
-
|
20
|
-
let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => "1_#{vmid}") }
|
21
|
-
let(:proxmox_snapshot) { 'snapshot1' }
|
25
|
+
|
22
26
|
let(:manager_user) do
|
23
27
|
roles = [Role.find_by(name: 'Snapshot Manager')]
|
24
28
|
FactoryBot.create(:user, :organizations => [tax_organization], :locations => [tax_location], :roles => roles)
|
@@ -34,7 +38,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
34
38
|
setup do
|
35
39
|
# Make sure that test-hosts are created here (by the admin-user)
|
36
40
|
host
|
37
|
-
proxmox_host
|
41
|
+
proxmox_host if defined?(TEST_PROXMOX)
|
38
42
|
@orig_user = User.current
|
39
43
|
User.current = view_user
|
40
44
|
end
|
@@ -51,14 +55,16 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
51
55
|
assert_not_empty body['results']
|
52
56
|
end
|
53
57
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
if defined?(TEST_PROXMOX)
|
59
|
+
test 'should get index of Proxmox Snapshots' do
|
60
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
61
|
+
get :index, params: { :host_id => proxmox_host.to_param }
|
62
|
+
assert_response :success
|
63
|
+
assert_not_nil assigns(:snapshots)
|
64
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
65
|
+
assert_not_empty body
|
66
|
+
assert_not_empty body['results']
|
67
|
+
end
|
62
68
|
end
|
63
69
|
|
64
70
|
test 'should search VMware snapshot' do
|
@@ -71,15 +77,17 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
71
77
|
assert_equal body['results'].count, 1
|
72
78
|
end
|
73
79
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
if defined?(TEST_PROXMOX)
|
81
|
+
test 'should search Proxmox snapshot' do
|
82
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
83
|
+
get :index, params: { :host_id => proxmox_host.to_param, :search => 'name= snapshot1' }
|
84
|
+
assert_response :success
|
85
|
+
assert_not_nil assigns(:snapshots)
|
86
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
87
|
+
assert_not_empty body
|
88
|
+
assert_not_empty body['results']
|
89
|
+
assert_equal body['results'].count, 1
|
90
|
+
end
|
83
91
|
end
|
84
92
|
|
85
93
|
test 'should refute search Vmware snapshot' do
|
@@ -95,13 +103,15 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
95
103
|
assert_not_empty body
|
96
104
|
end
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
106
|
+
if defined?(TEST_PROXMOX)
|
107
|
+
test 'should show Proxmox snapshot' do
|
108
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
109
|
+
get :show, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot }
|
110
|
+
assert_not_nil assigns(:snapshot)
|
111
|
+
assert_response :success
|
112
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
113
|
+
assert_not_empty body
|
114
|
+
end
|
105
115
|
end
|
106
116
|
|
107
117
|
test 'should 404 for unknown Vmware snapshot' do
|
@@ -125,10 +135,12 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
125
135
|
assert_response :forbidden
|
126
136
|
end
|
127
137
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
138
|
+
if defined?(TEST_PROXMOX)
|
139
|
+
test 'should refute revert Proxmox snapshot' do
|
140
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
141
|
+
put :revert, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param }
|
142
|
+
assert_response :forbidden
|
143
|
+
end
|
132
144
|
end
|
133
145
|
end
|
134
146
|
|
@@ -136,7 +148,7 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
136
148
|
setup do
|
137
149
|
# Make sure that test-hosts are created here (by the admin-user)
|
138
150
|
host
|
139
|
-
proxmox_host
|
151
|
+
proxmox_host if defined?(TEST_PROXMOX)
|
140
152
|
@orig_user = User.current
|
141
153
|
User.current = manager_user
|
142
154
|
end
|
@@ -153,14 +165,16 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
153
165
|
assert_not_empty body['results']
|
154
166
|
end
|
155
167
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
168
|
+
if defined?(TEST_PROXMOX)
|
169
|
+
test 'should get index of Proxmox Snapshots' do
|
170
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
171
|
+
get :index, params: { :host_id => proxmox_host.to_param }
|
172
|
+
assert_response :success
|
173
|
+
assert_not_nil assigns(:snapshots)
|
174
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
175
|
+
assert_not_empty body
|
176
|
+
assert_not_empty body['results']
|
177
|
+
end
|
164
178
|
end
|
165
179
|
|
166
180
|
test 'should search VMware snapshot' do
|
@@ -173,15 +187,17 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
173
187
|
assert_equal body['results'].count, 1
|
174
188
|
end
|
175
189
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
190
|
+
if defined?(TEST_PROXMOX)
|
191
|
+
test 'should search Proxmox snapshot' do
|
192
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
193
|
+
get :index, params: { :host_id => proxmox_host.to_param, :search => 'name= snapshot1' }
|
194
|
+
assert_response :success
|
195
|
+
assert_not_nil assigns(:snapshots)
|
196
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
197
|
+
assert_not_empty body
|
198
|
+
assert_not_empty body['results']
|
199
|
+
assert_equal body['results'].count, 1
|
200
|
+
end
|
185
201
|
end
|
186
202
|
|
187
203
|
test 'should refute search Vmware snapshot' do
|
@@ -197,13 +213,15 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
197
213
|
assert_not_empty body
|
198
214
|
end
|
199
215
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
216
|
+
if defined?(TEST_PROXMOX)
|
217
|
+
test 'should show Proxmox snapshot' do
|
218
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
219
|
+
get :show, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot }
|
220
|
+
assert_not_nil assigns(:snapshot)
|
221
|
+
assert_response :success
|
222
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
223
|
+
assert_not_empty body
|
224
|
+
end
|
207
225
|
end
|
208
226
|
|
209
227
|
test 'should 404 for unknown Vmware snapshot' do
|
@@ -217,11 +235,13 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
217
235
|
assert_not_nil assigns(:snapshot)
|
218
236
|
end
|
219
237
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
238
|
+
if defined?(TEST_PROXMOX)
|
239
|
+
test 'should create Proxmox snapshot' do
|
240
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
241
|
+
post :create, params: { :host_id => proxmox_host.to_param, :name => 'test' }
|
242
|
+
assert_response :created
|
243
|
+
assert_not_nil assigns(:snapshot)
|
244
|
+
end
|
225
245
|
end
|
226
246
|
|
227
247
|
test 'should update Vmware snapshot' do
|
@@ -230,18 +250,20 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
230
250
|
assert_response :success
|
231
251
|
end
|
232
252
|
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
253
|
+
if defined?(TEST_PROXMOX)
|
254
|
+
test 'should update Proxmox snapshot' do
|
255
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
256
|
+
description = 'snapshot1 updated'
|
257
|
+
put :update, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param, :description => description.to_param }
|
258
|
+
assert_response :success
|
259
|
+
end
|
239
260
|
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
261
|
+
test 'should refute update Proxmox snapshot name' do
|
262
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
263
|
+
name = 'test'
|
264
|
+
put :update, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param, :name => name.to_param }
|
265
|
+
assert_response :unprocessable_entity
|
266
|
+
end
|
245
267
|
end
|
246
268
|
|
247
269
|
test 'should destroy Vmware snapshot' do
|
@@ -249,24 +271,26 @@ class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
|
249
271
|
assert_response :success
|
250
272
|
end
|
251
273
|
|
252
|
-
test 'should destroy Proxmox snapshot' do
|
253
|
-
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
254
|
-
delete :destroy, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param }
|
255
|
-
assert_response :success
|
256
|
-
body = ActiveSupport::JSON.decode(@response.body)
|
257
|
-
assert_not_nil body['name']
|
258
|
-
assert_nil body['id']
|
259
|
-
end
|
260
|
-
|
261
274
|
test 'should revert Vmware snapshot' do
|
262
275
|
put :revert, params: { :host_id => host.to_param, :id => snapshot_id.to_param }
|
263
276
|
assert_response :success
|
264
277
|
end
|
265
278
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
279
|
+
if defined?(TEST_PROXMOX)
|
280
|
+
test 'should destroy Proxmox snapshot' do
|
281
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
282
|
+
delete :destroy, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param }
|
283
|
+
assert_response :success
|
284
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
285
|
+
assert_not_nil body['name']
|
286
|
+
assert_nil body['id']
|
287
|
+
end
|
288
|
+
|
289
|
+
test 'should revert Proxmox snapshot' do
|
290
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
291
|
+
put :revert, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param }
|
292
|
+
assert_response :success
|
293
|
+
end
|
270
294
|
end
|
271
295
|
end
|
272
296
|
end
|
@@ -15,13 +15,17 @@ module ForemanSnapshotManagement
|
|
15
15
|
let(:host) { FactoryBot.create(:host, :managed, :compute_resource => compute_resource, :uuid => uuid) }
|
16
16
|
let(:host2) { FactoryBot.create(:host, :managed, :compute_resource => compute_resource, :uuid => uuid2) }
|
17
17
|
let(:snapshot_id) { 'snapshot-0101' }
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
if defined?(TEST_PROXMOX)
|
20
|
+
let(:vmid) { '1_100' }
|
21
|
+
let(:proxmox_compute_resource) do
|
22
|
+
FactoryBot.create(:proxmox_cr)
|
23
|
+
ComputeResource.find_by(type: 'ForemanFogProxmox::Proxmox')
|
24
|
+
end
|
25
|
+
let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => vmid) }
|
26
|
+
let(:proxmox_snapshot) { 'snapshot1' }
|
21
27
|
end
|
22
|
-
|
23
|
-
let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => vmid) }
|
24
|
-
let(:proxmox_snapshot) { 'snapshot1' }
|
28
|
+
|
25
29
|
setup { ::Fog.mock! }
|
26
30
|
teardown { ::Fog.unmock! }
|
27
31
|
|
@@ -33,12 +37,14 @@ module ForemanSnapshotManagement
|
|
33
37
|
assert_template 'foreman_snapshot_management/snapshots/_index'
|
34
38
|
end
|
35
39
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
if defined?(TEST_PROXMOX)
|
41
|
+
test 'should get Proxmox index' do
|
42
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
43
|
+
get :index, params: { :host_id => proxmox_host.to_param }, session: set_session_user
|
44
|
+
assert_response :success
|
45
|
+
assert_not_nil assigns(:snapshots)
|
46
|
+
assert_template 'foreman_snapshot_management/snapshots/_index'
|
47
|
+
end
|
42
48
|
end
|
43
49
|
end
|
44
50
|
|
@@ -49,11 +55,13 @@ module ForemanSnapshotManagement
|
|
49
55
|
assert_includes flash[:notice] || flash[:success], 'Successfully created Snapshot.'
|
50
56
|
end
|
51
57
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
58
|
+
if defined?(TEST_PROXMOX)
|
59
|
+
test 'create valid proxmox snapshot' do
|
60
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
61
|
+
post :create, params: { :host_id => proxmox_host.to_param, :snapshot => { :name => 'test' } }, session: set_session_user
|
62
|
+
assert_redirected_to host_url(proxmox_host, :anchor => 'snapshots')
|
63
|
+
assert_includes flash[:notice] || flash[:success], 'Successfully created Snapshot.'
|
64
|
+
end
|
57
65
|
end
|
58
66
|
|
59
67
|
test 'create valid multiple' do
|
@@ -84,11 +92,13 @@ module ForemanSnapshotManagement
|
|
84
92
|
assert_includes flash[:notice] || flash[:success], 'Successfully deleted Snapshot.'
|
85
93
|
end
|
86
94
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
95
|
+
if defined?(TEST_PROXMOX)
|
96
|
+
test 'destroy successful' do
|
97
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
98
|
+
delete :destroy, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot }, session: set_session_user
|
99
|
+
assert_redirected_to host_url(proxmox_host, :anchor => 'snapshots')
|
100
|
+
assert_includes flash[:notice] || flash[:success], 'Successfully deleted Snapshot.'
|
101
|
+
end
|
92
102
|
end
|
93
103
|
|
94
104
|
test 'destroy with error' do
|
@@ -106,11 +116,13 @@ module ForemanSnapshotManagement
|
|
106
116
|
assert_includes flash[:notice] || flash[:success], 'VM successfully rolled back.'
|
107
117
|
end
|
108
118
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
119
|
+
if defined?(TEST_PROXMOX)
|
120
|
+
test 'revert successful proxmox snapshot' do
|
121
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
122
|
+
put :revert, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot }, session: set_session_user
|
123
|
+
assert_redirected_to host_url(proxmox_host, :anchor => 'snapshots')
|
124
|
+
assert_includes flash[:notice] || flash[:success], 'VM successfully rolled back.'
|
125
|
+
end
|
114
126
|
end
|
115
127
|
|
116
128
|
test 'revert with error' do
|
@@ -130,13 +142,15 @@ module ForemanSnapshotManagement
|
|
130
142
|
assert_equal(data, body)
|
131
143
|
end
|
132
144
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
145
|
+
if defined?(TEST_PROXMOX)
|
146
|
+
test 'update successful proxmox' do
|
147
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
148
|
+
data = { 'name' => 'snapshot1', 'description' => 'updated snapshot1' }
|
149
|
+
put :update, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot, :snapshot => data }, session: set_session_user
|
150
|
+
assert_response :success
|
151
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
152
|
+
assert_equal(data, body)
|
153
|
+
end
|
140
154
|
end
|
141
155
|
|
142
156
|
test 'update with error VMware snapshot' do
|
@@ -145,11 +159,13 @@ module ForemanSnapshotManagement
|
|
145
159
|
assert_response :unprocessable_entity
|
146
160
|
end
|
147
161
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
162
|
+
if defined?(TEST_PROXMOX)
|
163
|
+
test 'update with error proxmox snapshot' do
|
164
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
165
|
+
ForemanSnapshotManagement::Snapshot.any_instance.stubs(:save).returns(false)
|
166
|
+
put :update, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot, :snapshot => { :name => 'snapshot1', :description => 'fail' } }, session: set_session_user
|
167
|
+
assert_response :unprocessable_entity
|
168
|
+
end
|
153
169
|
end
|
154
170
|
end
|
155
171
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { API, actionTypeGenerator } from 'foremanReact/redux/API';
|
2
2
|
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
3
|
-
import { addToast } from 'foremanReact/
|
3
|
+
import { addToast } from 'foremanReact/components/ToastsList';
|
4
4
|
|
5
5
|
import {
|
6
6
|
SNAPSHOT_LIST,
|
@@ -62,13 +62,13 @@ Array [
|
|
62
62
|
Object {
|
63
63
|
"payload": Object {
|
64
64
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_SUCCESS",
|
65
|
-
"
|
65
|
+
"toast": Object {
|
66
66
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_SUCCESS",
|
67
67
|
"message": "Successfully removed Snapshot \\"Savegame\\" from host deep.thought",
|
68
68
|
"type": "success",
|
69
69
|
},
|
70
70
|
},
|
71
|
-
"type": "
|
71
|
+
"type": "toasts/addToast",
|
72
72
|
},
|
73
73
|
],
|
74
74
|
Array [
|
@@ -108,13 +108,13 @@ Array [
|
|
108
108
|
Object {
|
109
109
|
"payload": Object {
|
110
110
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_FAILURE",
|
111
|
-
"
|
111
|
+
"toast": Object {
|
112
112
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_FAILURE",
|
113
113
|
"message": "Error occurred while removing Snapshot: Error: some-error",
|
114
114
|
"type": "error",
|
115
115
|
},
|
116
116
|
},
|
117
|
-
"type": "
|
117
|
+
"type": "toasts/addToast",
|
118
118
|
},
|
119
119
|
],
|
120
120
|
Array [
|
@@ -151,13 +151,13 @@ Array [
|
|
151
151
|
Object {
|
152
152
|
"payload": Object {
|
153
153
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_FAILURE",
|
154
|
-
"
|
154
|
+
"toast": Object {
|
155
155
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_FAILURE",
|
156
156
|
"message": "Error occurred while rolling back VM: Error: some-error",
|
157
157
|
"type": "error",
|
158
158
|
},
|
159
159
|
},
|
160
|
-
"type": "
|
160
|
+
"type": "toasts/addToast",
|
161
161
|
},
|
162
162
|
],
|
163
163
|
Array [
|
@@ -194,13 +194,13 @@ Array [
|
|
194
194
|
Object {
|
195
195
|
"payload": Object {
|
196
196
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_SUCCESS",
|
197
|
-
"
|
197
|
+
"toast": Object {
|
198
198
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_SUCCESS",
|
199
199
|
"message": "Successfully rolled back Snapshot \\"Savegame\\" on host deep.thought",
|
200
200
|
"type": "success",
|
201
201
|
},
|
202
202
|
},
|
203
|
-
"type": "
|
203
|
+
"type": "toasts/addToast",
|
204
204
|
},
|
205
205
|
],
|
206
206
|
Array [
|
@@ -241,13 +241,13 @@ Array [
|
|
241
241
|
Object {
|
242
242
|
"payload": Object {
|
243
243
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_FAILURE",
|
244
|
-
"
|
244
|
+
"toast": Object {
|
245
245
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_FAILURE",
|
246
246
|
"message": "Error occurred while updating Snapshot: Error: some-error",
|
247
247
|
"type": "error",
|
248
248
|
},
|
249
249
|
},
|
250
|
-
"type": "
|
250
|
+
"type": "toasts/addToast",
|
251
251
|
},
|
252
252
|
],
|
253
253
|
Array [
|
@@ -288,13 +288,13 @@ Array [
|
|
288
288
|
Object {
|
289
289
|
"payload": Object {
|
290
290
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_SUCCESS",
|
291
|
-
"
|
291
|
+
"toast": Object {
|
292
292
|
"key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_SUCCESS",
|
293
293
|
"message": "Successfully updated Snapshot \\"Savegame\\"",
|
294
294
|
"type": "success",
|
295
295
|
},
|
296
296
|
},
|
297
|
-
"type": "
|
297
|
+
"type": "toasts/addToast",
|
298
298
|
},
|
299
299
|
],
|
300
300
|
Array [
|
@@ -18,6 +18,7 @@ const SnapshotForm = ({
|
|
18
18
|
capabilities,
|
19
19
|
...props
|
20
20
|
}) => {
|
21
|
+
const { setModalClosed } = props;
|
21
22
|
let nameValidation = Yup.string().max(80, 'Too Long!');
|
22
23
|
if (capabilities.limitSnapshotNameFormat)
|
23
24
|
nameValidation = nameValidation
|
@@ -36,7 +37,7 @@ const SnapshotForm = ({
|
|
36
37
|
includeRam: Yup.bool(),
|
37
38
|
});
|
38
39
|
|
39
|
-
const handleSubmit =
|
40
|
+
const handleSubmit = (values, actions) => {
|
40
41
|
const submitValues = {
|
41
42
|
include_ram: values.includeRam || false,
|
42
43
|
snapshot: {
|
@@ -45,22 +46,22 @@ const SnapshotForm = ({
|
|
45
46
|
},
|
46
47
|
};
|
47
48
|
|
48
|
-
|
49
|
+
submitForm({
|
49
50
|
item: 'Snapshot',
|
50
51
|
url: SNAPSHOT_CREATE_URL.replace(':hostId', hostId),
|
51
52
|
values: submitValues,
|
52
53
|
message: __('Snapshot successfully created!'),
|
54
|
+
successCallback: setModalClosed,
|
55
|
+
actions,
|
53
56
|
});
|
54
|
-
actions.setSubmitting(false);
|
55
|
-
props.setModalClosed();
|
56
57
|
};
|
57
58
|
|
58
59
|
return (
|
59
60
|
<ForemanForm
|
60
|
-
onSubmit={
|
61
|
+
onSubmit={handleSubmit}
|
61
62
|
initialValues={initialValues}
|
62
63
|
validationSchema={validationSchema}
|
63
|
-
onCancel={
|
64
|
+
onCancel={setModalClosed}
|
64
65
|
>
|
65
66
|
<TextField
|
66
67
|
name="name"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_snapshot_management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ATIX AG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Foreman-plugin to manage snapshots in a virtual-hardware environments.
|
14
14
|
email:
|
@@ -111,12 +111,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
|
-
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.7.6
|
115
116
|
signing_key:
|
116
117
|
specification_version: 4
|
117
118
|
summary: Snapshot Management for machines on virtualization-platforms
|
118
119
|
test_files:
|
119
|
-
- test/controllers/api/v2/snapshots_test.rb
|
120
|
-
- test/controllers/foreman_snapshot_management/snapshots_controller_test.rb
|
121
|
-
- test/test_plugin_helper.rb
|
122
120
|
- test/factories/proxmox_factory.rb
|
121
|
+
- test/test_plugin_helper.rb
|
122
|
+
- test/controllers/foreman_snapshot_management/snapshots_controller_test.rb
|
123
|
+
- test/controllers/api/v2/snapshots_test.rb
|