foreman_hyperv 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cf1610103bdfad147e262399c3c50667bf4450831ebb8e9a4f20211307a3d18
4
- data.tar.gz: a4623968a974d9de60af94cd0dfaa9957a89354f640897e8138c6c0b32f95b9a
3
+ metadata.gz: 156c82d3cc4630c1d222fc97370cef6b5f3128da1d97732dcef072f8b4adbbe3
4
+ data.tar.gz: d812c0f6a6785879bbe4cacff1f943237b24951ea8b5b5f2e2add668d2480b58
5
5
  SHA512:
6
- metadata.gz: a1007568c30b112299208b00a5df11c8d88c0b0e390365ede46efc67900489b7cdb40b6ca83a318505e6ff6f3fc167c6bb2239c18e910710a45572e161213852
7
- data.tar.gz: 51d064f97547b16ec490a6c9d9436c87efbed149957a6f66b6fef85d652ff0c91201e44c13a039ed53871db51b26487181ee11410bb45f45663ce6b6068ec1d3
6
+ metadata.gz: 89a21ca4968ec5adbc536b7cffde5e2619f4e54f704a259e52ec812ccb25271be31674c5bd0f6f154752c1a80d8b2eef836f497fe838781bd6f923ce1e8aa242
7
+ data.tar.gz: 16c7a09381db0854437d1620d708eabd7415459fc644577e508b45e94cd51e3c5b8bcd722eafeb049140615f15ea54fedbbf80e2a604dab17ecf82c4ea9395e2
@@ -1,20 +1,3 @@
1
- $(document).on('ContentLoad', function() { tfm.numFields.initAll(); });
2
-
3
- function hypervGenerationChange(item) {
4
- var toIter = ['#host_compute_attributes_secure_boot_enabled', '#compute_attribute_vm_attrs_secure_boot_enabled'];
5
- gen = $(item).val();
6
-
7
- if (gen == 'BIOS') {
8
- for (var i = 0; i < toIter.length; ++i) {
9
- $(toIter[i]).attr('disabled', true);
10
- }
11
- } else {
12
- for (var i = 0; i < toIter.length; ++i) {
13
- $(toIter[i]).removeAttr('disabled');
14
- }
15
- }
16
- }
17
-
18
1
  function hypervDynamicMemoryChange(item) {
19
2
  var toIter = [
20
3
  '#host_compute_attributes_memory_maximum',
@@ -8,6 +8,20 @@ module ForemanHyperv
8
8
  end
9
9
  end
10
10
 
11
+ def hyperv_boot_devices
12
+ devices = Fog::Hyperv::BOOT_DEVICE_ENUM_VALUES.dup
13
+ # devices.delete :Floppy if generation == :UEFI
14
+ devices.delete :IDE
15
+ devices.delete :LegacyNetworkAdapter
16
+ devices.map do |dev|
17
+ name = dev.to_s
18
+ name = 'Network Adapter' if dev == :NetworkAdapter
19
+ name = 'DVD' if dev == :CD
20
+ name = 'Floppy (Only for BIOS)' if dev == :Floppy
21
+ [dev, name]
22
+ end
23
+ end
24
+
11
25
  def hyperv_generations
12
26
  Fog::Hyperv::Compute::Server::VM_GENERATION_VALUES.map { |gen, num| [gen, "Generation #{num} (#{gen})"] }
13
27
  end
@@ -41,7 +41,7 @@ module FogExtensions
41
41
  end
42
42
 
43
43
  def access_vlan_id
44
- return nil if vlan_setting.access_vlan_id.zero?
44
+ return nil if (vlan_setting.access_vlan_id || 0).zero?
45
45
 
46
46
  vlan_setting.access_vlan_id
47
47
  end
@@ -49,7 +49,7 @@ module FogExtensions
49
49
  delegate :access_vlan_id=, to: :vlan_setting
50
50
 
51
51
  def native_vlan_id
52
- return nil if vlan_setting.native_vlan_id.zero?
52
+ return nil if (vlan_setting.native_vlan_id || 0).zero?
53
53
 
54
54
  vlan_setting.native_vlan_id
55
55
  end
@@ -68,7 +68,7 @@ module FogExtensions
68
68
  end
69
69
 
70
70
  def primary_vlan_id
71
- return nil if vlan_setting.primary_vlan_id.zero?
71
+ return nil if (vlan_setting.primary_vlan_id || 0).zero?
72
72
 
73
73
  vlan_setting.primary_vlan_id
74
74
  end
@@ -76,7 +76,7 @@ module FogExtensions
76
76
  delegate :primary_vlan_id=, to: :vlan_setting
77
77
 
78
78
  def secondary_vlan_id
79
- return nil if vlan_setting.secondary_vlan_id.zero?
79
+ return nil if (vlan_setting.secondary_vlan_id || 0).zero?
80
80
 
81
81
  vlan_setting.secondary_vlan_id
82
82
  end
@@ -43,6 +43,20 @@ module FogExtensions
43
43
  @cluster = service.clusters.get(name)
44
44
  end
45
45
 
46
+ def boot_device
47
+ :NetworkAdapter
48
+ end
49
+
50
+ def foreman_firmware_type
51
+ return 'bios' if generation_num == 1
52
+
53
+ secure_boot_enabled ? 'uefi_secure_boot' : 'uefi'
54
+ end
55
+
56
+ def foreman_firmware
57
+ generation_num == 1 ? 'bios' : 'efi'
58
+ end
59
+
46
60
  def vlan
47
61
  nic = network_adapters.first
48
62
 
@@ -69,16 +83,15 @@ module FogExtensions
69
83
 
70
84
  def secure_boot_enabled=(enabled)
71
85
  return if generation != :UEFI
72
-
73
- @secure_boot = enabled
74
86
  return unless persisted?
75
87
 
76
88
  firmware.secure_boot = enabled ? :On : :Off
89
+ firmware.save
77
90
  end
78
91
 
79
92
  def secure_boot_enabled
80
93
  return false if generation != :UEFI
81
- return @secure_boot unless persisted?
94
+ return unless persisted?
82
95
 
83
96
  firmware.secure_boot == :On
84
97
  end
@@ -108,6 +108,10 @@ module ForemanHyperv
108
108
  )
109
109
  end
110
110
 
111
+ def associated_host(vm)
112
+ associate_by("mac", vm.network_adapters.map(&:mac))
113
+ end
114
+
111
115
  delegate :servers, to: :client
112
116
 
113
117
  def switches(host)
@@ -120,7 +124,11 @@ module ForemanHyperv
120
124
  end
121
125
 
122
126
  def new_vm(attr = {})
127
+ firmware_type = attr.delete(:firmware_type).to_s
128
+ attr.merge!(process_firmware_attributes(attr[:foreman_firmware], firmware_type)) #, attr[:provision_method]))
123
129
  attr.delete :id
130
+
131
+ # logger.debug "New VM with arguments;\n#{attr}"
124
132
  vm = super
125
133
  iface_nested_attrs = nested_attributes_for :interfaces, attr[:interfaces_attributes]
126
134
  vm.network_adapters = iface_nested_attrs.map do |attr|
@@ -149,13 +157,17 @@ module ForemanHyperv
149
157
  attr.delete :computer_name if attr[:computer_name].blank?
150
158
  attr.delete :start
151
159
 
160
+ firmware_type = attr.delete(:firmware_type).to_s
161
+ attr.merge!(process_firmware_attributes(attr[:foreman_firmware], firmware_type)) #, attr[:provision_method]))
162
+
152
163
  validate_vm(attr, new: true)
153
164
  validate_interfaces(attr)
154
165
  validate_volumes(attr)
155
166
 
167
+ # logger.debug "Creating VM with arguments; #{attr}"
156
168
  vm = client.servers.new(
157
169
  name: attr[:name],
158
- computer_name: attr[:computer_name],
170
+ computer_name: attr[:computer_name].presence || hypervisor.name,
159
171
  generation: attr[:generation],
160
172
  dynamic_memory_enabled: Foreman::Cast.to_bool(attr[:dynamic_memory_enabled]),
161
173
  memory_startup: attr[:memory_startup].to_i,
@@ -164,13 +176,20 @@ module ForemanHyperv
164
176
  processor_count: attr[:processor_count].to_i,
165
177
  notes: attr[:notes]
166
178
  )
167
- # TODO: Allow configuring boot device?
168
- vm.create boot_device: :NetworkAdapter
179
+ vm.create(
180
+ # TODO: should be :VHD if image build - when image build support exists
181
+ boot_device: attr[:boot_device].present? ? attr[:boot_device].to_sym : :NetworkAdapter,
182
+ path: hypervisor.virtual_machine_path
183
+ )
169
184
 
170
- if vm.generation == :UEFI && attr[:secure_boot_enabled].present?
171
- f = vm.firmware
172
- f.secure_boot = Foreman::Cast.to_bool(attr[:secure_boot_enabled]) ? :On : :Off
173
- f.save if f.dirty?
185
+ if vm.generation == :UEFI
186
+ vm.secure_boot_enabled = attr[:secure_boot_enabled]
187
+ if attr[:tpm_enabled] == '1'
188
+ security = vm.security
189
+ security.change_key_protector :new
190
+ security.tpm_enabled = true
191
+ security.save
192
+ end
174
193
  end
175
194
 
176
195
  create_interfaces(vm, attr)
@@ -178,27 +197,26 @@ module ForemanHyperv
178
197
 
179
198
  vm.start if attr[:start] == '1'
180
199
  vm
181
- rescue StandardError => e
182
- if vm
200
+ rescue StandardError
201
+ if vm&.persisted?
183
202
  vm.stop
184
203
  vm.hard_drives.each { |hdd| hdd.destroy(underlying: true) }
185
- vm.destroy
204
+ vm.destroy(vm.path.end_with?(vm.name))
186
205
  end
187
206
 
188
- raise e
207
+ raise
189
208
  end
190
209
 
191
210
  def save_vm(uuid, web_attr)
192
211
  attr = web_attr.deep_symbolize_keys
212
+ attr.delete :start
193
213
 
194
214
  validate_vm(attr)
195
215
  validate_interfaces(attr)
196
216
  validate_volumes(attr)
197
217
 
198
- attr.delete :start
199
-
200
218
  vm = find_vm_by_uuid(uuid)
201
- logger.debug "Updating VM #{vm} with arguments; #{attr}"
219
+ # logger.debug "Updating VM #{vm} with arguments; #{attr}"
202
220
 
203
221
  vm.processor_count = attr[:processor_count].to_i
204
222
  vm.notes = attr[:notes].presence
@@ -207,10 +225,19 @@ module ForemanHyperv
207
225
  vm.memory_minimum = attr[:memory_minimum].to_i
208
226
  vm.memory_maximum = attr[:memory_maximum].to_i
209
227
  end
210
- if vm.generation == :UEFI && attr[:secure_boot_enabled].present?
211
- f = vm.firmware
212
- f.secure_boot = Foreman::Cast.to_bool(attr[:secure_boot_enabled]) ? :On : :Off
213
- f.save if f.dirty?
228
+ if vm.generation == :UEFI && attr[:tpm_enabled].present?
229
+ security = vm.security
230
+ security.tpm_enabled = attr[:tpm_enabled] == '1'
231
+ if security.tpm_enabled && security.key_protector.nil?
232
+ security.change_key_protector :new
233
+ end
234
+ security.save
235
+ end
236
+ if attr[:foreman_firmware].present?
237
+ firmware_type = attr.delete(:firmware_type).to_s
238
+ attr.merge!(process_firmware_attributes(attr[:foreman_firmware], firmware_type)) #, attr[:provision_method]))
239
+
240
+ vm.secure_boot_enabled = attr[:secure_boot_enabled]
214
241
  end
215
242
 
216
243
  update_interfaces(vm, attr)
@@ -225,7 +252,7 @@ module ForemanHyperv
225
252
  vm.stop turn_off: true
226
253
  vm.hard_drives.each { |hdd| hdd.destroy(underlying: true) }
227
254
  # TODO: Remove the empty VM folder
228
- vm.destroy
255
+ vm.destroy(vm.path.end_with?(vm.name))
229
256
  rescue ActiveRecord::RecordNotFound, Fog::Errors::NotFound
230
257
  # if the VM does not exists, we don't really care.
231
258
  true
@@ -251,8 +278,9 @@ module ForemanHyperv
251
278
  end
252
279
  end
253
280
 
254
- deep_update_required = proc do |old, new|
281
+ deep_update_required = proc do |path, old, new|
255
282
  old.merge(new) do |k, old_v, new_v|
283
+ k_path = path + [k]
256
284
  if %i[allowed_vlan_ids secondary_vlan_ids].include?(k)
257
285
  tmp = Fog::Hyperv::Compute::NetworkAdapter.new
258
286
 
@@ -261,17 +289,17 @@ module ForemanHyperv
261
289
  end
262
290
 
263
291
  if old_v.is_a?(Hash) && new_v.is_a?(Hash)
264
- deep_update_required.call(old_v, new_v)
292
+ deep_update_required.call(k_path, old_v, new_v)
265
293
  elsif old_v.to_s != new_v.to_s
266
294
  Rails.logger.debug do
267
- "Scheduling compute instance update because #{k} changed it's value from '#{old_v}' (#{old_v.class}) to '#{new_v}' (#{new_v.class})"
295
+ "Scheduling compute instance update because #{k_path.join('.')} changed it's value from '#{old_v}' (#{old_v.class}) to '#{new_v}' (#{new_v.class})"
268
296
  end
269
297
  return true
270
298
  end
271
299
  new_v
272
300
  end
273
301
  end
274
- deep_update_required.call(old_attrs.deep_symbolize_keys, new_attrs.deep_symbolize_keys)
302
+ deep_update_required.call([], old_attrs.deep_symbolize_keys, new_attrs.deep_symbolize_keys)
275
303
 
276
304
  false
277
305
  end
@@ -310,6 +338,19 @@ module ForemanHyperv
310
338
  )
