foreman_fog_proxmox 0.8.0 → 0.8.2

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 (93) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -1
  3. data/Rakefile +3 -1
  4. data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +2 -2
  5. data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +2 -2
  6. data/app/helpers/node_dashboard_helper.rb +13 -14
  7. data/app/helpers/proxmox_compute_selectors_helper.rb +49 -50
  8. data/app/helpers/proxmox_container_helper.rb +42 -36
  9. data/app/helpers/proxmox_form_helper.rb +38 -40
  10. data/app/helpers/proxmox_server_helper.rb +39 -41
  11. data/app/helpers/proxmox_vm_helper.rb +21 -25
  12. data/app/models/concerns/fog_extensions/proxmox/disk.rb +8 -8
  13. data/app/models/concerns/fog_extensions/proxmox/interface.rb +8 -8
  14. data/app/models/concerns/fog_extensions/proxmox/node.rb +24 -22
  15. data/app/models/concerns/fog_extensions/proxmox/server.rb +71 -59
  16. data/app/models/concerns/fog_extensions/proxmox/server_config.rb +47 -39
  17. data/app/models/concerns/fog_extensions/proxmox/volume.rb +8 -8
  18. data/app/models/concerns/host_ext/proxmox/interfaces.rb +21 -13
  19. data/app/models/concerns/orchestration/proxmox/compute.rb +14 -10
  20. data/app/models/foreman_fog_proxmox/options_select.rb +14 -14
  21. data/app/models/foreman_fog_proxmox/proxmox.rb +30 -466
  22. data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +54 -0
  23. data/app/models/foreman_fog_proxmox/proxmox_connection.rb +67 -0
  24. data/app/models/foreman_fog_proxmox/proxmox_console.rb +41 -0
  25. data/app/models/foreman_fog_proxmox/proxmox_images.rb +53 -0
  26. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +60 -0
  27. data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +49 -0
  28. data/app/models/foreman_fog_proxmox/proxmox_token_expiration.rb +30 -0
  29. data/app/models/foreman_fog_proxmox/proxmox_version.rb +36 -0
  30. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +108 -0
  31. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +162 -0
  32. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +74 -0
  33. data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +85 -0
  34. data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +7 -6
  35. data/app/overrides/compute_resources_vms/form/add_from_profile_to_compute_attributes_form.rb +13 -11
  36. data/app/overrides/compute_resources_vms/form/add_vm_type_to_networks_form.rb +13 -11
  37. data/app/overrides/compute_resources_vms/form/add_vm_type_to_nic_provider_specific_form.rb +8 -7
  38. data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb +7 -6
  39. data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb +7 -6
  40. data/app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb +7 -6
  41. data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +16 -16
  42. data/app/views/api/v2/compute_resources/proxmox.json.rabl +3 -1
  43. data/app/views/compute_resources/form/_proxmox.html.erb +3 -0
  44. data/app/views/compute_resources/show/_proxmox.html.erb +8 -0
  45. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb +5 -0
  46. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb +6 -1
  47. data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb +6 -0
  48. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb +6 -2
  49. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb +8 -2
  50. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +6 -0
  51. data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +15 -1
  52. data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +2 -2
  53. data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +1 -1
  54. data/app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb +6 -1
  55. data/app/views/compute_resources_vms/form/proxmox/container/_extended.html.erb +1 -1
  56. data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +1 -1
  57. data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +1 -1
  58. data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +2 -2
  59. data/config/routes.rb +4 -4
  60. data/lib/foreman_fog_proxmox/engine.rb +14 -14
  61. data/lib/foreman_fog_proxmox/semver.rb +78 -78
  62. data/lib/foreman_fog_proxmox/value.rb +5 -3
  63. data/lib/foreman_fog_proxmox/version.rb +1 -1
  64. data/lib/tasks/foreman_fog_proxmox_tasks.rake +3 -13
  65. data/locale/en/foreman_fog_proxmox.edit.po +472 -0
  66. data/locale/en/foreman_fog_proxmox.po +48 -24
  67. data/locale/en/foreman_fog_proxmox.po.time_stamp +0 -0
  68. data/locale/foreman_fog_proxmox.pot +140 -102
  69. data/locale/fr/foreman_fog_proxmox.edit.po +472 -0
  70. data/locale/fr/foreman_fog_proxmox.po +52 -28
  71. data/locale/fr/foreman_fog_proxmox.po.time_stamp +0 -0
  72. data/locale/gemspec.rb +2 -0
  73. data/test/{unit/foreman_fog_proxmox/proxmox_test_helpers.rb → factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb} +4 -140
  74. data/test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb +61 -0
  75. data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +134 -0
  76. data/test/factories/proxmox_factory.rb +15 -15
  77. data/test/functional/compute_resources_controller_test.rb +12 -10
  78. data/test/test_plugin_helper.rb +2 -0
  79. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +178 -182
  80. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +122 -126
  81. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +180 -187
  82. data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +116 -0
  83. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +71 -0
  84. data/test/unit/foreman_fog_proxmox/proxmox_test.rb +9 -479
  85. data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +82 -0
  86. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +207 -0
  87. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +92 -0
  88. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +324 -0
  89. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb +43 -0
  90. data/test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb +71 -0
  91. data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +63 -0
  92. data/test/unit/foreman_fog_proxmox/semver_test.rb +67 -53
  93. metadata +52 -14
