the_foreman_proxmox 0.3.0

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.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +619 -0
  3. data/README.md +102 -0
  4. data/Rakefile +47 -0
  5. data/app/assets/javascripts/the_foreman_proxmox/proxmox.js +110 -0
  6. data/app/controllers/concerns/the_foreman_proxmox/controller/parameters/compute_resource.rb +41 -0
  7. data/app/controllers/the_foreman_proxmox/compute_resources_controller.rb +38 -0
  8. data/app/helpers/proxmox_compute_helper.rb +154 -0
  9. data/app/helpers/proxmox_compute_selectors_helper.rb +148 -0
  10. data/app/models/concerns/fog_extensions/proxmox/disk.rb +29 -0
  11. data/app/models/concerns/fog_extensions/proxmox/server.rb +82 -0
  12. data/app/models/concerns/fog_extensions/proxmox/server_config.rb +49 -0
  13. data/app/models/concerns/fog_extensions/proxmox/volume.rb +29 -0
  14. data/app/models/the_foreman_proxmox/options_select.rb +36 -0
  15. data/app/models/the_foreman_proxmox/proxmox.rb +394 -0
  16. data/app/views/api/v2/compute_resources/proxmox.json.rabl +1 -0
  17. data/app/views/compute_resources/form/_proxmox.html.erb +24 -0
  18. data/app/views/compute_resources/show/_proxmox.html.erb +21 -0
  19. data/app/views/compute_resources_vms/form/proxmox/_base.html.erb +45 -0
  20. data/app/views/compute_resources_vms/form/proxmox/_config.html.erb +55 -0
  21. data/app/views/compute_resources_vms/form/proxmox/_network.html.erb +24 -0
  22. data/app/views/compute_resources_vms/form/proxmox/_volume.html.erb +23 -0
  23. data/app/views/compute_resources_vms/index/_proxmox.html.erb +45 -0
  24. data/app/views/compute_resources_vms/show/_proxmox.html.erb +36 -0
  25. data/app/views/dashboard/_the_foreman_proxmox_widget.erb +19 -0
  26. data/app/views/images/form/_proxmox.html.erb +4 -0
  27. data/config/routes.rb +24 -0
  28. data/lib/tasks/the_foreman_proxmox_tasks.rake +47 -0
  29. data/lib/the_foreman_proxmox.rb +23 -0
  30. data/lib/the_foreman_proxmox/engine.rb +92 -0
  31. data/lib/the_foreman_proxmox/version.rb +22 -0
  32. data/locale/Makefile +60 -0
  33. data/locale/en/foreman_proxmox.po +19 -0
  34. data/locale/gemspec.rb +2 -0
  35. data/locale/the_foreman_proxmox.pot +19 -0
  36. data/test/factories/the_foreman_proxmox_factories.rb +33 -0
  37. data/test/helpers/proxmox_compute_helper_test.rb +130 -0
  38. data/test/test_plugin_helper.rb +15 -0
  39. data/test/unit/the_foreman_proxmox_test.rb +11 -0
  40. metadata +143 -0