311
339
  end
312
340
 
341
+ def vm_compute_attributes(vm)
342
+ attr = super.slice(
343
+ :computer_name, :name, :generation,
344
+ :dynamic_memory_enabled,
345
+ :memory_maximum, :memory_minimum, :memory_startup,
346
+ :notes, :processor_count
347
+ )
348
+ attr[:foreman_firmware] = vm.foreman_firmware_type
349
+ attr[:tpm_enabled] = vm.tpm_enabled
350
+
351
+ attr
352
+ end
353
+
313
354
  def set_vm_volumes_attributes(vm, vm_attrs)
314
355
  volumes = vm.hard_drives || []
315
356
  vm_attrs[:volumes_attributes] = volumes.each_with_index.to_h do |volume, index|
@@ -362,6 +403,14 @@ module ForemanHyperv
362
403
  raise Foreman::Exception, 'VM lacks memory maximum' unless attr[:memory_maximum].to_i.positive?
363
404
  end
364
405
 
406
+ def generate_secure_boot_settings(firmware)
407
+ return {} unless firmware.to_s.include?('efi')
408
+
409
+ {
410
+ secure_boot_enabled: firmware.to_s.end_with?('secure_boot')
411
+ }
412
+ end
413
+
365
414
  def validate_interfaces(attr)
