foreman_snapshot_management 2.0.2 → 3.0.0

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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -4
  3. data/Rakefile +1 -1
  4. data/app/assets/javascripts/foreman_snapshot_management/locale/cs_CZ/foreman_snapshot_management.js +203 -0
  5. data/app/assets/javascripts/foreman_snapshot_management/locale/de/foreman_snapshot_management.js +201 -0
  6. data/app/assets/javascripts/foreman_snapshot_management/locale/el/foreman_snapshot_management.js +201 -0
  7. data/app/assets/javascripts/foreman_snapshot_management/locale/en/foreman_snapshot_management.js +198 -0
  8. data/app/assets/javascripts/foreman_snapshot_management/locale/fr/foreman_snapshot_management.js +203 -0
  9. data/app/assets/javascripts/foreman_snapshot_management/locale/ja/foreman_snapshot_management.js +199 -0
  10. data/app/assets/javascripts/foreman_snapshot_management/locale/ka/foreman_snapshot_management.js +201 -0
  11. data/app/assets/javascripts/foreman_snapshot_management/locale/zh_CN/foreman_snapshot_management.js +199 -0
  12. data/app/controllers/api/v2/snapshots_controller.rb +7 -3
  13. data/app/controllers/concerns/foreman/controller/parameters/snapshot.rb +1 -1
  14. data/app/controllers/foreman_snapshot_management/snapshots_controller.rb +20 -4
  15. data/app/helpers/foreman_snapshot_management/hosts_helper.rb +16 -0
  16. data/app/models/concerns/fog_extensions/proxmox/snapshots/mock.rb +1 -1
  17. data/app/models/concerns/fog_extensions/vsphere/snapshots/mock.rb +2 -2
  18. data/app/models/concerns/fog_extensions/vsphere/snapshots/real.rb +1 -1
  19. data/app/models/foreman_snapshot_management/proxmox_extensions.rb +5 -4
  20. data/app/models/foreman_snapshot_management/snapshot.rb +10 -9
  21. data/app/models/foreman_snapshot_management/vmware_extensions.rb +13 -3
  22. data/app/views/foreman_snapshot_management/snapshots/_index.html.erb +2 -1
  23. data/app/views/foreman_snapshot_management/snapshots/select_multiple_host.html.erb +5 -3
  24. data/config/routes.rb +1 -1
  25. data/lib/foreman_snapshot_management/engine.rb +24 -29
  26. data/lib/foreman_snapshot_management/version.rb +1 -1
  27. data/lib/tasks/foreman_snapshot_management_tasks.rake +1 -1
  28. data/locale/Makefile +8 -5
  29. data/locale/cs_CZ/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  30. data/locale/cs_CZ/foreman_snapshot_management.po +203 -0
  31. data/locale/de/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  32. data/locale/de/foreman_snapshot_management.po +22 -14
  33. data/locale/el/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  34. data/locale/el/foreman_snapshot_management.po +198 -0
  35. data/locale/en/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  36. data/locale/en/foreman_snapshot_management.po +22 -13
  37. data/locale/foreman_snapshot_management.pot +56 -35
  38. data/locale/fr/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  39. data/locale/fr/foreman_snapshot_management.po +204 -0
  40. data/locale/ja/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  41. data/locale/ja/foreman_snapshot_management.po +197 -0
  42. data/locale/ka/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  43. data/locale/ka/foreman_snapshot_management.po +198 -0
  44. data/locale/zh_CN/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  45. data/locale/zh_CN/foreman_snapshot_management.po +199 -0
  46. data/package.json +4 -3
  47. data/test/controllers/api/v2/snapshots_test.rb +1 -1
  48. data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +18 -3
  49. data/webpack/components/SnapshotManagement/SnapshotManagement.js +2 -0
  50. data/webpack/components/SnapshotManagement/components/SnapshotForm/SnapshotForm.js +53 -11
  51. data/webpack/components/SnapshotManagement/components/SnapshotForm/__tests__/__snapshots__/SnapshotForm.test.js.snap +262 -24
  52. data/webpack/components/SnapshotManagementCard/SnapshotManagementCard.js +64 -0
  53. data/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js +54 -0
  54. data/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap +117 -0
  55. data/webpack/components/SnapshotManagementCard/index.js +1 -0
  56. data/webpack/global_index.js +13 -0
  57. metadata +33 -10
  58. data/app/helpers/concerns/foreman_snapshot_management/hosts_helper_extension.rb +0 -9
