Sha256: 77e2e66a225d7a2e2461d193612dc000566edfeca67a44dcdc0ae1e264f54f4f

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

require 'fast_gettext'
require 'gettext_i18n_rails'
require 'fog'
require 'deface'

module ForemanXen
  #Inherit from the Rails module of the parent app (Foreman), not the plugin.
  #Thus, inherits from ::Rails::Engine and not from Rails::Engine
  class Engine < ::Rails::Engine

    initializer 'foreman_xen.register_gettext', :after => :load_config_initializers do |app|
      locale_dir    = File.join(File.expand_path('../../..', __FILE__), 'locale')
      locale_domain = 'foreman-xen'

      Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
    end

    initializer 'foreman_xen.register_plugin', :after => :finisher_hook do |app|
      Foreman::Plugin.register :foreman_xen do
        requires_foreman '>= 1.8'
        # Register xen compute resource in foreman
        compute_resource ForemanXen::Xenserver
      end

    end

    config.to_prepare do
      begin
        # extend fog xen server and image models.
        require 'fog/xenserver/models/compute/server'
        require File.expand_path('../../../app/models/concerns/fog_extensions/xenserver/server', __FILE__)
        require File.expand_path('../../../app/models/concerns/foreman_xen/host_helper_extensions', __FILE__)

        Fog::Compute::XenServer::Server.send(:include, ::FogExtensions::Xenserver::Server)
        ::HostsHelper.send(:include, ForemanXen::HostHelperExtensions)
      rescue => e
        puts "Foreman-Xen: skipping engine hook (#{e.to_s})"
      end
    end

  end




end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
foreman_xen-0.1.1 lib/foreman_xen/engine.rb
foreman_xen-0.1.0 lib/foreman_xen/engine.rb