foreman_fog_proxmox 0.16.1 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/foreman_fog_proxmox/hosts_controller.rb +1 -1
  3. data/app/helpers/proxmox_vm_attrs_helper.rb +3 -3
  4. data/app/helpers/proxmox_vm_cdrom_helper.rb +1 -1
  5. data/app/helpers/proxmox_vm_cloudinit_helper.rb +1 -1
  6. data/app/helpers/proxmox_vm_config_helper.rb +1 -1
  7. data/app/helpers/proxmox_vm_helper.rb +5 -5
  8. data/app/helpers/proxmox_vm_interfaces_helper.rb +1 -1
  9. data/app/helpers/proxmox_vm_os_template_helper.rb +1 -1
  10. data/app/helpers/proxmox_vm_uuid_helper.rb +1 -1
  11. data/app/helpers/proxmox_vm_volumes_helper.rb +3 -3
  12. data/app/models/concerns/host_ext/proxmox/for_vm.rb +1 -1
  13. data/app/models/foreman_fog_proxmox/proxmox.rb +4 -4
  14. data/app/models/foreman_fog_proxmox/proxmox_interfaces.rb +1 -1
  15. data/app/models/foreman_fog_proxmox/proxmox_vm_commands.rb +2 -2
  16. data/app/models/foreman_fog_proxmox/proxmox_vm_new.rb +2 -2
  17. data/app/models/foreman_fog_proxmox/proxmox_vm_queries.rb +2 -2
  18. data/app/models/foreman_fog_proxmox/proxmox_volumes.rb +2 -2
  19. data/app/views/compute_resources_vms/form/proxmox/_add_react_component_to_host_form.html.erb +0 -1
  20. data/app/views/templates/provisioning/user_data/proxmox_user_data.erb +119 -0
  21. data/db/migrate/20210312105013_update_proxmox_uuid_host.rb +1 -1
  22. data/db/seeds.d/71_provisioning_templates.rb +7 -0
  23. data/lib/foreman_fog_proxmox/engine.rb +22 -27
  24. data/lib/foreman_fog_proxmox/version.rb +1 -1
  25. data/test/unit/foreman_fog_proxmox/helpers/proxmox_container_helper_test.rb +1 -1
  26. data/test/unit/foreman_fog_proxmox/helpers/proxmox_server_helper_test.rb +1 -1
  27. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_helper_test.rb +2 -2
  28. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_uuid_helper_test.rb +2 -2
  29. data/test/unit/foreman_fog_proxmox/helpers/proxmox_vm_volumes_helper_test.rb +2 -2
  30. data/test/unit/foreman_fog_proxmox/proxmox_compute_attributes_test.rb +1 -1
  31. data/test/unit/foreman_fog_proxmox/proxmox_images_test.rb +1 -1
  32. data/test/unit/foreman_fog_proxmox/proxmox_interfaces_test.rb +3 -3
  33. data/test/unit/foreman_fog_proxmox/proxmox_test.rb +1 -1
  34. data/test/unit/foreman_fog_proxmox/proxmox_version_test.rb +1 -1
  35. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_container_test.rb +2 -2
  36. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb +2 -2
  37. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cdrom_test.rb +5 -2
  38. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_cloudinit_test.rb +2 -2
  39. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_hard_disk_test.rb +2 -2
  40. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_update_test.rb +2 -2
  41. data/test/unit/foreman_fog_proxmox/proxmox_vm_commands_test.rb +2 -2
  42. data/test/unit/foreman_fog_proxmox/proxmox_vm_new_test.rb +2 -2
  43. data/test/unit/foreman_fog_proxmox/proxmox_vm_queries_test.rb +2 -2
  44. data/webpack/components/GeneralTabContent.js +3 -3
  45. data/webpack/components/ProxmoxComputeSelectors.js +64 -20
  46. data/webpack/components/ProxmoxContainer/MountPoint.js +5 -8
  47. data/webpack/components/ProxmoxContainer/ProxmoxContainerOptions.js +3 -2
  48. data/webpack/components/ProxmoxContainer/ProxmoxContainerStorage.js +1 -1
  49. data/webpack/components/ProxmoxContainer/components/NetworkInterface.js +14 -13
  50. data/webpack/components/ProxmoxServer/ProxmoxServerHardware.js +22 -22
  51. data/webpack/components/ProxmoxServer/ProxmoxServerNetwork.js +1 -1
  52. data/webpack/components/ProxmoxServer/ProxmoxServerOptions.js +3 -3
  53. data/webpack/components/ProxmoxServer/components/HardDisk.js +13 -5
  54. data/webpack/components/ProxmoxServer/components/NetworkInterface.js +2 -2
  55. data/webpack/components/ProxmoxVmType.js +24 -21
  56. data/webpack/components/common/FormInputs.js +10 -2
  57. metadata +19 -17
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54d5a9b1f9b4ed97380a0fa47196d61bb4ca3b95761eeb81430332166b18cfcd
4
- data.tar.gz: ff6784567daf69fc12818289768a1c8e080655dcdd5b25934ef67950701eb7e0
3
+ metadata.gz: 4521dde2dff786a4f14fcf50c4eb68cd412596029a0f2ee32d54bd8154c51135
4
+ data.tar.gz: 6e316973c79ab4e51f95578e3c282a0d5345dde397afb5d14ad9ac011a8fc9d0
5
5
  SHA512:
