foreman_fog_proxmox 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of foreman_fog_proxmox might be problematic. Click here for more details.

Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +12 -5
  4. data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +33 -14
  5. data/app/helpers/proxmox_container_helper.rb +32 -38
  6. data/app/helpers/proxmox_server_helper.rb +34 -39
  7. data/app/helpers/proxmox_vm_helper.rb +1 -20
  8. data/app/models/concerns/fog_extensions/proxmox/interface.rb +29 -0
  9. data/app/models/concerns/fog_extensions/proxmox/node.rb +13 -0
  10. data/app/models/concerns/fog_extensions/proxmox/server.rb +4 -1
  11. data/app/models/concerns/host_ext/proxmox/interfaces.rb +37 -0
  12. data/app/models/concerns/orchestration/proxmox/compute.rb +38 -0
  13. data/app/models/foreman_fog_proxmox/proxmox.rb +71 -36
  14. data/app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb +24 -0
  15. data/app/views/compute_resources/form/_proxmox.html.erb +1 -1
  16. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb +0 -1
  17. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb +0 -1
  18. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +0 -1
  19. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +3 -6
  20. data/app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb +22 -0
  21. data/app/views/compute_resources_vms/form/proxmox/container/_network.html.erb +2 -1
  22. data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +6 -5
  23. data/app/views/compute_resources_vms/form/proxmox/container/_volume_rootfs.html.erb +3 -3
  24. data/app/views/compute_resources_vms/form/proxmox/server/_network.html.erb +2 -1
  25. data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +5 -4
  26. data/app/views/compute_resources_vms/show/_proxmox.html.erb +1 -1
  27. data/lib/foreman_fog_proxmox/engine.rb +4 -0
  28. data/lib/foreman_fog_proxmox/version.rb +1 -1
  29. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +28 -29
  30. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +28 -27
  31. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +0 -25
  32. data/test/unit/foreman_fog_proxmox/proxmox_test.rb +215 -5
  33. data/test/unit/foreman_fog_proxmox/proxmox_test_helpers.rb +10 -2
  34. metadata +9 -4
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module HostExt::Proxmox::Interfaces
21
+ extend ActiveSupport::Concern
22
+ def update(attributes = {})
23
+ add_interfaces_to_compute_attributes(attributes)
24
+ super(attributes)
25
+ end
26
+ def add_interfaces_to_compute_attributes(attributes)
27
+ attributes['compute_attributes']['interfaces_attributes'] = {}
28
+ attributes['interfaces_attributes'].each { |index,interface_attributes| add_interface_to_compute_attributes(index,interface_attributes,attributes['compute_attributes']['interfaces_attributes']) }
29
+ end
30
+ def add_interface_to_compute_attributes(index,interface_attributes,compute_attributes)
31
+ compute_attributes[index] = {}
32
+ compute_attributes[index].store('id',interface_attributes['identifier'])
33
+ compute_attributes[index].store('_delete',interface_attributes['_destroy'])
34
+ compute_attributes[index].store('macaddr',interface_attributes['mac'])
35
+ compute_attributes[index].merge!(interface_attributes['compute_attributes'].reject { |k,_v| k == 'id' })
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanFogProxmox.
6
+
7
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+
12
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module Orchestration::Proxmox::Compute
21
+ extend ActiveSupport::Concern
22
+
23
+ def setComputeUpdate
24
+ logger.info "Update Proxmox Compute instance for #{name}"
25
+ final_compute_attributes = compute_attributes.merge(compute_resource.host_compute_attrs(self))
26
+ compute_resource.save_vm uuid, final_compute_attributes
27
+ rescue => e
28
+ failure _("Failed to update a compute %{compute_resource} instance %{name}: %{e}") % { :compute_resource => compute_resource, :name => name, :e => e }, e
29
+ end
30
+
31
+ def delComputeUpdate
32
+ logger.info "Undo Update Proxmox Compute instance for #{name}"
33
+ final_compute_attributes = old.compute_attributes.merge(compute_resource.host_compute_attrs(old))
34
+ compute_resource.save_vm uuid, final_compute_attributes
35
+ rescue => e
36
+ failure _("Failed to undo update compute %{compute_resource} instance %{name}: %{e}") % { :compute_resource => compute_resource, :name => name, :e => e }, e
37
+ end
38
+ end
@@ -18,7 +18,10 @@
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  require 'fog/proxmox'
21
+ require 'fog/proxmox/helpers/nic_helper'
22
+ require 'fog/proxmox/helpers/disk_helper'
21
23
  require 'foreman_fog_proxmox/semver'
