Sha256: eb5208a767126ae0ba73514750ddfcf6b7bcae0c53c71d07311cf822e090c9b6

Contents?: true

Size: 1.05 KB

Versions: 48

Compression:

Stored size: 1.05 KB

Contents

require 'awesome_spawn'

module ManageIQ
module ApplianceConsole
  # Kerberos principal
  class Principal
    attr_accessor :ca_name
    attr_accessor :hostname
    attr_accessor :realm
    attr_accessor :service
    # kerberos principal name
    attr_accessor :name

    def initialize(options = {})
      options.each { |n, v| public_send("#{n}=", v) }
      @ca_name ||= "ipa"
      @realm = @realm.upcase if @realm
      @name ||= "#{service}/#{hostname}@#{realm}"
    end

    def register
      request if ipa? && !exist?
    end

    def subject_name
      "CN=#{hostname},OU=#{service},O=#{realm}"
    end

    def ipa?
      @ca_name == "ipa"
    end

    private

    def exist?
      AwesomeSpawn.run("/usr/bin/ipa", :params => ["-e", "skip_version_check=1", "service-find", "--principal", name]).success?
    end

    def request
      # using --force because these services tend not to be in dns
      # this is like VERIFY_NONE
      AwesomeSpawn.run!("/usr/bin/ipa", :params => ["-e", "skip_version_check=1", "service-add", "--force", name])
    end
  end
end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
manageiq-appliance_console-7.2.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-8.0.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.1.1 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.1.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.6 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.5 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.4 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.3 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.2 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-6.1.1 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.1 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-7.0.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-6.1.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-6.0.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-5.5.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-5.4.0 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-5.3.3 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-5.3.2 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-5.3.1 lib/manageiq/appliance_console/principal.rb
manageiq-appliance_console-5.3.0 lib/manageiq/appliance_console/principal.rb