Module: Chef::Knife::RhnBase
- Included in:
- RhnSystemDelete, RhnSystemDetails, RhnSystemMove, RhnSystemSystemgroups, RhnSystemgroupActive, RhnSystemgroupAdd, RhnSystemgroupCreate, RhnSystemgroupDelete, RhnSystemgroupInactive, RhnSystemgroupList, RhnSystemgroupOutdated, RhnSystemgroupRemove, RhnSystemgroupSystems
- Defined in:
- lib/chef/knife/rhn_base.rb
Class Method Summary collapse
Instance Method Summary collapse
- #get_config(key) ⇒ Object
- #get_satellite_system(system) ⇒ Object
- #set_rhn_connection_options ⇒ Object
Class Method Details
.included(includer) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef/knife/rhn_base.rb', line 13 def self.included(includer) includer.class_eval do deps do require 'readline' require 'chef/json_compat' end unless defined? $default $default = Hash.new end option :rhn_debug, :long => "--rhn-debug", :description => "Enable debugging for RHN connection", :boolean => false option :rhn_hostname, :short => "-h HOSTNAME", :long => "--rhn-hostname HOSTNAME", :description => "The hostname for RHN" option :rhn_no_https, :long => "--rhn-no-https", :description => "Disable HTTPS for RHN connection", :boolean => false option :rhn_password, :short => "-p PASSWORD", :long => "--rhn-password PASSWORD", :description => "The password for RHN" option :rhn_timeout, :long => "--rhn-timeout SECONDS", :description => "The timeout in seconds for RHN" $default[:rhn_timeout] = 30 option :rhn_username, :short => "-u USERNAME", :long => "--rhn-username USERNAME", :description => "The username for RHN" end end |
Instance Method Details
#get_config(key) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/chef/knife/rhn_base.rb', line 57 def get_config(key) key = key.to_sym rval = config[key] || Chef::Config[:knife][key] || $default[key] Chef::Log.debug("value for config item #{key}: #{rval}") rval end |
#get_satellite_system(system) ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chef/knife/rhn_base.rb', line 64 def get_satellite_system(system) satellite_system = RhnSatellite::System.get(system) if satellite_system.nil? ui.fatal "Could not find system in RHN!" exit 1 end satellite_system end |
#set_rhn_connection_options ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/chef/knife/rhn_base.rb', line 75 def RhnSatellite::Connection::Handler.debug_enabled = true if get_config(:rhn_debug) RhnSatellite::Connection::Handler.default_hostname = get_config(:rhn_hostname) RhnSatellite::Connection::Handler.default_https = false if get_config(:rhn_no_https) # See: https://github.com/duritong/ruby-rhn_satellite/issues/3 RhnSatellite::ActivationKey.https = false if get_config(:rhn_no_https) RhnSatellite::Api.https = false if get_config(:rhn_no_https) RhnSatellite::Channel.https = false if get_config(:rhn_no_https) RhnSatellite::ChannelAccess.https = false if get_config(:rhn_no_https) RhnSatellite::ChannelSoftware.https = false if get_config(:rhn_no_https) RhnSatellite::Packages.https = false if get_config(:rhn_no_https) RhnSatellite::System.https = false if get_config(:rhn_no_https) RhnSatellite::Systemgroup.https = false if get_config(:rhn_no_https) # End of issue 3 workaround RhnSatellite::Connection::Handler.default_timeout = get_config(:rhn_timeout) RhnSatellite::Connection::Handler.default_username = get_config(:rhn_username) password = get_config(:rhn_password) password ||= ask("RHN Password for #{get_config(:rhn_username)}: ") { |q| q.echo = "*" } RhnSatellite::Connection::Handler.default_password = password end |