foreman_ovirt 0.3.0 → 2.0.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 (69) hide show
  1. checksums.yaml +7 -0
  2. data/{LICENSE.txt → LICENSE} +0 -2
  3. data/README.md +140 -0
  4. data/Rakefile +37 -43
  5. data/app/assets/javascripts/foreman_ovirt/display.js +10 -0
  6. data/app/assets/javascripts/foreman_ovirt/host_edit.js +61 -0
  7. data/app/assets/javascripts/foreman_ovirt/nic_info.js +3 -0
  8. data/app/assets/javascripts/foreman_ovirt/ovirt.js +261 -0
  9. data/app/controllers/concerns/foreman_ovirt/compute_resources_vms_controller.rb +29 -0
  10. data/app/controllers/concerns/foreman_ovirt/parameters_extension.rb +35 -0
  11. data/app/controllers/foreman_ovirt/concerns/compute_resources_controller_extensions.rb +60 -0
  12. data/app/helpers/ovirt_compute_resource_helper.rb +26 -0
  13. data/app/models/concerns/fog_extensions/ovirt/server.rb +42 -0
  14. data/app/models/concerns/fog_extensions/ovirt/template.rb +14 -0
  15. data/app/models/concerns/fog_extensions/ovirt/volume.rb +11 -0
  16. data/app/models/foreman_ovirt/ovirt.rb +752 -0
  17. data/app/views/api/v2/compute_resources/ovirt.json.rabl +1 -0
  18. data/app/views/compute_resources/form/_ovirt.html.erb +14 -0
  19. data/app/views/compute_resources/show/_ovirt.html.erb +16 -0
  20. data/app/views/compute_resources_vms/form/ovirt/_base.html.erb +83 -0
  21. data/app/views/compute_resources_vms/form/ovirt/_network.html.erb +32 -0
  22. data/app/views/compute_resources_vms/form/ovirt/_volume.html.erb +16 -0
  23. data/app/views/compute_resources_vms/index/_ovirt.html.erb +12 -0
  24. data/app/views/compute_resources_vms/index/_ovirt_json.erb +6 -0
  25. data/app/views/compute_resources_vms/show/_ovirt.html.erb +55 -0
  26. data/app/views/images/form/_ovirt.html.erb +4 -0
  27. data/config/routes.rb +8 -13
  28. data/db/migrate/20250810212811_update_legacy_ovirt_compute_resource_type.rb +21 -0
  29. data/lib/foreman_ovirt/engine.rb +70 -0
  30. data/lib/foreman_ovirt/version.rb +3 -0
  31. data/lib/foreman_ovirt.rb +2 -1
  32. data/lib/tasks/foreman_ovirt_tasks.rake +30 -0
  33. data/locale/Makefile +73 -0
  34. data/locale/en/foreman_ovirt.po +19 -0
  35. data/locale/foreman_ovirt.pot +19 -0
  36. data/locale/gemspec.rb +2 -0
  37. data/package.json +39 -0
  38. data/test/factories/foreman_ovirt_factories.rb +5 -0
  39. data/test/test_plugin_helper.rb +6 -0
  40. data/test/unit/foreman_ovirt_test.rb +11 -0
  41. data/webpack/components/extensions/HostDetails/DetailsTabCards/OvirtCard.js +132 -0
  42. data/webpack/components/ovirt.js +20 -0
  43. data/webpack/global_index.js +14 -0
  44. data/webpack/global_test_setup.js +11 -0
  45. data/webpack/index.js +1 -0
  46. data/webpack/test_setup.js +17 -0
  47. metadata +157 -128
  48. data/.document +0 -5
  49. data/Gemfile +0 -14
  50. data/Gemfile.lock +0 -33
  51. data/README.rdoc +0 -20
  52. data/VERSION +0 -1
  53. data/app/controllers/foreman_ovirt/auth_source_ovirts_controller.rb +0 -57
  54. data/app/controllers/foreman_ovirt/dashboard_controller.rb +0 -10
  55. data/app/controllers/foreman_ovirt/hosts_controller.rb +0 -17
  56. data/app/models/foreman_ovirt/auth_source_ovirt.rb +0 -78
  57. data/app/models/foreman_ovirt/user_extensions.rb +0 -26
  58. data/app/views/foreman_ovirt/auth_source_ovirts/_form.html.erb +0 -17
  59. data/app/views/foreman_ovirt/auth_source_ovirts/edit.html.erb +0 -3
  60. data/app/views/foreman_ovirt/auth_source_ovirts/index.html.erb +0 -22
  61. data/app/views/foreman_ovirt/auth_source_ovirts/new.html.erb +0 -3
  62. data/app/views/foreman_ovirt/auth_source_ovirts/welcome.html.erb +0 -8
  63. data/app/views/foreman_ovirt/hosts/_overview.html.erb +0 -27
  64. data/app/views/foreman_ovirt/hosts/show.html.erb +0 -48
  65. data/app/views/foreman_ovirt/hosts/show_graphs.html.erb +0 -13
  66. data/app/views/layouts/application_ovirt.html.erb +0 -36
  67. data/config/initializers/ovirt_setup.rb +0 -30
  68. data/foreman_ovirt.gemspec +0 -74
  69. data/lib/engine.rb +0 -9
