Class: System
Instance Method Summary
collapse
Methods inherited from Sif::Loader
#initialize
Constructor Details
This class inherits a constructor from Sif::Loader
Instance Method Details
#delete(*systemid) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/system.rb', line 29
def delete(*systemid)
puts "Delete this system from spacewalk - ID #{systemid}"
system_api = Buzz::Api::System.new(@spacewalk_server, @username, @password)
response = system_api.delete_systems(systemid)
puts "RESP #{response}"
end
|
#delete_by_regex(regex) ⇒ Object
82
83
84
85
86
87
|
# File 'lib/system.rb', line 82
def delete_by_regex(regex)
systems_to_delete = find_systems_by_regex regex
system_ids = systems_to_delete.collect { |system| system['id']}
system_ids.each { |it| puts "Deleting #{it}"}
delete_systems system_ids
end
|
#deleteself ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/system.rb', line 12
def deleteself
server = XMLRPC::Client.new(@spacewalk_server, "/rpc/api", 80)
systemid_file_path = '/etc/sysconfig/rhn/systemid'
systemid_file_path = './systemid.xml'
if (!File.exists?(systemid_file_path))
puts "Cannot find system ID file - exiting"
exit -1
end
systemid_file = File.read systemid_file_path
doc = REXML::Document.new(systemid_file)
systemid = REXML::XPath.first( doc, 'string(//member[* = "system_id"]/value/string)' ).split('-')[1]
puts "Delete this system from spacewalk - ID #{systemid}"
delete_systems [systemid.to_i]
end
|
#list ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/system.rb', line 45
def list
server = XMLRPC::Client.new(@spacewalk_server, "/rpc/api", 80)
begin
key = server.call("auth.login", @username, @password)
puts "Using session key #{key}"
response = server.call("system.listSystems",
key
)
systems = []
puts "REP #{response}"
response.each do |system|
id = system['id']
name = system['name']
last_checkin = system['last_checkin'].to_time
puts "System: ID: #{id} name: #{name} last checked in: #{last_checkin}"
end
rescue XMLRPC::FaultException => e
puts "Error:"
puts e.faultCode
puts e.faultString
end
end
|
#list_by_regex(regex) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/system.rb', line 69
def list_by_regex(regex)
systems = find_systems_by_regex(regex)
systems.each do |system|
id = system['id']
name = system['name']
last_checkin = system['last_checkin'].to_time.ctime
puts "System: ID: #{id} name: #{name} last checked in: #{last_checkin}"
end
end
|
#noop ⇒ Object
39
40
41
42
|
# File 'lib/system.rb', line 39
def noop
puts "NOOP:"
puts "HOST #{@spacewalk_server} #{parent_options} #{@lol}"
end
|