6
- metadata.gz: d5746802f2ca998ce4d516c35bb472b52e76d5c248307faf035eb7a46c1bf9b6eb31feffc7236509f7c0cf15a7af672601537c51b00fff3aff3babf2d4501231
7
- data.tar.gz: 82127d47aa58601018263e066ea5149926cc4a6bdab14f54917175f5762f87d246410ea90050cca5e7021393b73c097a638df17e9a4531f7a75754991e4e7f61
6
+ metadata.gz: 9d034e8a37538e334329ab3a8df9447325ca7d2809a0b185819bc0fe62757fc39cee691799fa8699802d50855da41d3e4f8df17a3a2ffe1924376dfbcbacfc20
7
+ data.tar.gz: '09e3bd0ebb1cd6ece7103cc0d07f0d0c5a0c02598a8f72787359599ee8a8004c6c3add7d9d43a7ffdd9b2486c4fe2faeb5fa28b05ddc83cf290fe0ff55211b5a'
@@ -24,7 +24,7 @@ module ForemanFogProxmox
24
24
  prepend Overrides
25
25
  end
26
26
  module Overrides
27
- include ForemanFogProxmox::ProxmoxVmNew
27
+ include ForemanFogProxmox::ProxmoxVMNew
28
28
  # Clone the host
29
29
  def clone
30
30
  super
@@ -24,7 +24,7 @@ require 'foreman_fog_proxmox/value'
24
24
  require 'foreman_fog_proxmox/hash_collection'
25
25
 
26
26
  # Convert a foreman form server hash into a fog-proxmox server attributes hash
27
- module ProxmoxVmAttrsHelper
27
+ module ProxmoxVMAttrsHelper
28
28
  def object_to_attributes_hash(vms, from_profile, start_checked)
29
29
  param_scope = from_profile ? "compute_attribute[vm_attrs]" : "host[compute_attributes]"
30
30
  vm_h = ActiveSupport::HashWithIndifferentAccess.new
@@ -114,11 +114,11 @@ module ProxmoxVmAttrsHelper
114
114
  start_after_create: vms.start_after_create,
115
115
  templated: vms.templated,
116
116
  }
117
- vms_keys = [:pool, :start_after_create]
117
+ vms_keys = [:cpu_type, :nameserver, :searchdomain, :hostname]
118
118
  extra_attrs = ActiveSupport::HashWithIndifferentAccess.new
119
119
  attributes.each do |key, value|
120
120
  camel_key = key.to_s.include?('_') ? snake_to_camel(key.to_s).to_sym : key
121
- nested_key = vms_keys.include?(key) ? key : "config_attributes[#{key}]"
121
+ nested_key = vms_keys.include?(key) ? "config_attributes[#{key}]" : key
122
122
  value = start_checked if key == :start_after_create
123
123
  extra_attrs[camel_key] = { name: "#{param_scope}[#{nested_key}]", value: value }
124
124
  end
@@ -23,7 +23,7 @@ require 'foreman_fog_proxmox/value'
23
23
  require 'foreman_fog_proxmox/hash_collection'
24
24
 
25
25
  # Convert a foreman form server hash into a fog-proxmox server attributes hash
26
- module ProxmoxVmCdromHelper
26
+ module ProxmoxVMCdromHelper
27
27
  def parse_server_cdrom(args)