@@ -0,0 +1 @@
1
+ attributes :user, :datacenter, :use_v4, :ovirt_quota, :display_type, :keyboard_layout
@@ -0,0 +1,14 @@
1
+
2
+ <%= text_f f, :url, :size => "col-md-8", :help_block => _("e.g. https://ovirt.example.com/ovirt-engine/api") %>
3
+ <%= text_f f, :user, :help_block => _("e.g. admin@internal") %>
4
+ <%= password_f f, :password, :keep_value => true, :unset => unset_password? %>
5
+ <% datacenters = (f.object.uuid.nil? && controller.action_name != 'test_connection') ? [] : f.object.datacenters rescue []%>
6
+ <%= selectable_f(f, :uuid, datacenters, {}, {:label => _('Datacenter'),
7
+ :onchange => 'datacenterSelected();',
8
+ :help_inline_permanent => load_datacenters_button_f(f, !datacenters.empty?) }) %>
9
+ <% quotas = (f.object.uuid.nil? && controller.action_name != 'test_connection') ? [] : f.object.quotas.all rescue []%>
10
+ <%= select_f f, :ovirt_quota, quotas, :id, :name, {}, :label => _("Quota ID") %>
11
+ <%= select_f f, :display_type, f.object.display_types, :to_s , :upcase, { }, :label => _("Default Display Type") %>
12
+ <%= select_f f, :keyboard_layout, f.object.keyboard_layouts,:downcase, :to_s, { }, :label => _("Default VNC Keyboard") %>
13
+ <%= textarea_f f, :public_key, :label => _("X509 Certification Authorities"), :size => "col-md-8",
14
+ :placeholder => _("Optionally provide a CA, or a correctly ordered CA chain. If left blank, a self-signed CA will be populated automatically by the server during the first request.") %>
@@ -0,0 +1,16 @@
1
+ <tr>
2
+ <td><%= _("URL") %></td>
3
+ <td><%= @compute_resource.url %></td>
4
+ </tr>
5
+ <tr>
6
+ <td><%= _("Operating systems API supported?") %></td>
7
+ <td><%= @compute_resource.supports_operating_systems? ? icon_text("ok", "", :kind => "pficon") : icon_text("error-circle-o", "", :kind => "pficon") %></td>
8
+ </tr>
9
+ <tr>
10
+ <td><%= _("Default Display Type") %></td>
11
+ <td><%= @compute_resource.display_type.upcase %></td>
12
+ </tr>
13
+ <tr>
14
+ <td><%= _("Default VNC Keyboard") %></td>
15
+ <td><%= @compute_resource.keyboard_layout %></td>
16
+ </tr>
@@ -0,0 +1,83 @@
1
+
2
+ <%= text_f f, :name, :label => _('Name'), :label_size => "col-md-3" if show_vm_name? %>
3
+ <% clusters = compute_resource.clusters %>
4
+ <%= select_f f, :cluster, clusters, :id, :name, { },
5
+ { :disabled => !new_vm, :'data-url' => cluster_selected_compute_resource_path(compute_resource),
6
+ :onchange => 'clusterSelected(this);',
7
+ :help_inline => :indicator,
8
+ :label => _('Cluster'), :label_size => "col-md-2" } %>
9
+ <%= f.hidden_field :cluster if !new_vm %>
10
+
11
+ <%= select_f f, :vm_template, compute_resource.templates, :id, :full_name, {:include_blank => _("Blank template")},
12
+ { :disabled => !new_vm, :'data-url' => template_selected_compute_resource_path(compute_resource),
13
+ :onchange => 'templateSelected(this);',
14
+ :help_inline => :indicator,
15
+ :help_block => _("oVirt template to use"),
16
+ :label => _('Template'), :label_size => "col-md-2" } %>
17
+ <%= f.hidden_field :template if !new_vm %>
18
+
19
+ <%= select_f f, :instance_type, compute_resource.instance_types, :id, :name, {:include_blank => _("Custom instance type")},
20
+ { :disabled => !new_vm, :'data-url' => instance_type_selected_compute_resource_path(compute_resource),
21
+ :onchange => 'instanceTypeSelected(this);',
22
+ :help_inline => :indicator,
23
+ :help_block => _("oVirt instance type. Provided memory, sockets and cores values will be overriden by instance types values"),
24
+ :label => _('Instance type'), :label_size => "col-md-2" } %>
25
+ <%= f.hidden_field :instance_type if !new_vm %>
26
+
27
+ <%
28
+ if params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:instance_type]
29
+ instance_type = compute_resource.instance_type(params[:host][:compute_attributes][:instance_type])
30
+ end
31
+ disable_cores = !new_vm || (new_vm && instance_type && instance_type.cores.present?)
32
+ disable_sockets = !new_vm || (new_vm && instance_type && instance_type.sockets.present?)
33
+ disable_mem = !new_vm || (new_vm && instance_type && instance_type.memory.present?)
34
+ %>
35
+
36
+ <div id="cores-input">
37
+ <%= counter_f(f, :cores, label: _('Cores per socket'), value: f.object.cores.to_i, disabled: disable_cores) %>
38
+ </div>
39
+ <div id="sockets-input">
40
+ <%= counter_f(f, :sockets, label: _('Sockets'), value: f.object.sockets.to_i, disabled: disable_sockets) %>
41
+ </div>
42
+ <div id="memory-input">
43
+ <%= byte_size_f(f, :memory, label: _('Memory'), value: f.object.memory.to_i, disabled: disable_mem) %>
44
+ </div>
45
+
46
+ <% checked = params[:host] && params[:host][:compute_attributes] && params[:host][:compute_attributes][:start] || '1' %>
47
+ <%= checkbox_f f, :ha, { :checked => (f.object.ha == '1') , :label => _('Highly Available'), :label_size => "col-md-2" } %>
48
+ <%= checkbox_f f, :start, { :checked => (checked == '1'), :help_inline => _("Power ON this machine"), :label => _('Start'), :label_size => "col-md-2" } if new_vm && controller_name != "compute_attributes" %>
49
+
50
+ <%= f.fields_for :display, OpenStruct.new(f.object.display) do |display_f| %>
51
+ <%= select_f display_f, :type, compute_resource.display_types, :downcase, :upcase,
52
+ { },
53
+ { :label_size => "col-md-2",
54
+ :label => _("Display Type"),
55
+ :class => 'display_type',
56
+ :disabled => f.object.status != "down" && !new_vm } %>
57
+ <%= select_f display_f, :keyboard_layout, compute_resource.keyboard_layouts, :downcase, :to_s,
58
+ { },
59
+ { :label_size => "col-md-2",
60
+ :label => _("Keyboard"),
61
+ :class => 'keyboard_layout',
62
+ :disabled => f.object.status != "down" && !new_vm } %>
63
+ <% end %>
64
+
65
+ <% if host %>
66
+ <%
67
+ arch ||= nil ; os ||= nil
68
+ images = possible_images(compute_resource, arch, os)
69
+ -%>
70
+
71
+ <div id='image_selection'>
72
+ <%= select_f f, :image_id, images, :uuid, :name,{:include_blank => (images.empty? || images.size == 1) ? false : _('Please select an image')},
73
+ { :disabled => true, :'data-url' => template_selected_compute_resource_path(compute_resource),
74
+ :onchange => 'templateSelected(this);',
75
+ :help_inline => :indicator,
76
+ :help_block => _("Image to use"),
77
+ :label => _('Image'), :label_size => "col-md-2"} %>
78
+ </div>
79
+ <% end %>
80
+
81
+ <%= javascript_include_tag 'foreman_ovirt/ovirt', "data-turbolinks-track" => true %>
82
+ <%= javascript_include_tag 'foreman_ovirt/nic_info', "data-turbolinks-track" => true %>
83
+ <%= javascript_include_tag 'foreman_ovirt/display', "data-turbolinks-track" => true %>
@@ -0,0 +1,32 @@
1
+ <%= text_f f, :name,
2
+ :class => "ovirt_name",
3
+ :size => "col-md-8", :disabled => !new_vm,
4
+ :label => _('Name'), :label_size => "col-md-3" %>
5
+
6
+ <% selected_cluster ||= params.fetch(:host, {}).fetch(:compute_attributes, {}).fetch(:cluster, nil) %>
7
+ <% selected_cluster ||= compute_resource.clusters.first.try(:id) %>
8
+ <% vnic_profiles = compute_resource.vnic_profiles %>
9
+ <% networks = compute_resource.networks(selected_cluster ? { :cluster_id => selected_cluster } : { }) %>
10
+ <%= select_f f, :vnic_profile, vnic_profiles,
11
+ :id, :name, {},
12
+ :class => "ovirt_network",
13
+ :size => "col-md-8", :disabled => !new_vm,
14
+ :label => _('Vnic Profile'), :label_size => "col-md-3",
15
+ :onchange => 'vnicSelected(this)',
16
+ :data => {
17
+ :profiles => JSON.generate(vnic_profiles.map do |p|
18
+ { id: p.id, name: p.name, network: p.network ? { id: p.network.id, name: p.network.name } : nil }
19
+ end),
20
+ :networks => JSON.generate(networks.map { |n| { id: n.id, name: n.name } })
21
+ } %>
22
+ <%= select_f f, :network, networks,
23
+ :id, :name, {},
24
+ :class => "ovirt_network",
25
+ :size => "col-md-8", :disabled => !new_vm,
26
+ :label => _('Network'), :label_size => "col-md-3" %>
27
+
28
+ <%= select_f f, :interface, compute_resource.nictypes,
29
+ :id, :name, {},
30
+ :class => "ovirt_network",
31
+ :size => "col-md-8", :disabled => !new_vm,
32
+ :label => _('Interface type'), :label_size => "col-md-3" %>
@@ -0,0 +1,16 @@
1
+
2
+ <%= text_f f,:size_gb, :label => _('Size (GB)'), :label_size => "col-md-2", :disabled => !new_vm, :class => "col-md-2" %>
3
+ <%= f.hidden_field :size_gb if !new_vm %>
4
+ <%= select_f f, :storage_domain, ovirt_storage_domains_for_select(compute_resource), :id, :label,
5
+ { }, :label => _('Storage domain'), :label_size => "col-md-2", :disabled => !new_vm, :class => "col-md-2" %>
6
+ <%= f.hidden_field :storage_domain if !new_vm %>
7
+ <%= f.hidden_field :id %>
8
+ <%= checkbox_f f, :preallocate, {:disabled => !new_vm, :checked => f.object.sparse == 'false', :help_inline => _('Uses thin provisioning if unchecked'), :label => _('Preallocate disk'), :label_size => "col-md-2" } %>
9
+ <%= checkbox_f f, :wipe_after_delete, {:disabled => !new_vm, :checked => f.object.wipe_after_delete == 'true', :label => _('Wipe disk after delete'), :label_size => "col-md-2" } %>
10
+ <%= select_f f, :interface, [OpenStruct.new({:id =>'virtio_scsi', :name =>'VirtIO SCSI'}), OpenStruct.new({:id =>'virtio', :name =>'VirtIO'}), OpenStruct.new({:id =>'ide', :name =>'IDE'})],
11
+ :id, :name, { }, :label => _('Disk interface'), :label_size => "col-md-2", :disabled => !new_vm, :class => "col-md-2" %>
12
+ <%= f.hidden_field :interface if !new_vm %>
13
+ <%= field(f, :bootable, :label => _('Bootable'), :label_size => "col-md-2") do
14
+ radio_button_f f, :bootable, {:disabled => !new_vm, :value=> 'true', :checked => f.object.bootable == 'true', :onclick => 'bootableRadio(this)',
15
+ :text => _('Only one volume can be bootable')}
16
+ end %>
@@ -0,0 +1,12 @@
1
+ <thead>
2
+ <tr>
3
+ <th><%= _('Name') %></th>
4
+ <th><%= _('CPUs') %></th>
5
+ <th><%= _('Memory') %></th>
6
+ <th><%= _('Power') %></th>
7
+ <th><%= _('Actions') %></th>
8
+ </tr>
9
+ </thead>
10
+ <tbody>
11
+
12
+ </tbody>
@@ -0,0 +1,6 @@
1
+ {
2
+ "draw": <%= params['draw'].to_i || '1' %>,
3
+ "recordsTotal": <%= ovirt_fake_vms_count %>,
4
+ "recordsFiltered": <%= ovirt_fake_vms_count %>,
5
+ "data": <%= ovirt_vms_data %>
6
+ }
@@ -0,0 +1,55 @@
1
+ <% title @vm.name %>
2
+
3
+ <div class='col-md-12'>
4
+ <table class="<%= table_css_classes %>">
5
+ <thead>
6
+ <tr><th colspan="2"><%=_('Properties') %></th></tr>
7
+ </thead>
8
+ <tbody>
9
+ <tr>
10
+ <td><%= _('Name') %></td>
11
+ <td><%= @vm.name %></td>
12
+ </tr>
13
+ <tr>
14
+ <td><%= _('VCPU(s)') %></td>
15
+ <td><%= @vm.cores %></td>
16
+ </tr>
17
+ <tr>
18
+ <td><%= _('UUID') %></td>
19
+ <td><%= @vm.identity %></td>
20
+ </tr>
21
+ <tr>
22
+ <td><%= _('Memory') %></td>
23
+ <td><%= number_to_human_size @vm.memory %>
24
+ </td>
25
+ </tr>
26
+ <tr>
27
+ <td><%= _('Display') %></td>
28
+ <td><%= @vm.display[:type] %>
29
+ (<%= @vm.display[:port] %>)</td>
30
+ </tr>
31
+ <% if @vm.display[:type] == 'vnc' %>
32
+ <tr>
33
+ <td><%= _('Keyboard') %></td>
34
+ <td><%= @vm.display[:keyboard_layout] %></td>
35
+ </tr>
36
+ <% end %>
37
+ <% @vm.interfaces.each do |nic| %>
38
+ <tr>
39
+ <td><%= _('NIC') %></td>
40
+ <td><%= "#{nic.name} - #{nic.mac}" %></td>
41
+ </tr>
42
+ <% end %>
43
+ <% @vm.volumes.each do |vol| %>
44
+ <tr>
45
+ <td><%= _('Disk') %></td>
46
+ <td><%= _("using %s") % number_to_human_size(vol.size) %></td>
47
+ </tr>
48
+ <% end %>
49
+ <tr>
50
+ <td><%= _('Running on') %></td>
51
+ <td><%= link_to @compute_resource, compute_resource_path(@compute_resource) %></td>
52
+ </tr>
53
+ </tbody>
54
+ </table>
55
+ </div>
@@ -0,0 +1,4 @@
1
+ <%= text_f f, :username, :value => @image.username || "root", :help_inline => _("The user that is used to ssh into the instance, normally cloud-user, ec2-user, ubuntu, root etc") %>
2
+ <%= checkbox_f f, :user_data, :help_inline => _("Does this image support user data input (e.g. via cloud-init)?") %>
3
+ <%= password_f f, :password, :help_inline => _("Password to authenticate with - used for SSH finish step.") %>
4
+ <%= image_field(f) %>
data/config/routes.rb CHANGED
@@ -1,16 +1,11 @@
1
1
  Rails.application.routes.draw do