24
+ require 'foreman_fog_proxmox/value'
22
25
 
23
26
  module ForemanFogProxmox
24
27
  class Proxmox < ComputeResource
@@ -42,7 +45,7 @@ module ForemanFogProxmox
42
45
  end
43
46
 
44
47
  def capabilities
45
- [:build, :new_volume, :image]
48
+ [:build, :new_volume, :new_interface, :image]
46
49
  end
47
50
 
48
51
  def self.model_name
@@ -65,7 +68,11 @@ module ForemanFogProxmox
65
68
  version_suitable?
66
69
  rescue => e
67
70
  errors[:base] << e.message
68
- errors[:url] << e.message
71
+ if e.message.include?('SSL')
72
+ errors[:ssl_certs] << e.message
73
+ else
74
+ errors[:url] << e.message
75
+ end
69
76
  end
70
77
 
71
78
  def nodes
@@ -129,12 +136,17 @@ module ForemanFogProxmox
129
136
  host.interfaces.select(&:physical?).each.with_index.reduce({}) do |hash, (nic, index)|
130
137
  # Set default interface identifier to net[n]
131
138
  nic.identifier = "net%{index}" % {index: index} if nic.identifier.empty?
132
- raise ::Foreman::Exception.new _("Invalid identifier interface[%{index}]. Must be net[n] with n integer >= 0" % { index: index }) unless Fog::Proxmox::NicHelper.valid?(nic.identifier)
139
+ raise ::Foreman::Exception.new _("Invalid identifier interface[%{index}]. Must be net[n] with n integer >= 0" % { index: index }) unless Fog::Proxmox::NicHelper.nic?(nic.identifier)
133
140
  # Set default container interface name to eth[n]
134
141
  container = host.compute_attributes['type'] == 'lxc'
135
142
  nic.compute_attributes['name'] = "eth%{index}" % {index: index} if container && nic.compute_attributes['name'].empty?
136
143
  raise ::Foreman::Exception.new _("Invalid name interface[%{index}]. Must be eth[n] with n integer >= 0" % { index: index }) if container && !/^(eth)(\d+)$/.match?(nic.compute_attributes['name'])
137
144
  nic_compute_attributes = nic.compute_attributes.merge(id: nic.identifier)
145
+ mac = nic.mac
146
+ mac = nic.attributes['mac'] unless mac
147
+ nic_compute_attributes.store(:macaddr, mac) if (mac && !mac.empty?)
148
+ interface_compute_attributes = host.compute_attributes['interfaces_attributes'].select { |_k,v| v['id'] == nic.identifier }
149
+ nic_compute_attributes.store(:_delete, interface_compute_attributes[interface_compute_attributes.keys[0]]['_delete']) unless interface_compute_attributes.empty?
138
150
  nic_compute_attributes.store(:ip, nic.ip) if (nic.ip && !nic.ip.empty?)
139
151
  nic_compute_attributes.store(:ip6, nic.ip6) if (nic.ip6 && !nic.ip6.empty?)
140
152
  hash.merge(index.to_s => nic_compute_attributes)
@@ -187,35 +199,17 @@ module ForemanFogProxmox
187
199
  Fog::Proxmox::Compute::Interface.new(opts)
188
200
  end
189
201
 
190
- # used by host.clone
191
202
  def vm_compute_attributes(vm)