366
415
  interfaces = nested_attributes_for :interfaces, attr[:interfaces_attributes]
367
416
  interfaces.reject! { |iface| iface[:_destroy] == '1' }
@@ -14,34 +14,12 @@
14
14
  cluster_errors << ex
15
15
  end
16
16
  -%>
17
- <% if clusters.any? %>
17
+ <% if clusters.any? -%>
18
18
  <%= select_f f, :cluster_name, clusters, :to_s, :to_s, { include_blank: true }, label: _('Cluster'), disabled: !new_host %>
19
- <% if computers.count > 1 %>
19
+ <% if computers.count > 1 -%>
20
20
  <%= select_f f, :computer_name, computers, :name, :name, {}, label: _('Computer Name'), disabled: !new_host, onload: 'hypervHostChange(this);', onchange: 'hypervHostChange(this);' %>
21
21
  <% end -%>
22
- <% end %>
23
- <div class="clearfix">
24
- <div class="form-group">
25
- <label class="col-md-2 control-label">Available resources</label>
26
- <div class="col-md-4 help-block" id="hypervComputerInformation">
27
- <% computers.each do |host| -%>
28
- <table class="hyperv-host-info" style="<%= (host.name == f.object.computer_name) ? '' : 'display: none' %>" data-host="<%= host.name %>">
29
- <tbody>
30
- <tr>
31
- <td>CPU:</td>
32
- <td style="padding-left:0.5em;"><%= host.logical_processor_count %></td>
33
- </tr>
34
- <tr>
35
- <td>Memory:</td>
36
- <td style="padding-left:0.5em;"><%= number_to_human_size(host.memory_capacity) %></td>
37
- </tr>
38
- </tbody>
39
- </table>
40
22
  <% end -%>