@@ -0,0 +1,201 @@
1
+ locales['foreman_snapshot_management'] = locales['foreman_snapshot_management'] || {}; locales['foreman_snapshot_management']['ka'] = {
2
+ "domain": "foreman_snapshot_management",
3
+ "locale_data": {
4
+ "foreman_snapshot_management": {
5
+ "": {
6
+ "Project-Id-Version": "foreman_snapshot_management 2.0.2",
7
+ "Report-Msgid-Bugs-To": "",
8
+ "PO-Revision-Date": "2019-10-22 11:54+0000",
9
+ "Last-Translator": "Temuri Doghonadze <temuri.doghonadze@gmail.com>, 2022",
10
+ "Language-Team": "Georgian (https://www.transifex.com/foreman/teams/114/ka/)",
11
+ "MIME-Version": "1.0",
12
+ "Content-Type": "text/plain; charset=UTF-8",
13
+ "Content-Transfer-Encoding": "8bit",
14
+ "Language": "ka",
15
+ "Plural-Forms": "nplurals=2; plural=(n!=1);",
16
+ "lang": "ka",
17
+ "domain": "foreman_snapshot_management",
18
+ "plural_forms": "nplurals=2; plural=(n!=1);"
19
+ },
20
+ "List all snapshots": [
21
+ "სწრაფი ასლების სია"
22
+ ],
23
+ "Name of this snapshot": [
24
+ "სწრაფი ასლის სახელი"
25
+ ],
26
+ "Description of this snapshot": [
27
+ "სწრაფი ასლის აღწერა"
28
+ ],
29
+ "Create a snapshot": [
30
+ "სწრაფი ასლის შექმნა"
31
+ ],
32
+ "Whether to include the RAM state in the snapshot": [
33
+ "სწრაფ ასლში ოპერატიული მეხსიერების მდგომარეობის შენახვა"
34
+ ],
35
+ "Whether to include the Quiesce state in the snapshot": [
36
+ "იქნება თუ არა ჩასმული სწრაფ ასლში Quiesce -ის მდგომარეობა"
37
+ ],
38
+ "Update a snapshot": [
39
+ "სწრაფი ასლის განახლება"
40
+ ],
41
+ "Delete a snapshot": [
42
+ "სწრაფი ასლის წაშლა"
43
+ ],
44
+ "Revert Host to a snapshot": [
45
+ "ჰოსტის სწრაფ ასლზე დაბრუნება"
46
+ ],
47
+ "Error occurred while creating Snapshot: %s": [
48
+ "სწრაფი ასლის შექმნის შეცდომა: %s"
49
+ ],
50
+ "Error occurred while removing Snapshot: %s": [
51
+ "სწრაფი ასლის წაშლის შეცდომა: %s"
52
+ ],
53
+ "VM successfully rolled back.": [
54
+ "ვმ-ი წარმატებით დაბრუნდა."
55
+ ],
56
+ "Error occurred while rolling back VM: %s": [
57
+ "შეცდომა ვმ-ს დაბრუნებისას: %s"
58
+ ],
59
+ "Failed to update Snapshot: %s": [
60
+ "სწრაფი ასლის განახლების შეცდომა"
61
+ ],
62
+ "Error occurred while creating Snapshot for:%s": [
63
+ "სწრაფი ასლის შექმნის შეცდომა: %s"
64
+ ],
65
+ "Created %{snapshots} for %{num} %{hosts}": [
66
+ "შექმნილია %{snapshots} %{num} %{hosts}-სთვის"
67
+ ],
68
+ "Snapshot": [
69
+ "სწრაფი ასლი",
70
+ "სწრაფი ასლები"
71
+ ],
72
+ "host": [
73
+ "ჰოსტი",
74
+ "ჰოსტი"
75
+ ],
76
+ "No hosts were found with that id, name or query filter": [
77
+ "მითითებული ID-ით, სახელით ან საძებნი სტრიქონით ჰოსტები ნაპოვნი არაა"
78
+ ],
79
+ "Something went wrong while selecting hosts - %s": [
80
+ "შეცდომა ჰოსტების მონიშვნისას - %s"
81
+ ],
82
+ "No capable hosts found.": [
83
+ "შესაძლებლობის მქონე ჰოსტები ნაპოვნი არაა."
84
+ ],
85
+ "Create Snapshot": [
86
+ "სწრაფი ასლის შექმნა"
87
+ ],
88
+ "Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _": [
89
+ "სახელი უნდა შეიცავდეს მინიმუმ 2 სიმბოლოს დაწყებული ასოებით. მისაღები სიმბოლოებია A-Z a-z 0-9 _"
90
+ ],
91
+ "Unable to create Proxmox Snapshot": [
92
+ "Proxmox-ის სწრაფი ასლის შექმნა შეუძლებელია"
93
+ ],
94
+ "Unable to remove Proxmox Snapshot": [
95
+ "Proxmox-ის სწრაფი ასლის წაშლა შეუძლებელია"
96
+ ],
97
+ "Unable to revert Proxmox Snapshot": [
98
+ "Proxmox-ის სწრაფი ასლის დაბრუნება შეუძლებელია"
99
+ ],
100
+ "Snapshot name cannot be changed": [
101
+ "სწრაფი ასლის სახელის შეცვლა შეუძლებელია"
102
+ ],
103
+ "Unable to update Proxmox Snapshot": [
104
+ "Proxmox-ის სწრაფი ასლის განახლება შეუძლებელია"
105
+ ],
106
+ "Unable to create VMWare Snapshot with Quiesce. Check Power and VMWare Tools status.": [
107
+ "Quiesce-ით VMWare-ის სწრაფი ასლის შექმნა შეუძლებელია. შეამოწმეთ მისი კვება და VMWare Tools-ის მდგომარეობა."
108
+ ],
109
+ "Unable to create VMWare Snapshot. Cannot set both Memory and Quiesce options.": [
110
+ "VMWare-ის სწრაფი ასლის შექმნის შეცდომა. Quiesce -ის და მეხსიერების პარამეტრების ერთდროული დაყენება შეუძლებელია."
111
+ ],
112
+ "Unable to create VMWare Snapshot": [
113
+ "VMWare-ის სწრაფი ასლის შექმნა შეუძლებელია"
114
+ ],
115
+ "Unable to remove VMWare Snapshot": [
116
+ "VMWare-ის სწრაფი ასლის წაშლა შეუძლებელია"
117
+ ],
118
+ "Unable to revert VMWare Snapshot": [
119
+ "VMWare-ის სწრაფი ასლის დაბრუნება შეუძლებელია"
120
+ ],
121
+ "Unable to update VMWare Snapshot": [
122
+ "VMWare-ის სწრაფი ასლის განახლება შეუძლებელია"
123
+ ],
124
+ "No capable hosts selected": [
125
+ "შესაძლებლობის მქონე ჰოსტები მონიშნული არაა"
126
+ ],
127
+ "Description": [
128
+ "აღწერა"
129
+ ],
130
+ "Snapshot Mode": [
131
+ ""
132
+ ],
133
+ "Select Snapshot Mode between mutually exclusive options, 'Memory' (includes RAM) and 'Quiesce'.": [
134
+ ""
135
+ ],
136
+ "Loading Snapshots information ...": [
137
+ "სწრაფი ასლების ინფორმაციის ჩატვირთვა ..."
138
+ ],
139
+ "Snapshots": [
140
+ "სწრაფი ასლები"
141
+ ],
142
+ "Successfully removed Snapshot \\\"%s\\\" from host %s": [
143
+ "სწრაფი ასლის (%s) წაშლა ჰოსტიდან %s წარმატებით დასრულდა"
144
+ ],
145
+ "Successfully updated Snapshot \\\"%s\\\"": [
146
+ "სწრაფი ასლი (%s) წარმატებით განახლდა"
147
+ ],
148
+ "Error occurred while updating Snapshot: %s": [
149
+ "შეცდომა სწრაფი ასლის განახლებისას: %s"
150
+ ],
151
+ "Successfully rolled back Snapshot \\\"%s\\\" on host %s": [
152
+ "ჰოსტი %s წარმატებით დაბრუნდა სწრაფ ასლზე \\\"%s\\\""
153
+ ],
154
+ "Memory": [
155
+ ""
156
+ ],
157
+ "Quiesce": [
158
+ ""
159
+ ],
160
+ "Snapshot successfully created!": [
161
+ "სწრაფი ასლი წარმატებით შეიქმნა!"
162
+ ],
163
+ "Name": [
164
+ "სახელი"
165
+ ],
166
+ "Create Snapshot for %s": [
167
+ "%s-ის სწრაფი ასლის შექმნა"
168
+ ],
169
+ "N/A": [
170
+ "არარსებული"
171
+ ],
172
+ "Action": [
173
+ "მოქმედება"
174
+ ],
175
+ "Failed to load snapshot list": [
176
+ "სწრაფი ასლების სიის ჩატვირთვის შეცდომა"
177
+ ],
178
+ "edit entry": [
179
+ "ჩანაწერის ჩასწორება"
180
+ ],
181
+ "Rollback to \\\"%s\\\"?": [
182
+ "დავაბრუნო \\\"%s\\\"-ზე?"
183
+ ],
184
+ "Rollback": [
185
+ "უკან დაბრუნება"
186
+ ],
187
+ "Delete Snapshot \\\"%s\\\"?": [
188
+ "წავშალო სწრაფი ასლი \\\"%s\\\"?"
189
+ ],
190
+ "Delete": [
191
+ "წაშლა"
192
+ ],
193
+ "Foreman-plugin to manage snapshots in a virtual-hardware environments.": [
194
+ "Foreman-ის დამატება ვირტუალურ გარემოში სწრაფი ასლების სამართავად."
195
+ ],
196
+ "Include RAM": [
197
+ "RAM-ის ჩათვლით"
198
+ ]
199
+ }
200
+ }
201
+ };
@@ -0,0 +1,199 @@
1
+ locales['foreman_snapshot_management'] = locales['foreman_snapshot_management'] || {}; locales['foreman_snapshot_management']['zh_CN'] = {
2
+ "domain": "foreman_snapshot_management",
3
+ "locale_data": {
4
+ "foreman_snapshot_management": {
5
+ "": {
6
+ "Project-Id-Version": "foreman_snapshot_management 2.0.2",
7
+ "Report-Msgid-Bugs-To": "",
8
+ "PO-Revision-Date": "2019-10-22 11:54+0000",
9
+ "Last-Translator": "Amit Upadhye <aupadhye@redhat.com>, 2022",
10
+ "Language-Team": "Chinese (China) (https://www.transifex.com/foreman/teams/114/zh_CN/)",
11
+ "MIME-Version": "1.0",
12
+ "Content-Type": "text/plain; charset=UTF-8",
13
+ "Content-Transfer-Encoding": "8bit",
14
+ "Language": "zh_CN",
15
+ "Plural-Forms": "nplurals=1; plural=0;",
16
+ "lang": "zh_CN",
17
+ "domain": "foreman_snapshot_management",
18
+ "plural_forms": "nplurals=1; plural=0;"
19
+ },
20
+ "List all snapshots": [
21
+ "列出所有快照"
22
+ ],
23
+ "Name of this snapshot": [
24
+ "此快照的名称"
25
+ ],
26
+ "Description of this snapshot": [
27
+ "此快照的描述"
28
+ ],
29
+ "Create a snapshot": [
30
+ "创建快照"
31
+ ],
32
+ "Whether to include the RAM state in the snapshot": [
33
+ "是否在快照中包含 RAM 状态"
34
+ ],
35
+ "Whether to include the Quiesce state in the snapshot": [
36
+ "是否在快照中包含 Quiesce 状态"
37
+ ],
38
+ "Update a snapshot": [
39
+ "更新快照"
40
+ ],
41
+ "Delete a snapshot": [
42
+ "删除快照"
43
+ ],
44
+ "Revert Host to a snapshot": [
45
+ "将主机恢复到快照"
46
+ ],
47
+ "Error occurred while creating Snapshot: %s": [
48
+ "创建快照时出现错误:%s"
49
+ ],
50
+ "Error occurred while removing Snapshot: %s": [
51
+ "删除快照时发生错误:%s"
52
+ ],
53
+ "VM successfully rolled back.": [
54
+ "虚拟机成功回滚。"
55
+ ],
56
+ "Error occurred while rolling back VM: %s": [
57
+ "回滚虚拟机时出现错误:%s"
58
+ ],
59
+ "Failed to update Snapshot: %s": [
60
+ "更新快照失败:%s"
61
+ ],
62
+ "Error occurred while creating Snapshot for:%s": [
63
+ "创建产品时发生错误:%s"
64
+ ],
65
+ "Created %{snapshots} for %{num} %{hosts}": [
66
+ "为 %{num} %{hosts} 创建的 %{snapshots}"
67
+ ],
68
+ "Snapshot": [
69
+ "快照"
70
+ ],
71
+ "host": [
72
+ "主机"
73
+ ],
74
+ "No hosts were found with that id, name or query filter": [
75
+ "未找到符合此 id、名称或者查询过滤器的主机"
76
+ ],
77
+ "Something went wrong while selecting hosts - %s": [
78
+ "选择主机时出错 - %s"
79
+ ],
80
+ "No capable hosts found.": [
81
+ "未找到可用的主机。"
82
+ ],
83
+ "Create Snapshot": [
84
+ "创建快照"
85
+ ],
86
+ "Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _": [
87
+ "名称必须至少包含以字面开头的 2 个字符。有效字符为 A-Z a-z 0-9 _"
88
+ ],
89
+ "Unable to create Proxmox Snapshot": [
90
+ "无法创建 Proxmox 快照"
91
+ ],
92
+ "Unable to remove Proxmox Snapshot": [
93
+ "无法删除 Proxmox 快照"
94
+ ],
95
+ "Unable to revert Proxmox Snapshot": [
96
+ "无法恢复 Proxmox 快照"
97
+ ],
98
+ "Snapshot name cannot be changed": [
99
+ "无法更改快照名称"
100
+ ],
101
+ "Unable to update Proxmox Snapshot": [
102
+ "无法更新 Proxmox 快照"
103
+ ],
104
+ "Unable to create VMWare Snapshot with Quiesce. Check Power and VMWare Tools status.": [
105
+ "无法使用 Quiesce 创建 VMWare 快照。检查 Power 和 VMWare 工具状态。"
106
+ ],
107
+ "Unable to create VMWare Snapshot. Cannot set both Memory and Quiesce options.": [
108
+ "无法创建 VMWare 快照。无法同时设置 Memory 和 Quiesce 选项。"
109
+ ],
110
+ "Unable to create VMWare Snapshot": [
111
+ "无法创建 VMWare 快照"
112
+ ],
113
+ "Unable to remove VMWare Snapshot": [
114
+ "无法删除 VMWare 快照"
115
+ ],
116
+ "Unable to revert VMWare Snapshot": [
117
+ "无法恢复 VMWare 快照"
118
+ ],
119
+ "Unable to update VMWare Snapshot": [
120
+ "无法更新 VMWare 快照"
121
+ ],
122
+ "No capable hosts selected": [
123
+ "没有选择可用的主机"
124
+ ],
125
+ "Description": [
126
+ "描述"
127
+ ],
128
+ "Snapshot Mode": [
129
+ ""
130
+ ],
131
+ "Select Snapshot Mode between mutually exclusive options, 'Memory' (includes RAM) and 'Quiesce'.": [
132
+ ""
133
+ ],
134
+ "Loading Snapshots information ...": [
135
+ "加载快照信息..."
136
+ ],
137
+ "Snapshots": [
138
+ "快照"
139
+ ],
140
+ "Successfully removed Snapshot \\\"%s\\\" from host %s": [
141
+ "成功从主机 %s 中删除快照 \\\"%s\\\""
142
+ ],
143
+ "Successfully updated Snapshot \\\"%s\\\"": [
144
+ "成功更新快照 \\\"%s\\\""
145
+ ],
146
+ "Error occurred while updating Snapshot: %s": [
147
+ "更新快照时发生错误:%s"
148
+ ],
149
+ "Successfully rolled back Snapshot \\\"%s\\\" on host %s": [
150
+ "在主机 %s 上成功回滚快照 \\\"%s\\\""
151
+ ],
152
+ "Memory": [
153
+ ""
154
+ ],
155
+ "Quiesce": [
156
+ ""
157
+ ],
158
+ "Snapshot successfully created!": [
159
+ "成功创建快照!"
160
+ ],
161
+ "Name": [
162
+ "名称"
163
+ ],
164
+ "Create Snapshot for %s": [
165
+ "为 %s 创建快照"
166
+ ],
167
+ "N/A": [
168
+ "不适用"
169
+ ],
170
+ "Action": [
171
+ "操作"
172
+ ],
173
+ "Failed to load snapshot list": [
174
+ "加载快照列表失败"
175
+ ],
176
+ "edit entry": [
177
+ "编辑条目"
178
+ ],
179
+ "Rollback to \\\"%s\\\"?": [
180
+ "回滚到 \\\"%s\\\"?"
181
+ ],
182
+ "Rollback": [
183
+ "回滚rollback"
184
+ ],
185
+ "Delete Snapshot \\\"%s\\\"?": [
186
+ "删除快照 \\\"%s\\\"?"
187
+ ],
188
+ "Delete": [
189
+ "刪除"
190
+ ],
191
+ "Foreman-plugin to manage snapshots in a virtual-hardware environments.": [
192
+ "Foreman-plugin,用于在虚拟硬件环境中管理快照。"
193
+ ],
194
+ "Include RAM": [
195
+ "包括 RAM"
196
+ ]
197
+ }
198
+ }
199
+ };
@@ -16,7 +16,7 @@ module Api
16
16
  meta :search => [{ :name => 'name', :type => 'string' }]
