foreman_fog_proxmox 0.13.0 → 0.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +42 -9
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_compute_resource.js +25 -13
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js +62 -60
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm_server.js +2 -2
- data/app/assets/javascripts/foreman_fog_proxmox/proxmox_volume.js +10 -10
- data/app/controllers/concerns/foreman_fog_proxmox/compute_resources_vms_controller.rb +80 -0
- data/app/controllers/foreman_fog_proxmox/compute_resources_controller.rb +23 -25
- data/app/helpers/proxmox_compute_resources_vms_helper.rb +99 -0
- data/app/helpers/proxmox_vm_config_helper.rb +5 -4
- data/app/helpers/proxmox_vm_uuid_helper.rb +34 -0
- data/app/models/concerns/fog_extensions/proxmox/server.rb +4 -0
- data/app/models/concerns/host_ext/proxmox/associator.rb +46 -0
- data/app/models/concerns/host_ext/proxmox/for_vm.rb +33 -0
- data/app/models/concerns/orchestration/proxmox/compute.rb +65 -7
- data/app/models/foreman_fog_proxmox/proxmox.rb +4 -0
- data/app/models/foreman_fog_proxmox/proxmox_compute_attributes.rb +3 -6
- data/app/models/foreman_fog_proxmox/proxmox_images.rb +13 -4
- data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +2 -1
- data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +5 -3
- data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +2 -4
- data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +14 -7
- data/app/models/foreman_fog_proxmox/vms.rb +1 -1
- data/app/services/concerns/foreman_fog_proxmox/compute_resource_host_associator.rb +34 -0
- data/app/services/foreman_fog_proxmox/node_dashboard/data.rb +6 -2
- data/app/views/api/v2/compute_resources/proxmox.json.rabl +1 -1
- data/app/views/compute_resources_vms/form/proxmox/server/_volume_cdrom.html.erb +1 -1
- data/app/views/compute_resources_vms/index/_proxmox.html.erb +2 -2
- data/config/routes.rb +7 -7
- data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +29 -0
- data/lib/foreman_fog_proxmox/engine.rb +13 -2
- data/lib/foreman_fog_proxmox/version.rb +1 -1
- data/test/functional/compute_resources_controller_test.rb +4 -4
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +4 -3
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +3 -1
- data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb +38 -0
- data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +3 -3
- data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +2 -2
- data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +3 -3
- metadata +12 -3
@@ -26,9 +26,8 @@ module ForemanFogProxmox
|
|
26
26
|
when 'lxc'
|
27
27
|
host.compute_attributes['config_attributes'].store('hostname', host.name)
|
28
28
|
when 'qemu'
|
29
|
-
|
30
|
-
|
31
|
-
end
|
29
|
+
host.compute_attributes['config_attributes'].store('name', host.name)
|
30
|
+
raise ::Foreman::Exception, format(_('Operating system family %<type>s is not consistent with %<ostype>s'), type: host.operatingsystem.type, ostype: ostype) unless compute_os_types(host).include?(ostype)
|
32
31
|
end
|
33
32
|
super
|
34
33
|
end
|
@@ -49,9 +48,7 @@ module ForemanFogProxmox
|
|
49
48
|
vm_attrs = vm_attrs.merge(vmid: vm.identity, node_id: vm.node_id, type: vm.type)
|
50
49
|
if vm.respond_to?(:config)
|
51
50
|
vm_attrs[:volumes_attributes] = Hash[vm.config.disks.each_with_index.map { |disk, idx| [idx.to_s, disk.attributes] }] if vm.config.respond_to?(:disks)
|
52
|
-
if vm.config.respond_to?(:interfaces)
|
53
|
-
vm_attrs[:interfaces_attributes] = Hash[vm.config.interfaces.each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }]
|
54
|
-
end
|
51
|
+
vm_attrs[:interfaces_attributes] = Hash[vm.config.interfaces.each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }] if vm.config.respond_to?(:interfaces)
|
55
52
|
vm_attrs[:config_attributes] = vm.config.attributes.reject do |key, value|
|
56
53
|
not_config_key?(vm, key) || ForemanFogProxmox::Value.empty?(value.to_s) || Fog::Proxmox::DiskHelper.disk?(key.to_s) || Fog::Proxmox::NicHelper.nic?(key.to_s)
|
57
54
|
end
|
@@ -31,8 +31,17 @@ module ForemanFogProxmox
|
|
31
31
|
storage.volumes.list_by_content_type(type).sort_by(&:volid) if storage
|
32
32
|
end
|
33
33
|
|
34
|
+
def template_name(template)
|
35
|
+
image = find_vm_by_uuid(template_uuid(template))
|
36
|
+
image&.name
|
37
|
+
end
|
38
|
+
|
39
|
+
def template_uuid(template)
|
40
|
+
id.to_s + '_' + template.vmid.to_s
|
41
|
+
end
|
42
|
+
|
34
43
|
def available_images
|
35
|
-
templates.collect { |template| OpenStruct.new(id: template
|
44
|
+
templates.collect { |template| OpenStruct.new(id: template_uuid(template), name: template_name(template)) }
|
36
45
|
end
|
37
46
|
|
38
47
|
def templates
|
@@ -44,15 +53,15 @@ module ForemanFogProxmox
|
|
44
53
|
volumes.select(&:template?)
|
45
54
|
end
|
46
55
|
|
47
|
-
def template(
|
48
|
-
find_vm_by_uuid(
|
56
|
+
def template(uuid)
|
57
|
+
find_vm_by_uuid(uuid)
|
49
58
|
end
|
50
59
|
|
51
60
|
def clone_from_image(image_id, args, vmid)
|
52
61
|
logger.debug(format(_('create_vm(): clone %<image_id>s in %<vmid>s'), image_id: image_id, vmid: vmid))
|
53
62
|
image = find_vm_by_uuid(image_id)
|
54
63
|
image.clone(vmid)
|
55
|
-
clone = find_vm_by_uuid(vmid)
|
64
|
+
clone = find_vm_by_uuid(id.to_s + '_' + vmid.to_s)
|
56
65
|
options = {}
|
57
66
|
options.store(:name, args[:name]) unless clone.container?
|
58
67
|
options.store(:hostname, args[:name]) if clone.container?
|
@@ -18,6 +18,7 @@
|
|
18
18
|
# along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
|
20
20
|
require 'fog/proxmox/helpers/ip_helper'
|
21
|
+
require 'net/validations'
|
21
22
|
|
22
23
|
module ForemanFogProxmox
|
23
24
|
module ProxmoxInterfaces
|
@@ -104,7 +105,7 @@ module ForemanFogProxmox
|
|
104
105
|
def set_mac(nic_compute_attributes, mac, type)
|
105
106
|
mac_attr_name = { 'qemu' => :macaddr, 'lxc' => :hwaddr }
|
106
107
|
mac_key = mac_attr_name[type] || 'mac'
|
107
|
-
nic_compute_attributes[mac_key] = mac
|
108
|
+
nic_compute_attributes[mac_key] = Net::Validations.normalize_mac(mac)
|
108
109
|
end
|
109
110
|
|
110
111
|
def host_interfaces_attrs(host)
|
@@ -50,14 +50,16 @@ module ForemanFogProxmox
|
|
50
50
|
end
|
51
51
|
rescue StandardError => e
|
52
52
|
logger.warn(format(_('failed to create vm: %<e>s'), e: e))
|
53
|
-
destroy_vm vm.id if vm
|
53
|
+
destroy_vm client.identity + '_' + vm.id if vm
|
54
54
|
raise e
|
55
55
|
end
|
56
56
|
|
57
57
|
def destroy_vm(uuid)
|
58
58
|
vm = find_vm_by_uuid(uuid)
|
59
|
-
|
60
|
-
|
59
|
+
unless vm.nil?
|
60
|
+
vm.stop if vm.ready?
|
61
|
+
vm.destroy
|
62
|
+
end
|
61
63
|
rescue ActiveRecord::RecordNotFound
|
62
64
|
# if the VM does not exists, we don't really care.
|
63
65
|
true
|
@@ -166,9 +166,7 @@ module ForemanFogProxmox
|
|
166
166
|
def convert_config_attributes(new_attr)
|
167
167
|
config_attributes = new_attr[:config_attributes]
|
168
168
|
config_attributes[:volumes_attributes] = Hash[config_attributes[:disks].each_with_index.map { |disk, idx| [idx.to_s, disk.attributes] }] if config_attributes.key?(:disks)
|
169
|
-
if config_attributes.key?(:interfaces)
|
170
|
-
config_attributes[:interfaces_attributes] = Hash[config_attributes[:interfaces].each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }]
|
171
|
-
end
|
169
|
+
config_attributes[:interfaces_attributes] = Hash[config_attributes[:interfaces].each_with_index.map { |interface, idx| [idx.to_s, interface_compute_attributes(interface.attributes)] }] if config_attributes.key?(:interfaces)
|
172
170
|
config_attributes.delete_if { |key, _value| ['disks', 'interfaces'].include?(key) }
|
173
171
|
end
|
174
172
|
|
@@ -181,7 +179,7 @@ module ForemanFogProxmox
|
|
181
179
|
new_attr_type ||= type
|
182
180
|
logger.debug(format(_('new_typed_vm(%<type>s): new_attr_type=%<new_attr_type>s'), type: type, new_attr_type: new_attr_type))
|
183
181
|
logger.debug(format(_('new_typed_vm(%<type>s): new_attr=%<new_attr>s'), type: type, new_attr: new_attr))
|
184
|
-
options = !new_attr.key?('vmid') || ForemanFogProxmox::Value.empty?(new_attr['vmid']) ?
|
182
|
+
options = !new_attr.key?('vmid') || ForemanFogProxmox::Value.empty?(new_attr['vmid']) ? vm_typed_instance_defaults(type).merge(new_attr).merge(type: type) : new_attr
|
185
183
|
logger.debug(format(_('new_typed_vm(%<type>s): options=%<options>s'), type: type, options: options))
|
186
184
|
vm_h = parse_typed_vm(options, type).deep_symbolize_keys
|
187
185
|
logger.debug(format(_('new_typed_vm(%<type>s): vm_h=%<vm_h>s'), type: type, vm_h: vm_h))
|
@@ -20,6 +20,7 @@
|
|
20
20
|
module ForemanFogProxmox
|
21
21
|
module ProxmoxVmQueries
|
22
22
|
include ProxmoxPools
|
23
|
+
include ProxmoxVmUuidHelper
|
23
24
|
|
24
25
|
def nodes
|
25
26
|
nodes = client.nodes.all if client
|
@@ -42,34 +43,40 @@ module ForemanFogProxmox
|
|
42
43
|
end
|
43
44
|
|
44
45
|
# TODO: Pagination with filters
|
45
|
-
def vms(
|
46
|
+
def vms(opts = {})
|
46
47
|
vms = []
|
47
48
|
nodes.each { |node| vms += node.servers.all + node.containers.all }
|
49
|
+
if opts.key?(:eager_loading) && opts[:eager_loading]
|
50
|
+
vms_eager = []
|
51
|
+
vms.each { |vm| vms_eager << vm.collection.get(vm.identity) }
|
52
|
+
vms = vms_eager
|
53
|
+
end
|
48
54
|
ForemanFogProxmox::Vms.new(vms)
|
49
55
|
end
|
50
56
|
|
51
57
|
def find_vm_by_uuid(uuid)
|
52
58
|
# look for the uuid on all known nodes
|
53
59
|
vm = nil
|
60
|
+
vmid = extract_vmid(uuid)
|
54
61
|
nodes.each do |node|
|
55
|
-
vm =
|
56
|
-
vm ||=
|
62
|
+
vm = find_vm_in_servers_by_vmid(node.servers, vmid)
|
63
|
+
vm ||= find_vm_in_servers_by_vmid(node.containers, vmid)
|
57
64
|
unless vm.nil?
|
58
|
-
logger.debug("found vm #{
|
65
|
+
logger.debug("found vm #{vmid} on node #{node.node}")
|
59
66
|
break
|
60
67
|
end
|
61
68
|
end
|
62
69
|
vm
|
63
70
|
end
|
64
71
|
|
65
|
-
def
|
66
|
-
vm = servers.get(
|
72
|
+
def find_vm_in_servers_by_vmid(servers, vmid)
|
73
|
+
vm = servers.get(vmid) unless ForemanFogProxmox::Value.empty?(vmid)
|
67
74
|
pool_owner(vm) if vm
|
68
75
|
vm
|
69
76
|
rescue Fog::Errors::NotFound
|
70
77
|
nil
|
71
78
|
rescue StandardError => e
|
72
|
-
Foreman::Logging.exception(format(_('Failed retrieving proxmox server vm by vmid=%<vmid>s'), vmid:
|
79
|
+
Foreman::Logging.exception(format(_('Failed retrieving proxmox server vm by vmid=%<vmid>s'), vmid: vmid), e)
|
73
80
|
raise(ActiveRecord::RecordNotFound, e)
|
74
81
|
end
|
75
82
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright 2021 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 ForemanFogProxmox
|
21
|
+
module ComputeResourceHostAssociator
|
22
|
+
extend ActiveSupport::Concern
|
23
|
+
included do
|
24
|
+
prepend Overrides
|
25
|
+
end
|
26
|
+
module Overrides
|
27
|
+
def associate_hosts
|
28
|
+
compute_resource.vms(:eager_loading => true).each do |vm|
|
29
|
+
associate_vm(vm) if Host.for_vm_uuid(compute_resource, vm).empty?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -24,9 +24,13 @@ module ForemanFogProxmox
|
|
24
24
|
@filter = filter
|
25
25
|
end
|
26
26
|
|
27
|
+
def node
|
28
|
+
@compute_resource = ComputeResource.where(type: 'ForemanFogProxmox::Proxmox').first
|
29
|
+
@compute_resource.nodes.first
|
30
|
+
end
|
31
|
+
|
27
32
|
def node_id
|
28
|
-
|
29
|
-
@compute_resource&.node_id
|
33
|
+
node&.identity
|
30
34
|
end
|
31
35
|
|
32
36
|
def statistics
|
@@ -27,7 +27,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
|
|
27
27
|
<%= radio_button_f f, :cdrom, :value => 'cdrom' , :text => _('Physical'), :onclick => 'cdromSelected(this)' %>
|
28
28
|
<%= radio_button_f f, :cdrom, :value => 'image' , :text => _('Image'), :onclick => 'cdromSelected(this)' %>
|
29
29
|
<% end %>
|
30
|
-
<%= field_set_tag
|
30
|
+
<%= field_set_tag(_("Image"), :id => "cdrom_image_form_#{f.index}", :class => ('hide' unless %[image].include? f.object.cdrom), :disabled => (%[cdrom none].include? f.object.cdrom)) do %>
|
31
31
|
<%= select_f f, :storage, compute_resource.storages(node_id,'iso'), :storage, :storage, { :include_blank => true }, :label => _('Storage'), :label_size => "col-md-2", :onchange => 'storageIsoSelected(this)' %>
|
32
32
|
<%= select_f f, :volid, compute_resource.images_by_storage(node_id, f.object.storage, 'iso'), :volid, :volid, { :include_blank => true }, :label => _('Image ISO'), :label_size => "col-md-2" %>
|
33
33
|
<% end %>
|
@@ -31,7 +31,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
|
|
31
31
|
<tbody>
|
32
32
|
<% @vms.each do |vm| -%>
|
33
33
|
<tr>
|
34
|
-
<td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.
|
34
|
+
<td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.unique_cluster_identity(@compute_resource)) %></td>
|
35
35
|
<td><%= vm.node_id %></td>
|
36
36
|
<td><%= vm.type %></td>
|
37
37
|
<td><%= vm.cpus %></td>
|
@@ -41,7 +41,7 @@ along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %>
|
|
41
41
|
<td>
|
42
42
|
<%= action_buttons(
|
43
43
|
vm_power_action(vm, authorizer),
|
44
|
-
display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.
|
44
|
+
display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.unique_cluster_identity(@compute_resource)).merge(:auth_object => @compute_resource, :authorizer => authorizer))) %>
|
45
45
|
</td>
|
46
46
|
</tr>
|
47
47
|
<% end -%>
|
data/config/routes.rb
CHANGED
@@ -19,12 +19,12 @@
|
|
19
19
|
|
20
20
|
Rails.application.routes.draw do
|
21
21
|
namespace :foreman_fog_proxmox do
|
22
|
-
match 'isos/:node_id/:storage', :to => 'compute_resources#
|
23
|
-
match 'ostemplates/:node_id/:storage', :to => 'compute_resources#
|
24
|
-
match 'isos/:node_id', :to => 'compute_resources#
|
25
|
-
match 'ostemplates/:node_id', :to => 'compute_resources#
|
26
|
-
match 'storages/:node_id', :to => 'compute_resources#
|
27
|
-
match 'isostorages/:node_id', :to => 'compute_resources#
|
28
|
-
match 'bridges/:node_id', :to => 'compute_resources#
|
22
|
+
match 'isos/:compute_resource_id/:node_id/:storage', :to => 'compute_resources#isos_by_id_and_node_and_storage', :via => 'get'
|
23
|
+
match 'ostemplates/:compute_resource_id/:node_id/:storage', :to => 'compute_resources#ostemplates_by_id_and_node_and_storage', :via => 'get'
|
24
|
+
match 'isos/:compute_resource_id/:node_id', :to => 'compute_resources#isos_by_id_and_node', :via => 'get'
|
25
|
+
match 'ostemplates/:compute_resource_id/:node_id', :to => 'compute_resources#ostemplates_by_id_and_node', :via => 'get'
|
26
|
+
match 'storages/:compute_resource_id/:node_id', :to => 'compute_resources#storages_by_id_and_node', :via => 'get'
|
27
|
+
match 'isostorages/:compute_resource_id/:node_id', :to => 'compute_resources#iso_storages_by_id_and_node', :via => 'get'
|
28
|
+
match 'bridges/:compute_resource_id/:node_id', :to => 'compute_resources#bridges_by_id_and_node', :via => 'get'
|
29
29
|
end
|
30
30
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
include ProxmoxVmUuidHelper
|
2
|
+
class UpdateProxmoxUuidHost < ActiveRecord::Migration[6.0]
|
3
|
+
|
4
|
+
def up
|
5
|
+
execute(sql(:concat))
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
execute(sql(:substring))
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def concat
|
15
|
+
"concat(h.compute_resource_id, '_', h.uuid) "
|
16
|
+
end
|
17
|
+
|
18
|
+
def substring
|
19
|
+
"substring(h.uuid, position('_' in h.uuid) + 1, length(h.uuid)) "
|
20
|
+
end
|
21
|
+
|
22
|
+
def sql(func_type)
|
23
|
+
sql = 'update hosts h set uuid = '
|
24
|
+
sql += send(func_type)
|
25
|
+
sql += 'from compute_resources cr '
|
26
|
+
sql += "where cr.id = h.compute_resource_id and cr.type = 'ForemanFogProxmox::Proxmox';"
|
27
|
+
sql
|
28
|
+
end
|
29
|
+
end
|
@@ -26,6 +26,7 @@ module ForemanFogProxmox
|
|
26
26
|
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
27
27
|
config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
|
28
28
|
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
29
|
+
config.autoload_paths += Dir["#{config.root}/app/services/concerns"]
|
29
30
|
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
30
31
|
config.autoload_paths += Dir["#{config.root}/app/services"]
|
31
32
|
|
@@ -46,7 +47,13 @@ module ForemanFogProxmox
|
|
46
47
|
widget 'foreman_fog_proxmox_widget', name: N_('Foreman Fog Proxmox widget'), sizex: 8, sizey: 1
|
47
48
|
security_block :foreman_fog_proxmox do
|
48
49
|
permission :view_compute_resource, { :compute_resources =>
|
49
|
-
|
50
|
+
[:ostemplates_by_id_and_node_and_storage,
|
51
|
+
:isos_by_id_and_node_and_storage,
|
52
|
+
:ostemplates_by_id_and_node,
|
53
|
+
:isos_by_id_and_node,
|
54
|
+
:storages_by_id_and_node,
|
55
|
+
:iso_storages_by_id_and_node,
|
56
|
+
:bridges_by_id_and_node] }
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|
@@ -95,10 +102,14 @@ module ForemanFogProxmox
|
|
95
102
|
Fog::Proxmox::Compute::ServerConfig.include FogExtensions::Proxmox::ServerConfig
|
96
103
|
Fog::Proxmox::Compute::Interface.include FogExtensions::Proxmox::Interface
|
97
104
|
Fog::Proxmox::Compute::Disk.include FogExtensions::Proxmox::Disk
|
98
|
-
::ComputeResourcesController.include ForemanFogProxmox::Controller::Parameters::ComputeResource
|
99
105
|
Fog::Proxmox::Compute::Node.include FogExtensions::Proxmox::Node
|
106
|
+
::ComputeResourcesController.include ForemanFogProxmox::Controller::Parameters::ComputeResource
|
107
|
+
::ComputeResourcesVmsController.include ForemanFogProxmox::ComputeResourcesVmsController
|
100
108
|
::Host::Managed.include Orchestration::Proxmox::Compute
|
101
109
|
::Host::Managed.include HostExt::Proxmox::Interfaces
|
110
|
+
::Host::Managed.include HostExt::Proxmox::Associator
|
111
|
+
::Host::Base.include HostExt::Proxmox::ForVm
|
112
|
+
::ComputeResourceHostAssociator.include ForemanFogProxmox::ComputeResourceHostAssociator
|
102
113
|
end
|
103
114
|
end
|
104
115
|
end
|
@@ -21,25 +21,25 @@ require 'test_plugin_helper'
|
|
21
21
|
module ForemanFogProxmox
|
22
22
|
class ComputeResourcesControllerTest < ActionController::TestCase
|
23
23
|
test 'should get isos by node and storage' do
|
24
|
-
get :
|
24
|
+
get :isos_by_id_and_node_and_storage, params: { :compute_resource_id => 1, :node_id => 'proxmox', :storage => 'local' }
|
25
25
|
assert_response :found
|
26
26
|
show_response = @response.body
|
27
27
|
assert_not show_response.empty?
|
28
28
|
end
|
29
29
|
test 'should get ostemplates by node and storage' do
|
30
|
-
get :
|
30
|
+
get :ostemplates_by_id_and_node_and_storage, params: { :compute_resource_id => 1, :node_id => 'proxmox', :storage => 'local' }
|
31
31
|
assert_response :found
|
32
32
|
show_response = @response.body
|
33
33
|
assert_not show_response.empty?
|
34
34
|
end
|
35
35
|
test 'should get isos by node' do
|
36
|
-
get :
|
36
|
+
get :isos_by_id_and_node, params: { :compute_resource_id => 1, :node_id => 'proxmox' }
|
37
37
|
assert_response :found
|
38
38
|
show_response = @response.body
|
39
39
|
assert_not show_response.empty?
|
40
40
|
end
|
41
41
|
test 'should get ostemplates by node' do
|
42
|
-
get :
|
42
|
+
get :ostemplates_by_id_and_node, params: { :compute_resource_id => 1, :node_id => 'proxmox' }
|
43
43
|
assert_response :found
|
44
44
|
show_response = @response.body
|
45
45
|
assert_not show_response.empty?
|
@@ -33,7 +33,6 @@ module ForemanFogProxmox
|
|
33
33
|
|
34
34
|
let(:host_form) do
|
35
35
|
{ 'vmid' => '100',
|
36
|
-
'name' => 'test',
|
37
36
|
'type' => 'lxc',
|
38
37
|
'node_id' => 'proxmox',
|
39
38
|
'ostemplate_storage' => 'local',
|
@@ -49,7 +48,7 @@ module ForemanFogProxmox
|
|
49
48
|
'cpuunits' => '',
|
50
49
|
'arch' => 'amd64',
|
51
50
|
'ostype' => 'debian',
|
52
|
-
'hostname' => '',
|
51
|
+
'hostname' => 'toto-tata.pve',
|
53
52
|
'nameserver' => '',
|
54
53
|
'searchdomain' => ''
|
55
54
|
|
@@ -88,7 +87,7 @@ module ForemanFogProxmox
|
|
88
87
|
let(:container) do
|
89
88
|
{ 'vmid' => '100',
|
90
89
|
:vmid => '100',
|
91
|
-
'
|
90
|
+
'hostname' => 'toto-tata.pve',
|
92
91
|
'type' => 'lxc',
|
93
92
|
:type => 'lxc',
|
94
93
|
'node_id' => 'proxmox',
|
@@ -148,6 +147,7 @@ module ForemanFogProxmox
|
|
148
147
|
assert_equal 536_870_912, vm[:memory]
|
149
148
|
assert_equal 'local-lvm:1073741824', vm[:rootfs]
|
150
149
|
assert_equal 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876', vm[:net0]
|
150
|
+
assert_equal 'toto-tata.pve', vm[:hostname]
|
151
151
|
assert_not vm.key?(:config)
|
152
152
|
assert_not vm.key?(:node)
|
153
153
|
assert_not vm.key?(:type)
|
@@ -165,6 +165,7 @@ module ForemanFogProxmox
|
|
165
165
|
:cores => '1',
|
166
166
|
:arch => 'amd64',
|
167
167
|
:ostype => 'debian',
|
168
|
+
:hostname => 'toto-tata.pve',
|
168
169
|
:net0 => 'name=eth0,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876',
|
169
170
|
:net1 => 'name=eth1,bridge=vmbr0,ip=dhcp,ip6=dhcp,gw=192.168.56.100,gw6=2001:0:1234::c1c0:abcd:876',
|
170
171
|
:rootfs => 'local-lvm:1073741824',
|