2
-
3
- constraints(:id => /[^\/]+/) do
4
- # Special show host for oVirt
5
- get "hosts/:id/ovirt" => "foreman_ovirt/hosts#show"
6
-
7
- # Special show host graphs for oVirt
8
- get "hosts/:id/graphs/ovirt" => "foreman_ovirt/hosts#show_graphs"
2
+ namespace :api, :defaults => { :format => 'json' } do
3
+ scope "(:apiv)", :module => :v2, :defaults => { :apiv => 'v2' }, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
4
+ constraints(:id => /[^\/]+/) do
5
+ resources :compute_resources, :except => [:new, :edit] do
6
+ get :available_vnic_profiles, :on => :member
7
+ end
8
+ end
9
+ end
9
10
  end
10
-
11
- # auth_source_ovirt resource
12
- resources :auth_source_ovirts, :controller => "foreman_ovirt/auth_source_ovirts"
13
-
14
- # Special dashboard for oVirt
15
- get "dashboard/ovirt" => "foreman_ovirt/dashboard#index"
16
11
  end
@@ -0,0 +1,21 @@
1
+ class UpdateLegacyOvirtComputeResourceType < ActiveRecord::Migration[7.0]
2
+ # Temporary model definition to ensure the migration is self-contained
3
+ # and independent of the application's model, which may change over time.
4
+ class ComputeResource < ActiveRecord::Base
5
+ self.table_name = :compute_resources
6
+ # Disable STI to allow direct manipulation of the 'type' column.
7
+ self.inheritance_column = :_type_disabled
8
+ end
9
+
10
+ # Migrate the legacy class name to the new plugin class name.
11
+ def up
12
+ say "Updating legacy oVirt compute resource types to ForemanOvirt::Ovirt"
13
+ ComputeResource.where(type: 'Foreman::Model::Ovirt').update_all(type: 'ForemanOvirt::Ovirt')
14
+ end
15
+
16
+ # Revert the class name back to the legacy value.
17
+ def down
18
+ say "Reverting oVirt compute resource types back to legacy Foreman::Model::Ovirt"
19
+ ComputeResource.where(type: 'ForemanOvirt::Ovirt').update_all(type: 'Foreman::Model::Ovirt')
20
+ end
21
+ end
@@ -0,0 +1,70 @@
1
+ module ForemanOvirt
2
+ class Engine < ::Rails::Engine
3
+ engine_name 'foreman_ovirt'
4
+
5
+ initializer 'foreman_ovirt.load_app_instance_data' do |app|
6
+ ForemanOvirt::Engine.paths['db/migrate'].existent.each do |path|
7
+ app.config.paths['db/migrate'] << path
8
+ end
9
+ end
10
+
11
+ initializer 'foreman_ovirt.register_plugin', :before => :finisher_hook do |app|
12
+ app.reloader.to_prepare do
13
+ Foreman::Plugin.register :foreman_ovirt do
14
+ requires_foreman '>= 3.16'
15
+ compute_resource ForemanOvirt::Ovirt
16
+ register_gettext
17
+
18
+ register_global_js_file 'global'
19
+
20
+ security_block :foreman_ovirt do
21
+ permission :view_compute_resources, { :'foreman_ovirt/compute_resources' =>
22
+ [:available_vnic_profiles] }
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ # Precompile any JS or CSS files under app/assets/
29
+ # If requiring files from each other, list them explicitly here to avoid precompiling the same
30
+ # content twice.
31
+ assets_to_precompile =
32
+ Dir.chdir(root) do
33
+ Dir['app/assets/javascripts/foreman_ovirt/**/*',
34
+ 'app/assets/stylesheets/foreman_ovirt/**/*'].map do |f|
35
+ f.split(File::SEPARATOR, 4).last
36
+ end
37
+ end
38
+ initializer 'foreman_ovirt.assets.precompile' do |app|
39
+ app.config.assets.precompile += assets_to_precompile
40
+ end
41
+ initializer 'foreman_ovirt.configure_assets', group: :assets do
42
+ SETTINGS[:foreman_ovirt] = {
43
+ assets: {
44
+ precompile: assets_to_precompile,
45
+ },
46
+ }
47
+ end
48
+
49
+ config.to_prepare do
50
+ require 'fog/ovirt'
51
+ require 'fog/ovirt/models/compute/server'
52
+ Fog::Ovirt::Compute::Server.include FogExtensions::Ovirt::Server
53
+ require 'fog/ovirt/models/compute/template'
54
+ Fog::Ovirt::Compute::Template.include FogExtensions::Ovirt::Template
55
+ require 'fog/ovirt/models/compute/volume'
56
+ Fog::Ovirt::Compute::Volume.include FogExtensions::Ovirt::Volume
57
+
58
+ ::ComputeResourcesVmsController.include ForemanOvirt::ComputeResourcesVmsController
59
+ ::ComputeResourcesController.include ForemanOvirt::ParametersExtension
60
+ rescue StandardError => e
61
+ Rails.logger.warn "ForemanOvirt: skipping engine hook (#{e})"
62
+ end
63
+
64
+ rake_tasks do
65
+ Rake::Task['db:seed'].enhance do
66
+ ForemanOvirt::Engine.load_seed
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanOvirt
2
+ VERSION = '2.0.0'.freeze
3
+ end
data/lib/foreman_ovirt.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'foreman_ovirt/engine'
2
+
1
3
  module ForemanOvirt