17
17
  def index
18
18
  if params[:search]
19
- search = params[:search].match(/^\s*name\s*=\s*(\w+)\s*$/) || params[:search].match(/^\s*name\s*=\s*\"([^"]+)\"\s*$/)
19
+ search = params[:search].match(/^\s*name\s*=\s*(\w+)\s*$/) || params[:search].match(/^\s*name\s*=\s*"([^"]+)"\s*$/)
20
20
  raise "Field '#{params[:search]}' not recognized for searching!" unless search
21
21
 
22
22
  snapshot = resource_class.find_for_host_by_name(@host, search[1])
@@ -34,7 +34,8 @@ module Api
34
34
  param :host_id, :identifier_dottable, :required => true
35
35
  param :id, :identifier_dottable, :required => true
36
36
 
37
- def show; end
37
+ def show
38
+ end
38
39
 
39
40
  def_param_group :snapshot do
40
41
  param :snapshot, Hash, :required => true, :action_aware => true do
@@ -46,10 +47,13 @@ module Api
46
47
  api :POST, '/hosts/:host_id/snapshots', N_('Create a snapshot')
47
48
  param :host_id, :identifier_dottable, :required => true
48
49
  param :include_ram, :bool, :default_value => false, :desc => N_('Whether to include the RAM state in the snapshot')