@@ -16,9 +16,10 @@
16
16
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
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
- )
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
+ :namespaced => true
25
+ )
@@ -1,4 +1,3 @@
1
-
2
1
  # frozen_string_literal: true
3
2
 
4
3
  # Copyright 2018 Tristan Robert
@@ -18,20 +17,21 @@
18
17
  # You should have received a copy of the GNU General Public License
19
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
20
19
 
21
- module ForemanFogProxmox::NodeDashboard
20
+ module ForemanFogProxmox
21
+ module NodeDashboard
22
22
  class Data
23
-
24
- def initialize(filter="")
25
- @filter = filter
26
- end
27
-
28
- def node_id
29
- @compute_resource = ComputeResource.find_by(type: 'ForemanFogProxmox::Proxmox')
30
- @compute_resource.node_id if @compute_resource
31
- end
32
-
33
- def statistics
34
- node.statistics('rrddata', { timeframe: 'hour', cf: 'AVERAGE' }) if node_id
35
- end
23
+ def initialize(filter = '')
24
+ @filter = filter
25
+ end
26
+
27
+ def node_id
28
+ @compute_resource = ComputeResource.find_by(type: 'ForemanFogProxmox::Proxmox')
29
+ @compute_resource&.node_id
30
+ end
31
+
32
+ def statistics
33
+ node.statistics('rrddata', timeframe: 'hour', cf: 'AVERAGE') if node_id
34
+ end
36
35
  end
37
- end
36
+ end
37
+ end
@@ -1 +1,3 @@
1
- attributes :user, :url, :ssl_verify_peer, :disable_proxy
1
+ # frozen_string_literal: true
2
+
3
+ attributes :user, :url, :ssl_verify_peer, :disable_proxy
@@ -19,6 +19,9 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
19
19
 
20
20
  <% nodes = f.object.nodes rescue nil %>
21
21
  <% node_id = !!f.object.node_id ? f.object.node_id : '' %>
22
+ <% token_expired = f.object.token_expired? %>
23
+ <% token_deadline = f.object.token_deadline %>
24
+ <%= checkbox_f f, :renew, :label => _("Renew expired token ?"), :checked_value => '1', :label_help => _("Token expires on #{token_deadline}") %>
22
25
  <%= 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
26
  <%= text_f f, :user , :help_block => _("e.g. root@pam") %>
24
27
  <%= password_f f, :password, :keep_value => true, :unset => unset_password? %>
@@ -23,3 +23,11 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
23
23
  <td><%= _("Version") %></td>
24
24
  <td><%= @compute_resource.version%></td>
25
25
  </tr>
26
+ <tr>
27
+ <td><%= _("Token has expired?") %></td>
28
+ <td><%= @compute_resource.token_expired?%></td>
29
+ </tr>
30
+ <tr>
31
+ <td><%= _("Token expires on") %></td>
32
+ <td><%= @compute_resource.token_deadline%></td>
33
+ </tr>
@@ -14,5 +14,10 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if @set.compute_resource.class == ForemanFogProxmox::Proxmox %>
17
18
  <%= render :partial => "compute_form",