41
- </div>
42
- </div>
43
- </div>
44
-
45
23
  <% cluster_errors.each do |err| -%>
46
24
  <div class="alert alert-warning alert-dismissable">
47
25
  <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
@@ -49,10 +27,22 @@
49
27
  </div>
50
28
  <% end -%>
51
29
 
52
- <%= select_f f, :generation, hyperv_generations, :first, :last, {}, label: 'Firmware', disabled: !new_host, onchange: 'hypervGenerationChange(this);' %>
53
- <% if new_host || f.object.generation == :UEFI -%>
54
- <%= checkbox_f f, :secure_boot_enabled, { label: _('Enable Secure Boot'), disabled: f.object.generation == :BIOS }, 'true', 'false' %>
55
- <% end -%>
30
+ <%
31
+ firmware_type = compute_resource.firmware_type(f.object.foreman_firmware, f.object.secure_boot_enabled)
32
+ -%>
33
+ <%= field(f, :foreman_firmware, :label => _('Firmware'), :label_help => _("Choose 'Automatic' to set the firmware based on the PXE loader of the host. If no PXE loader is selected, firmware defaults to BIOS."), :label_size => "col-md-2") do
34
+ compute_resource.firmware_types.collect do |type, name|
35
+ enabled = new_vm
36
+ enabled ||= firmware_type != :bios && type.to_s.start_with?('uefi')
37
+
38
+ radio_button_f f, :foreman_firmware, { :checked => (firmware_type == type), :disabled => !enabled, :value => type, :text => _(name) }
39
+ end.join(' ').html_safe
40
+ end %>
41
+ <%= checkbox_f f, :tpm_enabled, { help_inline: _('Add Virtual TPM module to the VM.'),
42
+ label: _('Virtual TPM'),
43
+ label_help: _('Only compatible with UEFI firmware.'),
44
+ label_size: 'col-md-2' } %>
45
+ <%= select_f f, :boot_device, hyperv_boot_devices, :first, :last, {}, label: _('Boot device'), label_help: _('Has effect only for network based provisioning'), class: 'col-md-2' if new_vm %>
56
46
 