2
- require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
3
4
  end
@@ -0,0 +1,30 @@
1
+ # Ensure the task is only defined when the main app is loaded.
2
+ if defined?(Rails) && Rails.application
3
+ namespace :foreman_ovirt do
4
+ namespace :db do
5
+ desc "Prevents the destructive core oVirt data migration from being run by marking it as complete."
6
+ task :prevent_core_migration => :environment do
7
+ # The version of the Foreman core migration to skip.
8
+ version_to_skip = 20250414121956
9
+ migration_context = ActiveRecord::Base.connection.migration_context
10
+
11
+ all_migrations = migration_context.migrations.map(&:version)
12
+ run_migrations = migration_context.get_all_versions
13
+
14
+ # A migration needs to be run if it exists on disk but is not yet marked as run in the database.
15
+ if all_migrations.include?(version_to_skip) && !run_migrations.include?(version_to_skip)
16
+ Rails.logger.info "[foreman_ovirt] Marking core migration #{version_to_skip} (MigrateOvirtResources) as complete to prevent data loss."
17
+ ActiveRecord::SchemaMigration.create!(version: version_to_skip.to_s)
18
+ Rails.logger.info "[foreman_ovirt] Core migration successfully skipped."
19
+ else
20
+ Rails.logger.debug "[foreman_ovirt] Core migration #{version_to_skip} does not need to be skipped (already migrated or not found)."
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ # Enhance the core db:migrate task to run our prevention task first.
27
+ if Rake::Task.task_defined?('db:migrate')
28
+ Rake::Task['db:migrate'].enhance(['foreman_ovirt:db:prevent_core_migration'])
29
+ end
30
+ end
data/locale/Makefile ADDED
@@ -0,0 +1,73 @@
1
+ #
2
+ # Makefile for PO merging and MO generation. More info in the README.
3
+ #
4
+ # make all-mo (default) - generate MO files
5
+ # make check - check translations using translate-tool
6
+ # make tx-update - download and merge translations from Transifex
7
+ # make clean - clean everything
8
+ #
9
+ DOMAIN = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).name')
10
+ VERSION = $(shell ruby -rrubygems -e 'puts Gem::Specification::load(Dir.glob("../*.gemspec")[0]).version')
11
+ POTFILE = $(DOMAIN).pot
12
+ MOFILE = $(DOMAIN).mo
13
+ POFILES = $(shell find . -name '$(DOMAIN).po')
14
+ MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
+ POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16
+ EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
17
+ JSFILES = $(shell find ../app/assets/javascripts/*/locale -name '$(DOMAIN).js')
18
+
19
+ %.mo: %.po
20
+ mkdir -p $(shell dirname $@)/LC_MESSAGES
21
+ msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
22
+
23
+ # Generate MO files from PO files
24
+ all-mo: $(MOFILES)
25
+
26
+ # Check for malformed strings
27
+ %.pox: %.po
28
+ msgfmt -c $<
29
+ pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
30
+ -t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
31
+ cat $@
32
+ ! grep -q msgid $@
33
+
34
+ %.edit.po: %.po.time_stamp
35
+ touch $@
36
+
37
+ # gettext will trash the .edit.po file if the time stamp doesn't exist or is older than the po file
38
+ %.po.time_stamp: %.po
39
+ touch --reference $< $@
40
+
41
+ # Prevent make from treating this as an intermediate file to be cleaned up
42
+ .PRECIOUS: %.po.time_stamp
43
+
44
+ check: $(POXFILES)
45
+
46
+ # Unify duplicate translations
47
+ uniq-po:
48
+ for f in $(shell find ./ -name "*.po") ; do \
49
+ msguniq $$f -o $$f ; \
50
+ done
51
+
52
+ tx-pull: $(EDITFILES)
53
+ # Initialize new languages
54
+ cd .. && tx pull -f --all --minimum-perc 50
55
+ # Force update all existing languages
56
+ cd .. && tx pull -f --minimum-perc 0
57
+ for f in $(EDITFILES) ; do \
58
+ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
59
+ done
60
+
61
+ tx-update: tx-pull
62
+ @echo
63
+ @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation
64
+ @echo then run rake plugin:po_to_json[$(DOMAIN)] from the Foreman installation
65
+ @echo then run make -C locale mo-files to finish
66
+ @echo
67
+
68
+ mo-files: $(MOFILES)
69
+ git add $(POFILES) $(POTFILE) $(JSFILES) ../locale/*/LC_MESSAGES
70
+ git commit -m "i18n - pulling from tx"
71
+ @echo
72
+ @echo Changes commited!
73
+ @echo
@@ -0,0 +1,19 @@
1
+ # foreman_ovirt
2
+ #
3
+ # This file is distributed under the same license as foreman_ovirt.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: version 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-20 08:46+0100\n"
11
+ "PO-Revision-Date: 2014-08-20 08:54+0100\n"
12
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
13
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language: \n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+
@@ -0,0 +1,19 @@
1
+ # foreman_ovirt
2
+ #
3
+ # This file is distributed under the same license as foreman_ovirt.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: version 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-20 08:46+0100\n"
11
+ "PO-Revision-Date: 2014-08-20 08:46+0100\n"
12
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
13
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language: \n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
+
data/locale/gemspec.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Matches foreman_ovirt.gemspec
2
+ _('ForemanOvirt plugin adds oVirt compute resource to Foreman using fog-ovirt.')
data/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "foreman_ovirt",
3
+ "version": "1.0.0",
4
+ "description": "DESCRIPTION",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "lint": "tfm-lint --plugin -d /webpack",
8
+ "test": "tfm-test --config jest.config.js",
9
+ "test:watch": "tfm-test --plugin --watchAll",
10
+ "test:current": "tfm-test --plugin --watch",
11
+ "publish-coverage": "tfm-publish-coverage",
12
+ "create-react-component": "yo react-domain"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/markt-de/foreman_ovirt.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/markt-de/foreman_ovirt/issues"
20
+ },
21
+ "peerDependencies": {
22
+ "@theforeman/vendor": ">= 15.0.0"
23
+ },
24
+ "dependencies": {
25
+ "react-intl": "^2.8.0"
26
+ },
27
+ "devDependencies": {
28
+ "@babel/core": "^7.7.0",
29
+ "@theforeman/builder": ">= 15.0.1",
30
+ "@theforeman/eslint-plugin-foreman": ">= 15.0.1",
31
+ "@theforeman/find-foreman": ">= 15.0.1",
32
+ "@theforeman/test": ">= 15.0.1",
33
+ "@theforeman/vendor-dev": ">= 15.0.1",
34
+ "babel-eslint": "^10.0.3",
35
+ "eslint": "^6.7.2",
36
+ "prettier": "^1.19.1",
37
+ "react-redux-test-utils": "^0.2.0"
38
+ }
39
+ }
@@ -0,0 +1,5 @@
1
+ FactoryBot.define do
2
+ factory :host do
3
+ name 'foreman_ovirt'
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ # This calls the main test_helper in Foreman-core
2
+ require 'test_helper'
3
+
4
+ # Add plugin to FactoryBot's paths
5
+ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories')
6
+ FactoryBot.reload
@@ -0,0 +1,11 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class ForemanOvirtTest < ActiveSupport::TestCase
4
+ setup do
5
+ User.current = User.find_by_login 'admin'
6
+ end
7
+
8
+ test 'the truth' do
9
+ assert true
10
+ end
11
+ end