diff --git a/app/controllers/katello/concerns/smart_proxies_controller_extensions.rb b/app/controllers/katello/concerns/smart_proxies_controller_extensions.rb deleted file mode 100644 index 2a1648af7ad..00000000000 --- a/app/controllers/katello/concerns/smart_proxies_controller_extensions.rb +++ /dev/null @@ -1,68 +0,0 @@ -module Katello - module Concerns - module SmartProxiesControllerExtensions - extend ActiveSupport::Concern - - module Overrides - def show - @task_search_url = main_app.foreman_tasks_tasks_path(:search => "resource_id = #{@smart_proxy.id} AND resource_type = #{@smart_proxy.class}") - render 'foreman/smart_proxies/show', :layout => 'katello/layouts/foreman_with_bastion' - end - - def action_permission - if params[:action] == 'pulp_status' || params[:action] == 'pulp_storage' - :view - else - super - end - end - end - - included do - prepend Overrides - helper 'bastion/layout' - - append_view_path('app/views/foreman') - before_action :find_resource_and_status, :only => [:pulp_storage, :pulp_status] - - def pulp_storage - @storage = @smart_proxy.pulp_disk_usage - respond_to do |format| - format.html { render :layout => false } - format.json { render :json => {:success => true, :message => @storage} } - end - rescue ::Foreman::WrappedException => e - Rails.logger.warn _('Error connecting. Got: %s') % e - respond_to do |format| - format.html { render :plain => _('Error retrieving Pulp storage') } - format.json { render :json => {:success => false, :message => e} } - end - end - - def pulp_status - pulp_connection = @proxy_status[:pulp] || @proxy_status[:pulpnode] - @pulp_status = pulp_connection.status - if @pulp_status['fatal'] - Rails.logger.warn @pulp_status['fatal'] - respond_to do |format| - format.html { render :plain => _('Error connecting to Pulp service') } - format.json { render :json => {:success => false, :message => @pulp_status['fatal']} } - end - else - respond_to do |format| - format.html { render :layout => false } - format.json { render :json => {:success => true, :message => @pulp_status} } - end - end - end - end - - private - - def find_resource_and_status - find_resource - find_status - end - end - end -end diff --git a/app/services/katello/proxy_status/pulp.rb b/app/services/katello/proxy_status/pulp.rb deleted file mode 100644 index da53eefa7dd..00000000000 --- a/app/services/katello/proxy_status/pulp.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'uri' - -module Katello - module ProxyStatus - class Pulp < ::ProxyStatus::Base - def storage - fetch_proxy_data do - api.pulp_storage - end - end - - def status - begin - body = RestClient.get(pulp_url) - rescue => e - return {'fatal' => _('Unable to connect. Got: %s') % e} - end - fail _("Pulp does not appear to be running.") if body.empty? - json = JSON.parse(body) - json['errors'] = {} - - if json['known_workers'].empty? - json['errors']['known_workers'] = _("No pulp workers running.") - end - - if json['database_connection'] && json['database_connection']['connected'] != true - json['errors']['database_connection'] = _("Pulp database connection issue.") - end - - if json['messaging_connection'] && json['messaging_connection']['connected'] != true - json['errors']['messaging_connection'] = _("Pulp message bus connection issue.") - end - - json - end - - def self.humanized_name - 'Pulp' - end - - private - - def pulp_url - url = URI.parse(proxy.url) - url.port = 443 - url.path = '/pulp/api/v2/status/' - url.to_s - end - end - end -end -::ProxyStatus.status_registry.add(Katello::ProxyStatus::Pulp) diff --git a/app/services/katello/proxy_status/pulp_node.rb b/app/services/katello/proxy_status/pulp_node.rb deleted file mode 100644 index 1adcc6a7d02..00000000000 --- a/app/services/katello/proxy_status/pulp_node.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Katello - module ProxyStatus - class PulpNode < Katello::ProxyStatus::Pulp - def self.humanized_name - 'PulpNode' - end - end - end -end -::ProxyStatus.status_registry.add(Katello::ProxyStatus::PulpNode) diff --git a/lib/katello/engine.rb b/lib/katello/engine.rb index 021774d449d..35a412c65b4 100644 --- a/lib/katello/engine.rb +++ b/lib/katello/engine.rb @@ -188,14 +188,11 @@ class Engine < ::Rails::Engine require_dependency "#{Katello::Engine.root}/app/lib/katello/api/v2/rendering" require_dependency "#{Katello::Engine.root}/app/controllers/katello/api/api_controller" require_dependency "#{Katello::Engine.root}/app/controllers/katello/api/v2/api_controller" - require_dependency "#{Katello::Engine.root}/app/services/katello/proxy_status/pulp" - require_dependency "#{Katello::Engine.root}/app/services/katello/proxy_status/pulp_node" #Api controller extensions ::Api::V2::HostsController.include Katello::Concerns::Api::V2::HostsControllerExtensions ::Api::V2::HostsBulkActionsController.include Katello::Concerns::Api::V2::HostsBulkActionsControllerExtensions ::Api::V2::HostgroupsController.include Katello::Concerns::Api::V2::HostgroupsControllerExtensions - ::Api::V2::SmartProxiesController.include Katello::Concerns::Api::V2::SmartProxiesControllerExtensions ::Api::V2::RegistrationController.include ::Foreman::Controller::SmartProxyAuth ::Api::V2::RegistrationController.prepend Katello::Concerns::Api::V2::RegistrationControllerExtensions ::Api::V2::RegistrationCommandsController.include Katello::Concerns::Api::V2::RegistrationCommandsControllerExtensions diff --git a/lib/proxy_api/pulp.rb b/lib/proxy_api/pulp.rb deleted file mode 100644 index 6b33a8eff80..00000000000 --- a/lib/proxy_api/pulp.rb +++ /dev/null @@ -1,22 +0,0 @@ -module ProxyAPI - class Pulp < ::ProxyAPI::Resource - def initialize(args) - @url = args[:url] + "/pulp/status" - super args - end - - def pulp_storage - @url += "/disk_usage" - @pulp_storage ||= parse(get) - rescue => e - raise ::ProxyAPI::ProxyException.new(url, e, N_("Unable to detect pulp storage")) - end - - def capsule_puppet_path - @url += "/puppet" - @capsule_puppet_path ||= parse(get) - rescue => e - raise ::ProxyAPI::ProxyException.new(url, e, N_("Unable to detect puppet path")) - end - end -end diff --git a/lib/proxy_api/pulp_node.rb b/lib/proxy_api/pulp_node.rb deleted file mode 100644 index 29a2b9b3377..00000000000 --- a/lib/proxy_api/pulp_node.rb +++ /dev/null @@ -1,22 +0,0 @@ -module ProxyAPI - class PulpNode < ::ProxyAPI::Resource - def initialize(args) - @url = args[:url] + "/pulpnode/status" - super args - end - - def pulp_storage - @url += "/disk_usage" - @pulp_storage ||= parse(get) - rescue => e - raise ::ProxyAPI::ProxyException.new(url, e, N_("Unable to detect pulp storage")) - end - - def capsule_puppet_path - @url += "/puppet" - @capsule_puppet_path ||= parse(get) - rescue => e - raise ::ProxyAPI::ProxyException.new(url, e, N_("Unable to detect puppet path")) - end - end -end diff --git a/test/controllers/foreman/smart_proxies_controller_test.rb b/test/controllers/foreman/smart_proxies_controller_test.rb deleted file mode 100644 index 4ebd8d1a660..00000000000 --- a/test/controllers/foreman/smart_proxies_controller_test.rb +++ /dev/null @@ -1,48 +0,0 @@ -require 'katello_test_helper' - -class SmartProxiesControllerTest < ActionController::TestCase - include VCR::TestCase - - def models - @smart_proxy = FactoryBot.create(:smart_proxy, :with_pulp3) - end - - def proxy_storage_response - response = {"pulp_dir" => {"filesystem" => "/dev/vda3", "1k-blocks" => 39_603_264, "used" => 30_135_856, "available" => 7_432_652, - "percent" => "81%", "mounted" => "/", "path" => "/var/lib/pulp", "size" => "kilobyte"}, - "pulp_content_dir" => {"filesystem" => "/dev/vda2", "1k-blocks" => 499_656, "used" => 196_060, "available" => 266_900, - "percent" => "43%", "mounted" => "/dev/vda2", "path" => "/var/lib/pulp/content", "size" => "kilobyte"}, - "mongodb_dir" => {"filesystem" => "/dev/vda3", "1k-blocks" => 39_603_264, "used" => 30_135_856, "available" => 7_432_652, - "percent" => "81%", "mounted" => "/", "path" => "/var/lib/mongodb", "size" => "kilobyte"}} - ProxyAPI::Pulp.any_instance.stubs(:pulp_storage).returns(response) - end - - def proxy_status_response - response = {"known_workers" => [{"last_heartbeat" => "2016-01-20T08:17:02Z", "name" => "scheduler@katello-centos7-devel.example.com"}], - "messaging_connection" => {"connected" => true}, - "database_connection" => {"connected" => true}, - "api_version" => "2", - "versions" => {"platform_version" => "2.6.4"}, - "errors" => {}} - Katello::ProxyStatus::Pulp.any_instance.stubs(:status).returns(response.to_json) - end - - def setup - setup_controller_defaults(false) - setup_foreman_routes - login_user(User.find(users(:admin).id)) - models - proxy_status_response - proxy_storage_response - end - - def test_smart_proxy_pulp_storage - get :pulp_storage, params: { :id => @smart_proxy.id } - assert_response :success - end - - def test_smart_proxy_pulp_status - get :pulp_status, params: { :id => @smart_proxy.id } - assert_response :success - end -end