18
19
  :locals => { :f => f2, :compute_resource => @set.compute_resource, :selected_cluster => @set.vm_attrs['cluster'], :from_profile => true } %>
20
+ <% else %>
21
+ <%= render :partial => "compute_form",
22
+ :locals => { :f => f2, :compute_resource => @set.compute_resource, :selected_cluster => @set.vm_attrs['cluster'] } %>
23
+ <% end %>
@@ -14,5 +14,10 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
17
18
  <%= render :partial => provider_partial(compute_resource, 'base'),
18
- :locals => { :f => f, :compute_resource => compute_resource, :new_host => true, :new_vm => true, :hide_image => true, :from_profile => from_profile }.merge(args_for_compute_resource_partial(@host)) %>
19
+ :locals => { :f => f, :compute_resource => compute_resource, :new_host => true, :new_vm => true, :hide_image => true, :from_profile => from_profile }.merge(args_for_compute_resource_partial(@host)) %>
20
+ <% else %>
21
+ <%= render :partial => provider_partial(compute_resource, 'base'),
22
+ :locals => { :f => f, :compute_resource => compute_resource, :new_host => true, :new_vm => true, :hide_image => true }.merge(args_for_compute_resource_partial(@host)) %>
23
+ <% end %>
@@ -14,5 +14,11 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+
18
+ <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
17
19
  <%= render :partial => provider_partial(compute_resource, 'base'),
18
20
  :locals => { :f => f, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :from_profile => false }.merge(args_for_compute_resource_partial(@host)) %>
21
+ <% else %>
22
+ <%= render :partial => provider_partial(compute_resource, 'base'),
23
+ :locals => { :f => f, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm }.merge(args_for_compute_resource_partial(@host)) %>
24
+ <% end %>
@@ -14,10 +14,14 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
18
18
  <% vm_type = f.object.respond_to?('type') ? f.object.type : nil %>
19
19
 
20
20
  <%= render :partial => provider_partial(compute_resource, 'network'),
21
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 },
22
22
  :layout => 'compute_resources_vms/form/deletable_layout' %>
23
-
23
+ <% else %>
24
+ <%= render :partial => provider_partial(compute_resource, 'network'),
25
+ :locals => { :f => i, :compute_resource => compute_resource, :new_host => new_host, :new_vm => new_vm, :remove_title => _('remove network interface'), :selected_cluster => selected_cluster },
26
+ :layout => 'compute_resources_vms/form/deletable_layout' %>
27
+ <% end %>
@@ -14,7 +14,7 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
18
18
  <% vm_type = f.object.respond_to?('type') ? f.object.type : nil %>
19
19
 
20
20
  <%= new_child_fields_template(f, compute_resource.interfaces_attrs_name, {
@@ -22,4 +22,10 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
22
22
  :partial => provider_partial(compute_resource, 'network'),
23
23
  :form_builder_attrs => { :vm_type => vm_type, :compute_resource => compute_resource, :new_host => new_host, :new_vm => new_vm, :remove_title => _('remove network interface') },
24
24
  :layout => 'compute_resources_vms/form/deletable_layout' }) %>
25
-
25
+ <% else %>
26
+ <%= new_child_fields_template(f, compute_resource.interfaces_attrs_name, {
27
+ :object => compute_resource.new_interface,
28
+ :partial => provider_partial(compute_resource, 'network'),
29
+ :form_builder_attrs => { :compute_resource => compute_resource, :new_host => new_host, :new_vm => new_vm, :remove_title => _('remove network interface') },
30
+ :layout => 'compute_resources_vms/form/deletable_layout' }) %>
31
+ <% end %>
@@ -14,10 +14,16 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if @host.compute_resource.class == ForemanFogProxmox::Proxmox %>
17
18
  <% compute_attributes = f.options[:parent_builder].object.compute_attributes %>
18
19
  <% vm_type = compute_attributes ? compute_attributes['type'] : f.object.type %>
19
20
 
20
21
  <%= f.fields_for 'compute_attributes', OpenStruct.new(f.object.compute_attributes) do |f| %>
21
22
  <%= 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 %>
22
23
  <% end %>
