linux_admin 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/linux_admin.rb +0 -1
- data/lib/linux_admin/common.rb +3 -97
- data/lib/linux_admin/exceptions.rb +1 -20
- data/lib/linux_admin/registration_system/subscription_manager.rb +2 -2
- data/lib/linux_admin/version.rb +1 -1
- data/spec/common_spec.rb +7 -144
- data/spec/deb_spec.rb +2 -2
- data/spec/disk_spec.rb +1 -2
- data/spec/mountable_spec.rb +8 -8
- data/spec/rpm_spec.rb +5 -5
- data/spec/spec_helper.rb +9 -4
- data/spec/subscription_manager_spec.rb +7 -1
- metadata +24 -17
- data/.gitignore +0 -17
- data/.travis.yml +0 -3
- data/Gemfile +0 -4
- data/Rakefile +0 -6
- data/examples/subscription_manager_hosted.rb +0 -25
- data/lib/linux_admin/command_result.rb +0 -14
- data/linux_admin.gemspec +0 -38
- data/spec/command_result_spec.rb +0 -13
data/lib/linux_admin.rb
CHANGED
data/lib/linux_admin/common.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'awesome_spawn'
|
2
2
|
|
3
3
|
class LinuxAdmin
|
4
4
|
module Common
|
@@ -7,105 +7,11 @@ class LinuxAdmin
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def run(cmd, options = {})
|
10
|
-
|
11
|
-
|
12
|
-
launch_params = {}
|
13
|
-
launch_params[:chdir] = options[:chdir] if options[:chdir]
|
14
|
-
|
15
|
-
output = ""
|
16
|
-
error = ""
|
17
|
-
status = nil
|
18
|
-
command_line = build_cmd(cmd, params)
|
19
|
-
|
20
|
-
begin
|
21
|
-
output, error = launch(command_line, launch_params)
|
22
|
-
status = exitstatus
|
23
|
-
ensure
|
24
|
-
output ||= ""
|
25
|
-
error ||= ""
|
26
|
-
self.exitstatus = nil
|
27
|
-
end
|
28
|
-
rescue Errno::ENOENT => err
|
29
|
-
raise NoSuchFileError.new(err.message) if NoSuchFileError.detected?(err.message)
|
30
|
-
raise
|
31
|
-
else
|
32
|
-
CommandResult.new(command_line, output, error, status)
|
10
|
+
AwesomeSpawn.run(cmd, options)
|
33
11
|
end
|
34
12
|
|
35
13
|
def run!(cmd, options = {})
|
36
|
-
|
37
|
-
command_result = run(cmd, options)
|
38
|
-
|
39
|
-
if command_result.exit_status != 0
|
40
|
-
message = "#{cmd} exit code: #{command_result.exit_status}"
|
41
|
-
raise CommandResultError.new(message, command_result)
|
42
|
-
end
|
43
|
-
|
44
|
-
command_result
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def sanitize(params)
|
50
|
-
return [] if params.blank?
|
51
|
-
params.collect do |k, v|
|
52
|
-
v = case v
|
53
|
-
when Array; v.collect {|i| i.to_s.shellescape}
|
54
|
-
when NilClass; v
|
55
|
-
else v.to_s.shellescape
|
56
|
-
end
|
57
|
-
[k, v]
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def assemble_params(sanitized_params)
|
62
|
-
sanitized_params.collect do |pair|
|
63
|
-
pair_joiner = pair.first.to_s.end_with?("=") ? "" : " "
|
64
|
-
pair.flatten.compact.join(pair_joiner)
|
65
|
-
end.join(" ")
|
66
|
-
end
|
67
|
-
|
68
|
-
def build_cmd(cmd, params = nil)
|
69
|
-
return cmd.to_s if params.blank?
|
70
|
-
"#{cmd} #{assemble_params(sanitize(params))}"
|
71
|
-
end
|
72
|
-
|
73
|
-
# IO pipes have a maximum size of 64k before blocking,
|
74
|
-
# so we need to read and write synchronously.
|
75
|
-
# http://stackoverflow.com/questions/13829830/ruby-process-spawn-stdout-pipe-buffer-size-limit/13846146#13846146
|
76
|
-
THREAD_SYNC_KEY = "LinuxAdmin-exitstatus"
|
77
|
-
|
78
|
-
def launch(cmd, spawn_options = {})
|
79
|
-
out_r, out_w = IO.pipe
|
80
|
-
err_r, err_w = IO.pipe
|
81
|
-
pid = Kernel.spawn(cmd, {:err => err_w, :out => out_w}.merge(spawn_options))
|
82
|
-
wait_for_process(pid, out_w, err_w)
|
83
|
-
wait_for_pipes(out_r, err_r)
|
84
|
-
end
|
85
|
-
|
86
|
-
def wait_for_process(pid, out_w, err_w)
|
87
|
-
self.exitstatus = :not_done
|
88
|
-
Thread.new(Thread.current) do |parent_thread|
|
89
|
-
_, status = Process.wait2(pid)
|
90
|
-
out_w.close
|
91
|
-
err_w.close
|
92
|
-
parent_thread[THREAD_SYNC_KEY] = status.exitstatus
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def wait_for_pipes(out_r, err_r)
|
97
|
-
out = out_r.read
|
98
|
-
err = err_r.read
|
99
|
-
sleep(0.1) while exitstatus == :not_done
|
100
|
-
return out, err
|
101
|
-
end
|
102
|
-
|
103
|
-
def exitstatus
|
104
|
-
Thread.current[THREAD_SYNC_KEY]
|
105
|
-
end
|
106
|
-
|
107
|
-
def exitstatus=(value)
|
108
|
-
Thread.current[THREAD_SYNC_KEY] = value
|
14
|
+
AwesomeSpawn.run!(cmd, options)
|
109
15
|
end
|
110
16
|
end
|
111
17
|
end
|
@@ -1,24 +1,5 @@
|
|
1
|
-
class CommandResultError < StandardError
|
2
|
-
attr_reader :result
|
3
|
-
|
4
|
-
def initialize(message, result)
|
5
|
-
super(message)
|
6
|
-
@result = result
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
1
|
class LinuxAdmin
|
11
|
-
class
|
12
|
-
def initialize(message)
|
13
|
-
super(message.split("No such file or directory -").last.split(" ").first)
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.detected?(message)
|
17
|
-
message.start_with?("No such file or directory -")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class CredentialError < CommandResultError
|
2
|
+
class CredentialError < AwesomeSpawn::CommandResultError
|
22
3
|
def initialize(result)
|
23
4
|
super("Invalid username or password", result)
|
24
5
|
end
|
@@ -4,7 +4,7 @@ class LinuxAdmin
|
|
4
4
|
class SubscriptionManager < RegistrationSystem
|
5
5
|
def run!(cmd, options = {})
|
6
6
|
super(cmd, options)
|
7
|
-
rescue CommandResultError => err
|
7
|
+
rescue AwesomeSpawn::CommandResultError => err
|
8
8
|
raise CredentialError.new(err.result) if err.result.error.downcase.include?("invalid username or password")
|
9
9
|
raise
|
10
10
|
end
|
@@ -140,4 +140,4 @@ class LinuxAdmin
|
|
140
140
|
config
|
141
141
|
end
|
142
142
|
end
|
143
|
-
end
|
143
|
+
end
|
data/lib/linux_admin/version.rb
CHANGED
data/spec/common_spec.rb
CHANGED
@@ -11,23 +11,9 @@ describe LinuxAdmin::Common do
|
|
11
11
|
Object.send(:remove_const, :TestClass)
|
12
12
|
end
|
13
13
|
|
14
|
-
let(:params) do
|
15
|
-
{
|
16
|
-
"--user" => "bob",
|
17
|
-
"--pass" => "P@$sw0^& |<>/-+*d%",
|
18
|
-
"--db" => nil,
|
19
|
-
"--desc=" => "Some Description",
|
20
|
-
nil => ["pkg1", "some pkg"]
|
21
|
-
}
|
22
|
-
end
|
23
|
-
|
24
|
-
let (:modified_params) do
|
25
|
-
params.to_a + [123, 456].collect {|pool| ["--pool", pool]}
|
26
|
-
end
|
27
|
-
|
28
14
|
subject { TestClass }
|
29
15
|
|
30
|
-
context "
|
16
|
+
context "#cmd" do
|
31
17
|
it "looks up local command from id" do
|
32
18
|
d = double(LinuxAdmin::Distro)
|
33
19
|
d.class::COMMANDS = {:sh => '/bin/sh'}
|
@@ -36,136 +22,13 @@ describe LinuxAdmin::Common do
|
|
36
22
|
end
|
37
23
|
end
|
38
24
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
subject.stub(:exitstatus => 0)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "sanitizes crazy params" do
|
46
|
-
subject.should_receive(:launch).once.with("true --user bob --pass P@\\$sw0\\^\\&\\ \\|\\<\\>/-\\+\\*d\\% --db --desc=Some\\ Description pkg1 some\\ pkg --pool 123 --pool 456", {})
|
47
|
-
subject.send(run_method, "true", :params => modified_params)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sanitizes fixnum array params" do
|
51
|
-
subject.should_receive(:launch).once.with("true 1", {})
|
52
|
-
subject.send(run_method, "true", :params => {nil => [1]})
|
53
|
-
end
|
54
|
-
|
55
|
-
it "sanitizes Pathname option value" do
|
56
|
-
require 'pathname'
|
57
|
-
subject.should_receive(:launch).once.with("true /usr/bin/ruby", {})
|
58
|
-
subject.send(run_method, "true", :params => {nil => [Pathname.new("/usr/bin/ruby")]})
|
59
|
-
end
|
60
|
-
|
61
|
-
it "sanitizes Pathname option" do
|
62
|
-
require 'pathname'
|
63
|
-
subject.should_receive(:launch).once.with("true /usr/bin/ruby", {})
|
64
|
-
subject.send(run_method, "true", :params => {Pathname.new("/usr/bin/ruby") => nil})
|
65
|
-
end
|
66
|
-
|
67
|
-
it "as empty hash" do
|
68
|
-
subject.should_receive(:launch).once.with("true", {})
|
69
|
-
subject.send(run_method, "true", :params => {})
|
70
|
-
end
|
71
|
-
|
72
|
-
it "as nil" do
|
73
|
-
subject.should_receive(:launch).once.with("true", {})
|
74
|
-
subject.send(run_method, "true", :params => nil)
|
75
|
-
end
|
76
|
-
|
77
|
-
it "won't modify caller params" do
|
78
|
-
orig_params = params.dup
|
79
|
-
subject.stub(:launch)
|
80
|
-
subject.send(run_method, "true", :params => params)
|
81
|
-
expect(orig_params).to eq(params)
|
82
|
-
end
|
83
|
-
|
84
|
-
it "Pathname command" do
|
85
|
-
subject.should_receive(:launch).once.with("/usr/bin/ruby", {})
|
86
|
-
subject.send(run_method, Pathname.new("/usr/bin/ruby"), {})
|
87
|
-
end
|
88
|
-
|
89
|
-
it "Pathname command with params" do
|
90
|
-
subject.should_receive(:launch).once.with("/usr/bin/ruby -v", {})
|
91
|
-
subject.send(run_method, Pathname.new("/usr/bin/ruby"), :params => {"-v" => nil})
|
92
|
-
end
|
93
|
-
|
94
|
-
it "supports spawn's chdir option" do
|
95
|
-
subject.should_receive(:launch).once.with("true", {:chdir => ".."})
|
96
|
-
subject.send(run_method, "true", :chdir => "..")
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
context "with real execution" do
|
101
|
-
before do
|
102
|
-
Kernel.stub(:spawn).and_call_original
|
103
|
-
end
|
104
|
-
|
105
|
-
it "command ok exit ok" do
|
106
|
-
expect(subject.send(run_method, "true")).to be_kind_of CommandResult
|
107
|
-
end
|
108
|
-
|
109
|
-
it "command ok exit bad" do
|
110
|
-
if run_method == "run!"
|
111
|
-
error = nil
|
112
|
-
|
113
|
-
# raise_error with do/end block notation is broken in rspec-expectations 2.14.x
|
114
|
-
# and has been fixed in master but not yet released.
|
115
|
-
# See: https://github.com/rspec/rspec-expectations/commit/b0df827f4c12870aa4df2f20a817a8b01721a6af
|
116
|
-
expect {subject.send(run_method, "false")}.to raise_error {|e| error = e }
|
117
|
-
expect(error).to be_kind_of CommandResultError
|
118
|
-
expect(error.result).to be_kind_of CommandResult
|
119
|
-
else
|
120
|
-
expect {subject.send(run_method, "false")}.to_not raise_error
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
it "command bad" do
|
125
|
-
expect {subject.send(run_method, "XXXXX --user=bob")}.to raise_error(LinuxAdmin::NoSuchFileError, "No such file or directory - XXXXX")
|
126
|
-
end
|
127
|
-
|
128
|
-
context "#exit_status" do
|
129
|
-
it "command ok exit ok" do
|
130
|
-
expect(subject.send(run_method, "true").exit_status).to eq(0)
|
131
|
-
end
|
132
|
-
|
133
|
-
it "command ok exit bad" do
|
134
|
-
expect(subject.send(run_method, "false").exit_status).to eq(1) if run_method == "run"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context "#output" do
|
139
|
-
it "command ok exit ok" do
|
140
|
-
expect(subject.send(run_method, "echo \"Hello World\"").output).to eq("Hello World\n")
|
141
|
-
end
|
142
|
-
|
143
|
-
it "command ok exit bad" do
|
144
|
-
expect(subject.send(run_method, "echo 'bad' && false").output).to eq("bad\n") if run_method == "run"
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
context "#error" do
|
149
|
-
it "command ok exit ok" do
|
150
|
-
expect(subject.send(run_method, "echo \"Hello World\" >&2").error).to eq("Hello World\n")
|
151
|
-
end
|
152
|
-
|
153
|
-
it "command ok exit bad" do
|
154
|
-
expect(subject.send(run_method, "echo 'bad' >&2 && false").error).to eq("bad\n") if run_method == "run"
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
25
|
+
it "#run" do
|
26
|
+
AwesomeSpawn.should_receive(:run).with("echo", nil => "test")
|
27
|
+
subject.run("echo", nil => "test")
|
158
28
|
end
|
159
29
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context ".run!" do
|
167
|
-
include_examples "run" do
|
168
|
-
let(:run_method) {"run!"}
|
169
|
-
end
|
30
|
+
it "#run!" do
|
31
|
+
AwesomeSpawn.should_receive(:run!).with("echo", nil => "test")
|
32
|
+
subject.run!("echo", nil => "test")
|
170
33
|
end
|
171
34
|
end
|
data/spec/deb_spec.rb
CHANGED
@@ -39,9 +39,9 @@ Origin: Ubuntu
|
|
39
39
|
Supported: 9m
|
40
40
|
Task: kubuntu-desktop, kubuntu-full, kubuntu-active, kubuntu-active-desktop, kubuntu-active-full, kubuntu-active, edubuntu-desktop-gnome, ubuntustudio-font-meta
|
41
41
|
EOS
|
42
|
-
described_class.should_receive(:run).
|
42
|
+
described_class.should_receive(:run!).
|
43
43
|
with(described_class::APT_CACHE_CMD, :params => ["show", "ruby"]).
|
44
|
-
and_return(
|
44
|
+
and_return(double(:output => data))
|
45
45
|
metadata = described_class.info("ruby")
|
46
46
|
metadata['package'].should == 'ruby'
|
47
47
|
metadata['priority'].should == 'optional'
|
data/spec/disk_spec.rb
CHANGED
@@ -54,8 +54,7 @@ eos
|
|
54
54
|
|
55
55
|
it "returns [] on non-zero parted rc" do
|
56
56
|
disk = LinuxAdmin::Disk.new :path => '/dev/hda'
|
57
|
-
disk.
|
58
|
-
disk.stub(:launch)
|
57
|
+
disk.should_receive(:run).and_return(double(:output => "", :exit_status => 1))
|
59
58
|
disk.partitions.should == []
|
60
59
|
end
|
61
60
|
|
data/spec/mountable_spec.rb
CHANGED
@@ -27,20 +27,20 @@ eos
|
|
27
27
|
|
28
28
|
describe "#mount_point_exists?" do
|
29
29
|
it "uses mount" do
|
30
|
-
TestMountable.should_receive(:run!).with(TestMountable.cmd(:mount)).and_return(
|
30
|
+
TestMountable.should_receive(:run!).with(TestMountable.cmd(:mount)).and_return(double(:output => ""))
|
31
31
|
TestMountable.mount_point_exists?('/mnt/usb')
|
32
32
|
end
|
33
33
|
|
34
34
|
context "disk mounted at specified location" do
|
35
35
|
it "returns true" do
|
36
|
-
TestMountable.should_receive(:run!).and_return(
|
36
|
+
TestMountable.should_receive(:run!).and_return(double(:output => @mount_out1))
|
37
37
|
TestMountable.mount_point_exists?('/mnt/usb').should be_true
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
context "no disk mounted at specified location" do
|
42
42
|
it "returns false" do
|
43
|
-
TestMountable.should_receive(:run!).and_return(
|
43
|
+
TestMountable.should_receive(:run!).and_return(double(:output => @mount_out2))
|
44
44
|
TestMountable.mount_point_exists?('/mnt/usb').should be_false
|
45
45
|
end
|
46
46
|
end
|
@@ -48,20 +48,20 @@ eos
|
|
48
48
|
|
49
49
|
describe "#mount_point_available?" do
|
50
50
|
it "uses mount" do
|
51
|
-
TestMountable.should_receive(:run!).with(TestMountable.cmd(:mount)).and_return(
|
51
|
+
TestMountable.should_receive(:run!).with(TestMountable.cmd(:mount)).and_return(double(:output => ""))
|
52
52
|
TestMountable.mount_point_available?('/mnt/usb')
|
53
53
|
end
|
54
54
|
|
55
55
|
context "disk mounted at specified location" do
|
56
56
|
it "returns false" do
|
57
|
-
TestMountable.should_receive(:run!).and_return(
|
57
|
+
TestMountable.should_receive(:run!).and_return(double(:output => @mount_out1))
|
58
58
|
TestMountable.mount_point_available?('/mnt/usb').should be_false
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
context "no disk mounted at specified location" do
|
63
63
|
it "returns true" do
|
64
|
-
TestMountable.should_receive(:run!).and_return(
|
64
|
+
TestMountable.should_receive(:run!).and_return(double(:output => @mount_out2))
|
65
65
|
TestMountable.mount_point_available?('/mnt/usb').should be_true
|
66
66
|
end
|
67
67
|
end
|
@@ -85,8 +85,8 @@ eos
|
|
85
85
|
describe "#mount" do
|
86
86
|
it "sets mount point" do
|
87
87
|
# ignore actual mount cmds
|
88
|
-
@mountable.should_receive(:run!).and_return(
|
89
|
-
TestMountable.should_receive(:run!).and_return(
|
88
|
+
@mountable.should_receive(:run!).and_return(double(:output => ""))
|
89
|
+
TestMountable.should_receive(:run!).and_return(double(:output => ""))
|
90
90
|
|
91
91
|
@mountable.mount('/mnt/sda2').should == '/mnt/sda2'
|
92
92
|
@mountable.mount_point.should == '/mnt/sda2'
|
data/spec/rpm_spec.rb
CHANGED
@@ -28,8 +28,8 @@ describe LinuxAdmin::Rpm do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it ".import_key" do
|
31
|
-
described_class.should_receive(:run).with("rpm", {:params=>{"--import"=>"abc"}})
|
32
|
-
expect
|
31
|
+
described_class.should_receive(:run!).with("rpm", {:params => {"--import" => "abc"}})
|
32
|
+
expect { described_class.import_key("abc") }.to_not raise_error
|
33
33
|
end
|
34
34
|
|
35
35
|
describe "#info" do
|
@@ -59,9 +59,9 @@ object-oriented programming. It has many features to process text
|
|
59
59
|
files and to do system management tasks (as in Perl). It is simple,
|
60
60
|
straight-forward, and extensible.
|
61
61
|
EOS
|
62
|
-
described_class.should_receive(:run).
|
62
|
+
described_class.should_receive(:run!).
|
63
63
|
with(described_class::RPM_CMD, :params => {"-qi" => "ruby"}).
|
64
|
-
and_return(
|
64
|
+
and_return(double(:output => data))
|
65
65
|
metadata = described_class.info("ruby")
|
66
66
|
metadata['name'].should == 'ruby'
|
67
67
|
metadata['version'].should == '2.0.0.247'
|
@@ -79,7 +79,7 @@ EOS
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it ".upgrade" do
|
82
|
-
described_class.should_receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(
|
82
|
+
described_class.should_receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(double(:exit_status => 0))
|
83
83
|
expect(described_class.upgrade("abc")).to be_true
|
84
84
|
end
|
85
85
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
Coveralls.wear!
|
3
|
-
|
4
|
-
require 'linux_admin'
|
5
1
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
2
|
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
7
3
|
# Require this file using `require "spec_helper"` to ensure that it is only
|
@@ -28,6 +24,15 @@ RSpec.configure do |config|
|
|
28
24
|
end
|
29
25
|
end
|
30
26
|
|
27
|
+
begin
|
28
|
+
require 'coveralls'
|
29
|
+
Coveralls.wear!
|
30
|
+
rescue LoadError
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'linux_admin'
|
34
|
+
|
35
|
+
|
31
36
|
def data_file_path(to)
|
32
37
|
File.expand_path(to, File.join(File.dirname(__FILE__), "data"))
|
33
38
|
end
|
@@ -140,7 +140,13 @@ describe LinuxAdmin::SubscriptionManager do
|
|
140
140
|
|
141
141
|
it "with invalid credentials" do
|
142
142
|
run_options = ["subscription-manager orgs", {:params=>{"--username="=>"BadUser", "--password="=>"BadPass"}}]
|
143
|
-
|
143
|
+
error = AwesomeSpawn::CommandResultError.new("",
|
144
|
+
double(
|
145
|
+
:error => "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html",
|
146
|
+
:exit_status => 255
|
147
|
+
)
|
148
|
+
)
|
149
|
+
AwesomeSpawn.should_receive(:run!).once.with(*run_options).and_raise(error)
|
144
150
|
expect { described_class.new.organizations({:username=>"BadUser", :password=>"BadPass"}) }.to raise_error(LinuxAdmin::CredentialError)
|
145
151
|
end
|
146
152
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linux_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-02-
|
15
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 1.1
|
120
|
+
version: '1.1'
|
121
121
|
type: :runtime
|
122
122
|
prerelease: false
|
123
123
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -125,7 +125,23 @@ dependencies:
|
|
125
125
|
requirements:
|
126
126
|
- - ~>
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version: 1.1
|
128
|
+
version: '1.1'
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: awesome_spawn
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ~>
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 1.1.0
|
137
|
+
type: :runtime
|
138
|
+
prerelease: false
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ~>
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.1.0
|
129
145
|
- !ruby/object:Gem::Dependency
|
130
146
|
name: nokogiri
|
131
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,15 +176,7 @@ executables: []
|
|
160
176
|
extensions: []
|
161
177
|
extra_rdoc_files: []
|
162
178
|
files:
|
163
|
-
- .gitignore
|
164
|
-
- .travis.yml
|
165
|
-
- Gemfile
|
166
|
-
- LICENSE.txt
|
167
|
-
- README.md
|
168
|
-
- Rakefile
|
169
|
-
- examples/subscription_manager_hosted.rb
|
170
179
|
- lib/linux_admin.rb
|
171
|
-
- lib/linux_admin/command_result.rb
|
172
180
|
- lib/linux_admin/common.rb
|
173
181
|
- lib/linux_admin/deb.rb
|
174
182
|
- lib/linux_admin/disk.rb
|
@@ -192,8 +200,8 @@ files:
|
|
192
200
|
- lib/linux_admin/volume_group.rb
|
193
201
|
- lib/linux_admin/yum.rb
|
194
202
|
- lib/linux_admin/yum/repo_file.rb
|
195
|
-
-
|
196
|
-
-
|
203
|
+
- README.md
|
204
|
+
- LICENSE.txt
|
197
205
|
- spec/common_spec.rb
|
198
206
|
- spec/data/rhn/output_rhn-channel_list
|
199
207
|
- spec/data/rhn/output_rhn-channel_list_available
|
@@ -245,7 +253,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
253
|
version: '0'
|
246
254
|
segments:
|
247
255
|
- 0
|
248
|
-
hash:
|
256
|
+
hash: -1812183474622246574
|
249
257
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
258
|
none: false
|
251
259
|
requirements:
|
@@ -254,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
254
262
|
version: '0'
|
255
263
|
segments:
|
256
264
|
- 0
|
257
|
-
hash:
|
265
|
+
hash: -1812183474622246574
|
258
266
|
requirements: []
|
259
267
|
rubyforge_project:
|
260
268
|
rubygems_version: 1.8.23
|
@@ -262,7 +270,6 @@ signing_key:
|
|
262
270
|
specification_version: 3
|
263
271
|
summary: LinuxAdmin is a module to simplify management of linux systems.
|
264
272
|
test_files:
|
265
|
-
- spec/command_result_spec.rb
|
266
273
|
- spec/common_spec.rb
|
267
274
|
- spec/data/rhn/output_rhn-channel_list
|
268
275
|
- spec/data/rhn/output_rhn-channel_list_available
|
data/.gitignore
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
$:.push("../lib")
|
2
|
-
require 'linux_admin'
|
3
|
-
|
4
|
-
username = "MyUsername"
|
5
|
-
password = "MyPassword"
|
6
|
-
|
7
|
-
|
8
|
-
reg_status = LinuxAdmin.registered?
|
9
|
-
puts "Registration Status: #{reg_status.to_s}"
|
10
|
-
|
11
|
-
unless reg_status
|
12
|
-
puts "Registering to Subscription Manager..."
|
13
|
-
LinuxAdmin::SubscriptionManager.register(:username => username, :password => password)
|
14
|
-
end
|
15
|
-
|
16
|
-
reg_type = LinuxAdmin.registration_type
|
17
|
-
puts "Registration System: #{reg_type}"
|
18
|
-
|
19
|
-
puts "Subscribing to channels..."
|
20
|
-
reg_type.subscribe(reg_type.available_subscriptions.keys.first)
|
21
|
-
puts "Checking for updates..."
|
22
|
-
if LinuxAdmin::Yum.updates_available?
|
23
|
-
puts "Updates Available \n Updating..."
|
24
|
-
puts "Updates Applied" if LinuxAdmin::Yum.update
|
25
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
class CommandResult
|
2
|
-
attr_reader :command_line, :output, :error, :exit_status
|
3
|
-
|
4
|
-
def initialize(command_line, output, error, exit_status)
|
5
|
-
@command_line = command_line
|
6
|
-
@output = output
|
7
|
-
@error = error
|
8
|
-
@exit_status = exit_status
|
9
|
-
end
|
10
|
-
|
11
|
-
def inspect
|
12
|
-
"#{to_s.chop} @exit_status=#{@exit_status}>"
|
13
|
-
end
|
14
|
-
end
|
data/linux_admin.gemspec
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'linux_admin/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
|
8
|
-
# Dynamically create the authors information {name => e-mail}
|
9
|
-
authors_hash = Hash[`git log --no-merges --reverse --format='%an,%ae'`.split("\n").uniq.collect {|i| i.split(",")}]
|
10
|
-
|
11
|
-
spec.name = "linux_admin"
|
12
|
-
spec.version = LinuxAdmin::VERSION
|
13
|
-
spec.authors = authors_hash.keys
|
14
|
-
spec.email = authors_hash.values
|
15
|
-
spec.description = %q{
|
16
|
-
LinuxAdmin is a module to simplify management of linux systems.
|
17
|
-
It should be a single place to manage various system level configurations,
|
18
|
-
registration, updates, etc.
|
19
|
-
}
|
20
|
-
spec.summary = %q{LinuxAdmin is a module to simplify management of linux systems.}
|
21
|
-
spec.homepage = "http://github.com/ManageIQ/linux_admin"
|
22
|
-
spec.license = "MIT"
|
23
|
-
|
24
|
-
spec.files = `git ls-files`.split($/)
|
25
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
26
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
27
|
-
spec.require_paths = ["lib"]
|
28
|
-
|
29
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
30
|
-
spec.add_development_dependency "rake"
|
31
|
-
spec.add_development_dependency "rspec", "~> 2.13"
|
32
|
-
spec.add_development_dependency "coveralls"
|
33
|
-
|
34
|
-
spec.add_dependency "activesupport", "> 3.2"
|
35
|
-
spec.add_dependency "inifile", "~> 2.0.2"
|
36
|
-
spec.add_dependency "more_core_extensions", "~> 1.1.2"
|
37
|
-
spec.add_dependency "nokogiri"
|
38
|
-
end
|
data/spec/command_result_spec.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe CommandResult do
|
4
|
-
context "#inspect" do
|
5
|
-
it "will not display sensitive information" do
|
6
|
-
command_result = described_class.new("aaa", "bbb", "ccc", 0).inspect
|
7
|
-
|
8
|
-
expect(command_result.include?("aaa")).to be_false
|
9
|
-
expect(command_result.include?("bbb")).to be_false
|
10
|
-
expect(command_result.include?("ccc")).to be_false
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|