50
+ param :quiesce, :bool, :default_value => false, :desc => N_('Whether to include the Quiesce state in the snapshot')
49
51
  param_group :snapshot, :as => :create
50
52
 
51
53
  def create
52
- @snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge(include_ram: Foreman::Cast.to_bool(params[:include_ram])))
54
+ @snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge(
55
+ include_ram: Foreman::Cast.to_bool(params[:include_ram]), quiesce: Foreman::Cast.to_bool(params[:quiesce])
56
+ ))
53
57
  process_response @snapshot.create
54
58
  end
55
59
 
@@ -6,7 +6,7 @@ module Foreman::Controller::Parameters::Snapshot
6
6
  class_methods do
7
7
  def snapshot_params_filter
8
8
  Foreman::ParameterFilter.new(::ForemanSnapshotManagement::Snapshot).tap do |filter|
9
- filter.permit :name, :description, :include_ram, :host_id
9
+ filter.permit :name, :description, :include_ram, :quiesce, :host_id
10
10
  end
11
11
  end
12
12
  end
@@ -28,7 +28,7 @@ module ForemanSnapshotManagement
28
28
  #
29
29
  # This method creates a Snapshot with a given name and optional description.
30
30
  def create
31
- @snapshot = Snapshot.new(snapshot_params.merge(host: @host).merge(include_ram: params[:snapshot][:include_ram]))
31
+ @snapshot = Snapshot.new(snapshot_params.merge(host: @host).merge(include_ram: params[:snapshot][:include_ram], quiesce: params[:snapshot][:quiesce]))
32
32
 