24
+ <% else %>
25
+ <%= f.fields_for 'compute_attributes', OpenStruct.new(f.object.compute_attributes) do |f| %>
26
+ <%= render provider_partial(@host.compute_resource, 'network'), :f => f, :disabled => f.object.persisted?, :compute_resource => @host.compute_resource, :new_host => new_vm, :new_vm => new_vm %>
27
+ <% end %>
28
+ <% end %>
23
29
 
@@ -14,7 +14,7 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
18
18
  <% type = f.object.type %>
19
19
  <% server = type == 'qemu' %>
20
20
  <% container = type == 'lxc' %>
@@ -52,5 +52,19 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
52
52
 
53
53
  <%= add_child_link_typed '+ ' + _("Add Volume"), :volumes, 'server', { :class => "info #{'hide' unless server}", :title => _('add new storage volume') } %>
54
54
  <%= add_child_link_typed '+ ' + _("Add Volume"), :volumes, 'container', { :class => "info #{'hide' unless container}", :title => _('add new storage volume') } %>
55
+ <% else %>
56
+ <%= new_child_fields_template(f, :volumes, {
57
+ :object => volume,
58
+ :partial => provider_partial(compute_resource, 'volume'),
59
+ :form_builder_attrs => { :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :remove_title => _('remove storage volume') },
60
+ :layout => "compute_resources_vms/form/#{item_layout}_layout" }) %>
61
+
62
+ <%= f.fields_for :volumes do |i| %>
63
+ <%= render :partial => provider_partial(compute_resource, 'volume'), :locals => { :f => i, :compute_resource => compute_resource, :new_host => new_vm, :new_vm => new_vm, :remove_title => _('remove storage volume') }, :layout => "compute_resources_vms/form/#{item_layout}_layout" %>
64
+ <% end %>
55
65
 
66
+ <% if new_vm %>
67
+ <%= add_child_link '+ ' + _("Add Volume"), :volumes, { :class => "info", :title => _('add new storage volume') } %>
68
+ <% end %>
69
+ <% end %>
56
70
 
@@ -31,9 +31,9 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
31
31
  <%= render :partial => "compute_resources_vms/form/proxmox/container/advanced", :locals => { :f => f, :compute_resource => compute_resource, :new_vm => new_vm } %>
32
32
 
33
33
  <!-- Config Options Settings-->
34
- <%= f.fields_for :config, compute_resource.new_server_vm(object_to_config_hash(f.object,'qemu')).config, include_id: false do |server_config|%>
34
+ <%= f.fields_for :config, compute_resource.new_server_vm(object_to_config_hash(f.object)).config, include_id: false do |server_config|%>
35
35
  <%= render :partial => "compute_resources_vms/form/proxmox/server/config", :locals => { :f => server_config, :compute_resource => compute_resource, :host => @host, :new_vm => new_vm, :item_layout => 'removable', :type => f.object.type } %>
36
36
  <% end %>
37
- <%= f.fields_for :config, compute_resource.new_container_vm(object_to_config_hash(f.object,'lxc')).config, include_id: false do |container_config|%>
37
+ <%= f.fields_for :config, compute_resource.new_container_vm(object_to_config_hash(f.object)).config, include_id: false do |container_config|%>
38
38
  <%= render :partial => "compute_resources_vms/form/proxmox/container/config", :locals => { :f => container_config, :compute_resource => compute_resource, :host => @host, :new_vm => new_vm, :item_layout => 'removable', :type => f.object.type } %>
39
39
  <% end %>
@@ -34,4 +34,4 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
34
34
  :label_size => "col-md-2" %>
35
35
  </div>
36
36
  <% end %>
37
- <% end %>
37
+ <% end %>
@@ -14,9 +14,14 @@ GNU General Public License for more details.
14
14
 
15
15
  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
+ <% if compute_resource.class == ForemanFogProxmox::Proxmox %>
18
18
  <% volume_rootfs = f.object.respond_to?(:rootfs?) && f.object.rootfs? %>
19
19
 
20
20
  <% unless volume_rootfs %>
21
21
  <%= remove_child_link('X', f, { :method => :'_delete', :title => local_assigns[:remove_title], :class => 'label label-danger' }) %>
