foreman_snapshot_management 1.6.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -2
- data/Rakefile +7 -2
- data/app/controllers/api/v2/snapshots_controller.rb +37 -7
- data/app/controllers/concerns/foreman/controller/parameters/snapshot.rb +1 -1
- data/app/controllers/foreman_snapshot_management/snapshots_controller.rb +5 -5
- data/app/models/concerns/fog_extensions/proxmox/snapshots/mock.rb +24 -0
- data/app/models/foreman_snapshot_management/proxmox_extensions.rb +101 -0
- data/app/models/foreman_snapshot_management/snapshot.rb +28 -28
- data/app/models/foreman_snapshot_management/vmware_extensions.rb +40 -13
- data/app/views/api/v2/snapshots/base.json.rabl +2 -0
- data/app/views/api/v2/snapshots/main.json.rabl +2 -2
- data/app/views/foreman_snapshot_management/snapshots/_index.html.erb +12 -74
- data/app/views/hosts/_snapshots_tab.html.erb +8 -0
- data/lib/foreman_snapshot_management/engine.rb +35 -16
- data/lib/foreman_snapshot_management/version.rb +1 -1
- data/lib/tasks/foreman_snapshot_management_tasks.rake +2 -2
- 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.po +179 -11
- data/locale/foreman_snapshot_management.pot +259 -8
- data/locale/gemspec.rb +1 -1
- data/package.json +46 -0
- data/test/controllers/api/v2/snapshots_test.rb +250 -39
- data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +61 -9
- data/test/factories/proxmox_factory.rb +18 -0
- data/test/test_plugin_helper.rb +3 -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 +50 -37
@@ -1,19 +1,270 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
# This file is distributed under the same license as foreman_snapshot_management.
|
1
|
+
# SOME DESCRIPTIVE TITLE.
|
2
|
+
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
3
|
+
# This file is distributed under the same license as the foreman_snapshot_management package.
|
4
|
+
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
|
4
5
|
#
|
5
6
|
#, fuzzy
|
6
7
|
msgid ""
|
7
8
|
msgstr ""
|
8
|
-
"Project-Id-Version:
|
9
|
+
"Project-Id-Version: foreman_snapshot_management 1.0.0\n"
|
9
10
|
"Report-Msgid-Bugs-To: \n"
|
10
|
-
"POT-Creation-Date:
|
11
|
-
"PO-Revision-Date:
|
12
|
-
"Last-Translator:
|
13
|
-
"Language-Team:
|
11
|
+
"POT-Creation-Date: 2021-05-07 09:44+0000\n"
|
12
|
+
"PO-Revision-Date: 2021-05-07 09:44+0000\n"
|
13
|
+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
14
|
+
"Language-Team: LANGUAGE <LL@li.org>\n"
|
14
15
|
"Language: \n"
|
15
16
|
"MIME-Version: 1.0\n"
|
16
17
|
"Content-Type: text/plain; charset=UTF-8\n"
|
17
18
|
"Content-Transfer-Encoding: 8bit\n"
|
18
19
|
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
|
19
20
|
|
21
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:13
|
22
|
+
msgid "List all snapshots"
|
23
|
+
msgstr ""
|
24
|
+
|
25
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:41
|
26
|
+
msgid "Name of this snapshot"
|
27
|
+
msgstr ""
|
28
|
+
|
29
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:42
|
30
|
+
msgid "Description of this snapshot"
|
31
|
+
msgstr ""
|
32
|
+
|
33
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:46
|
34
|
+
msgid "Create a snapshot"
|
35
|
+
msgstr ""
|
36
|
+
|
37
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:48
|
38
|
+
msgid "Whether to include the RAM state in the snapshot"
|
39
|
+
msgstr ""
|
40
|
+
|
41
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:56
|
42
|
+
msgid "Update a snapshot"
|
43
|
+
msgstr ""
|
44
|
+
|
45
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:65
|
46
|
+
msgid "Delete a snapshot"
|
47
|
+
msgstr ""
|
48
|
+
|
49
|
+
#: ../app/controllers/api/v2/snapshots_controller.rb:73
|
50
|
+
msgid "Revert Host to a snapshot"
|
51
|
+
msgstr ""
|
52
|
+
|
53
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:36
|
54
|
+
msgid "Error occurred while creating Snapshot: %s"
|
55
|
+
msgstr ""
|
56
|
+
|
57
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:48
|
58
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagementActions.js:81
|
59
|
+
msgid "Error occurred while removing Snapshot: %s"
|
60
|
+
msgstr ""
|
61
|
+
|
62
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:58
|
63
|
+
msgid "VM successfully rolled back."
|
64
|
+
msgstr ""
|
65
|
+
|
66
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:60
|
67
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagementActions.js:199
|
68
|
+
msgid "Error occurred while rolling back VM: %s"
|
69
|
+
msgstr ""
|
70
|
+
|
71
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:72
|
72
|
+
msgid "Failed to update Snapshot: %s"
|
73
|
+
msgstr ""
|
74
|
+
|
75
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:92
|
76
|
+
msgid "Error occurred while creating Snapshot for:%s"
|
77
|
+
msgstr ""
|
78
|
+
|
79
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:94
|
80
|
+
msgid "Created %{snapshots} for %{num} %{hosts}"
|
81
|
+
msgstr ""
|
82
|
+
|
83
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:95
|
84
|
+
#: ../app/models/foreman_snapshot_management/snapshot.rb:52
|
85
|
+
#: ../app/views/foreman_snapshot_management/snapshots/select_multiple_host.html.erb:8
|
86
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js:156
|
87
|
+
msgid "Snapshot"
|
88
|
+
msgid_plural "Snapshots"
|
89
|
+
msgstr[0] ""
|
90
|
+
msgstr[1] ""
|
91
|
+
|
92
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:97
|
93
|
+
msgid "host"
|
94
|
+
msgid_plural "hosts"
|
95
|
+
msgstr[0] ""
|
96
|
+
msgstr[1] ""
|
97
|
+
|
98
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:140
|
99
|
+
msgid "No hosts were found with that id, name or query filter"
|
100
|
+
msgstr ""
|
101
|
+
|
102
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:147
|
103
|
+
msgid "Something went wrong while selecting hosts - %s"
|
104
|
+
msgstr ""
|
105
|
+
|
106
|
+
#: ../app/controllers/foreman_snapshot_management/snapshots_controller.rb:166
|
107
|
+
msgid "No capable hosts found."
|
108
|
+
msgstr ""
|
109
|
+
|
110
|
+
#:
|
111
|
+
#: ../app/helpers/concerns/foreman_snapshot_management/hosts_helper_extension.rb:6
|
112
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagement.js:46
|
113
|
+
msgid "Create Snapshot"
|
114
|
+
msgstr ""
|
115
|
+
|
116
|
+
#: ../app/models/foreman_snapshot_management/proxmox_extensions.rb:15
|
117
|
+
msgid ""
|
118
|
+
"Name must contain at least 2 characters starting with alphabet. Valid characte"
|
119
|
+
"rs are A-Z a-z 0-9 _"
|
120
|
+
msgstr ""
|
121
|
+
|
122
|
+
#: ../app/models/foreman_snapshot_management/proxmox_extensions.rb:22
|
123
|
+
msgid "Unable to create Proxmox Snapshot"
|
124
|
+
msgstr ""
|
125
|
+
|
126
|
+
#: ../app/models/foreman_snapshot_management/proxmox_extensions.rb:32
|
127
|
+
msgid "Unable to remove Proxmox Snapshot"
|
128
|
+
msgstr ""
|
129
|
+
|
130
|
+
#: ../app/models/foreman_snapshot_management/proxmox_extensions.rb:42
|
131
|
+
msgid "Unable to revert Proxmox Snapshot"
|
132
|
+
msgstr ""
|
133
|
+
|
134
|
+
#: ../app/models/foreman_snapshot_management/proxmox_extensions.rb:49
|
135
|
+
msgid "Snapshot name cannot be changed"
|
136
|
+
msgstr ""
|
137
|
+
|
138
|
+
#: ../app/models/foreman_snapshot_management/proxmox_extensions.rb:55
|
139
|
+
msgid "Unable to update Proxmox Snapshot"
|
140
|
+
msgstr ""
|
141
|
+
|
142
|
+
#: ../app/models/foreman_snapshot_management/vmware_extensions.rb:18
|
143
|
+
msgid "Unable to create VMWare Snapshot"
|
144
|
+
msgstr ""
|
145
|
+
|
146
|
+
#: ../app/models/foreman_snapshot_management/vmware_extensions.rb:29
|
147
|
+
msgid "Unable to remove VMWare Snapshot"
|
148
|
+
msgstr ""
|
149
|
+
|
150
|
+
#: ../app/models/foreman_snapshot_management/vmware_extensions.rb:40
|
151
|
+
msgid "Unable to revert VMWare Snapshot"
|
152
|
+
msgstr ""
|
153
|
+
|
154
|
+
#: ../app/models/foreman_snapshot_management/vmware_extensions.rb:51
|
155
|
+
msgid "Unable to update VMWare Snapshot"
|
156
|
+
msgstr ""
|
157
|
+
|
158
|
+
#:
|
159
|
+
#: ../app/views/foreman_snapshot_management/snapshots/select_multiple_host.html.erb:4
|
160
|
+
msgid "No capable hosts selected"
|
161
|
+
msgstr ""
|
162
|
+
|
163
|
+
#:
|
164
|
+
#: ../app/views/foreman_snapshot_management/snapshots/select_multiple_host.html.erb:11
|
165
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js:75
|
166
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js:162
|
167
|
+
msgid "Description"
|
168
|
+
msgstr ""
|
169
|
+
|
170
|
+
#:
|
171
|
+
#: ../app/views/foreman_snapshot_management/snapshots/select_multiple_host.html.erb:14
|
172
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js:81
|
173
|
+
msgid "Include RAM"
|
174
|
+
msgstr ""
|
175
|
+
|
176
|
+
#: ../app/views/hosts/_snapshots_tab.html.erb:13
|
177
|
+
msgid "Loading Snapshots information ..."
|
178
|
+
msgstr ""
|
179
|
+
|
180
|
+
#: ../lib/foreman_snapshot_management/engine.rb:64
|
181
|
+
msgid "Snapshots"
|
182
|
+
msgstr ""
|
183
|
+
|
184
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagementActions.js:60
|
185
|
+
msgid "Successfully removed Snapshot \"%s\" from host %s"
|
186
|
+
msgstr ""
|
187
|
+
|
188
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagementActions.js:126
|
189
|
+
msgid "Successfully updated Snapshot \"%s\""
|
190
|
+
msgstr ""
|
191
|
+
|
192
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagementActions.js:145
|
193
|
+
msgid "Error occurred while updating Snapshot: %s"
|
194
|
+
msgstr ""
|
195
|
+
|
196
|
+
#: ../webpack/components/SnapshotManagement/SnapshotManagementActions.js:180
|
197
|
+
msgid "Successfully rolled back Snapshot \"%s\" on host %s"
|
198
|
+
msgstr ""
|
199
|
+
|
200
|
+
#:
|
201
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js:52
|
202
|
+
msgid "Snapshot successfully created!"
|
203
|
+
msgstr ""
|
204
|
+
|
205
|
+
#:
|
206
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js:69
|
207
|
+
msgid "Name"
|
208
|
+
msgstr ""
|
209
|
+
|
210
|
+
#:
|
211
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js:14
|
212
|
+
msgid "Create Snapshot for %s"
|
213
|
+
msgstr ""
|
214
|
+
|
215
|
+
#:
|
216
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js:122
|
217
|
+
msgid "N/A"
|
218
|
+
msgstr ""
|
219
|
+
|
220
|
+
#:
|
221
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js:171
|
222
|
+
msgid "Action"
|
223
|
+
msgstr ""
|
224
|
+
|
225
|
+
#:
|
226
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js:203
|
227
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js:205
|
228
|
+
msgid "Failed to load snapshot list"
|
229
|
+
msgstr ""
|
230
|
+
|
231
|
+
#:
|
232
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js:28
|
233
|
+
msgid "edit entry"
|
234
|
+
msgstr ""
|
235
|
+
|
236
|
+
#:
|
237
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js:42
|
238
|
+
msgid "Rollback to \"%s\"?"
|
239
|
+
msgstr ""
|
240
|
+
|
241
|
+
#:
|
242
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js:46
|
243
|
+
msgid "Rollback"
|
244
|
+
msgstr ""
|
245
|
+
|
246
|
+
#:
|
247
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js:60
|
248
|
+
msgid "Delete Snapshot \"%s\"?"
|
249
|
+
msgstr ""
|
250
|
+
|
251
|
+
#:
|
252
|
+
#: ../webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js:64
|
253
|
+
msgid "Delete"
|
254
|
+
msgstr ""
|
255
|
+
|
256
|
+
#: action_names.rb:2
|
257
|
+
msgid "Import Puppet classes"
|
258
|
+
msgstr ""
|
259
|
+
|
260
|
+
#: action_names.rb:3
|
261
|
+
msgid "Import facts"
|
262
|
+
msgstr ""
|
263
|
+
|
264
|
+
#: action_names.rb:4
|
265
|
+
msgid "Action with sub plans"
|
266
|
+
msgstr ""
|
267
|
+
|
268
|
+
#: gemspec.rb:4
|
269
|
+
msgid "Foreman-plugin to manage snapshots in a virtual-hardware environments."
|
270
|
+
msgstr ""
|
data/locale/gemspec.rb
CHANGED
data/package.json
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
{
|
2
|
+
"name": "foreman_snapshot_management",
|
3
|
+
"version": "2.0.1",
|
4
|
+
"description": "Foreman-plugin to manage snapshots in a virtual-hardware environments.",
|
5
|
+
"main": "index.js",
|
6
|
+
"scripts": {
|
7
|
+
"lint": "tfm-lint --plugin -d /webpack",
|
8
|
+
"stylelint": "stylelint webpack/**/*.scss",
|
9
|
+
"test": "tfm-test --config jest.config.js",
|
10
|
+
"test:watch": "tfm-test --plugin --watchAll",
|
11
|
+
"test:current": "tfm-test --plugin --watch",
|
12
|
+
"publish-coverage": "tfm-publish-coverage",
|
13
|
+
"stories": "tfm-stories --plugin",
|
14
|
+
"stories:build": "tfm-build-stories --plugin",
|
15
|
+
"create-react-component": "yo react-domain"
|
16
|
+
},
|
17
|
+
"repository": {
|
18
|
+
"type": "git",
|
19
|
+
"url": "git+https://github.com/ATIX-AG/foreman_snapshot_management.git"
|
20
|
+
},
|
21
|
+
"bugs": {
|
22
|
+
"url": "http://projects.theforeman.org/projects/foreman_snapshot_management/issues"
|
23
|
+
},
|
24
|
+
"peerDependencies": {
|
25
|
+
"@theforeman/vendor": ">= 4.0.0"
|
26
|
+
},
|
27
|
+
"dependencies": {
|
28
|
+
"react-intl": "^2.8.0"
|
29
|
+
},
|
30
|
+
"devDependencies": {
|
31
|
+
"@babel/core": "^7.7.0",
|
32
|
+
"@sheerun/mutationobserver-shim": "^0.3.3",
|
33
|
+
"@theforeman/builder": "^4.0.0",
|
34
|
+
"@theforeman/eslint-plugin-foreman": "6.0.0",
|
35
|
+
"@theforeman/find-foreman": "^4.8.0",
|
36
|
+
"@theforeman/stories": "^7.0.0",
|
37
|
+
"@theforeman/test": "^8.0.0",
|
38
|
+
"@theforeman/vendor-dev": "^4.0.0",
|
39
|
+
"babel-eslint": "^10.0.3",
|
40
|
+
"eslint": "^6.7.2",
|
41
|
+
"prettier": "^1.19.1",
|
42
|
+
"react-redux-test-utils": "^0.2.0",
|
43
|
+
"stylelint": "^9.3.0",
|
44
|
+
"stylelint-config-standard": "^18.0.0"
|
45
|
+
}
|
46
|
+
}
|
@@ -1,61 +1,272 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'test_plugin_helper'
|
4
4
|
|
5
5
|
class Api::V2::SnapshotsControllerTest < ActionController::TestCase
|
6
|
-
let(:tax_location) { Location.
|
7
|
-
let(:tax_organization) { Organization.
|
6
|
+
let(:tax_location) { Location.find_by(name: 'Location 1') }
|
7
|
+
let(:tax_organization) { Organization.find_by(name: 'Organization 1') }
|
8
8
|
let(:compute_resource) do
|
9
9
|
cr = FactoryBot.create(:compute_resource, :vmware, :uuid => 'Solutions', :locations => [tax_location], organizations: [tax_organization])
|
10
|
-
ComputeResource.
|
10
|
+
ComputeResource.find_by(id: cr.id)
|
11
11
|
end
|
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
|
+
let(:proxmox_compute_resource) do
|
16
|
+
cr = FactoryBot.create(:proxmox_cr)
|
17
|
+
ComputeResource.find_by(id: cr.id)
|
18
|
+
end
|
19
|
+
let(:vmid) { '100' }
|
20
|
+
let(:proxmox_host) { FactoryBot.create(:host, :managed, :compute_resource => proxmox_compute_resource, :uuid => "1_#{vmid}") }
|
21
|
+
let(:proxmox_snapshot) { 'snapshot1' }
|
22
|
+
let(:manager_user) do
|
23
|
+
roles = [Role.find_by(name: 'Snapshot Manager')]
|
24
|
+
FactoryBot.create(:user, :organizations => [tax_organization], :locations => [tax_location], :roles => roles)
|
25
|
+
end
|
26
|
+
let(:view_user) do
|
27
|
+
roles = [Role.find_by(name: 'Snapshot Viewer')]
|
28
|
+
FactoryBot.create(:user, :organizations => [tax_organization], :locations => [tax_location], :roles => roles)
|
29
|
+
end
|
15
30
|
setup { ::Fog.mock! }
|
16
31
|
teardown { ::Fog.unmock! }
|
17
32
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
33
|
+
context 'view user' do
|
34
|
+
setup do
|
35
|
+
# Make sure that test-hosts are created here (by the admin-user)
|
36
|
+
host
|
37
|
+
proxmox_host
|
38
|
+
@orig_user = User.current
|
39
|
+
User.current = view_user
|
40
|
+
end
|
41
|
+
teardown do
|
42
|
+
User.current = @orig_user
|
43
|
+
end
|
26
44
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
45
|
+
test 'should get index of Vmware Snapshots' do
|
46
|
+
get :index, params: { :host_id => host.to_param }
|
47
|
+
assert_response :success
|
48
|
+
assert_not_nil assigns(:snapshots)
|
49
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
50
|
+
assert_not_empty body
|
51
|
+
assert_not_empty body['results']
|
52
|
+
end
|
34
53
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
54
|
+
test 'should get index of Proxmox Snapshots' do
|
55
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
56
|
+
get :index, params: { :host_id => proxmox_host.to_param }
|
57
|
+
assert_response :success
|
58
|
+
assert_not_nil assigns(:snapshots)
|
59
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
60
|
+
assert_not_empty body
|
61
|
+
assert_not_empty body['results']
|
62
|
+
end
|
39
63
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
64
|
+
test 'should search VMware snapshot' do
|
65
|
+
get :index, params: { :host_id => host.to_param, :search => 'name= clean' }
|
66
|
+
assert_response :success
|
67
|
+
assert_not_nil assigns(:snapshots)
|
68
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
69
|
+
assert_not_empty body
|
70
|
+
assert_not_empty body['results']
|
71
|
+
assert_equal body['results'].count, 1
|
72
|
+
end
|
45
73
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
74
|
+
test 'should search Proxmox snapshot' do
|
75
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
76
|
+
get :index, params: { :host_id => proxmox_host.to_param, :search => 'name= snapshot1' }
|
77
|
+
assert_response :success
|
78
|
+
assert_not_nil assigns(:snapshots)
|
79
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
80
|
+
assert_not_empty body
|
81
|
+
assert_not_empty body['results']
|
82
|
+
assert_equal body['results'].count, 1
|
83
|
+
end
|
51
84
|
|
52
|
-
|
53
|
-
|
54
|
-
|
85
|
+
test 'should refute search Vmware snapshot' do
|
86
|
+
get :index, params: { :host_id => host.to_param, :search => 'name != clean' }
|
87
|
+
assert_response :internal_server_error
|
88
|
+
end
|
89
|
+
|
90
|
+
test 'should show Vmware snapshot' do
|
91
|
+
get :show, params: { :host_id => host.to_param, :id => snapshot_id }
|
92
|
+
assert_not_nil assigns(:snapshot)
|
93
|
+
assert_response :success
|
94
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
95
|
+
assert_not_empty body
|
96
|
+
end
|
97
|
+
|
98
|
+
test 'should show Proxmox snapshot' do
|
99
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
100
|
+
get :show, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot }
|
101
|
+
assert_not_nil assigns(:snapshot)
|
102
|
+
assert_response :success
|
103
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
104
|
+
assert_not_empty body
|
105
|
+
end
|
106
|
+
|
107
|
+
test 'should 404 for unknown Vmware snapshot' do
|
108
|
+
get :show, params: { :host_id => host.to_param, :id => 'does-not-exist' }
|
109
|
+
assert_response :not_found
|
110
|
+
end
|
111
|
+
|
112
|
+
test 'should refute create Vmware snapshot' do
|
113
|
+
post :create, params: { :host_id => host.to_param, :name => 'test' }
|
114
|
+
assert_response :forbidden
|
115
|
+
end
|
116
|
+
|
117
|
+
test 'should refute update Vmware snapshot' do
|
118
|
+
name = 'test'
|
119
|
+
put :update, params: { :host_id => host.to_param, :id => snapshot_id.to_param, :name => name.to_param }
|
120
|
+
assert_response :forbidden
|
121
|
+
end
|
122
|
+
|
123
|
+
test 'should refute destroy Vmware snapshot' do
|
124
|
+
delete :destroy, params: { :host_id => host.to_param, :id => snapshot_id.to_param }
|
125
|
+
assert_response :forbidden
|
126
|
+
end
|
127
|
+
|
128
|
+
test 'should refute revert Proxmox snapshot' do
|
129
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
130
|
+
put :revert, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param }
|
131
|
+
assert_response :forbidden
|
132
|
+
end
|
55
133
|
end
|
56
134
|
|
57
|
-
|
58
|
-
|
59
|
-
|
135
|
+
context 'manager user' do
|
136
|
+
setup do
|
137
|
+
# Make sure that test-hosts are created here (by the admin-user)
|
138
|
+
host
|
139
|
+
proxmox_host
|
140
|
+
@orig_user = User.current
|
141
|
+
User.current = manager_user
|
142
|
+
end
|
143
|
+
teardown do
|
144
|
+
User.current = @orig_user
|
145
|
+
end
|
146
|
+
|
147
|
+
test 'should get index of Vmware Snapshots' do
|
148
|
+
get :index, params: { :host_id => host.to_param }
|
149
|
+
assert_response :success
|
150
|
+
assert_not_nil assigns(:snapshots)
|
151
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
152
|
+
assert_not_empty body
|
153
|
+
assert_not_empty body['results']
|
154
|
+
end
|
155
|
+
|
156
|
+
test 'should get index of Proxmox Snapshots' do
|
157
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
158
|
+
get :index, params: { :host_id => proxmox_host.to_param }
|
159
|
+
assert_response :success
|
160
|
+
assert_not_nil assigns(:snapshots)
|
161
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
162
|
+
assert_not_empty body
|
163
|
+
assert_not_empty body['results']
|
164
|
+
end
|
165
|
+
|
166
|
+
test 'should search VMware snapshot' do
|
167
|
+
get :index, params: { :host_id => host.to_param, :search => 'name= clean' }
|
168
|
+
assert_response :success
|
169
|
+
assert_not_nil assigns(:snapshots)
|
170
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
171
|
+
assert_not_empty body
|
172
|
+
assert_not_empty body['results']
|
173
|
+
assert_equal body['results'].count, 1
|
174
|
+
end
|
175
|
+
|
176
|
+
test 'should search Proxmox snapshot' do
|
177
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
178
|
+
get :index, params: { :host_id => proxmox_host.to_param, :search => 'name= snapshot1' }
|
179
|
+
assert_response :success
|
180
|
+
assert_not_nil assigns(:snapshots)
|
181
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
182
|
+
assert_not_empty body
|
183
|
+
assert_not_empty body['results']
|
184
|
+
assert_equal body['results'].count, 1
|
185
|
+
end
|
186
|
+
|
187
|
+
test 'should refute search Vmware snapshot' do
|
188
|
+
get :index, params: { :host_id => host.to_param, :search => 'name != clean' }
|
189
|
+
assert_response :internal_server_error
|
190
|
+
end
|
191
|
+
|
192
|
+
test 'should show Vmware snapshot' do
|
193
|
+
get :show, params: { :host_id => host.to_param, :id => snapshot_id }
|
194
|
+
assert_not_nil assigns(:snapshot)
|
195
|
+
assert_response :success
|
196
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
197
|
+
assert_not_empty body
|
198
|
+
end
|
199
|
+
|
200
|
+
test 'should show Proxmox snapshot' do
|
201
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
202
|
+
get :show, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot }
|
203
|
+
assert_not_nil assigns(:snapshot)
|
204
|
+
assert_response :success
|
205
|
+
body = ActiveSupport::JSON.decode(@response.body)
|
206
|
+
assert_not_empty body
|
207
|
+
end
|
208
|
+
|
209
|
+
test 'should 404 for unknown Vmware snapshot' do
|
210
|
+
get :show, params: { :host_id => host.to_param, :id => 'does-not-exist' }
|
211
|
+
assert_response :not_found
|
212
|
+
end
|
213
|
+
|
214
|
+
test 'should create Vmware snapshot' do
|
215
|
+
post :create, params: { :host_id => host.to_param, :name => 'test' }
|
216
|
+
assert_response :created
|
217
|
+
assert_not_nil assigns(:snapshot)
|
218
|
+
end
|
219
|
+
|
220
|
+
test 'should create Proxmox snapshot' do
|
221
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
222
|
+
post :create, params: { :host_id => proxmox_host.to_param, :name => 'test' }
|
223
|
+
assert_response :created
|
224
|
+
assert_not_nil assigns(:snapshot)
|
225
|
+
end
|
226
|
+
|
227
|
+
test 'should update Vmware snapshot' do
|
228
|
+
name = 'test'
|
229
|
+
put :update, params: { :host_id => host.to_param, :id => snapshot_id.to_param, :name => name.to_param }
|
230
|
+
assert_response :success
|
231
|
+
end
|
232
|
+
|
233
|
+
test 'should update Proxmox snapshot' do
|
234
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
235
|
+
description = 'snapshot1 updated'
|
236
|
+
put :update, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param, :description => description.to_param }
|
237
|
+
assert_response :success
|
238
|
+
end
|
239
|
+
|
240
|
+
test 'should refute update Proxmox snapshot name' do
|
241
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
242
|
+
name = 'test'
|
243
|
+
put :update, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param, :name => name.to_param }
|
244
|
+
assert_response :unprocessable_entity
|
245
|
+
end
|
246
|
+
|
247
|
+
test 'should destroy Vmware snapshot' do
|
248
|
+
delete :destroy, params: { :host_id => host.to_param, :id => snapshot_id.to_param }
|
249
|
+
assert_response :success
|
250
|
+
end
|
251
|
+
|
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
|
+
test 'should revert Vmware snapshot' do
|
262
|
+
put :revert, params: { :host_id => host.to_param, :id => snapshot_id.to_param }
|
263
|
+
assert_response :success
|
264
|
+
end
|
265
|
+
|
266
|
+
test 'should revert Proxmox snapshot' do
|
267
|
+
Host::Managed.any_instance.stubs(:vm_exists?).returns(false)
|
268
|
+
put :revert, params: { :host_id => proxmox_host.to_param, :id => proxmox_snapshot.to_param }
|
269
|
+
assert_response :success
|
270
|
+
end
|
60
271
|
end
|
61
272
|
end
|