33
33
  if @snapshot.create
34
34
  process_success
@@ -75,10 +75,12 @@ module ForemanSnapshotManagement
75
75
  end
76
76
 
77
77
  define_action_permission ['select_multiple_host', 'create_multiple_host'], :create
78
- def select_multiple_host; end
78
+ def select_multiple_host
79
+ end
79
80
 
80
81
  def create_multiple_host
81
82
  data = snapshot_params
83
+ snapshot_mode_assignment(params[:snapshot][:snapshot_mode], data)
82
84
  snapshots_created = 0
83
85
  errors = []
84
86
  @hosts.each do |h|
@@ -94,7 +96,7 @@ module ForemanSnapshotManagement
94
96
  msg = _('Created %{snapshots} for %{num} %{hosts}') % {
95
97
  snapshots: n_('Snapshot', 'Snapshots', snapshots_created),
96
98
  num: snapshots_created,
97
- hosts: n_('host', 'hosts', snapshots_created)
99
+ hosts: n_('host', 'hosts', snapshots_created),
98
100
  }
99
101
  # for backwards compatibility
100
102
  if respond_to? :success
@@ -106,10 +108,24 @@ module ForemanSnapshotManagement
106
108
  redirect_back_or_to hosts_path
107
109
  end
108
110
 
111
+ def snapshot_mode_assignment(snapshot_mode, data)
112
+ case snapshot_mode
113
+ when 'memory'
114
+ data[:include_ram] = true
115
+ data[:quiesce] = false
116
+ when 'quiesce'
117
+ data[:include_ram] = false
118
+ data[:quiesce] = true
119
+ else
120
+ data[:include_ram] = false
121
+ data[:quiesce] = false
122
+ end
123
+ end
124
+
109
125
  private