22
+ <% end %>
23
+ <% else %>
24
+ <% if new_vm %>
25
+ <%= remove_child_link('X', f, { :method => :'_delete', :title => local_assigns[:remove_title], :class => 'label label-danger' }) %>
26
+ <% end %>
22
27
  <% end %>
@@ -20,7 +20,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
20
20
  <%= field_set_tag _("Extended"), :id => "container_config_ext", :class => ('hide' unless (new_vm && container)), :disabled => (!container || !new_vm) do %>
21
21
  <div id="ostemplate_form">
22
22
  <%= select_f f, :ostemplate_storage, compute_resource.storages('vztmpl'), :storage, :storage, { :include_blank => true }, :disabled => !new_vm, :class => ('hide' unless new_vm), :label => _('Template storage'), :label_size => "col-md-2", :onchange => 'storageOstemplateSelected(this)' %>
23
- <%= select_f f, :ostemplate_file, compute_resource.images_by_storage('vztmpl',f.object.ostemplate_storage), :volid, :volid, { :include_blank => true }, :disabled => !new_vm, :class => ('hide' unless new_vm), :label => _('OS Template'), :label_size => "col-md-2", :required => true %>
23
+ <%= select_f f, :ostemplate_file, compute_resource.images_by_storage(f.object.ostemplate_storage, 'vztmpl'), :volid, :volid, { :include_blank => true }, :disabled => !new_vm, :class => ('hide' unless new_vm), :label => _('OS Template'), :label_size => "col-md-2", :required => true %>
24
24
  </div>
25
25
  <%= password_proxmox_f f, :password, :label => _("Root password"), :required => true %>
26
26
  <% end %>
@@ -22,6 +22,6 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
22
22
  <%= f.hidden_field :volid if !new_vm %>
23
23
  <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
24
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 %>
25
+ <%= text_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
26
  <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
27
27
  <% end %>
@@ -52,7 +52,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
52
52
  <%= radio_button_f f, :cdrom, :value => 'image' , :text => _('Image'), :onclick => 'cdromSelected(this)' %>
53
53
  <div id='cdrom_image_form' class='<%= 'hide' if %[none cdrom].include? f.object.cdrom %>'>
54
54
  <%= select_f f, :cdrom_storage, compute_resource.storages('iso'), :storage, :storage, { :include_blank => true }, :label => _('Storage'), :label_size => "col-md-2", :onchange => 'storageIsoSelected(this)' %>
55
- <%= select_f f, :cdrom_iso, compute_resource.images_by_storage('iso',f.object.cdrom_storage), :volid, :volid, { :include_blank => true }, :label => _('Image ISO'), :label_size => "col-md-2" %>
55
+ <%= select_f f, :cdrom_iso, compute_resource.images_by_storage(f.object.cdrom_storage, 'iso'), :volid, :volid, { :include_blank => true }, :label => _('Image ISO'), :label_size => "col-md-2" %>
56
56
  </div>
57
57
  <% end %>
58
58
  <%= field_set_tag _("Operating System"), :id => "server_config_os", :class => 'hide', :disabled => !server do %>
@@ -22,7 +22,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
22
22
  <%= f.hidden_field :volid if !new_vm %>
23
23
  <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2" %>
24
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
+ <%= text_f f, :device, :label => _('Device'), :label_size => "col-md-2", :disabled => !new_volume, :'data-min' => 0, :'data-soft-max' => proxmox_max_device(f.object.controller), :onchange => 'deviceSelected(this)' %>
26
26
  <%= select_f f, :cache, proxmox_caches_map, :id, :name, { }, :label => _('Cache'), :label_size => "col-md-2" %>
27
27
  <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2" %>
28
- <% end %>
28
+ <% end %>
data/config/routes.rb CHANGED
@@ -18,8 +18,8 @@
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  Rails.application.routes.draw do
21
- namespace :foreman_fog_proxmox do
22
- match 'isos/:storage', :to => 'compute_resources#isos', :via => 'get'
23
- match 'ostemplates/:storage', :to => 'compute_resources#ostemplates', :via => 'get'
24
- end
21
+ namespace :foreman_fog_proxmox do
22
+ match 'isos/:storage', :to => 'compute_resources#isos', :via => 'get'
23
+ match 'ostemplates/:storage', :to => 'compute_resources#ostemplates', :via => 'get'
24
+ end
25
25
  end