192
- vm_attrs = vm.attributes.reject { |key,value| [:config, :vmid].include?(key.to_sym) || value.to_s.empty? }
193
- vm_attrs = set_vm_config_attributes(vm, vm_attrs)
194
- vm_attrs = set_vm_volumes_attributes(vm, vm_attrs)
195
- vm_attrs = set_vm_interfaces_attributes(vm, vm_attrs)
196
- vm_attrs
197
- end
198
-
199
- def set_vm_config_attributes(vm, vm_attrs)
203
+ vm_attrs = {}
200
204
  if vm.respond_to?(:config)
201
- config = vm.config.attributes.reject { |key,value| [:disks, :interfaces, :vmid].include?(key) || value.to_s.empty?}
202
- vm_attrs[:config_attributes] = config
203
- end
204
- vm_attrs
205
- end
206
-
207
- def set_vm_volumes_attributes(vm, vm_attrs)
208
- if vm.config.respond_to?(:disks)
209
- volumes = vm.config.disks || []
210
- vm_attrs[:volumes_attributes] = Hash[volumes.each_with_index.map { |volume, idx| [idx.to_s, volume.attributes] }]
211
- end
212
- vm_attrs
213
- end
214
-
215
- def set_vm_interfaces_attributes(vm, vm_attrs)
216
- if vm.config.respond_to?(:interfaces)
217
- interfaces = vm.config.interfaces || []
218
- vm_attrs[:interfaces_attributes] = Hash[interfaces.each_with_index.map { |interface, idx| [idx.to_s, interface.attributes] }]
205
+ vm_attrs = vm_attrs.merge(vmid: vm.identity, node_id: vm.node_id, type: vm.type)
206
+ if vm.config.respond_to?(:disks)
207
+ vm_attrs[:volumes_attributes] = Hash[vm.config.disks.each_with_index.map { |disk, idx| [idx.to_s, disk.attributes] }]
208
+ end
209
+ if vm.config.respond_to?(:interfaces)
210
+ vm_attrs[:interfaces_attributes] = Hash[vm.config.interfaces.each_with_index.map { |interface, idx| [idx.to_s, interface.attributes] }]
211
+ end
212
+ vm_attrs[:config_attributes] = vm.config.attributes.reject { |key,value| [:disks, :interfaces, :vmid, :node_id, :node, :type].include?(key) || !vm.config.respond_to?(key) || ForemanFogProxmox::Value.empty?(value.to_s) || Fog::Proxmox::DiskHelper.disk?(key.to_s) || Fog::Proxmox::NicHelper.nic?(key.to_s) }
219
213
  end
220
214
  vm_attrs
221
215
  end
@@ -239,15 +233,19 @@ module ForemanFogProxmox
239
233
  end
240
234
 
241
235
  def new_container_vm(new_attr = {})
242
- new_attr.merge(node_id: node_id)
243
- vm = node.containers.new(parse_container_vm(vm_container_instance_defaults.merge(new_attr.merge(type: 'lxc'))).deep_symbolize_keys)
236
+ options = new_attr
237
+ options = options.merge(node_id: node_id).merge(type: 'lxc').merge(vmid: next_vmid)
238
+ options= vm_container_instance_defaults.merge(options) if new_attr.empty?
239
+ vm = node.containers.new(parse_container_vm(options).deep_symbolize_keys)
244
240
  logger.debug(_("new_container_vm() vm.config=%{config}") % { config: vm.config.inspect })
245
241
  vm
246
242
  end
247
243
 
248
244
  def new_server_vm(new_attr = {})
249
- new_attr.merge(node_id: node_id)
250
- vm = node.servers.new(parse_server_vm(vm_server_instance_defaults.merge(new_attr.merge(type: 'qemu'))).deep_symbolize_keys)
245
+ options = new_attr
246
+ options = options.merge(node_id: node_id).merge(type: 'qemu').merge(vmid: next_vmid)
247
+ options = vm_server_instance_defaults.merge(options) if new_attr.empty?
248
+ vm = node.servers.new(parse_server_vm(options).deep_symbolize_keys)
251
249
  logger.debug(_("new_server_vm() vm.config=%{config}") % { config: vm.config.inspect })