28
28
  cdrom_media = args['cdrom'] if args.key?('cdrom')
29
29
  cdrom_image = args['volid'] if args.key?('volid')
@@ -23,7 +23,7 @@ require 'foreman_fog_proxmox/value'
23
23
  require 'foreman_fog_proxmox/hash_collection'
24
24
 
25
25
  # Convert a foreman form server hash into a fog-proxmox server attributes hash
26
- module ProxmoxVmCloudinitHelper
26
+ module ProxmoxVMCloudinitHelper
27
27
  def parse_server_cloudinit(args)
28
28
  cloudinit_h = {}
29
29
  cloudinit = args['cloudinit']
@@ -24,7 +24,7 @@ require 'foreman_fog_proxmox/value'
24
24
  require 'foreman_fog_proxmox/hash_collection'
25
25
 
26
26
  # Convert a foreman form server hash into a fog-proxmox server attributes hash
27
- module ProxmoxVmConfigHelper
27
+ module ProxmoxVMConfigHelper
28
28
  def object_to_config_hash(vm, type)
29
29
  vm_h = ActiveSupport::HashWithIndifferentAccess.new
30
30
  main_a = ['vmid', 'type']
@@ -21,11 +21,11 @@ require 'fog/proxmox/helpers/disk_helper'
21
21
  require 'fog/proxmox/helpers/nic_helper'
22
22
  require 'foreman_fog_proxmox/value'
23
23
 
24
- module ProxmoxVmHelper
25
- include ProxmoxVmInterfacesHelper
26
- include ProxmoxVmVolumesHelper
27
- include ProxmoxVmConfigHelper
28
- include ProxmoxVmOsTemplateHelper
24
+ module ProxmoxVMHelper
25
+ include ProxmoxVMInterfacesHelper
26
+ include ProxmoxVMVolumesHelper
27
+ include ProxmoxVMConfigHelper
28
+ include ProxmoxVMOsTemplateHelper
29
29
 
30
30
  def vm_collection(type)
31
31
  collection = :servers
@@ -23,7 +23,7 @@ require 'foreman_fog_proxmox/value'
23
23
  require 'foreman_fog_proxmox/hash_collection'
24
24
 
25
25
  # Convert a foreman form server hash into a fog-proxmox server attributes hash
26
- module ProxmoxVmInterfacesHelper
26
+ module ProxmoxVMInterfacesHelper
27
27
  def parsed_typed_interfaces(args, type, parsed_vm)
28
28
  interfaces_to_add, interfaces_to_delete = parse_typed_interfaces(args, type)
29
29
  interfaces_to_add.each { |interface| parsed_vm = parsed_vm.merge(interface) }
@@ -22,7 +22,7 @@ require 'fog/proxmox/helpers/nic_helper'
22
22
  require 'foreman_fog_proxmox/value'
23
23
  require 'foreman_fog_proxmox/hash_collection'
24
24
 
25
- module ProxmoxVmOsTemplateHelper
25
+ module ProxmoxVMOsTemplateHelper
26
26
  def ostemplate_keys
27
27
  ['ostemplate_storage', 'ostemplate_file']
28
28
  end
@@ -17,7 +17,7 @@
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 ProxmoxVmUuidHelper
20
+ module ProxmoxVMUuidHelper
21
21
  UUID_REGEXP = /(?<cluster_id>\d+)_(?<vmid>\d+)/.freeze
22
22
  def extract(uuid, name)
23
23
  captures_h = uuid ? UUID_REGEXP.match(uuid.to_s) : { cluster_id: '', vmid: '' }
@@ -23,9 +23,9 @@ require 'foreman_fog_proxmox/value'
23
23
  require 'foreman_fog_proxmox/hash_collection'
24
24
 
25
25
  # Convert a foreman form server hash into a fog-proxmox server attributes hash
26
- module ProxmoxVmVolumesHelper
27
- include ProxmoxVmCdromHelper
28
- include ProxmoxVmCloudinitHelper
26
+ module ProxmoxVMVolumesHelper
27
+ include ProxmoxVMCdromHelper
28
+ include ProxmoxVMCloudinitHelper
29
29
 
30
30
  def add_disk_options(disk, args)