57
47
  <%= counter_f f, :processor_count, label: _('CPUs'), label_size: 'col-md-2' %>
58
48
  <%= byte_size_f f, :memory_startup, label: _('Memory (Startup)'), label_size: 'col-md-2' %>
@@ -61,7 +51,7 @@
61
51
  <%= byte_size_f f, :memory_maximum, class: 'col-md-2', label: _('Memory Maximum'), disabled: !f.object.dynamic_memory_enabled %>
62
52
  <%= byte_size_f f, :memory_minimum, class: 'col-md-2', label: _('Memory Minimum'), disabled: !f.object.dynamic_memory_enabled %>
63
53
 
64
- <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' %>
54
+ <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' -%>
65
55
  <%= checkbox_f f, :start, { checked: (checked == '1'), help_inline: _("Power ON this machine"), label: _('Start'), label_size: "col-md-2"} if new_host && controller_name != "compute_attributes" %>
66
56
 
67
57
  <%= textarea_f f, :notes, rows: '3', label: _('Notes') %>
@@ -9,26 +9,26 @@
9
9
 
10
10
  <%# If Access mode %>
11
11
  <div data-hyperv-vlan-mode="access" class="<%= 'hide' unless f.object.vlan_operation_mode.to_s == 'Access' %>">
12
- <%= number_f f, :access_vlan_id, label: _('Access VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Access') %>
12
+ <%= number_f f, :access_vlan_id, label: _('Access VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Access') %>
13
13
  </div>
14
14
  <%# If Trunk mode %>
15
15
  <div data-hyperv-vlan-mode="trunk" class="<%= 'hide' unless f.object.vlan_operation_mode.to_s == 'Trunk' %>">