252
250
  vm
253
251
  end
@@ -331,14 +329,51 @@ module ForemanFogProxmox
331
329
  !find_vm_by_uuid(image).nil?
332
330
  end
333
331
 
332
+ def save_volumes(vm, volumes_attributes)
333
+ if volumes_attributes
334
+ volumes_attributes.each_value do |volume_attributes|
335
+ id = volume_attributes['id']
336
+ disk = vm.config.disks.get(id)
337
+ delete = volume_attributes['_delete']
338
+ if disk
339
+ if delete == '1'
340
+ vm.detach(id)
341
+ device = Fog::Proxmox::DiskHelper.extract_device(id)
342
+ vm.detach('unused' + device.to_s)
343
+ else
344
+ diff_size = volume_attributes['size'].to_i - disk.size
345
+ raise ::Foreman::Exception.new(_("Unable to shrink %{id} size. Proxmox allows only increasing size.") % { id: id }) unless diff_size >= 0
346
+ if diff_size > 0
347
+ extension = '+' + (diff_size / GIGA).to_s + 'G'
348
+ vm.extend(id,extension)
349
+ elsif disk.storage != volume_attributes['storage']
350
+ vm.move(id,volume_attributes['storage'])
351
+ end
352
+ end
353
+ else
354
+ options = {}
355
+ options.store(:mp, volume_attributes['mp']) if vm.container?
356
+ disk_attributes = { id: id, storage: volume_attributes['storage'], size: (volume_attributes['size'].to_i / GIGA).to_s }
357
+ vm.attach(disk_attributes, options) unless delete == '1'
358
+ end
359
+ end
360
+ end
361
+ end
362
+
334
363
  def save_vm(uuid, new_attributes)
335
364
  vm = find_vm_by_uuid(uuid)
336
- templated = new_attributes[:templated]
365
+ templated = new_attributes['templated']
337
366
  if (templated == '1' && !vm.templated?)
338
367
  vm.create_template
339
368
  else
369
+ volumes_attributes = new_attributes['volumes_attributes']
370
+ save_volumes(vm, volumes_attributes)
340
371
  parsed_attr = vm.container? ? parse_container_vm(new_attributes.merge(type: vm.type)) : parse_server_vm(new_attributes.merge(type: vm.type))
341
- vm.update(parsed_attr.reject { |key,value| [:templated,:ostemplate,:ostemplate_file,:ostemplate_storage].include? key.to_sym || ForemanFogProxmox::Value.empty?(value) })
372
+ config_attributes = parsed_attr.reject { |key,_value| [:templated,:ostemplate,:ostemplate_file,:ostemplate_storage,:volumes_attributes].include? key.to_sym }
373
+ config_attributes = config_attributes.reject { |_key,value| ForemanFogProxmox::Value.empty?(value) }
374
+ cdrom_attributes = parsed_attr.select { |_key,value| Fog::Proxmox::DiskHelper.cdrom?(value.to_s) }
375
+ config_attributes = config_attributes.reject { |key,_value| Fog::Proxmox::DiskHelper.disk?(key) }
376
+ vm.update(config_attributes.merge(cdrom_attributes))
342
377
  end
343
378
  vm = find_vm_by_uuid(uuid)
344
379
  end
@@ -0,0 +1,24 @@
1
+ # Copyright 2018 Tristan Robert
2
+
3
+ # This file is part of ForemanFogProxmox.
4
+
5
+ # ForemanFogProxmox is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+
10
+ # ForemanFogProxmox is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
17
+
18
+ Deface::Override.new(
19
+ :virtual_path => "compute_resources_vms/form/_removable_layout",
20
+ :name => "remove_new_vm_from_removable_layout",
21
+ :replace_contents => "div.remove-button",
22
+ :partial => "compute_resources_vms/form/proxmox/removable_layout",
23
+ :original => "8b7383e57fbe158fc12bf8bc1003431f2f2cb6f5"
24
+ )
@@ -22,7 +22,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
22
22
  <%= text_f f, :url, :help_block => _("e.g. https://127.0.0.1:8006/api2/json"), :help_inline_permanent => load_button_f(f, !!nodes, _("Test failed")) %>
