foreman_snapshot_management 2.0.3 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) 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 +5 -4
  13. data/app/controllers/foreman_snapshot_management/snapshots_controller.rb +6 -4
  14. data/app/helpers/foreman_snapshot_management/hosts_helper.rb +16 -0
  15. data/app/models/concerns/fog_extensions/proxmox/snapshots/mock.rb +1 -1
  16. data/app/models/concerns/fog_extensions/vsphere/snapshots/mock.rb +2 -2
  17. data/app/models/concerns/fog_extensions/vsphere/snapshots/real.rb +1 -1
  18. data/app/models/foreman_snapshot_management/proxmox_extensions.rb +2 -1
  19. data/app/models/foreman_snapshot_management/snapshot.rb +11 -10
  20. data/config/routes.rb +1 -1
  21. data/lib/foreman_snapshot_management/engine.rb +24 -29
  22. data/lib/foreman_snapshot_management/version.rb +1 -1
  23. data/lib/tasks/foreman_snapshot_management_tasks.rake +1 -1
  24. data/locale/Makefile +7 -8
  25. data/locale/cs_CZ/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  26. data/locale/cs_CZ/foreman_snapshot_management.po +12 -4
  27. data/locale/de/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  28. data/locale/de/foreman_snapshot_management.po +12 -4
  29. data/locale/el/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  30. data/locale/el/foreman_snapshot_management.po +12 -4
  31. data/locale/fr/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  32. data/locale/fr/foreman_snapshot_management.po +12 -4
  33. data/locale/ja/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  34. data/locale/ja/foreman_snapshot_management.po +12 -4
  35. data/locale/ka/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  36. data/locale/ka/foreman_snapshot_management.po +12 -4
  37. data/locale/zh_CN/LC_MESSAGES/foreman_snapshot_management.mo +0 -0
  38. data/locale/zh_CN/foreman_snapshot_management.po +12 -4
  39. data/package.json +1 -1
  40. data/test/controllers/api/v2/snapshots_test.rb +1 -1
  41. data/test/controllers/foreman_snapshot_management/snapshots_controller_test.rb +1 -1
  42. data/webpack/components/SnapshotManagementCard/SnapshotManagementCard.js +12 -9
  43. data/webpack/components/SnapshotManagementCard/__tests__/SnapshotManagementCard.test.js +1 -0
  44. data/webpack/components/SnapshotManagementCard/__tests__/__snapshots__/SnapshotManagementCard.test.js.snap +1 -16
  45. metadata +16 -8
  46. 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
@@ -51,8 +52,8 @@ module Api
51
52
 
52
53
  def create
53
54
  @snapshot = resource_class.new(snapshot_params.to_h.merge(host: @host).merge(
54
- include_ram: Foreman::Cast.to_bool(params[:include_ram]), quiesce: Foreman::Cast.to_bool(params[:quiesce])
55
- ))
55
+ include_ram: Foreman::Cast.to_bool(params[:include_ram]), quiesce: Foreman::Cast.to_bool(params[:quiesce])
56
+ ))
56
57
  process_response @snapshot.create
57
58
  end
58
59
 
@@ -75,7 +75,8 @@ 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
@@ -95,7 +96,7 @@ module ForemanSnapshotManagement
95
96
  msg = _('Created %{snapshots} for %{num} %{hosts}') % {
96
97
  snapshots: n_('Snapshot', 'Snapshots', snapshots_created),
97
98
  num: snapshots_created,
98
- hosts: n_('host', 'hosts', snapshots_created)
99
+ hosts: n_('host', 'hosts', snapshots_created),
99
100
  }
100
101
  # for backwards compatibility
101
102
  if respond_to? :success
@@ -108,10 +109,11 @@ module ForemanSnapshotManagement
108
109
  end
109
110
 
110
111
  def snapshot_mode_assignment(snapshot_mode, data)
111
- if snapshot_mode == 'memory'
112
+ case snapshot_mode
113
+ when 'memory'
112
114
  data[:include_ram] = true
113
115
  data[:quiesce] = false
114
- elsif snapshot_mode == 'quiesce'
116
+ when 'quiesce'
115
117
  data[:include_ram] = false
116
118
  data[:quiesce] = true
117
119
  else
@@ -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
 
@@ -12,8 +12,9 @@ module ForemanSnapshotManagement
12
12
  # This method creates a Snapshot with a given name and optional description.
13
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
+ include_ram = include_ram ? 1 : 0
17
18
  snapshot = server.snapshots.create(name: name, vmstate: include_ram)
18
19
  snapshot.description = description
19
20
  snapshot.update
@@ -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, :snapshot_mode
16
- attr_writer :create_time, :quiesce
17
- attr_reader :name, :description, :include_ram, :host_id, :quiesce
15
+ attr_accessor :id, :raw_snapshot, :parent, :snapshot_mode, :quiesce
16
+ attr_writer :create_time
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?
data/config/routes.rb CHANGED
@@ -20,7 +20,7 @@ Rails.application.routes.draw do
20
20
  end
21
21
  end
22
22
 
23
- constraints(host_id: %r{[^\/]+}) do
23
+ constraints(host_id: %r{[^/]+}) do
24
24
  resources :hosts, only: [] do
25
25
  resources :snapshots, module: 'foreman_snapshot_management', only: [:index, :create, :destroy, :update] do
26
26
  member do