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
@@ -1,17 +0,0 @@
1
- module ForemanOvirt
2
- class HostsController < ::HostsController
3
-
4
- skip_before_filter :verify_authenticity_token
5
- layout 'layouts/application_ovirt'
6
-
7
- def show
8
- super
9
- end
10
-
11
- def show_graphs
12
- @host = ::Host.find_by_name(params[:id])
13
- show
14
- end
15
-
16
- end
17
- end
@@ -1,78 +0,0 @@
1
- module ForemanOvirt
2
- class AuthSourceOvirt < AuthSource
3
- validates_presence_of :host, :port
4
- validates_length_of :host, :port, :maximum => 60, :allow_nil => false
5
- validates_numericality_of :port, :only_integer => true
6
-
7
- def authenticate(login, password)
8
-
9
- # oVirt passes the username with "ovirt_" prefix. We remove it in this function.
10
- # The login name in Foreman will include the "ovirt_" prefix, but all the other user details won't
11
- # The reason for this prefix is that the login source of this user will always be the oVirt Authentication source
12
- login = login.sub("ovirt_","")
13
-
14
- userDetails = get_user_details(login, password)
15
-
16
- return nil unless !userDetails.nil?
17
-
18
- # In case a field is empty, we put the login as the value
19
- # The oVirt login must be in the form of user@domain, so it is also valid as
20
- # E-mail value
21
- attrs = {:firstname => userDetails.has_key?('name') ? userDetails['name'] : login.split("@")[0],
22
- :lastname => userDetails['surname'],
23
- :mail => userDetails.has_key?('email') ? userDetails['email'] : login,
24
- :auth_source_id => self.id }
25
- attrs
26
- end
27
-
28
- def auth_method_name
29
- "OVIRT"
30
- end
31
- alias_method :to_label, :auth_method_name
32
-
33
- def can_set_password?
34
- false
35
- end
36
-
37
- private
38
-
39
- def get_user_details(login, password)
40
- response = get_user_from_ovirt(login, password)
41
- userDetails = !response.nil? ? JSON.parse(response) : nil
42
- userDetails
43
- end
44
-
45
- def get_user_from_ovirt(login, password)
46
- logger.debug "oVirt-Auth with User " + login
47
- logger.debug "oVirt host name is " + host
48
- logger.debug "oVirt port number is " + port.to_s()
49
-
50
- prefix = tls ? 'https' : 'http'
51
- url=prefix + '://' + host + ':' + port.to_s()
52
-
53
- logger.debug "oVirt URL is " + url
54
-
55
- # password contains the oVirt engine session ID followed by the
56
- # guid of the user
57
- user_id_location = password.rindex(';')
58
- user_id = password[user_id_location + 1 .. password.length()]
59
- session_id = password[0 .. user_id_location - 1]
60
-
61
- session_id_escaped = Rack::Utils.escape(session_id)
62
-
63
- # The password we get is the REST session ID
64
- # We set it in the cookie, using the "Prefer" header
65
- # to keep the session alive
66
- session_id = ({ :JSESSIONID => session_id_escaped })
67
- headers = ({ :content_type => 'application/json',
68
- :accept => 'application/json',
69
- :Prefer => "persistent-auth",
70
- :cookies => ( session_id )
71
- })
72
-
73
- # We query for the user, to get its details
74
- response = RestClient::Resource.new(url)['/api/users/' + user_id].get(headers)
75
- response
76
- end
77
- end
78
- end
@@ -1,26 +0,0 @@
1
- module ForemanOvirt
2
- module UserExtensions
3
- extend ActiveSupport::Concern
4
- included do
5
- after_save :add_role_to_user
6
- end
7
-
8
- module InstanceMethods
9
- def add_role_to_user
10
- logger.debug "add_role_to_user started"
11
- user_auth_source = AuthSource.find(auth_source)
12
- logger.debug "auth source is: " + user_auth_source.type
13
- if (user_auth_source && user_auth_source.type == "ForemanOvirt::AuthSourceOvirt")
14
- # Checking auth_source is oVirt
15
- ovirt_role_id = Role.find_by_name("Ovirt").id
16
- if (!user_roles.find_by_role_id(ovirt_role_id))
17
- logger.debug "adding oVirt role to user " + name
18
- user_roles.create(:role_id => ovirt_role_id)
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
25
- # Add Ovirt role to ovirt user
26
- User.send :include, ForemanOvirt::UserExtensions
@@ -1,17 +0,0 @@
1
- <% title_actions link_to(icon_text("question-sign", "Documentation", :class => "icon-white"), "http://theforeman.org/projects/foreman/wiki/LDAP_Authentication", :rel => "external", :class => "btn-info") %>
2
-
3
- <%= form_for @auth_source_ovirt, :url => auth_source_ovirts_path do |f| %>
4
- <%= base_errors_for @auth_source_ovirt %>
5
-
6
- <%= text_f f, :name %>
7
- <%= text_f f, :host %>
8
- <%= text_f f, :port %>
9
- <%= checkbox_f f, :tls, :label => "HTTPS", :checked => true %>
10
- <%#= text_f f, :account, :help_inline =>"Use this account to authenticate,<i>optional</i>".html_safe %>
11
- <%#= password_f f, :account_password, :onfocus => "this.value='';", :help_inline => "Use this account to authenticate, <i>optional</i>".html_safe %>
12
- <%#= text_f f, :base_dn, :label => "basedn", :class => "input-xxlarge" %>
13
- <%= checkbox_f f, :onthefly_register, :label => "On-the-fly user creation",
14
- :help_inline => "oVirt user will have his Foreman account automatically created the first time he logs into Foreman", :checked => true %>
15
-
16
- <%= submit_or_cancel f %>
17
- <% end %>
@@ -1,3 +0,0 @@
1
- <% title "Edit Auth Source oVirt" %>
2
-
3
- <%= render :partial => 'form' %>
@@ -1,22 +0,0 @@
1
- <% title "oVirt Authentication" %>
2
-
3
- <% title_actions link_to("New oVirt Authentication Source", new_auth_source_ovirt_path) %>
4
-
5
- <table class="table table-bordered table-striped">
6
- <tr>
7
- <th>Name</th>
8
- <th>Host</th>
9
- <th>On the fly Register</th>
10
- <th>HTTPS</th>
11
- <th></th>
12
- </tr>
13
- <% for auth_source_ovirt in @auth_source_ovirts %>
14
- <tr>
15
- <td><%=h auth_source_ovirt.name %></td>
16
- <td><%=h auth_source_ovirt.host %></td>
17
- <td><%=checked_icon auth_source_ovirt.onthefly_register %></td>
18
- <td><%=checked_icon auth_source_ovirt.tls %></td>
19
- <td><%=link_to ("Delete", auth_source_ovirt_path(auth_source_ovirt.id), :method => :delete, :confirm => "Delete #{auth_source_ovirt.name}?") %></td>
20
- </tr>
21
- <% end %>
22
- </table>
@@ -1,3 +0,0 @@
1
- <% title "New Auth Source oVirt" %>
2
-
3
- <%= render :partial => 'form' %>
@@ -1,8 +0,0 @@
1
- <% title_actions link_to("New authentication source", new_auth_source_ovirt) %>
2
- <% title "Authentication source configuration" %>
3
- <div id="welcome">
4
- <p> Foreman can use oVirt based service for user information and authentication.<p>
5
-
6
- <p> The authentication process currently requires an oVirt engine.</p>
7
- </div>
8
-
@@ -1,27 +0,0 @@
1
- <table class="table table-bordered table-striped">
2
- <%# CHANGED HERE %>
3
-
4
- <!-- <tr>
5
- <th>Details</th>
6
- </tr>
7
- <tr>
8
- <td>
9
- <%#= link_to_if_authorized("Audits", hash_for_host_audits_path(:host_id => @host), :title => "Host audit entries" , :class => 'btn btn-small') %>
10
- <%#= link_to_if_authorized("Facts", hash_for_host_facts_path(:host_id => @host), :title => "Browse host facts" , :class => 'btn btn-small') %>
11
- <%#= link_to_if_authorized("Reports", hash_for_host_reports_path(:host_id => @host), :title => "Browse host reports" , :class => 'btn btn-small') %>
12
- <%#= link_to("YAML", externalNodes_host_path(:name => @host), :title => "Puppet external nodes YAML dump" , :class => 'btn btn-small') %>
13
- </td>
14
- </tr> -->
15
- </table>
16
- <table class="table table-bordered table-striped">
17
- <tr>
18
- <th>Properties</th>
19
- <th></th>
20
- </tr>
21
- <% overview_fields(host).each do |name, value| -%>
22
- <tr>
23
- <td><%= name %></td>
24
- <td><%= value %></td>
25
- </tr>
26
- <% end -%>
27
- </table>
@@ -1,48 +0,0 @@
1
- <% javascript 'charts' %>
2
- <% title @host.to_label, icon(@host.os) + @host.to_label %>
3
-
4
- <% @vm = @host.compute_resource.find_vm_by_uuid(@host.uuid) rescue nil %>
5
- <%#= host_title_actions(@host, @vm) %>
6
- <% content_for(:search_bar) {reports_show} %>
7
-
8
- <div class="row-fluid">
9
- <div class="span4">
10
- <ul id="myTab" class="nav nav-tabs">
11
- <li class="active"><a href="#properties" data-toggle="tab">Properties</a></li>
12
- <li><a href="#metrics" data-toggle="tab">Metrics</a></li>
13
- <% if SETTINGS[:unattended] %>
14
- <li><a href="#template" data-toggle="tab">Templates</a></li>
15
- <% end %>
16
- <% if @vm %>
17
- <li><a href="#vm" data-toggle="tab">Virtual Machine</a></li>
18
- <% end %>
19
- </ul>
20
- <div id="myTabContent" class="tab-content">
21
- <div class="tab-pane active in" id="properties">
22
- <%# CHANGED HERE %>
23
- <%= render :partial => "foreman_ovirt/hosts/overview", :locals => { :host => @host } %>
24
- </div>
25
- <div class="tab-pane" id="metrics">
26
- <% if @report_summary.size == 0 -%>
27
- <p>No puppet activity for this host in the last <%= @range %> days</p>
28
- <% else -%>
29
- <%= render :partial => "hosts/metrics", :locals => { :report_summary => @report_summary[@host.name][:metrics] } %>
30
- <% end -%>
31
- </div>
32
- <div class="tab-pane" id="template">
33
- <%= show_templates -%>
34
- </div>
35
- <div class="tab-pane" id="vm">
36
- <% if @vm %>
37
- <% @compute_resource = @host.compute_resource %>
38
- <%= render("compute_resources_vms/show/#{@host.compute_resource.provider.downcase}") rescue nil %>
39
- <% end %>
40
- </div>
41
-
42
- </div>
43
- </div>
44
- <div class="span8">
45
- <%= runtime_chart 'runtime_graph', 'Runtime', "last #{@range} days", @host.runtime_chart(@range.days.ago) %>
46
- <%= report_status_chart 'resource_graph', 'Resources', "last #{@range} days", @host.resources_chart(@range.days.ago) %>
47
- </div>
48
- </div>
@@ -1,13 +0,0 @@
1
- <% javascript 'charts' %>
2
- <% title @host.to_label, icon(@host.os) + @host.to_label %>
3
-
4
- <% @vm = @host.compute_resource.find_vm_by_uuid(@host.uuid) rescue nil %>
5
- <%#= host_title_actions(@host, @vm) %>
6
- <% content_for(:search_bar) {reports_show} %>
7
-
8
- <div class="row-fluid">
9
- <div class="span8">
10
- <%= runtime_chart 'runtime_graph', 'Runtime', "last #{@range} days", @host.runtime_chart(@range.days.ago) %>
11
- <%= report_status_chart 'resource_graph', 'Resources', "last #{@range} days", @host.resources_chart(@range.days.ago) %>
12
- </div>
13
- </div>
@@ -1,36 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title> <%= h(yield(:title) || "Foreman") %></title>
5
- <%= stylesheet_link_tag 'jquery-ui', 'jquery.jnotify', 'bootstrap.min', 'style', 'bootstrap-responsive.min' %>
6
- <%#If we need ovirt.css, put it on foreman/public, and add it here= stylesheet_link_tag 'jquery-ui', 'jquery.jnotify', 'bootstrap.min', 'style', 'bootstrap-responsive.min', 'ovirt' %>
7
- <%= javascript_include_tag :defaults, 'jquery_ujs', 'jquery-ui', 'highcharts', 'charts', 'jquery.jnotify', 'jquery.jeditable',
8
- 'bootstrap.min' %>
9
- <%= csrf_meta_tag %>
10
- <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
11
- <meta name="apple-mobile-web-app-capable" content="yes">
12
- <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0;" />
13
- <%= yield(:head) %>
14
- </head>
15
-
16
- <body>
17
- <div id="wrap">
18
-
19
- <div id="main-ovirt">
20
- <%#= content_tag('div', flash[:error], :class => 'flash error') if flash[:error] -%>
21
- <%#= content_tag('div', flash[:warning], :class => 'flash warning') if flash[:warning] -%>
22
- <%#= content_tag('div', flash[:notice], :class => 'flash notice') if flash[:notice] -%>
23
- <%#= render 'common/notice' unless @notices.empty? -%>
24
- <div id="content" class="container">
25
- <div class="row">
26
- <div id="title_action" class="span0">
27
- <div class="btn-toolbar ra"><%=h yield(:title_actions) %></div>
28
- </div>
29
- </div>
30
-
31
- <%= yield %>
32
- </div>
33
- </div>
34
- </div>
35
- </body>
36
- </html>
@@ -1,30 +0,0 @@
1
- # Requiring the foreman_ovirt bundler group
2
- Bundler.require(:foreman_ovirt)
3
-
4
- # Add permissions
5
- Foreman::AccessControl.map do |map|
6
- map.security_block :ovirt do |map|
7
- map.permission :view_ovirt, { 'foreman_ovirt/hosts' => [:show, :show_graphs],
8
- 'foreman_ovirt/dashboard' => [:index] }
9
- end
10
- end
11
-
12
- # Add a new role called 'oVirt' if it doesn't exist
13
- Role.transaction do
14
- ovirt_role = Role.find_or_create_by_name("Ovirt")
15
- if ovirt_role.permissions.empty?
16
- ovirt_role.update_attribute :permissions, [:view_ovirt]
17
- end
18
- end
19
- #require 'foreman_ovirt/auth_source_ovirt'
20
- # Adding an oVirt authentication source for all the oVirt compute resources
21
- User.current = User.admin
22
- ForemanOvirt::AuthSourceOvirt.transaction do
23
- Foreman::Model::Ovirt.unscoped.all.each do |compute_resource|
24
- name = compute_resource.name
25
- next if ForemanOvirt::AuthSourceOvirt.find_by_name(name)
26
- url = URI(compute_resource.url)
27
- tls = url.scheme == "https" ? true : false
28
- ForemanOvirt::AuthSourceOvirt.create(:name => name, :host => url.host, :port => url.port, :onthefly_register => true, :tls => tls)
29
- end
30
- end
@@ -1,74 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = "foreman_ovirt"
8
- s.version = "0.3.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Oved Ourfali"]
12
- s.date = "2012-12-20"
13
- s.description = "Foreman oVirt plugin"
14
- s.email = "ovedo@redhat.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- "Gemfile",
22
- "Gemfile.lock",
23
- "LICENSE.txt",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "app/controllers/foreman_ovirt/auth_source_ovirts_controller.rb",
28
- "app/controllers/foreman_ovirt/dashboard_controller.rb",
29
- "app/controllers/foreman_ovirt/hosts_controller.rb",
30
- "app/models/foreman_ovirt/auth_source_ovirt.rb",
31
- "app/models/foreman_ovirt/user_extensions.rb",
32
- "app/views/foreman_ovirt/auth_source_ovirts/_form.html.erb",
33
- "app/views/foreman_ovirt/auth_source_ovirts/edit.html.erb",
34
- "app/views/foreman_ovirt/auth_source_ovirts/index.html.erb",
35
- "app/views/foreman_ovirt/auth_source_ovirts/new.html.erb",
36
- "app/views/foreman_ovirt/auth_source_ovirts/welcome.html.erb",
37
- "app/views/foreman_ovirt/hosts/_overview.html.erb",
38
- "app/views/foreman_ovirt/hosts/show.html.erb",
39
- "app/views/foreman_ovirt/hosts/show_graphs.html.erb",
40
- "app/views/layouts/application_ovirt.html.erb",
41
- "config/initializers/ovirt_setup.rb",
42
- "config/routes.rb",
43
- "foreman_ovirt.gemspec",
44
- "lib/engine.rb",
45
- "lib/foreman_ovirt.rb"
46
- ]
47
- s.homepage = "http://github.com/oourfali/foreman_ovirt"
48
- s.licenses = ["GPL-3"]
49
- s.require_paths = ["lib"]
50
- s.rubygems_version = "1.8.10"
51
- s.summary = "Plugin engine for Foreman-Ovirt integration"
52
-
53
- if s.respond_to? :specification_version then
54
- s.specification_version = 3
55
-
56
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
57
- s.add_development_dependency(%q<shoulda>, [">= 0"])
58
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
59
- s.add_development_dependency(%q<bundler>, ["~> 1.2.2"])
60
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
61
- else
62
- s.add_dependency(%q<shoulda>, [">= 0"])
63
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
64
- s.add_dependency(%q<bundler>, ["~> 1.2.2"])
65
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
66
- end
67
- else
68
- s.add_dependency(%q<shoulda>, [">= 0"])
69
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
70
- s.add_dependency(%q<bundler>, ["~> 1.2.2"])
71
- s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
72
- end
73
- end
74
-
data/lib/engine.rb DELETED
@@ -1,9 +0,0 @@
1
- module ForemanOvirt
2
- class Engine < ::Rails::Engine
3
-
4
- config.to_prepare do
5
- User.send :include, ForemanOvirt::UserExtensions
6
- end
7
- end
8
- end
9
-