@@ -60,10 +60,11 @@ module ForemanFogProxmox
60
60
  app.config.assets.precompile += assets_to_precompile
61
61
  end
62
62
  initializer 'foreman_fog_proxmox.configure_assets', group: :assets do
63
- SETTINGS[:foreman_fog_proxmox] = {
64
- assets: {
65
- precompile: assets_to_precompile
66
- } }
63
+ SETTINGS[:foreman_fog_proxmox] = {
64
+ assets: {
65
+ precompile: assets_to_precompile
66
+ }
67
+ }
67
68
  end
68
69
 
69
70
  rake_tasks do
@@ -86,16 +87,15 @@ module ForemanFogProxmox
86
87
  require 'fog/compute/proxmox/models/volume'
87
88
  require 'fog/compute/proxmox/models/node'
88
89
 
89
- Fog::Proxmox::Compute::Server.send :include, FogExtensions::Proxmox::Server
90
- Fog::Proxmox::Compute::ServerConfig.send :include, FogExtensions::Proxmox::ServerConfig
91
- Fog::Proxmox::Compute::Disk.send :include, FogExtensions::Proxmox::Disk
92
- Fog::Proxmox::Compute::Interface.send :include, FogExtensions::Proxmox::Interface
93
- Fog::Proxmox::Compute::Volume.send :include, FogExtensions::Proxmox::Volume
94
- ::ComputeResourcesController.send :include, ForemanFogProxmox::Controller::Parameters::ComputeResource
95
- Fog::Proxmox::Compute::Node.send :include, FogExtensions::Proxmox::Node
96
- ::Host::Managed.send :include, Orchestration::Proxmox::Compute
97
- ::Host::Managed.send :include, HostExt::Proxmox::Interfaces
90
+ Fog::Proxmox::Compute::Server.include FogExtensions::Proxmox::Server
91
+ Fog::Proxmox::Compute::ServerConfig.include FogExtensions::Proxmox::ServerConfig
92
+ Fog::Proxmox::Compute::Disk.include FogExtensions::Proxmox::Disk
93
+ Fog::Proxmox::Compute::Interface.include FogExtensions::Proxmox::Interface
94
+ Fog::Proxmox::Compute::Volume.include FogExtensions::Proxmox::Volume
95
+ ::ComputeResourcesController.include ForemanFogProxmox::Controller::Parameters::ComputeResource
96
+ Fog::Proxmox::Compute::Node.include FogExtensions::Proxmox::Node
97
+ ::Host::Managed.include Orchestration::Proxmox::Compute
98
+ ::Host::Managed.include HostExt::Proxmox::Interfaces
98
99
  end
99
-
100
100
  end
101
101
  end
@@ -17,86 +17,86 @@
17
17
  # You should have received a copy of the GNU General Public License
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
- module ForemanFogProxmox::Semver
21
- SEMVER_REGEX = /^(\d+)[.]{1}(\d+)[.]{1}(\d+)[-]{0,1}(\w+){0,1}$/
20
+ module ForemanFogProxmox
21
+ module Semver
22
+ SEMVER_REGEX = /^(\d+)[.](\d+)([.](\d+))?(-([.\w]+))?$/.freeze
22
23
  class SemverClass
