Class: Spacewalk::Server
- Inherits:
-
Object
- Object
- Spacewalk::Server
- Defined in:
- lib/spacewalk/server.rb
Constant Summary collapse
- ACTION_VERSION =
from /usr/sbin/rhn_check action version we understand
2
Instance Method Summary collapse
- #actions ⇒ Object
-
#initialize(options = {}) ⇒ Server
constructor
Initialize server xmlrpc port options: :noconfig => true - don’t load @config :server => string - url of server (for initial registration) :systemid => string.
-
#osversion ⇒ Object
get system O/S version.
- #refresh_hardware(devices) ⇒ Object
- #register(activationkey, profile_name, other = {}) ⇒ Object
- #send_packages(packages) ⇒ Object
-
#welcome ⇒ Object
welcome to/from server.
Constructor Details
#initialize(options = {}) ⇒ Server
Initialize server xmlrpc port options:
:noconfig => true - don't load @config
:server => string - url of server (for initial registration)
:systemid => string
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/spacewalk/server.rb', line 65 def initialize = {} @config = Spacewalk::Config.new if [:noconfig] uri = URI.parse([:server]) uri.path = "/XMLRPC" else uri = URI.parse(@config.serverurl) end args = {:host=>uri.host, :path => uri.path, :use_ssl => (uri.scheme == "https")} unless [:noconfig] if @config.httpProxy args[:proxy_host], clientargs[:proxy_port] = @config.httpProxy.split ":" end end @client = XMLRPC::Client.new_from_hash args @client.http_header_extra = {} welcome # parse server capabilities @capabilities = Spacewalk::Capabilities.new @client @client.http_header_extra["X-Up2date-Version"] = "1.6.42" # from rhn-client-tools.spec @client.http_header_extra["X-RHN-Client-Capability"] = "packages.extended_profile(2)=1" @systemid = [:systemid] unless @systemid || [:noconfig] @systemid = Spacewalk::SystemId.new(@client, @config).to_xml end # check for distribution update # my_id = @systemid.os_release # server_id = osversion end |
Instance Method Details
#actions ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/spacewalk/server.rb', line 118 def actions report = Spacewalk::StatusReport.status result = call "queue.get", @systemid, ACTION_VERSION, report puts "Actions => #{result.inspect}" if action = result["action"] result["action"] = @client.get_parser.parseMethodCall(action) end puts "Actions => #{result.inspect}" end |
#osversion ⇒ Object
get system O/S version
110 111 112 113 114 115 116 |
# File 'lib/spacewalk/server.rb', line 110 def osversion result = @config.versionOverride unless result # find rpm provider of redhat-release or distribution-release, get its version end result end |
#refresh_hardware(devices) ⇒ Object
151 152 153 |
# File 'lib/spacewalk/server.rb', line 151 def refresh_hardware devices call "registration.refresh_hw_profile", @systemid, devices end |
#register(activationkey, profile_name, other = {}) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/spacewalk/server.rb', line 130 def register activationkey, profile_name, other = {} auth_dict = {} auth_dict["profile_name"] = profile_name #"os_release" : up2dateUtils.getVersion(), #"release_name" : up2dateUtils.getOSRelease(), #"architecture" : up2dateUtils.getArch() } # dict of other bits to send auth_dict.update other auth_dict["token"] = activationkey # auth_dict["username"] = username # auth_dict["password"] = password # if cfg['supportsSMBIOS']: # auth_dict["smbios"] = _encode_characters(hardware.get_smbios()) STDERR.puts "registration.new_system #{auth_dict.inspect}" @systemid = call "registration.new_system", auth_dict end |
#send_packages(packages) ⇒ Object
148 149 150 |
# File 'lib/spacewalk/server.rb', line 148 def send_packages packages call "registration.add_packages", @systemid, packages end |
#welcome ⇒ Object
welcome to/from server
104 105 106 107 |
# File 'lib/spacewalk/server.rb', line 104 def welcome result = call "registration.welcome_message" puts "Welcome => #{result.inspect}" end |