110
126
 
111
127
  def snapshot_params
112
- params.require(:snapshot).permit(:name, :description, :include_ram)
128
+ params.require(:snapshot).permit(:name, :description, :include_ram, :quiesce)
113
129
  end
114
130
 
115
131
  # Find Host
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ForemanSnapshotManagement
4
+ module HostsHelper
5
+ def snapshot_multiple_actions
6
+ return [] unless can_create_snapshots?
7
+ [{ action: [_('Create Snapshot'), select_multiple_host_snapshots_path], priority: 1000 }]
8
+ end
9
+
10
+ private
11
+
12
+ def can_create_snapshots?
13
+ User.current.can?(:create_snapshots)
14
+ end
15
+ end
16
+ end
@@ -15,7 +15,7 @@ module FogExtensions
15
15
  'exitstatus' => 'OK',
16
16
  'status' => 'stopped',
17
17
  'id' => '100',
18
- 'pid' => 15_891
18
+ 'pid' => 15_891,
19
19
  }
20
20
  end
21
21
  end
@@ -15,7 +15,7 @@ module FogExtensions
15
15
  raise ArgumentError, 'removeChildren is a required parameter' unless options.key? 'removeChildren'
16
16
 
17
17
  {
18
- 'task_state' => 'success'
18
+ 'task_state' => 'success',
19
19
  }
