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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +200 -2
  3. data/Rakefile +9 -2
  4. data/app/controllers/api/v2/snapshots_controller.rb +39 -7
  5. data/app/controllers/concerns/foreman/controller/parameters/snapshot.rb +2 -0
  6. data/app/controllers/foreman_snapshot_management/snapshots_controller.rb +10 -7
  7. data/app/helpers/concerns/foreman_snapshot_management/hosts_helper_extension.rb +2 -0
  8. data/app/helpers/foreman_snapshot_management/snapshot_helper.rb +2 -0
  9. data/app/models/concerns/fog_extensions/proxmox/snapshots/mock.rb +24 -0
  10. data/app/models/concerns/fog_extensions/vsphere/snapshots/mock.rb +2 -0
  11. data/app/models/concerns/fog_extensions/vsphere/snapshots/real.rb +4 -2
  12. data/app/models/foreman_snapshot_management/proxmox_extensions.rb +101 -0
  13. data/app/models/foreman_snapshot_management/snapshot.rb +36 -30
  14. data/app/models/foreman_snapshot_management/vmware_extensions.rb +42 -13
  15. data/app/views/api/v2/snapshots/base.json.rabl +4 -0
  16. data/app/views/api/v2/snapshots/create.json.rabl +2 -0
  17. data/app/views/api/v2/snapshots/destroy.json.rabl +2 -0
  18. data/app/views/api/v2/snapshots/index.json.rabl +2 -0
  19. data/app/views/api/v2/snapshots/main.json.rabl +4 -2
  20. data/app/views/api/v2/snapshots/revert.json.rabl +2 -0
  21. data/app/views/api/v2/snapshots/show.json.rabl +2 -0
  22. data/app/views/api/v2/snapshots/update.json.rabl +2 -0
  23. data/app/views/foreman_snapshot_management/snapshots/_index.html.erb +12 -74
  24. data/app/views/{foreman_snapshot_management/hosts/_snapshots_tab_content.html.erb → hosts/_snapshots_tab.html.erb} +8 -0
  25. data/config/routes.rb +2 -0
  26. data/lib/foreman_snapshot_management.rb +2 -0
  27. data/lib/foreman_snapshot_management/engine.rb +56 -17
  28. data/lib/foreman_snapshot_management/version.rb +3 -1
  29. data/lib/tasks/foreman_snapshot_management_tasks.rake +31 -10
  30. data/locale/de/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  31. data/locale/de/foreman_snapshot_management.po +195 -0
  32. data/locale/en/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  33. data/locale/en/foreman_snapshot_management.edit.po +0 -0
  34. data/locale/en/foreman_snapshot_management.po +179 -11
  35. data/locale/foreman_snapshot_management.pot +259 -8
  36. data/locale/gemspec.rb +3 -1
  37. data/package.json +46 -0
  38. data/test/controllers/api/v2/snapshots_test.rb +252 -39
  39. data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +63 -9
  40. data/test/factories/proxmox_factory.rb +18 -0
  41. data/test/test_plugin_helper.rb +5 -0
  42. data/webpack/components/SnapshotManagement/SnapshotManagement.js +84 -0
  43. data/webpack/components/SnapshotManagement/SnapshotManagementActions.js +212 -0
  44. data/webpack/components/SnapshotManagement/SnapshotManagementConstants.js +9 -0
  45. data/webpack/components/SnapshotManagement/SnapshotManagementReducer.js +100 -0
  46. data/webpack/components/SnapshotManagement/SnapshotManagementSelectors.js +8 -0
  47. data/webpack/components/SnapshotManagement/__tests__/SnapshotManagementActions.test.js +123 -0
  48. data/webpack/components/SnapshotManagement/__tests__/SnapshotManagementReducer.test.js +157 -0
  49. data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementActions.test.js.snap +314 -0
  50. data/webpack/components/SnapshotManagement/__tests__/__snapshots__/SnapshotManagementReducer.test.js.snap +214 -0
  51. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +118 -0
  52. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotFormConstants.js +5 -0
  53. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/SnapshotForm.test.js +26 -0
  54. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +476 -0
  55. data/webpack/components/SnapshotManagement/components/SnapshotForm/index.js +19 -0
  56. data/webpack/components/SnapshotManagement/components/SnapshotForm/snapshotForm.scss +3 -0
  57. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModal.js +37 -0
  58. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/SnapshotFormModalConstants.js +1 -0
  59. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/SnapshotFormModal.test.js +19 -0
  60. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/__tests__/__snapshots__/SnapshotFormModal.test.js.snap +19 -0
  61. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/index.js +12 -0
  62. data/webpack/components/SnapshotManagement/components/SnapshotFormModal/useSnapshotFormModal.js +7 -0
  63. data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotList.js +314 -0
  64. data/webpack/components/SnapshotManagement/components/SnapshotList/SnapshotListHelper.js +70 -0
  65. data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/SnapshotList.test.js +88 -0
  66. data/webpack/components/SnapshotManagement/components/SnapshotList/__tests__/__snapshots__/SnapshotList.test.js.snap +1081 -0
  67. data/webpack/components/SnapshotManagement/components/SnapshotList/snapshotList.scss +13 -0
  68. data/webpack/components/SnapshotManagement/index.js +33 -0
  69. data/webpack/components/SnapshotManagement/snapshotManagement.scss +5 -0
  70. data/webpack/global_index.js +7 -0
  71. data/webpack/global_test_setup.js +11 -0
  72. data/webpack/index.js +8 -0
  73. data/webpack/reducers.js +7 -0
  74. data/webpack/test_setup.js +17 -0
  75. metadata +52 -54
  76. data/app/overrides/hosts/add_tab_to_host_overview.rb +0 -11
  77. data/app/views/foreman_snapshot_management/hosts/_snapshots_tab.html.erb +0 -3