23
23
  <%= text_f f, :user , :help_block => _("e.g. root@pam") %>
24
24
  <%= password_f f, :password, :keep_value => true, :unset => unset_password? %>
25
- <%= checkbox_f f, :ssl_verify_peer, :label => _("SSL verify peer"), :checked => true, :onchange => "sslVerifyPeerSelected(this)" %>
25
+ <%= checkbox_f f, :ssl_verify_peer, :label => _("SSL verify peer"), :checked_value => '1', :onchange => "sslVerifyPeerSelected()" %>
26
26
  <%= textarea_f f, :ssl_certs, :label => _("X509 Certification Authorities"), :size => "col-md-4",
27
27
  :placeholder => _("Optionally provide a CA, or a correctly ordered CA chain. If left blank, disable ssl_verify_peer.") %>
28
28
  <%= select_f f, :node_id, nodes, :node, :node, { :include_blank => true }, :label => _('Node'), :label_size => "col-md-2", :required => true, :disabled => (node_id != '') %>
@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License
16
16
  along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% vm_type = f.object.respond_to?('type') ? f.object.type : nil %>
19
- <% logger.debug("vm_type=#{vm_type}") %>
20
19
 
21
20
  <%= render :partial => provider_partial(compute_resource, 'network'),
22
21
  :locals => { :f => i, :vm_type => vm_type, :compute_resource => compute_resource, :new_host => new_host, :new_vm => new_vm, :remove_title => _('remove network interface'), :selected_cluster => selected_cluster },
@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License
16
16
  along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% vm_type = f.object.respond_to?('type') ? f.object.type : nil %>
19
- <% logger.debug("vm_type=#{vm_type}") %>
20
19
 