20
20
  end
21
21
 
@@ -25,7 +25,7 @@ module FogExtensions
25
25
  raise ArgumentError, 'description is a required parameter' unless options.key? 'description'
26
26
 
27
27
  {
28
- 'task_state' => 'success'
28
+ 'task_state' => 'success',
29
29
  }
30
30
  end
31
31
  end
@@ -17,7 +17,7 @@ module FogExtensions
17
17
  task.wait_for_completion
18
18
 
19
19
  {
20
- 'task_state' => task.info.state
20
+ 'task_state' => task.info.state,
21
21
  }
22
22
  end
23
23
 
@@ -4,17 +4,18 @@ module ForemanSnapshotManagement
4
4
  module ProxmoxExtensions
5
5
  # Extend Proxmox's capabilities with snapshots.
6
6
  def capabilities
7
- super + [:snapshots]
7
+ super + [:snapshots, :limit_snapshot_name_format, :snapshot_include_ram]
8
8
  end
9
9
 
10
10
  # Create a Snapshot.
11
11
  #
12
12
  # This method creates a Snapshot with a given name and optional description.
13
- def create_snapshot(host, name, description, _include_ram = false)
13
+ def create_snapshot(host, name, description, include_ram = false, _quiesce = false)
14
14
  server = find_vm_by_uuid host.uuid
15
- raise _('Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _') unless /^[A-Za-z][\w]{1,}$/.match?(name)
15
+ raise _('Name must contain at least 2 characters starting with alphabet. Valid characters are A-Z a-z 0-9 _') unless /^[A-Za-z]\w{1,}$/.match?(name)
16
16
 
17
- snapshot = server.snapshots.create(name: name)
17
+ include_ram = include_ram ? 1 : 0
18
+ snapshot = server.snapshots.create(name: name, vmstate: include_ram)
18
19
  snapshot.description = description
19
20
  snapshot.update
20
21
  rescue StandardError => e
@@ -12,20 +12,21 @@ module ForemanSnapshotManagement
12
12
  include ActiveModel::ForbiddenAttributesProtection
13
13
 
14
14
  define_model_callbacks :create, :save, :destroy, :revert