@@ -0,0 +1 @@
1
+ attributes :user, :url, :ssl_verify_peer, :disable_proxy
@@ -0,0 +1,24 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <% node = f.object.node rescue nil %>
19
+ <%= text_f f, :url, :help_block => _("e.g. https://127.0.0.1:8006/api2/json"), :help_inline_permanent => load_button_f(f, !!node, _("Test failed")) %>
20
+ <%= text_f f, :user , :help_block => _("e.g. root@pam") %>
21
+ <%= password_f f, :password, :keep_value => true, :unset => unset_password? %>
22
+ <%= checkbox_f f, :ssl_verify_peer, :label => _("SSL verify peer") %>
23
+ <%= textarea_f f, :ssl_certs, :label => _("X509 Certification Authorities"), :size => "col-md-8",
24
+ :placeholder => _("Optionally provide a CA, or a correctly ordered CA chain. If left blank, disable ssl_verify_peer.") %>
@@ -0,0 +1,21 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <tr>
19
+ <td><%= _("URL") %></td>
20
+ <td><%= @compute_resource.url %></td>
21
+ </tr>
@@ -0,0 +1,45 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <%= javascript_include_tag 'the_foreman_proxmox/proxmox' %>
19
+
20
+ <%= javascript_tag("$(document).on('ContentLoad', tfm.numFields.initAll)"); %>
21
+
22
+ <!-- VM General Settings -->
23
+ <%= field_set_tag _("General"), :id => "general" do %>
24
+ <%= checkbox_f f, :templated, :label => _('Create image?'), :disabled => new_vm || f.object.templated? %>
25
+ <%= counter_f f, :vmid, :label => _('VM ID'), :label_size => "col-md-2", :required => true, :disabled => !new_vm %>
26
+ <%= select_f f, :node, compute_resource.nodes, :node, :node, { }, :label => _('Node'), :label_size => "col-md-2", :required => true, :disabled => !new_vm %>
27
+ <% unless local_assigns[:hide_image] && !new_vm %>
28
+ <%
29
+ arch ||= nil ; os ||= nil
30
+ images = possible_images(compute_resource, arch, os)
31
+ -%>
32
+ <div id='image_selection'>
33
+ <%= select_f f, :image_id, images, :uuid, :name, { :include_blank => true },
34
+ :disabled => true,
35
+ :help_inline => :indicator,
36
+ :label => _('Image'),
37
+ :label_size => "col-md-2" %>
38
+ </div>
39
+ <% end %>
40
+ <% end %>
41
+
42
+ <!-- Config -->
43
+ <%= f.fields_for :config do |config_f|%>
44
+ <%= render :partial => 'compute_resources_vms/form/proxmox/config', :locals => { :f => config_f, :compute_resource => compute_resource, :host => @host, :new_vm => new_vm, :item_layout => 'removable' } %>
45
+ <% end %>
@@ -0,0 +1,55 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <%= field_set_tag _("Config options"), :id => "config_options" do %>
19
+ <%= textarea_f f, :description, :label => _('Description'), :label_size => "col-md-2" %>
20
+ <%= text_f f, :boot, :label => _('Start/Shutdown order'), :label_size => "col-md-2" %>
21
+ <%= checkbox_f f, :onboot, :label => _('Start at boot') %>
22
+ <%= checkbox_f f, :agent, :label => _('Qemu Agent') %>
23
+ <%= checkbox_f f, :kvm, :label => _('KVM'), :label_help => _('Enable/disable KVM hardware virtualization') %>
24
+ <%= select_f f, :keyboard, proxmox_keyboards_map, :id, :name, { }, :label => _('Keyboard'), :label_size => "col-md-2" %>
25
+ <%= select_f f, :vga, proxmox_vgas_map, :id, :name, { :include_blank => true }, :label => _('VGA'), :label_size => "col-md-2" %>
26
+ <% end %>
27
+ <%= field_set_tag _("CPU"), :id => "cpu" do %>
28
+ <%= select_f f, :cpu_type, proxmox_cpus_map, :id, :name, { }, :label => _('Type'), :label_size => "col-md-2" %>
29
+ <%= counter_f f, :sockets, :class => "input-mini", :label => _('Sockets'), :label_size => "col-md-2" %>
30
+ <%= counter_f f, :cores, :class => "input-mini", :label => _('Cores'), :label_size => "col-md-2" %>
31
+ <%= counter_f f, :vcpus, :class => "input-mini", :label => _('VCPUs'), :label_size => "col-md-2" %>
32
+ <%= counter_f f, :cpulimit, :class => "input-mini", :label => _('CPU limit'), :label_size => "col-md-2" %>
33
+ <%= counter_f f, :cpuunits, :class => "input-mini", :label => _('CPU units'), :label_size => "col-md-2" %>
34
+ <%= checkbox_f f, :numa, :label => _('Enable NUMA') %>
35
+ <%= checkbox_f f, :pcid, :label => _('PCID') %>
36
+ <%= checkbox_f f, :spectre, :label => _('Spectre-CTRL') %>
37
+ <% end %>
38
+ <%= field_set_tag _("Memory"), :id => "memory" do %>
39
+ <%= byte_size_f f, :memory, :class => "input-mini", :label => _('Memory'), :label_size => "col-md-2" %>
40
+ <%= byte_size_f f, :min_memory, :class => "input-mini", :label => _('Minimum memory'), :label_size => "col-md-2" %>
41
+ <%= counter_f f, :shares, :class => "input-mini", :label => _('Shares'), :label_size => "col-md-2" %>
42
+ <%= checkbox_f f, :balloon, :label => _('Ballooning Device') %>
43
+ <% end %>
44
+ <%= field_set_tag _("CD-ROM"), :id => "cdrom" do %>
45
+ <%= radio_button_f f, :cdrom, :value => 'none', :text => _('None'), :onclick => 'cdromSelected(this)' %>
46
+ <%= radio_button_f f, :cdrom, :value => 'cdrom' , :text => _('Physical'), :onclick => 'cdromSelected(this)' %>
47
+ <%= radio_button_f f, :cdrom, :value => 'image' , :text => _('Image'), :onclick => 'cdromSelected(this)' %>
48
+ <div id='cdrom_image_form' class='<%= 'hide' if %[none cdrom].include? f.object.cdrom %>'>
49
+ <%= select_f f, :cdrom_storage, compute_resource.storages_isos, :storage, :storage, { :include_blank => true }, :label => _('Storage'), :label_size => "col-md-2", :onchange => 'storageIsoSelected(this)' %>
50
+ <%= select_f f, :cdrom_iso, compute_resource.isos(f.object.cdrom_storage), :volid, :volid, { :include_blank => true }, :label => _('Image ISO'), :label_size => "col-md-2" %>
51
+ </div>
52
+ <% end %>
53
+ <%= field_set_tag _("Operating System"), :id => "config_os" do %>
54
+ <%= select_f f, :ostype, proxmox_operating_systems_map, :id, :name, { :include_blank => true }, :label => _('OS type'), :label_size => "col-md-2" %>
55
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <%= select_f f, :model, proxmox_networkcards_map, :id, :name, { }, :label => _('Card'), :label_size => "col-md-2" %>
19
+ <%= select_f f, :bridge, compute_resource.bridges, :iface, :iface, { }, :label => _('Bridge'), :label_size => "col-md-2" %>
20
+ <%= counter_f f, :tag, :class => "input-mini", :label => _('VLAN tag'), :label_size => "col-md-2" %>
21
+ <%= counter_f f, :rate, :class => "input-mini", :label => _('Rate limit'), :label_size => "col-md-2" %>
22
+ <%= counter_f f, :queues, :class => "input-mini", :label => _('Multiqueue'), :label_size => "col-md-2" %>
23
+ <%= checkbox_f f, :firewall, :label => _('Firewall') %>
24
+ <%= checkbox_f f, :link_down, :label => _('Disconnect') %>
@@ -0,0 +1,23 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <%= f.hidden_field :volid if !new_vm %>
19
+ <%= select_f f, :storage, compute_resource.storages, :storage, :storage, { }, :label => _('Storage'), :label_size => "col-md-2", :disabled => !new_vm %>
20
+ <%= select_f f, :controller, proxmox_controllers_map, :id, :name, { }, :label => _('Controller'), :label_size => "col-md-2", :disabled => !new_vm, :onchange => 'controllerSelected(this)' %>
21
+ <%= counter_f f, :device, :label => _('Device'), :label_size => "col-md-2", :disabled => !new_vm, :'data-soft-max' => proxmox_max_device(f.object.controller) %>
22
+ <%= select_f f, :cache, proxmox_caches_map, :id, :name, { }, :label => _('Cache'), :label_size => "col-md-2" %>
23
+ <%= byte_size_f f, :size, :class => "input-mini", :label => _("Size"), :label_size => "col-md-2", :disabled => !new_vm %>
@@ -0,0 +1,45 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <table class="table table-bordered" data-table='inline'>
19
+ <thead>
20
+ <tr>
21
+ <th><%= _('Name') -%></th>
22
+ <th><%= _('CPUs') -%></th>
23
+ <th><%= _('Memory') -%></th>
24
+ <th><%= _('Power') -%></th>
25
+ <th><%= _('Uptime') -%></th>
26
+ <th></th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+ <% @vms.each do |vm| -%>
31
+ <tr>
32
+ <td><%= link_to_if_authorized vm.name, hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity) %></td>
33
+ <td><%= vm.cpus %></td>
34
+ <td><%= (vm.memory.to_i / (1024 * 1024)).to_s %> MB</td>
35
+ <td> <span <%= vm_power_class(vm.ready?) %>> <%= vm_state(vm) %></span> </td>
36
+ <td><%= vm.uptime %></td>
37
+ <td>
38
+ <%= action_buttons(
39
+ vm_power_action(vm, authorizer),
40
+ display_delete_if_authorized(hash_for_compute_resource_vm_path(:compute_resource_id => @compute_resource, :id => vm.identity).merge(:auth_object => @compute_resource, :authorizer => authorizer))) %>
41
+ </td>
42
+ </tr>
43
+ <% end -%>
44
+ </tbody>
45
+ </table>
@@ -0,0 +1,36 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <% title @vm.name %>
19
+ <div class='span12'>
20
+ <table class="table table-bordered table-striped">
21
+ <tr>
22
+ <th colspan="2">Properties</th>
23
+ </tr>
24
+
25
+ <%= prop :name %>
26
+ <%= prop :templated? %>
27
+ <%= prop :mac %>
28
+ <%= prop :memory %>
29
+ <%= prop :vga %>
30
+ <%= prop :cpus %>
31
+ <%= prop :uptime %>
32
+ <%= prop :vmid %>
33
+ <%= prop :description %>
34
+ <%= prop :disks %>
35
+ </table>
36
+ </div>
@@ -0,0 +1,19 @@
1
+ <%# Copyright 2018 Tristan Robert
2
+
3
+ This file is part of TheForemanProxmox.
4
+
5
+ TheForemanProxmox is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ TheForemanProxmox is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>. %>
17
+
18
+ <h4 class="header ca"><%= _('TheForemanProxmox') %></h4>
19
+ <%= _('Widget content') %>
@@ -0,0 +1,4 @@
1
+ <%= text_f f, :username, :placeholder => "root", :help_inline => _("The user that is used to ssh into the instance, normally cloud-user, ubuntu, root etc") %>
2
+ <%= password_f f, :password, :help_inline => _("Password to authenticate with - used for SSH finish step.") %>
3
+ <%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input (e.g. via cloud-init)?") %>
4
+ <%= image_field(f, :label => _("Image VMID"), :help_inline => _("vmid of template vm.")) %>
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of TheForemanProxmox.
6
+
7
+ # TheForemanProxmox 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
+ # TheForemanProxmox 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 TheForemanProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ Rails.application.routes.draw do
21
+ namespace :the_foreman_proxmox do
22
+ match 'isos/:storage', :to => 'compute_resources#isos', :via => 'get'
23
+ end
24
+ end
@@ -0,0 +1,47 @@
1
+ require 'rake/testtask'
2
+
3
+ # Tasks
4
+ namespace :the_foreman_proxmox do
5
+ namespace :example do
6
+ desc 'Example Task'
7
+ task task: :environment do
8
+ # Task goes here
9
+ end
10
+ end
11
+ end
12
+
13
+ # Tests
14
+ namespace :test do
15
+ desc 'Test TheForemanProxmox'
16
+ Rake::TestTask.new(:the_foreman_proxmox) do |t|
17
+ test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
18
+ t.libs << ['test', test_dir]
19
+ t.pattern = "#{test_dir}/**/*_test.rb"
20
+ t.verbose = true
21
+ t.warning = false
22
+ end
23
+ end
24
+
25
+ namespace :the_foreman_proxmox do
26
+ task :rubocop do
27
+ begin
28
+ require 'rubocop/rake_task'
29
+ RuboCop::RakeTask.new(:rubocop_the_foreman_proxmox) do |task|
30
+ task.patterns = ["#{TheForemanProxmox::Engine.root}/app/**/*.rb",
31
+ "#{TheForemanProxmox::Engine.root}/lib/**/*.rb",
32
+ "#{TheForemanProxmox::Engine.root}/test/**/*.rb"]
33
+ end
34
+ rescue StandardError
35
+ puts 'Rubocop not loaded.'
36
+ end
37
+
38
+ Rake::Task['rubocop_the_foreman_proxmox'].invoke
39
+ end
40
+ end
41
+
42
+ Rake::Task[:test].enhance ['test:the_foreman_proxmox']
43
+
44
+ load 'tasks/jenkins.rake'
45
+ if Rake::Task.task_defined?(:'jenkins:unit')
46
+ Rake::Task['jenkins:unit'].enhance ['test:the_foreman_proxmox', 'the_foreman_proxmox:rubocop']
47
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanProxmox.
6
+
7
+ # ForemanProxmox 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
+ # ForemanProxmox 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 ForemanProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require 'the_foreman_proxmox/engine'
21
+
22
+ module TheForemanProxmox
23
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2018 Tristan Robert
4
+
5
+ # This file is part of ForemanProxmox.
6
+
7
+ # ForemanProxmox 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
+ # ForemanProxmox 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 ForemanProxmox. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module TheForemanProxmox
21
+ class Engine < ::Rails::Engine
22
+ engine_name 'the_foreman_proxmox'
23
+
24
+ config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
25
+ config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
26
+ config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
27
+ config.autoload_paths += Dir["#{config.root}/app/overrides"]
28
+
29
+ # Add any db migrations
30
+ initializer 'the_foreman_proxmox.load_app_instance_data' do |app|
31
+ TheForemanProxmox::Engine.paths['db/migrate'].existent.each do |path|
32
+ app.config.paths['db/migrate'] << path
33
+ end
34
+ end
35
+
36
+ initializer 'the_foreman_proxmox.register_plugin', :before => :finisher_hook do |_app|
37
+ Foreman::Plugin.register :the_foreman_proxmox do
38
+ requires_foreman '>= 1.17'
39
+ # Register Proxmox VE compute resource in foreman
40
+ compute_resource TheForemanProxmox::Proxmox
41
+ parameter_filter(ComputeResource, :uuid)
42
+ # add dashboard widget
43
+ widget 'the_foreman_proxmox_widget', name: N_('Foreman plugin template widget'), sizex: 4, sizey: 1
44
+ end
45
+ end
46
+
47
+ # Precompile any JS or CSS files under app/assets/
48
+ # If requiring files from each other, list them explicitly here to avoid precompiling the same
49
+ # content twice.
50
+ assets_to_precompile =
51
+ Dir.chdir(root) do
52
+ Dir['app/assets/javascripts/**/*', 'app/assets/stylesheets/**/*'].map do |f|
53
+ f.split(File::SEPARATOR, 4).last
54
+ end
55
+ end
56
+ initializer 'the_foreman_proxmox.assets.precompile' do |app|
57
+ app.config.assets.precompile += assets_to_precompile
58
+ end
59
+ initializer 'the_foreman_proxmox.configure_assets', group: :assets do
60
+ SETTINGS[:the_foreman_proxmox] = {
61
+ assets: {
62
+ precompile: assets_to_precompile
63
+ }, :js_compressor => Uglifier.new(:mangle => false) }
64
+ end
65
+
66
+ rake_tasks do
67
+ Rake::Task['db:seed'].enhance do
68
+ TheForemanProxmox::Engine.load_seed
69
+ end
70
+ end
71
+
72
+ initializer 'the_foreman_proxmox.register_gettext', after: :load_config_initializers do |_app|
73
+ locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
74
+ locale_domain = 'the_foreman_proxmox'
75
+ Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
76
+ end
77
+
78
+ config.to_prepare do
79
+ require 'fog/compute/proxmox/models/server'
80
+ require 'fog/compute/proxmox/models/server_config'
81
+ require 'fog/compute/proxmox/models/disk'
82
+ require 'fog/compute/proxmox/models/volume'
83
+
84
+ Fog::Compute::Proxmox::Server.send :include, FogExtensions::Proxmox::Server
85
+ Fog::Compute::Proxmox::ServerConfig.send :include, FogExtensions::Proxmox::ServerConfig
86
+ Fog::Compute::Proxmox::Disk.send :include, FogExtensions::Proxmox::Disk
87
+ Fog::Compute::Proxmox::Volume.send :include, FogExtensions::Proxmox::Volume
88
+ ::ComputeResourcesController.send :include, TheForemanProxmox::Controller::Parameters::ComputeResource
89
+ end
90
+
91
+ end
92
+ end