23
- attr_accessor :major
24
- attr_accessor :minor
25
- attr_accessor :patch
26
- attr_accessor :qualifier
27
- def initialize(major,minor,patch, qualifier = '')
28
- @major = major.to_i
29
- @minor = minor.to_i
30
- @patch = patch.to_i
31
- @qualifier = qualifier.nil? ? '' : qualifier
32
- end
33
- def to_s
34
- flat = "#{major}.#{minor}.#{patch}"
35
- flat += "-#{qualifier}" unless qualifier == ''
36
- end
37
- def <=(other)
38
- raise TypeError unless other.is_a?(SemverClass)
39
- if @major == other.major
40
- if @minor == other.minor
41
- return @patch <= other.patch
42
- else
43
- return @minor <= other.minor
44
- end
45
- else
46
- return @major <= other.major
47
- end
48
- end
49
- def <(other)
50
- raise TypeError unless other.is_a?(SemverClass)
51
- if @major == other.major
52
- if @minor == other.minor
53
- return @patch < other.patch
54
- else
55
- return @minor < other.minor
56
- end
57
- else
58
- return @major < other.major
59
- end
60
- end
61
- def >(other)
62
- raise TypeError unless other.is_a?(SemverClass)
63
- if @major == other.major
64
- if @minor == other.minor
65
- return @patch > other.patch
66
- else
67
- return @minor > other.minor
68
- end
69
- else
70
- return @major > other.major
71
- end
72
- end
73
- def >=(other)
74
- raise TypeError unless other.is_a?(SemverClass)
75
- if @major == other.major
76
- if @minor == other.minor
77
- return @patch >= other.patch
78
- else
79
- return @minor >= other.minor
80
- end
81
- else
82
- return @major >= other.major
83
- end
84
- end
85
- def ==(other)
86
- raise TypeError unless other.is_a?(SemverClass)
87
- @major == other.major && @minor == other.minor && @patch == other.patch && @qualifier == other.qualifier
88
- end
24
+ attr_accessor :major
25
+ attr_accessor :minor
26
+ attr_accessor :patch
27
+ attr_accessor :qualifier
28
+
29
+ def initialize(major, minor, patch, qualifier = '')
30
+ @major = major.to_i
31
+ @minor = minor.to_i
32
+ @patch = patch.to_i
33
+ @qualifier = qualifier.nil? ? '' : qualifier
34
+ end
35
+
36
+ def to_s
37
+ flat = "#{major}.#{minor}.#{patch}"
38
+ flat += "-#{qualifier}" unless qualifier == ''
39
+ flat
40
+ end
41
+
42
+ def <=(other)
43
+ raise TypeError unless other.is_a?(SemverClass)
44
+
45
+ result = @patch <= other.patch
46
+ result = @major <= other.major unless @major == other.major
47
+ result = @minor < other.minor unless @minor == other.minor
48
+ result
49
+ end
50
+
51
+ def <(other)
52
+ raise TypeError unless other.is_a?(SemverClass)
53
+
54
+ result = @patch < other.patch
55
+ result = @major < other.major unless @major == other.major
56
+ result = @minor < other.minor unless @minor == other.minor
57
+ result
58
+ end
59
+
60
+ def >(other)
61
+ raise TypeError unless other.is_a?(SemverClass)
62
+
63
+ result = @patch > other.patch
64
+ result = @major > other.major unless @major == other.major
65
+ result = @minor > other.minor unless @minor > other.minor
66
+ result
67
+ end
68
+
69
+ def >=(other)
70
+ raise TypeError unless other.is_a?(SemverClass)
71
+
72
+ result = @patch >= other.patch
73
+ result = @major >= other.major unless @major == other.major
74
+ result = @minor >= other.minor unless @minor == other.minor
75
+ result
76
+ end
77
+
78
+ def ==(other)
79
+ raise TypeError unless other.is_a?(SemverClass)
80
+
81
+ @major == other.major && @minor == other.minor && @patch == other.patch && @qualifier == other.qualifier
82
+ end
89
83
  end
90
- def self.is_semver?(version)
91
- version.is_a?(String) && version.match(SEMVER_REGEX)
84
+
85
+ def self.semver?(version)
86
+ version.is_a?(String) && version.match(SEMVER_REGEX)
92
87
  end
88
+
93
89
  def self.to_semver(version)
94
- raise ArgumentError unless self.is_semver?(version)
95
- version_a = version.scan(SEMVER_REGEX)
96
- raise ArgumentError if version_a.empty?
97
- semver_a = version_a.first
98
- raise ArgumentError if semver_a.empty?
99
- raise ArgumentError if semver_a.size < 4
100
- SemverClass.new(semver_a[0],semver_a[1],semver_a[2],semver_a[3])
90
+ raise ArgumentError unless semver?(version)
91
+
92
+ version_a = version.scan(SEMVER_REGEX)
93
+ raise ArgumentError if version_a.empty?
94
+
95
+ semver_a = version_a.first
96
+ raise ArgumentError if semver_a.empty?
97
+ raise ArgumentError unless semver_a.size == 6
98
+
99
+ SemverClass.new(semver_a[0], semver_a[1], semver_a[3], semver_a[5])
101
100
  end
102
- end
101
+ end
102
+ end