31
31
  options = ForemanFogProxmox::HashCollection.new_hash_reject_keys(args,
@@ -19,7 +19,7 @@
19
19
 
20
20
  module HostExt
21
21
  module Proxmox
22
- module ForVm
22
+ module ForVM
23
23
  extend ActiveSupport::Concern
24
24
  module ClassMethods
25
25
  def for_vm_uuid(cr, vm)
@@ -23,11 +23,11 @@ require 'foreman_fog_proxmox/value'
23
23
 
24
24
  module ForemanFogProxmox
25
25
  class Proxmox < ComputeResource
26
- include ProxmoxVmHelper
26
+ include ProxmoxVMHelper
27
27
  include ProxmoxConnection
28
- include ProxmoxVmNew
29
- include ProxmoxVmCommands
30
- include ProxmoxVmQueries
28
+ include ProxmoxVMNew
29
+ include ProxmoxVMCommands
30
+ include ProxmoxVMQueries
31
31
  include ProxmoxComputeAttributes
32
32
  include ProxmoxVolumes
33
33
  include ProxmoxInterfaces
@@ -118,7 +118,7 @@ module ForemanFogProxmox
118
118
  def set_mac(nic_compute_attributes, mac, type)
119
119
  mac_attr_name = { 'qemu' => :macaddr, 'lxc' => :hwaddr }
120
120
  mac_key = mac_attr_name[type] || 'mac'
121
- nic_compute_attributes[mac_key] = Net::Validations.normalize_mac(mac)
121
+ nic_compute_attributes[mac_key] = Net::Validations.normalize_mac(mac).upcase
122
122
  end
123
123
 
124
124
  def host_interfaces_attrs(host)
@@ -20,10 +20,10 @@
20
20
  require 'foreman_fog_proxmox/hash_collection'
21
21
 
22
22
  module ForemanFogProxmox
23
- module ProxmoxVmCommands
23
+ module ProxmoxVMCommands
24
24
  include ProxmoxVolumes
25
25
  include ProxmoxPools
26
- include ProxmoxVmHelper
26
+ include ProxmoxVMHelper
27
27
 
28
28
  def start_on_boot(vm, args)
29
29
  startonboot = args[:start_after_create].blank? ? false : Foreman::Cast.to_bool(args[:start_after_create])
@@ -23,8 +23,8 @@ require 'fog/proxmox/helpers/disk_helper'
23
23
  require 'foreman_fog_proxmox/hash_collection'
24
24
 
25
25
  module ForemanFogProxmox
26
- module ProxmoxVmNew
27
- include ProxmoxVmHelper
26
+ module ProxmoxVMNew
27
+ include ProxmoxVMHelper
28
28
 
29
29
  def cdrom_defaults
30
30
  { storage_type: 'cdrom', id: 'ide2', volid: 'none', media: 'cdrom' }
@@ -18,9 +18,9 @@
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module ForemanFogProxmox
21
- module ProxmoxVmQueries
21
+ module ProxmoxVMQueries
22
22
  include ProxmoxPools
23
- include ProxmoxVmUuidHelper
23
+ include ProxmoxVMUuidHelper
24
24
 
25
25
  def nodes
26
26
  nodes = client.nodes.all if client
@@ -22,7 +22,7 @@ require 'foreman_fog_proxmox/hash_collection'
22
22
 
23
23
  module ForemanFogProxmox
24
24
  module ProxmoxVolumes
25
- include ProxmoxVmHelper
25
+ include ProxmoxVMHelper
26
26
 
27
27
  def delete_volume(vm, id, volume_attributes)
28
28
  logger.info("vm #{vm.identity} delete volume #{id}")
@@ -107,7 +107,7 @@ module ForemanFogProxmox
107
107
  return false unless disk
108
108
 
109
109
  # Return boolean if disk of type hard_disk, cloud_init, cdrom or rootfs(LXC container) exists
110
- if disk.hard_disk? || disk.cloud_init? || disk.rootfs?
110
+ if disk.hard_disk? || disk.cloud_init? || disk.rootfs? || disk.mount_point?
111
111
  volume_attributes['volid'].present?
112
112
  elsif disk.cdrom?
113
113
  volume_attributes['cdrom'].present?
@@ -1,5 +1,4 @@
1
1
  <% content_for(:javascripts) do %>
2
2
  <%= webpacked_plugins_js_for :foreman_fog_proxmox %>
3
- <%= javascript_include_tag 'foreman_fog_proxmox/proxmox_vm', "data-turbolinks-track" => true %>
4
3
  <% end %>
5
4
  <%= react_component('ProxmoxVmType', { registerComp: true }) unless @host.managed %>
@@ -0,0 +1,119 @@
1
+ <%#
2
+ kind: user_data
3
+ name: Proxmox UserData
4
+ model: ProvisioningTemplate
5
+ require:
6
+ - plugin: foreman_fog_proxmox
7
+ version: 0.16.1
8
+ oses:
9
+ - AlmaLinux
10
+ - Amazon
11
+ - CentOS
12
+ - CentOS_Stream
13
+ - Debian
14
+ - Rocky
15
+ - Ubuntu
16
+ description: |
17
+ This template is used during image based provisioning with Proxmox Compute Resource, when
18
+ the image is configured to use user-data and network config. The output is a list of
19
+ cloud-init directives that cloud-init parses to configures the VM booted from the image.
20
+ The image must have cloud-init installed in order for this to work.
21
+
22
+ This template accepts the following parameters:
23
+ - ssh_pwauth: boolean (default=true unless ssh_authorized_keys)
24
+ - ssh_authorized_keys: string w newline seperated keys (default="")
25
+ - package_upgrade: boolean (default=false)
26
+ - reboot: boolean (default=false)
27
+ - skip-puppet-setup: boolean (default=false)
28
+ -%>
29
+ <%
30
+ ssh_pwauth = host_param('ssh_pwauth') ? host_param_true?('ssh_pwauth') : !host_param('ssh_authorized_keys')
31
+ rhel_compatible = @host.operatingsystem.family == 'Redhat' && @host.operatingsystem.name != 'Fedora'
32
+ # safemode renderer does not support unary negation
33
+ puppet_enabled = !host_param_true?('skip-puppet-setup') && (host_puppet_server.present? || host_param_true?('force-puppet'))
34
+ salt_enabled = host_param('salt_master') ? true : false
35
+ chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
36
+ -%>
37
+ <%
38
+ username_to_create = host_param('username_to_create', 'root')
39
+ password_to_create = host_param('password_to_create') || @host.root_pass
40
+ -%>
41
+ #cloud-config
42
+ hostname: <%= @host.shortname %>
43
+ fqdn: <%= @host %>
44
+ manage_etc_hosts: true
45
+ <% if ssh_pwauth -%>
46
+ <%# Don't enable this in production. It is very insecure! Use ssh_authorized_keys instead...
47
+ http://cloudinit.readthedocs.io/en/latest/topics/examples.html#including-users-and-groups -%>
48
+ ssh_pwauth: true
49
+ users:
50
+ - name: <%= username_to_create %>
51
+ shell: /bin/bash
52
+ sudo: ALL=(ALL) ALL
53
+ lock_passwd: false
54
+ hashed_passwd: <%= password_to_create %>
55
+ <% end -%>
56
+ <% if host_param('ssh_authorized_keys') -%>
57
+ ssh_authorized_keys:
58
+ <% host_param('ssh_authorized_keys').split("\n").each do |ssh_key| -%>
59
+ - <%= ssh_key %>
60
+ <% end -%>
61
+ <% end -%>
62
+
63
+ <% if host_param_true?('package_upgrade') -%>
64
+ package_upgrade: true
65
+ <% end -%>
66
+
67
+ runcmd:
68
+ <% if rhel_compatible -%>
69
+ - |
70
+ <%= indent(2) { snippet('epel') } %>
71
+ <% end -%>
72
+ - |
73
+ <%= indent(2) { snippet('remote_execution_ssh_keys') } %>
74
+ <% if chef_enabled -%>
75
+ - |
76
+ <%= indent(2) { snippet('chef_client') } %>
77
+ <% end -%>
78
+ <% if puppet_enabled -%>
79
+ - |
80
+ <%= indent(2) { snippet('puppetlabs_repo') } %>
81
+ - |
82
+ <%= indent(2) { snippet('puppet_setup') } %>
83
+ <% end -%>
84
+ <% if salt_enabled -%>
85
+ - |
86
+ <%= indent(2) { snippet('saltstack_setup') } %>
87
+ <% end -%>
88
+
89
+ <%# Contact Foreman to confirm instance is built -%>
90
+ phone_home:
91
+ url: <%= foreman_url('built') %>
92
+ post: []
93
+ tries: 10
94
+
95
+ <% if host_param_true?('reboot') -%>
96
+ power_state:
97
+ mode: reboot
98
+ timeout: 30
99
+ condition: true
100
+ <% end -%>
101
+
102
+ #network-config
103
+ version: 2
104
+ ethernets:
105
+ eth0:
106
+ match:
107
+ name: e*
108
+ dhcp4: false
109
+ dhcp6: false
110
+ addresses:
111
+ - <%= @host.ip %>/<%= @host.subnet.cidr %>
112
+ routes:
113
+ - to: 0.0.0.0
114
+ via: <%= @host.subnet.gateway %>
115
+ nameservers:
116
+ addresses:
117
+ - <%= @host.subnet.dns_primary%>
118
+ search:
119
+ - <%= @host.domain.name %>
@@ -1,4 +1,4 @@
1
- include ProxmoxVmUuidHelper
1
+ include ProxmoxVMUuidHelper
2
2
  class UpdateProxmoxUuidHost < ActiveRecord::Migration[6.0]
3
3
  def up
4
4
  execute(sql(:concat))
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ ProvisioningTemplate.without_auditing do
4
+ SeedHelper.import_templates(
5
+ Dir[File.join("#{ForemanFogProxmox::Engine.root}/app/views/templates/provisioning/**/*.erb")]
6
+ )
7
+ end
@@ -23,13 +23,6 @@ module ForemanFogProxmox
23
23
  class Engine < ::Rails::Engine
24
24
  engine_name 'foreman_fog_proxmox'
25
25
 
26
- config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
27
- config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
28
- config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
29
- config.autoload_paths += Dir["#{config.root}/app/services/concerns"]
30
- config.autoload_paths += Dir["#{config.root}/app/overrides"]
31
- config.autoload_paths += Dir["#{config.root}/app/services"]
32
-
33
26
  # Add any db migrations
34
27
  initializer 'foreman_fog_proxmox.load_app_instance_data' do |app|
35
28
  ForemanFogProxmox::Engine.paths['db/migrate'].existent.each do |path|
@@ -37,25 +30,27 @@ module ForemanFogProxmox
37
30
  end
38
31
  end
39
32
 
40
- initializer 'foreman_fog_proxmox.register_plugin', :before => :finisher_hook do |_app|
41
- Foreman::Plugin.register :foreman_fog_proxmox do
42
- requires_foreman '>= 1.22.0'
43
- # Add Global files for extending foreman-core components and routes
44
- register_global_js_file 'global'
45
- # Register Proxmox VE compute resource in foreman
46
- compute_resource ForemanFogProxmox::Proxmox
47
- parameter_filter(ComputeResource, :uuid)
48
- # add dashboard widget
49
- widget 'foreman_fog_proxmox_widget', name: N_('Foreman Fog Proxmox widget'), sizex: 8, sizey: 1
50
- security_block :foreman_fog_proxmox do
51
- permission :view_compute_resources, { :'foreman_fog_proxmox/compute_resources' =>
52
- [:ostemplates_by_id_and_node_and_storage,
53
- :isos_by_id_and_node_and_storage,
54
- :ostemplates_by_id_and_node,
55
- :isos_by_id_and_node,
56
- :storages_by_id_and_node,
57
- :iso_storages_by_id_and_node,
58
- :bridges_by_id_and_node] }
33
+ initializer 'foreman_fog_proxmox.register_plugin', :before => :finisher_hook do |app|
34
+ app.reloader.to_prepare do
35
+ Foreman::Plugin.register :foreman_fog_proxmox do
36
+ requires_foreman '>= 1.22.0'
37
+ # Add Global files for extending foreman-core components and routes
38
+ register_global_js_file 'global'
39
+ # Register Proxmox VE compute resource in foreman
40
+ compute_resource ForemanFogProxmox::Proxmox
41
+ parameter_filter(ComputeResource, :uuid)
42
+ # add dashboard widget
43
+ widget 'foreman_fog_proxmox_widget', name: N_('Foreman Fog Proxmox widget'), sizex: 8, sizey: 1
44
+ security_block :foreman_fog_proxmox do
45
+ permission :view_compute_resources, { :'foreman_fog_proxmox/compute_resources' =>
46
+ [:ostemplates_by_id_and_node_and_storage,
47
+ :isos_by_id_and_node_and_storage,
48
+ :ostemplates_by_id_and_node,
49
+ :isos_by_id_and_node,
50
+ :storages_by_id_and_node,
51
+ :iso_storages_by_id_and_node,
52
+ :bridges_by_id_and_node] }
53
+ end
59
54
  end
60
55
  end
61
56
  end
@@ -112,7 +107,7 @@ module ForemanFogProxmox
112
107
  ::Host::Managed.include Orchestration::Proxmox::Compute
113
108
  ::Host::Managed.include HostExt::Proxmox::Interfaces
114
109
  ::Host::Managed.include HostExt::Proxmox::Associator
115
- ::Host::Base.include HostExt::Proxmox::ForVm
110
+ ::Host::Base.include HostExt::Proxmox::ForVM
116
111
  ::ComputeResourceHostAssociator.include ForemanFogProxmox::ComputeResourceHostAssociator
117
112
  end
118
113
  end
@@ -18,5 +18,5 @@
18
18
  # along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module ForemanFogProxmox
21
- VERSION = '0.16.1'
21
+ VERSION = '0.17.0'
22
22
  end
@@ -21,7 +21,7 @@ require 'test_plugin_helper'
21
21
 
22
22
  module ForemanFogProxmox
23
23
  class ProxmoxContainerHelperTest < ActiveSupport::TestCase
24
- include ProxmoxVmHelper
24
+ include ProxmoxVMHelper
25
25
 
26
26
  describe 'parse' do
27
27
  setup { Fog.mock! }
@@ -21,7 +21,7 @@ require 'test_plugin_helper'
21
21
 
22
22
  module ForemanFogProxmox
23
23
  class ProxmoxServerHelperTest < ActiveSupport::TestCase
24
- include ProxmoxVmHelper
24
+ include ProxmoxVMHelper
25
25
 
26
26
  describe 'parse' do
27
27
  setup { Fog.mock! }
@@ -28,8 +28,8 @@ require 'fog/proxmox/compute/models/snapshots'
28
28
  require 'fog/proxmox/compute/models/tasks'
29
29
 
30
30
  module ForemanFogProxmox
31
- class ProxmoxVmHelperTest < ActiveSupport::TestCase
32
- include ProxmoxVmHelper
31
+ class ProxmoxVMHelperTest < ActiveSupport::TestCase
32
+ include ProxmoxVMHelper
33
33
 
34
34
  let(:container) do
35
35
  service = mock('service')
@@ -20,8 +20,8 @@
20
20
  require 'test_plugin_helper'
21
21
 
22
22
  module ForemanFogProxmox
23
- class ProxmoxVmUuidHelperTest < ActiveSupport::TestCase
24
- include ProxmoxVmUuidHelper
23
+ class ProxmoxVMUuidHelperTest < ActiveSupport::TestCase
24
+ include ProxmoxVMUuidHelper
25
25
 
26
26
  describe 'extract_vmid' do
27
27
  setup { Fog.mock! }
@@ -20,8 +20,8 @@
20
20
  require 'test_plugin_helper'
21
21
 
22
22
  module ForemanFogProxmox
23
- class ProxmoxVmVolumesHelperTest < ActiveSupport::TestCase
24
- include ProxmoxVmVolumesHelper
23
+ class ProxmoxVMVolumesHelperTest < ActiveSupport::TestCase
24
+ include ProxmoxVMVolumesHelper
25
25
 
26
26
  describe 'remove_deletes' do
27
27
  setup { Fog.mock! }
@@ -30,7 +30,7 @@ module ForemanFogProxmox
30
30
  include ProxmoxNodeMockFactory
31
31
  include ProxmoxServerMockFactory
32
32
  include ProxmoxContainerMockFactory
33
- include ProxmoxVmHelper
33
+ include ProxmoxVMHelper
34
34
 
35
35
  describe 'host_compute_attrs' do
36
36
  before do
@@ -21,7 +21,7 @@ require 'test_plugin_helper'
21
21
  require 'active_support/core_ext/hash/indifferent_access'
22
22
 
23
23
  module ForemanFogProxmox
24
- class ProxmoxVmCommandsServerTest < ActiveSupport::TestCase
24
+ class ProxmoxVMCommandsServerTest < ActiveSupport::TestCase
25
25
  include ComputeResourceTestHelpers
26
26
 
27
27
  describe 'clone_from_image' do
@@ -30,7 +30,7 @@ module ForemanFogProxmox
30
30
  include ProxmoxNodeMockFactory
31
31
  include ProxmoxServerMockFactory
32
32
  include ProxmoxContainerMockFactory
33
- include ProxmoxVmHelper
33
+ include ProxmoxVMHelper
34
34
 
35
35
  describe 'host_interfaces_attrs' do
36
36
  before do
@@ -54,7 +54,7 @@ module ForemanFogProxmox
54
54
 
55
55
  it 'sets interface identifier with server compute id, ip and ip6 and mac adress' do
56
56
  ip = '192.168.56.100'
57
- mac_address = '36:25:8c:53:0c:50'
57
+ mac_address = '36:25:8C:53:0C:50'
58
58
  ip6 = Array.new(4) { format('%<x>s', x: rand(16**4)) }.join(':') + '::1'
59
59
  compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'net0' })