16
- <%= number_f f, :native_vlan_id, label: _('Native VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Trunk') %>
17
- <%= text_f f, :allowed_vlan_ids, placeholder: '10,20-40,50', label: _('Allowed VLANs'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Trunk') %>
16
+ <%= number_f f, :native_vlan_id, label: _('Native VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Trunk') %>
17
+ <%= text_f f, :allowed_vlan_ids, placeholder: '10,20-40,50', label: _('Allowed VLANs'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Trunk') %>
18
18
  </div>
19
19
  <%# If Private mode %>
20
20
  <div data-hyperv-vlan-mode="private" class="<%= 'hide' unless f.object.vlan_operation_mode.to_s == 'Private' %>">
21
- <%= select_f f, :vlan_private_mode, hyperv_private_vlan_modes, :first, :last, {},
22
- label: _('VLAN private mode'), label_size: 'col-md-3', size: 'col-md-8',
23
- onchange: 'hypervVLANPrivateModeChange(this);',
24
- disabled: (f.object.vlan_operation_mode.to_s != 'Private') %>
25
- <%= number_f f, :primary_vlan_id, label: _('Primary VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Private') %>
26
- <%# If Isolated or Community private mode %>
27
- <div data-hyperv-vlan-private-mode="singular" class="<%= 'hide' if f.object.vlan_private_mode.to_s == 'Promiscuous' %>">
28
- <%= number_f f, :secondary_vlan_id, label: _('Secondary VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Private' || f.object.vlan_private_mode.to_s == 'Promiscuous') %>
29
- </div>
30
- <%# If Promiscuous private mode %>
31
- <div data-hyperv-vlan-private-mode="plural" class="<%= 'hide' unless f.object.vlan_private_mode.to_s == 'Promiscuous' %>">
32
- <%= text_f f, :secondary_vlan_ids, placeholder: '10,20-40,50', label: _('Secondary VLANs'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Private' || f.object.vlan_private_mode.to_s != 'Promiscuous') %>
33
- </div>
21
+ <%= select_f f, :vlan_private_mode, hyperv_private_vlan_modes, :first, :last, {},
22
+ label: _('VLAN private mode'), label_size: 'col-md-3', size: 'col-md-8',
23
+ onchange: 'hypervVLANPrivateModeChange(this);',
24
+ disabled: (f.object.vlan_operation_mode.to_s != 'Private') %>
25
+ <%= number_f f, :primary_vlan_id, label: _('Primary VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Private') %>
26
+ <%# If Isolated or Community private mode %>
27
+ <div data-hyperv-vlan-private-mode="singular" class="<%= 'hide' if f.object.vlan_private_mode.to_s == 'Promiscuous' %>">
28
+ <%= number_f f, :secondary_vlan_id, label: _('Secondary VLAN'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Private' || f.object.vlan_private_mode.to_s == 'Promiscuous') %>
29
+ </div>
30
+ <%# If Promiscuous private mode %>
31
+ <div data-hyperv-vlan-private-mode="plural" class="<%= 'hide' unless f.object.vlan_private_mode.to_s == 'Promiscuous' %>">
32
+ <%= text_f f, :secondary_vlan_ids, placeholder: '10,20-40,50', label: _('Secondary VLANs'), label_size: 'col-md-3', size: 'col-md-8', required: true, disabled: (f.object.vlan_operation_mode.to_s != 'Private' || f.object.vlan_private_mode.to_s != 'Promiscuous') %>
33
+ </div>
34
34
  </div>
@@ -4,5 +4,5 @@
4
4
  <%= f.hidden_field :id %>
5
5
  <%= f.hidden_field :basename %>
6
6
  <% end -%>
7
- <%= text_f f, :basename, label: _('Name'), help_inline: _('This is the VHD filename on disk, without extension'), required: true, disabled: f.object.persisted? %>
7
+ <%= text_f f, :basename, label: _('Name'), label_help: _('This is the VHD filename on disk, without extension'), required: true, disabled: f.object.persisted? %>
8
8
  <%= byte_size_f f, :size_bytes, label: _('Size') %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ForemanHyperv
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_hyperv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Olofsson
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '0.1'
18
+ version: '0.2'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '0.1'
25
+ version: '0.2'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: bundler
28
28
  requirement: !ruby/object:Gem::Requirement