@@ -0,0 +1,9 @@
1
+ export const SNAPSHOT_LIST = 'FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_LIST';
2
+ export const SNAPSHOT_LIST_URL = '/api/hosts/:host_id/snapshots/';
3
+ export const SNAPSHOT_DELETE = 'FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE';
4
+ export const SNAPSHOT_DELETE_URL = '/api/hosts/%s/snapshots/%s/';
5
+ export const SNAPSHOT_UPDATE = 'FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE';
6
+ export const SNAPSHOT_UPDATE_URL = '/api/hosts/%s/snapshots/%s/';
7
+ export const SNAPSHOT_ROLLBACK =
8
+ 'FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK';
9
+ export const SNAPSHOT_ROLLBACK_URL = '/api/hosts/%s/snapshots/%s/revert';
@@ -0,0 +1,100 @@
1
+ // This is an example for a generic redux's reducer
2
+ // Reducers should be registered to foreman-core
3
+ // For a further registration demonstration, have a look in `webpack/global_index.js`
4
+
5
+ import Immutable from 'seamless-immutable';
6
+ import { cloneDeep, findIndex } from 'lodash';
7
+
8
+ import { actionTypeGenerator } from 'foremanReact/redux/API';
9
+
10
+ import {
11
+ SNAPSHOT_LIST,
12
+ SNAPSHOT_DELETE,
13
+ SNAPSHOT_UPDATE,
14
+ SNAPSHOT_ROLLBACK,
15
+ } from './SnapshotManagementConstants';
16
+
17
+ export const initialState = Immutable({
18
+ isLoading: true,
19
+ isWorking: false,
20
+ hasError: false,
21
+ snapshots: [],
22
+ });
23
+
24
+ export default (state = initialState, action) => {
25
+ const { response } = action;
26
+
27
+ const listTypes = actionTypeGenerator(SNAPSHOT_LIST);
28
+ const deleteTypes = actionTypeGenerator(SNAPSHOT_DELETE);
29
+ const updateTypes = actionTypeGenerator(SNAPSHOT_UPDATE);
30
+ const rollbackTypes = actionTypeGenerator(SNAPSHOT_ROLLBACK);
31
+
32
+ switch (action.type) {
33
+ case 'SNAPSHOT_FORM_SUBMITTED':
34
+ return state.merge({
35
+ needsReload: true,
36
+ });
37
+ case listTypes.REQUEST:
38
+ return state.merge({
39
+ snapshots: [],
40
+ isLoading: true,
41
+ hasError: false,
42
+ needsReload: false,
43
+ });
44
+ case listTypes.SUCCESS:
45
+ return state.merge({
46
+ snapshots: response.results,
47
+ isLoading: false,
48
+ needsReload: false,
49
+ });
50
+ case listTypes.FAILURE:
51
+ return state.merge({
52
+ error: response,
53
+ hasError: true,
54
+ isLoading: false,
55
+ needsReload: false,
56
+ });
57
+ case deleteTypes.REQUEST:
58
+ return state.merge({
59
+ isWorking: true,
60
+ });
61
+ case deleteTypes.SUCCESS:
62
+ case deleteTypes.FAILURE:
63
+ return state.merge({
64
+ isWorking: false,
65
+ });
66
+ case updateTypes.REQUEST:
67
+ return state.merge({
68
+ isWorking: true,
69
+ });
70
+ case updateTypes.SUCCESS: {
71
+ const snapshots = cloneDeep(state.snapshots);
72
+ const index = findIndex(snapshots, { id: response.id });
73
+
74
+ snapshots[index].name = response.name;
75
+ snapshots[index].description = response.description;
76
+
77
+ return state.merge({
78
+ isWorking: false,
79
+ snapshots,
80
+ });
81
+ }
82
+ case updateTypes.FAILURE:
83
+ return state.merge({
84
+ isWorking: false,
85
+ });
86
+ case rollbackTypes.REQUEST:
87
+ return state.merge({
88
+ snapshots: state.snapshots,
89
+ isWorking: true,
90
+ });
91
+ case rollbackTypes.SUCCESS:
92
+ case rollbackTypes.FAILURE:
93
+ return state.merge({
94
+ snapshots: state.snapshots,
95
+ isWorking: false,
96
+ });
97
+ default:
98
+ return state;
99
+ }
100
+ };
@@ -0,0 +1,8 @@
1
+ const snapshotMgmt = state => state.foremanSnapshotManagement;
2
+
3
+ export const selectSnapshots = state => snapshotMgmt(state).snapshots;
4
+ export const selectIsLoading = state => snapshotMgmt(state).isLoading;
5
+ export const selectIsWorking = state => snapshotMgmt(state).isWorking;
6
+ export const selectHasError = state => snapshotMgmt(state).hasError;
7
+ export const selectError = state => snapshotMgmt(state).error;
8
+ export const selectNeedsReload = state => snapshotMgmt(state).needsReload;
@@ -0,0 +1,123 @@
1
+ import { testActionSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import { API } from 'foremanReact/redux/API';
3
+
4
+ import {
5
+ loadSnapshotList,
6
+ snapshotDeleteAction,
7
+ snapshotRollbackAction,
8
+ snapshotUpdateAction,
9
+ } from '../SnapshotManagementActions';
10
+
11
+ jest.mock('foremanReact/redux/API/API');
12
+
13
+ const successResponse = {
14
+ data: 'some-data',
15
+ };
16
+
17
+ const doLoadSnapshotList = (hostId, serverMock) => {
18
+ API.get.mockImplementation(serverMock);
19
+
20
+ return loadSnapshotList(hostId);
21
+ };
22
+
23
+ const doDeleteSnapshot = (host, rowData, serverMock) => {
24
+ API.delete.mockImplementation(serverMock);
25
+
26
+ return snapshotDeleteAction(host, rowData);
27
+ };
28
+
29
+ const doRollbackSnapshot = (host, rowData, serverMock) => {
30
+ API.put.mockImplementation(serverMock);
31
+
32
+ return snapshotRollbackAction(host, rowData);
33
+ };
34
+
35
+ const doUpdateSnapshot = (host, rowData, serverMock) => {
36
+ API.put.mockImplementation(serverMock);
37
+
38
+ return snapshotUpdateAction(host, rowData);
39
+ };
40
+
41
+ const listFixtures = {
42
+ 'should load snapshots and success': () =>
43
+ doLoadSnapshotList(42, async () => successResponse),
44
+
45
+ 'should load snapshots and fail': () =>
46
+ doLoadSnapshotList(42, async () => {
47
+ throw new Error('some-error');
48
+ }),
49
+ };
50
+
51
+ describe('Snapshot list actions', () =>
52
+ testActionSnapshotWithFixtures(listFixtures));
53
+
54
+ const deleteFixtures = {
55
+ 'should delete snapshot and success': () =>
56
+ doDeleteSnapshot(
57
+ { id: 42, name: 'deep.thought' },
58
+ { id: 'snapshot-0815', name: 'Savegame' },
59
+ async () => successResponse
60
+ ),
61
+
62
+ 'should load snapshots and fail': () =>
63
+ doDeleteSnapshot(
64
+ { id: 42, name: 'deep.thought' },
65
+ { id: 'snapshot-0815', name: 'Savegame' },
66
+ async () => {
67
+ throw new Error('some-error');
68
+ }
69
+ ),
70
+ };
71
+
72
+ describe('Snapshot snapshot-delete actions', () =>
73
+ testActionSnapshotWithFixtures(deleteFixtures));
74
+
75
+ const rollbackFixtures = {
76
+ 'should rollback snapshot and success': () =>
77
+ doRollbackSnapshot(
78
+ { id: 42, name: 'deep.thought' },
79
+ { id: 'snapshot-0815', name: 'Savegame' },
80
+ async () => successResponse
81
+ ),
82
+
83
+ 'should load snapshots and fail': () =>
84
+ doRollbackSnapshot(
85
+ { id: 42, name: 'deep.thought' },
86
+ { id: 'snapshot-0815', name: 'Savegame' },
87
+ async () => {
88
+ throw new Error('some-error');
89
+ }
90
+ ),
91
+ };
92
+
93
+ describe('Snapshot snapshot-rollback actions', () =>
94
+ testActionSnapshotWithFixtures(rollbackFixtures));
95
+
96
+ const updateFixtures = {
97
+ 'should update snapshot and success': () =>
98
+ doUpdateSnapshot(
99
+ { id: 42, name: 'deep.thought' },
100
+ {
101
+ id: 'snapshot-0815',
102
+ name: 'Savegame',
103
+ description: 'Saw the three headed monkey!',
104
+ },
105
+ async () => successResponse
106
+ ),
107
+
108
+ 'should load snapshots and fail': () =>
109
+ doUpdateSnapshot(
110
+ { id: 42, name: 'deep.thought' },
111
+ {
112
+ id: 'snapshot-0815',
113
+ name: 'Savegame',
114
+ description: 'Saw the three headed monkey!',
115
+ },
116
+ async () => {
117
+ throw new Error('some-error');
118
+ }
119
+ ),
120
+ };
121
+
122
+ describe('Snapshot snapshot-update actions', () =>
123
+ testActionSnapshotWithFixtures(updateFixtures));
@@ -0,0 +1,157 @@
1
+ import { testReducerSnapshotWithFixtures } from 'react-redux-test-utils';
2
+ import Immutable from 'seamless-immutable';
3
+
4
+ import { actionTypeGenerator } from 'foremanReact/redux/API';
5
+
6
+ import {
7
+ SNAPSHOT_LIST,
8
+ SNAPSHOT_DELETE,
9
+ SNAPSHOT_ROLLBACK,
10
+ SNAPSHOT_UPDATE,
11
+ } from '../SnapshotManagementConstants';
12
+ import reducer, { initialState } from '../SnapshotManagementReducer';
13
+
14
+ const listTypes = actionTypeGenerator(SNAPSHOT_LIST);
15
+ const deleteTypes = actionTypeGenerator(SNAPSHOT_DELETE);
16
+ const rollbackTypes = actionTypeGenerator(SNAPSHOT_ROLLBACK);
17
+ const updateTypes = actionTypeGenerator(SNAPSHOT_UPDATE);
18
+
19
+ const idleState = Immutable({
20
+ isLoading: false,
21
+ isWorking: false,
22
+ hasError: false,
23
+ snapshots: [
24
+ {
25
+ id: 'snapshot-15776',
26
+ name: 'test',
27
+ description: '123 testSnapshot',
28
+ created_at: '2021-01-19 15:03:47 UTC',
29
+ parent_id: null,
30
+ children_ids: null,
31
+ },
32
+ ],
33
+ });
34
+
35
+ const fixtures = {
36
+ 'should return initial state': {
37
+ state: initialState,
38
+ action: {
39
+ type: undefined,
40
+ payload: {},
41
+ },
42
+ },
43
+ 'should handle LIST_REQUEST': {
44
+ state: idleState,
45
+ action: {
46
+ type: listTypes.REQUEST,
47
+ // response: ,
48
+ },
49
+ },
50
+ 'should handle LIST_SUCCESS': {
51
+ state: idleState,
52
+ action: {
53
+ type: listTypes.SUCCESS,
54
+ payload: {},
55
+ response: {
56
+ results: [],
57
+ },
58
+ },
59
+ },
60
+ 'should handle LIST_FAILURE': {
61
+ state: idleState,
62
+ action: {
63
+ type: listTypes.FAILURE,
64
+ payload: {},
65
+ response: {
66
+ message: 'Something went wrong',
67
+ },
68
+ },
69
+ },
70
+ 'should handle ROLLBACK_REQUEST': {
71
+ state: idleState,
72
+ action: {
73
+ type: rollbackTypes.REQUEST,
74
+ // response: ,
75
+ },
76
+ },
77
+ 'should handle ROLLBACK_SUCCESS': {
78
+ state: idleState,
79
+ action: {
80
+ type: rollbackTypes.SUCCESS,
81
+ payload: {},
82
+ response: {
83
+ results: [],
84
+ },
85
+ },
86
+ },
87
+ 'should handle ROLLBACK_FAILURE': {
88
+ state: idleState,
89
+ action: {
90
+ type: rollbackTypes.FAILURE,
91
+ payload: {},
92
+ response: {
93
+ message: 'Something went wrong',
94
+ },
95
+ },
96
+ },
97
+ 'should handle DELETE_REQUEST': {
98
+ state: idleState,
99
+ action: {
100
+ type: deleteTypes.REQUEST,
101
+ // response: ,
102
+ },
103
+ },
104
+ 'should handle DELETE_SUCCESS': {
105
+ state: idleState,
106
+ action: {
107
+ type: deleteTypes.SUCCESS,
108
+ payload: {},
109
+ response: {
110
+ results: [],
111
+ },
112
+ },
113
+ },
114
+ 'should handle DELETE_FAILURE': {
115
+ state: idleState,
116
+ action: {
117
+ type: deleteTypes.FAILURE,
118
+ payload: {},
119
+ response: {
120
+ message: 'Something went wrong',
121
+ },
122
+ },
123
+ },
124
+ 'should handle UPDATE_REQUEST': {
125
+ state: idleState,
126
+ action: {
127
+ type: updateTypes.REQUEST,
128
+ // response: ,
129
+ },
130
+ },
131
+ 'should handle UPDATE_SUCCESS': {
132
+ state: idleState,
133
+ action: {
134
+ type: updateTypes.SUCCESS,
135
+ payload: {},
136
+ response: {
137
+ id: 'snapshot-15776',
138
+ name: 'test snapshot',
139
+ description: 'My most important snapshot.',
140
+ created_at: '2021-01-19 15:03:47 UTC',
141
+ },
142
+ },
143
+ },
144
+ 'should handle UPDATE_FAILURE': {
145
+ state: idleState,
146
+ action: {
147
+ type: updateTypes.FAILURE,
148
+ payload: {},
149
+ response: {
150
+ message: 'Something went wrong',
151
+ },
152
+ },
153
+ },
154
+ };
155
+
156
+ describe('SnapshotManagementReducer', () =>
157
+ testReducerSnapshotWithFixtures(reducer, fixtures));
@@ -0,0 +1,314 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Snapshot list actions should load snapshots and fail 1`] = `
4
+ Array [
5
+ Array [
6
+ Object {
7
+ "payload": Object {
8
+ "hostId": 42,
9
+ },
10
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_LIST_REQUEST",
11
+ },
12
+ ],
13
+ Array [
14
+ Object {
15
+ "payload": Object {
16
+ "hostId": 42,
17
+ },
18
+ "response": [Error: some-error],
19
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_LIST_FAILURE",
20
+ },
21
+ ],
22
+ ]
23
+ `;
24
+
25
+ exports[`Snapshot list actions should load snapshots and success 1`] = `
26
+ Array [
27
+ Array [
28
+ Object {
29
+ "payload": Object {
30
+ "hostId": 42,
31
+ },
32
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_LIST_REQUEST",
33
+ },
34
+ ],
35
+ Array [
36
+ Object {
37
+ "payload": Object {
38
+ "hostId": 42,
39
+ },
40
+ "response": "some-data",
41
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_LIST_SUCCESS",
42
+ },
43
+ ],
44
+ ]
45
+ `;
46
+
47
+ exports[`Snapshot snapshot-delete actions should delete snapshot and success 1`] = `
48
+ Array [
49
+ Array [
50
+ Object {
51
+ "payload": Object {
52
+ "host": Object {
53
+ "id": 42,
54
+ "name": "deep.thought",
55
+ },
56
+ "id": "snapshot-0815",
57
+ },
58
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_REQUEST",
59
+ },
60
+ ],
61
+ Array [
62
+ Object {
63
+ "payload": Object {
64
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_SUCCESS",
65
+ "message": Object {
66
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_SUCCESS",
67
+ "message": "Successfully removed Snapshot \\"Savegame\\" from host deep.thought",
68
+ "type": "success",
69
+ },
70
+ },
71
+ "type": "TOASTS_ADD",
72
+ },
73
+ ],
74
+ Array [
75
+ [Function],
76
+ ],
77
+ Array [
78
+ Object {
79
+ "payload": Object {
80
+ "host": Object {
81
+ "id": 42,
82
+ "name": "deep.thought",
83
+ },
84
+ "id": "snapshot-0815",
85
+ },
86
+ "response": "some-data",
87
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_SUCCESS",
88
+ },
89
+ ],
90
+ ]
91
+ `;
92
+
93
+ exports[`Snapshot snapshot-delete actions should load snapshots and fail 1`] = `
94
+ Array [
95
+ Array [
96
+ Object {
97
+ "payload": Object {
98
+ "host": Object {
99
+ "id": 42,
100
+ "name": "deep.thought",
101
+ },
102
+ "id": "snapshot-0815",
103
+ },
104
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_REQUEST",
105
+ },
106
+ ],
107
+ Array [
108
+ Object {
109
+ "payload": Object {
110
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_FAILURE",
111
+ "message": Object {
112
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_FAILURE",
113
+ "message": "Error occurred while removing Snapshot: Error: some-error",
114
+ "type": "error",
115
+ },
116
+ },
117
+ "type": "TOASTS_ADD",
118
+ },
119
+ ],
120
+ Array [
121
+ Object {
122
+ "payload": Object {
123
+ "host": Object {
124
+ "id": 42,
125
+ "name": "deep.thought",
126
+ },
127
+ "id": "snapshot-0815",
128
+ },
129
+ "response": [Error: some-error],
130
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_DELETE_FAILURE",
131
+ },
132
+ ],
133
+ ]
134
+ `;
135
+
136
+ exports[`Snapshot snapshot-rollback actions should load snapshots and fail 1`] = `
137
+ Array [
138
+ Array [
139
+ Object {
140
+ "payload": Object {
141
+ "host": Object {
142
+ "id": 42,
143
+ "name": "deep.thought",
144
+ },
145
+ "id": "snapshot-0815",
146
+ },
147
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_REQUEST",
148
+ },
149
+ ],
150
+ Array [
151
+ Object {
152
+ "payload": Object {
153
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_FAILURE",
154
+ "message": Object {
155
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_FAILURE",
156
+ "message": "Error occurred while rolling back VM: Error: some-error",
157
+ "type": "error",
158
+ },
159
+ },
160
+ "type": "TOASTS_ADD",
161
+ },
162
+ ],
163
+ Array [
164
+ Object {
165
+ "payload": Object {
166
+ "host": Object {
167
+ "id": 42,
168
+ "name": "deep.thought",
169
+ },
170
+ "id": "snapshot-0815",
171
+ },
172
+ "response": [Error: some-error],
173
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_FAILURE",
174
+ },
175
+ ],
176
+ ]
177
+ `;
178
+
179
+ exports[`Snapshot snapshot-rollback actions should rollback snapshot and success 1`] = `
180
+ Array [
181
+ Array [
182
+ Object {
183
+ "payload": Object {
184
+ "host": Object {
185
+ "id": 42,
186
+ "name": "deep.thought",
187
+ },
188
+ "id": "snapshot-0815",
189
+ },
190
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_REQUEST",
191
+ },
192
+ ],
193
+ Array [
194
+ Object {
195
+ "payload": Object {
196
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_SUCCESS",
197
+ "message": Object {
198
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_SUCCESS",
199
+ "message": "Successfully rolled back Snapshot \\"Savegame\\" on host deep.thought",
200
+ "type": "success",
201
+ },
202
+ },
203
+ "type": "TOASTS_ADD",
204
+ },
205
+ ],
206
+ Array [
207
+ Object {
208
+ "payload": Object {
209
+ "host": Object {
210
+ "id": 42,
211
+ "name": "deep.thought",
212
+ },
213
+ "id": "snapshot-0815",
214
+ },
215
+ "response": "some-data",
216
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_ROLLBACK_SUCCESS",
217
+ },
218
+ ],
219
+ ]
220
+ `;
221
+
222
+ exports[`Snapshot snapshot-update actions should load snapshots and fail 1`] = `
223
+ Array [
224
+ Array [
225
+ Object {
226
+ "payload": Object {
227
+ "host": Object {
228
+ "id": 42,
229
+ "name": "deep.thought",
230
+ },
231
+ "id": "snapshot-0815",
232
+ "snapshot": Object {
233
+ "description": "Saw the three headed monkey!",
234
+ "name": "Savegame",
235
+ },
236
+ },
237
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_REQUEST",
238
+ },
239
+ ],
240
+ Array [
241
+ Object {
242
+ "payload": Object {
243
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_FAILURE",
244
+ "message": Object {
245
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_FAILURE",
246
+ "message": "Error occurred while updating Snapshot: Error: some-error",
247
+ "type": "error",
248
+ },
249
+ },
250
+ "type": "TOASTS_ADD",
251
+ },
252
+ ],
253
+ Array [
254
+ Object {
255
+ "payload": Object {
256
+ "host": Object {
257
+ "id": 42,
258
+ "name": "deep.thought",
259
+ },
260
+ "id": "snapshot-0815",
261
+ },
262
+ "response": [Error: some-error],
263
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_FAILURE",
264
+ },
265
+ ],
266
+ ]
267
+ `;
268
+
269
+ exports[`Snapshot snapshot-update actions should update snapshot and success 1`] = `
270
+ Array [
271
+ Array [
272
+ Object {
273
+ "payload": Object {
274
+ "host": Object {
275
+ "id": 42,
276
+ "name": "deep.thought",
277
+ },
278
+ "id": "snapshot-0815",
279
+ "snapshot": Object {
280
+ "description": "Saw the three headed monkey!",
281
+ "name": "Savegame",
282
+ },
283
+ },
284
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_REQUEST",
285
+ },
286
+ ],
287
+ Array [
288
+ Object {
289
+ "payload": Object {
290
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_SUCCESS",
291
+ "message": Object {
292
+ "key": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_SUCCESS",
293
+ "message": "Successfully updated Snapshot \\"Savegame\\"",
294
+ "type": "success",
295
+ },
296
+ },
297
+ "type": "TOASTS_ADD",
298
+ },
299
+ ],
300
+ Array [
301
+ Object {
302
+ "payload": Object {
303
+ "host": Object {
304
+ "id": 42,
305
+ "name": "deep.thought",
306
+ },
307
+ "id": "snapshot-0815",
308
+ },
309
+ "response": "some-data",
310
+ "type": "FOREMAN_SNAPSHOT_MANAGEMENT_SNAPSHOT_UPDATE_SUCCESS",
311
+ },
312
+ ],
313
+ ]
314
+ `;