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.
- checksums.yaml +4 -4
- data/README.md +11 -1
- data/Rakefile +3 -1
- data/app/controllers/concerns/foreman_fog_proxmox/controller/parameters/compute_resource.rb +2 -2
- data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +2 -2
- data/app/helpers/node_dashboard_helper.rb +13 -14
- data/app/helpers/proxmox_compute_selectors_helper.rb +49 -50
- data/app/helpers/proxmox_container_helper.rb +42 -36
- data/app/helpers/proxmox_form_helper.rb +38 -40
- data/app/helpers/proxmox_server_helper.rb +39 -41
- data/app/helpers/proxmox_vm_helper.rb +21 -25
- data/app/models/concerns/fog_extensions/proxmox/disk.rb +8 -8
- data/app/models/concerns/fog_extensions/proxmox/interface.rb +8 -8
- data/app/models/concerns/fog_extensions/proxmox/node.rb +24 -22
- data/app/models/concerns/fog_extensions/proxmox/server.rb +71 -59
- data/app/models/concerns/fog_extensions/proxmox/server_config.rb +47 -39
- data/app/models/concerns/fog_extensions/proxmox/volume.rb +8 -8
- data/app/models/concerns/host_ext/proxmox/interfaces.rb +21 -13
- data/app/models/concerns/orchestration/proxmox/compute.rb +14 -10
- data/app/models/foreman_fog_proxmox/options_select.rb +14 -14
- data/app/models/foreman_fog_proxmox/proxmox.rb +30 -466
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +54 -0
- data/app/models/foreman_fog_proxmox/proxmox_connection.rb +67 -0
- data/app/models/foreman_fog_proxmox/proxmox_console.rb +41 -0
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +53 -0
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +60 -0
- data/app/models/foreman_fog_proxmox/proxmox_operating_systems.rb +49 -0
- data/app/models/foreman_fog_proxmox/proxmox_token_expiration.rb +30 -0
- data/app/models/foreman_fog_proxmox/proxmox_version.rb +36 -0
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +108 -0
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +162 -0
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +74 -0
- data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +85 -0
- data/app/overrides/compute_resources_vms/form/add_clone_to_new_vm_compute_detail.rb +7 -6
- data/app/overrides/compute_resources_vms/form/add_from_profile_to_compute_attributes_form.rb +13 -11
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_networks_form.rb +13 -11
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_nic_provider_specific_form.rb +8 -7
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_edit.rb +7 -6
- data/app/overrides/compute_resources_vms/form/add_vm_type_to_volumes_new_volume.rb +7 -6
- data/app/overrides/compute_resources_vms/form/remove_new_vm_from_removable_layout.rb +7 -6
- data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +16 -16
- data/app/views/api/v2/compute_resources/proxmox.json.rabl +3 -1
- data/app/views/compute_resources/form/_proxmox.html.erb +3 -0
- data/app/views/compute_resources/show/_proxmox.html.erb +8 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_attributes_form.html.erb +5 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb +6 -1
- data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_hosts_compute_detail_form.html.erb +6 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_form.html.erb +6 -2
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb +8 -2
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_nic_provider_specific_form.html.erb +6 -0
- data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_volumes_edit.html.erb +15 -1
- data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +2 -2
- data/app/views/compute_resources_vms/form/proxmox/_general.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/_removable_layout.html.erb +6 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_extended.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/container/_volume_mp.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/server/_config.html.erb +1 -1
- data/app/views/compute_resources_vms/form/proxmox/server/_volume.html.erb +2 -2
- data/config/routes.rb +4 -4
- data/lib/foreman_fog_proxmox/engine.rb +14 -14
- data/lib/foreman_fog_proxmox/semver.rb +78 -78
- data/lib/foreman_fog_proxmox/value.rb +5 -3
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/lib/tasks/foreman_fog_proxmox_tasks.rake +3 -13
- data/locale/en/foreman_fog_proxmox.edit.po +472 -0
- data/locale/en/foreman_fog_proxmox.po +48 -24
- data/locale/en/foreman_fog_proxmox.po.time_stamp +0 -0
- data/locale/foreman_fog_proxmox.pot +140 -102
- data/locale/fr/foreman_fog_proxmox.edit.po +472 -0
- data/locale/fr/foreman_fog_proxmox.po +52 -28
- data/locale/fr/foreman_fog_proxmox.po.time_stamp +0 -0
- data/locale/gemspec.rb +2 -0
- data/test/{unit/foreman_fog_proxmox/proxmox_test_helpers.rb → factories/foreman_fog_proxmox/proxmox_container_mock_factory.rb} +4 -140
- data/test/factories/foreman_fog_proxmox/proxmox_node_mock_factory.rb +61 -0
- data/test/factories/foreman_fog_proxmox/proxmox_server_mock_factory.rb +134 -0
- data/test/factories/proxmox_factory.rb +15 -15
- data/test/functional/compute_resources_controller_test.rb +12 -10
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +178 -182
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +122 -126
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +180 -187
- data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +116 -0
- data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +71 -0
- data/test/unit/foreman_fog_proxmox/proxmox_test.rb +9 -479
- data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +82 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +207 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +92 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +324 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb +43 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb +71 -0
- data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +63 -0
- data/test/unit/foreman_fog_proxmox/semver_test.rb +67 -53
- 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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
20
|
+
module ForemanFogProxmox
|
21
|
+
module NodeDashboard
|
22
22
|
class Data
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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
|
@@ -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 %>
|
data/app/views/compute_resources_vms/form/proxmox/_add_from_profile_to_compute_form.html.erb
CHANGED
@@ -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 %>
|
data/app/views/compute_resources_vms/form/proxmox/_add_vm_type_to_networks_new_childs_form.html.erb
CHANGED
@@ -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
|
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
|
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 %>
|
@@ -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(
|
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
|
-
<%=
|
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(
|
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
|
-
<%=
|
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
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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.
|
90
|
-
Fog::Proxmox::Compute::ServerConfig.
|
91
|
-
Fog::Proxmox::Compute::Disk.
|
92
|
-
Fog::Proxmox::Compute::Interface.
|
93
|
-
Fog::Proxmox::Compute::Volume.
|
94
|
-
::ComputeResourcesController.
|
95
|
-
Fog::Proxmox::Compute::Node.
|
96
|
-
::Host::Managed.
|
97
|
-
::Host::Managed.
|
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
|
21
|
-
|
20
|
+
module ForemanFogProxmox
|
21
|
+
module Semver
|
22
|
+
SEMVER_REGEX = /^(\d+)[.](\d+)([.](\d+))?(-([.\w]+))?$/.freeze
|
22
23
|
class SemverClass
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
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
|
-
|
91
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|