15
- attr_accessor :id, :raw_snapshot, :parent
15
+ attr_accessor :id, :raw_snapshot, :parent, :snapshot_mode, :quiesce
16
16
  attr_writer :create_time
17
17
  attr_reader :name, :description, :include_ram, :host_id
18
+
18
19
  define_attribute_methods :name, :description, :include_ram
19
20
 
20
21
  def self.model_name
21
22
  Struct.new(:name, :klass, :singular, :plural, :element,
22
- :human, :collection, :param_key, :i18n_key, :route_key, :singular_route_key).new(
23
- 'ForemanSnapshotManagement::Snapshot', ForemanSnapshotManagement::Snapshot,
24
- 'foreman_snapshot_management_snapshot', 'foreman_snapshot_management_snapshots',
25
- 'snapshot', 'Snapshot', 'foreman_snapshot_management/snapshots',
26
- 'snapshot', :'foreman_snapshot_management/snapshot', 'foreman_snapshot_management_snapshots',
27
- 'foreman_snapshot_management_snapshot'
28
- )
23
+ :human, :collection, :param_key, :i18n_key, :route_key, :singular_route_key).new(
24
+ 'ForemanSnapshotManagement::Snapshot', ForemanSnapshotManagement::Snapshot,
25
+ 'foreman_snapshot_management_snapshot', 'foreman_snapshot_management_snapshots',
26
+ 'snapshot', 'Snapshot', 'foreman_snapshot_management/snapshots',
27
+ 'snapshot', :'foreman_snapshot_management/snapshot', 'foreman_snapshot_management_snapshots',
28
+ 'foreman_snapshot_management_snapshot'
29
+ )
29
30
  end
30
31
 
31
32
  def self.any?
@@ -122,7 +123,7 @@ module ForemanSnapshotManagement
122
123
  handle_snapshot_errors do
123
124
  host.audit_comment = "Create snapshot #{name}"
124
125
  host.save!
125
- host.compute_resource.create_snapshot(host, name, description, include_ram)
126
+ host.compute_resource.create_snapshot(host, name, description, include_ram, quiesce)
126
127
  changes_applied
127
128
  end
128
129
  end
@@ -4,14 +4,24 @@ module ForemanSnapshotManagement
4
4
  module VmwareExtensions
5
5
  # Extend VMWare's capabilities with snapshots.
6
6
  def capabilities
7
- super + [:snapshots, :snapshot_include_ram, :editable_snapshot_name]
7
+ super + [:snapshots, :snapshot_include_ram, :snapshot_include_quiesce, :editable_snapshot_name]
8
8
  end
9
9
 
10
10
  # Create a Snapshot.
11
11
  #
12
12
  # This method creates a Snapshot with a given name and optional description.
13
- def create_snapshot(host, name, description, include_ram = false)
14
- task = client.vm_take_snapshot('instance_uuid' => host.uuid, 'name' => name, 'description' => description, 'memory' => include_ram)
13
+ def create_snapshot(host, name, description, include_ram = false, quiesce = false)
14
+ server = find_vm_by_uuid(host.uuid)
15
+ raise N_('Unable to create VMWare Snapshot with Quiesce. Check Power and VMWare Tools status.') if quiesce && (server.power_state != 'poweredOn' || server.tools_state != 'toolsOk')
16
+ raise N_('Unable to create VMWare Snapshot. Cannot set both Memory and Quiesce options.') if quiesce && include_ram
17
+
18
+ task = client.vm_take_snapshot(
19
+ 'instance_uuid' => host.uuid,
20
+ 'name' => name,
21
+ 'description' => description,
22
+ 'quiesce' => quiesce,
23
+ 'memory' => include_ram
24
+ )
15
25
  task_successful?(task)
16
26
  rescue RbVmomi::Fault => e
17
27
  Foreman::Logging.exception('Error creating VMWare Snapshot', e)
@@ -7,6 +7,7 @@
7
7
  capabilities:
8
8
  {
9
9
  editableSnapshotName: @host.compute_resource.capable?(:editable_snapshot_name),
10
- limitSnapshotNameFormat: @host.compute_resource.type == "ForemanFogProxmox::Proxmox"
10
+ limitSnapshotNameFormat: @host.compute_resource.capable?(:limit_snapshot_name_format),
11
+ quiesceOption: @host.compute_resource.capable?(:snapshot_include_quiesce)
11
12
  }
12
13
  }) %>