60
60
  physical_nic = FactoryBot.build(:nic_base_empty, :identifier => 'net0', :ip => ip, :ip6 => ip6,
@@ -131,7 +131,7 @@ module ForemanFogProxmox
131
131
 
132
132
  it 'sets container compute ip DHCP, mac adress and firewall' do
133
133
  ip = '192.168.56.100'
134
- mac_address = '36:25:8c:53:0c:50'
134
+ mac_address = '36:25:8C:53:0C:50'
135
135
  ip6 = '2001:0:1234::c1c0:abcd:876'
136
136
  firewall = '1'
137
137
  compute_attributes = ActiveSupport::HashWithIndifferentAccess.new({ 'id' => 'net0', 'dhcp' => '1',
@@ -30,7 +30,7 @@ module ForemanFogProxmox
30
30
  include ProxmoxNodeMockFactory
31
31
  include ProxmoxServerMockFactory
32
32
  include ProxmoxContainerMockFactory
33
- include ProxmoxVmHelper
33
+ include ProxmoxVMHelper
34
34
 
35
35
  should validate_presence_of(:url)
36
36
  should validate_presence_of(:user)
@@ -24,7 +24,7 @@ require 'active_support/core_ext/hash/indifferent_access'
24
24
  module ForemanFogProxmox
25
25
  class ProxmoxVersionTest < ActiveSupport::TestCase
26
26
  include ComputeResourceTestHelpers
27
- include ProxmoxVmHelper
27
+ include ProxmoxVMHelper
28
28
 
29
29
  wrong_version = { version: '5.a', release: '5.a-1' }.with_indifferent_access
30
30
  supported_version = { version: '5.4', release: '5.4-3' }.with_indifferent_access
@@ -24,11 +24,11 @@ require 'factories/foreman_fog_proxmox/proxmox_container_mock_factory'
24
24
  require 'active_support/core_ext/hash/indifferent_access'
25
25
 
26
26
  module ForemanFogProxmox
27
- class ProxmoxVmCommandsContainerTest < ActiveSupport::TestCase
27
+ class ProxmoxVMCommandsContainerTest < ActiveSupport::TestCase
28
28
  include ComputeResourceTestHelpers
29
29
  include ProxmoxNodeMockFactory
30
30
  include ProxmoxContainerMockFactory
31
- include ProxmoxVmHelper
31
+ include ProxmoxVMHelper
32
32
 
33
33
  describe 'save_vm' do
34
34
  before do
@@ -24,11 +24,11 @@ require 'factories/foreman_fog_proxmox/proxmox_server_mock_factory'
24
24
  require 'active_support/core_ext/hash/indifferent_access'
25
25
 
26
26
  module ForemanFogProxmox
27
- class ProxmoxVmCommandsServerCreateTest < ActiveSupport::TestCase
27
+ class ProxmoxVMCommandsServerCreateTest < ActiveSupport::TestCase
28
28
  include ComputeResourceTestHelpers
29
29
  include ProxmoxNodeMockFactory
30
30
  include ProxmoxServerMockFactory
31
- include ProxmoxVmHelper
31
+ include ProxmoxVMHelper
32
32
 
33
33
  describe 'create_vm' do
34
34
  it 'raises Foreman::Exception when vmid <= 100 and vmid > 0' do