21
20
  <%= new_child_fields_template(f, compute_resource.interfaces_attrs_name, {
22
21
  :object => compute_resource.new_interface,
@@ -16,7 +16,6 @@ You should have received a copy of the GNU General Public License
16
16
  along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
  <% compute_attributes = f.options[:parent_builder].object.compute_attributes %>
18
18
  <% vm_type = compute_attributes ? compute_attributes['type'] : f.object.type %>
19
- <% logger.debug("vm_type=#{vm_type}") %>
20
19
 
21
20
  <%= f.fields_for 'compute_attributes', OpenStruct.new(f.object.compute_attributes) do |f| %>
22
21
  <%= render provider_partial(@host.compute_resource, 'network'), :f => f, :vm_type => vm_type, :disabled => f.object.persisted?, :compute_resource => @host.compute_resource, :new_host => new_vm, :new_vm => new_vm %>
@@ -35,25 +35,22 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
35
35
 
36
36
 
37
37
  <%= f.fields_for :volumes do |i| %>
38
- <% if i.object.id == 'rootfs' %>
38
+ <% if i.object.rootfs? %>
39
39
  <div id="container_volumes_rootfs" style="<%= 'display: ' + (container ? 'block' : 'none') + ';' %>">
40
40
  <%= render :partial => provider_partial(compute_resource, 'container/volume_rootfs'), :locals => { :f => i, :type => type, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :remove_title => _('remove storage volume'), :disabled => !container }, :layout => "compute_resources_vms/form/#{item_layout}_layout" %>
41
41
  </div>
42
- <% elsif mount_point_disk?(i.object.id) %>
42
+ <% elsif i.object.mount_point? %>
43
43
  <div id="container_volumes_mp" style="<%= 'display: ' + (container ? 'block' : 'none') + ';' %>">
44
44
  <%= render :partial => provider_partial(compute_resource, 'container/volume_mp'), :locals => { :f => i, :type => type, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :remove_title => _('remove storage volume'), :disabled => !container }, :layout => "compute_resources_vms/form/#{item_layout}_layout" %>
45
45
  </div>
46
- <% elsif server_disk?(i.object.id) %>
46
+ <% elsif i.object.controller? %>
47
47
  <div id="server_volumes" style="<%= 'display: ' + (server ? 'block' : 'none') + ';' %>">
48
48
  <%= render :partial => provider_partial(compute_resource, 'server/volume'), :locals => { :f => i, :type => type, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :remove_title => _('remove storage volume'), :disabled => !server }, :layout => "compute_resources_vms/form/#{item_layout}_layout" %>
49
49
  </div>
50
50
  <% end %>
51
51
  <% end %>
52
52
 
53
- <% if new_vm %>
54
53
  <%= add_child_link_typed '+ ' + _("Add Volume"), :volumes, 'server', { :class => "info #{'hide' unless server}", :title => _('add new storage volume') } %>
55
54
  <%= add_child_link_typed '+ ' + _("Add Volume"), :volumes, 'container', { :class => "info #{'hide' unless container}", :title => _('add new storage volume') } %>
56
- <% end %>
57
-
58
55
 
59
56
 
@@ -0,0 +1,22 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of ForemanFogProxmox.
4
+
5
+ ForemanFogProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ ForemanFogProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <% volume_rootfs = f.object.respond_to?(:rootfs?) && f.object.rootfs? %>
19
+
20
+ <% unless volume_rootfs %>
21
+ <%= remove_child_link('X', f, { :method => :'_delete', :title => local_assigns[:remove_title], :class => 'label label-danger' }) %>
22
+ <% end %>
@@ -17,7 +17,8 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% container = type == 'lxc' %>
19
19
 
20
- <%= field_set_tag _("Nic"), :id => "container_network", :style => ('display: none;' unless container), :disabled => !container do %>
20
+ <%= field_set_tag _("Nic"), :id => "container_network_#{f.index}", :style => ('display: none;' unless container), :disabled => !container do %>
21
+ <%= f.hidden_field :id if !new_vm %>
21
22
  <%= text_f f, :name, :label => _('Name'), :label_size => "col-md-2" %>
22
23
  <%= counter_f f, :tag, :class => "input-mini", :label => _('VLAN tag'), :label_size => "col-md-2" %>
23
24
  <%= counter_f f, :rate, :class => "input-mini", :label => _('Rate limit'), :label_size => "col-md-2" %>
@@ -16,11 +16,12 @@ You should have received a copy of the GNU General Public License
16
16
  along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% container = type == 'lxc' %>
19
+ <% new_volume = f.object.volid.nil? %>
19
20
 
20
- <%= field_set_tag _("Mount point"), :id => "container_volume_#{f.index}", :class => ('hide' unless container), :disabled => !container do %>
21
+ <%= field_set_tag _("Mount point"), :id => "container_volume_mp_#{f.index}", :class => ('hide' unless container), :disabled => !container do %>
21
22
  <%= f.hidden_field :volid if !new_vm %>
22
- <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2", :disabled => !new_vm %>
23
- <%= text_f f, :mp, :label => _('Path'), :label_size => "col-md-2", :disabled => !new_vm, :required => true %>
24
- <%= counter_f f, :device, :label => _('Device'), :label_size => "col-md-2", :class => ('hide' if f.object.rootfs?), :disabled => (!new_vm || f.object.rootfs?), :'data-soft-max' => 10 %>
25
- <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2", :disabled => !new_vm %>
23
+ <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
24
+ <%= text_f f, :mp, :label => _('Path'), :label_size => "col-md-2", :required => true, :help_inline => _("e.g. /path/to/") %>
25
+ <%= counter_f f, :device, :label => _('Device'), :label_size => "col-md-2", :class => ('hide' if f.object.rootfs?), :disabled => (!new_volume || f.object.rootfs?), :'data-soft-max' => 10 %>
26
+ <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
26
27
  <% end %>
@@ -17,8 +17,8 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% container = type == 'lxc' %>
19
19
 
20
- <%= field_set_tag _("Rootfs"), :id => "container_volume_#{f.index}", :class => ('hide' unless container), :disabled => !container do %>
20
+ <%= field_set_tag _("Rootfs"), :id => "container_volume_rootfs", :class => ('hide' unless container), :disabled => !container do %>
21
21
  <%= f.hidden_field :volid if !new_vm %>
22
- <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2", :disabled => !new_vm %>
23
- <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2", :disabled => !new_vm %>
22
+ <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
23
+ <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
24
24
  <% end %>
@@ -17,7 +17,8 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% server = type == 'qemu' %>
19
19
 
20
- <%= field_set_tag _("Nic"), :id => "server_network", :style => ('display: none;' unless server), :disabled => !server do %>
20
+ <%= field_set_tag _("Nic"), :id => "server_network_#{f.index}", :style => ('display: none;' unless server), :disabled => !server do %>
21
+ <%= f.hidden_field :id if !new_vm %>
21
22
  <%= select_f f, :model, proxmox_networkcards_map, :id, :name, { }, :label => _('Card'), :label_size => "col-md-2" %>
22
23
  <%= select_f f, :bridge, compute_resource.bridges, :iface, :iface, { }, :label => _('Bridge'), :label_size => "col-md-2" %>
23
24
  <%= counter_f f, :tag, :class => "input-mini", :label => _('VLAN tag'), :label_size => "col-md-2" %>
@@ -16,12 +16,13 @@ You should have received a copy of the GNU General Public License
16
16
  along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
17
 
18
18
  <% server = type == 'qemu' %>
19
+ <% new_volume = f.object.volid.nil? %>
19
20
 
20
21
  <%= field_set_tag _("Disk"), :id => "server_volume_#{f.index}", :class => ('hide' unless server), :disabled => !server do %>
21
22
  <%= f.hidden_field :volid if !new_vm %>
22
- <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2", :disabled => !new_vm %>
23
- <%= select_f f, :controller, proxmox_controllers_map, :id, :name, { }, :label => _('Controller'), :label_size => "col-md-2", :disabled => !new_vm, :onchange => 'controllerSelected(this)' %>
24
- <%= counter_f f, :device, :label => _('Device'), :label_size => "col-md-2", :disabled => !new_vm, :'data-soft-max' => proxmox_max_device(f.object.controller), :onchange => 'deviceSelected(this)' %>
23
+ <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
24
+ <%= select_f f, :controller, proxmox_controllers_map, :id, :name, { }, :label => _('Controller'), :label_size => "col-md-2", :disabled => !new_volume, :onchange => 'controllerSelected(this)' %>
25
+ <%= counter_f f, :device, :label => _('Device'), :label_size => "col-md-2", :disabled => !new_volume, :'data-soft-max' => proxmox_max_device(f.object.controller), :onchange => 'deviceSelected(this)' %>
25
26
  <%= select_f f, :cache, proxmox_caches_map, :id, :name, { }, :label => _('Cache'), :label_size => "col-md-2" %>
26
- <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2", :disabled => !new_vm %>
27
+ <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
27
28
  <% end %>
@@ -26,7 +26,6 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
26
26
  <%= prop :type %>
27
27
  <%= prop :node_id %>
28
28
  <%= prop :templated? %>
29
- <%= prop :mac %>
30
29
  <%= prop :memory %>
31
30
  <% unless @vm.container? %>
32
31
  <%= prop :vga %>
@@ -36,5 +35,6 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
36
35
  <%= prop :vmid %>
37
36
  <%= prop :description %>
38
37
  <%= prop :disks %>
38
+ <%= prop :nics %>
39
39
  </table>
40
40
  </div>