linux_admin 0.8.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/linux_admin.rb +1 -1
- data/lib/linux_admin/common.rb +1 -1
- data/lib/linux_admin/deb.rb +1 -2
- data/lib/linux_admin/disk.rb +2 -2
- data/lib/linux_admin/distro.rb +25 -100
- data/lib/linux_admin/etc_issue.rb +5 -7
- data/lib/linux_admin/rpm.rb +2 -2
- data/lib/linux_admin/version.rb +1 -1
- data/spec/common_spec.rb +2 -15
- data/spec/disk_spec.rb +3 -3
- data/spec/distro_spec.rb +41 -15
- data/spec/etc_issue_spec.rb +40 -0
- data/spec/logical_volume_spec.rb +0 -2
- data/spec/physical_volume_spec.rb +0 -2
- data/spec/service_spec.rb +0 -4
- data/spec/spec_helper.rb +13 -8
- data/spec/volume_group_spec.rb +0 -2
- metadata +9 -8
- data/lib/linux_admin/package.rb +0 -18
- data/spec/package_spec.rb +0 -17
data/lib/linux_admin.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
require 'more_core_extensions/all'
|
2
|
+
require 'active_support'
|
2
3
|
require 'active_support/core_ext'
|
3
4
|
|
4
5
|
require 'linux_admin/registration_system'
|
5
6
|
|
6
7
|
require 'linux_admin/common'
|
7
8
|
require 'linux_admin/exceptions'
|
8
|
-
require 'linux_admin/package'
|
9
9
|
require 'linux_admin/rpm'
|
10
10
|
require 'linux_admin/deb'
|
11
11
|
require 'linux_admin/version'
|
data/lib/linux_admin/common.rb
CHANGED
data/lib/linux_admin/deb.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
# Licensed under the MIT License
|
5
5
|
|
6
6
|
class LinuxAdmin
|
7
|
-
class Deb
|
7
|
+
class Deb
|
8
8
|
APT_CACHE_CMD = '/usr/bin/apt-cache'
|
9
9
|
|
10
10
|
def self.from_line(apt_cache_line, in_description=false)
|
@@ -34,6 +34,5 @@ class LinuxAdmin
|
|
34
34
|
def self.info(pkg)
|
35
35
|
self.from_string(run!(APT_CACHE_CMD, :params => ["show", pkg]).output)
|
36
36
|
end
|
37
|
-
|
38
37
|
end
|
39
38
|
end
|
data/lib/linux_admin/disk.rb
CHANGED
@@ -53,7 +53,7 @@ class LinuxAdmin
|
|
53
53
|
public
|
54
54
|
|
55
55
|
def self.local
|
56
|
-
Dir.glob('/dev/[vhs]d[a-z]').collect do |d|
|
56
|
+
Dir.glob(['/dev/[vhs]d[a-z]', '/dev/xvd[a-z]']).collect do |d|
|
57
57
|
Disk.new :path => d
|
58
58
|
end
|
59
59
|
end
|
@@ -152,7 +152,7 @@ class LinuxAdmin
|
|
152
152
|
end
|
153
153
|
|
154
154
|
id = partitions.empty? ? 1 : (partitions.last.id + 1)
|
155
|
-
options = parted_options_array('mkpart', '-a opt', partition_type, start, finish)
|
155
|
+
options = parted_options_array('mkpart', '-a', 'opt', partition_type, start, finish)
|
156
156
|
run!(cmd(:parted), :params => { nil => options})
|
157
157
|
|
158
158
|
partition = Partition.new(:disk => self,
|
data/lib/linux_admin/distro.rb
CHANGED
@@ -8,135 +8,60 @@ require 'linux_admin/etc_issue'
|
|
8
8
|
class LinuxAdmin
|
9
9
|
module Distros
|
10
10
|
def self.generic
|
11
|
-
@generic ||=
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.redhat
|
15
|
-
@redhat ||= RedHat.new
|
11
|
+
@generic ||= Distro.new(:generic)
|
16
12
|
end
|
17
13
|
|
18
14
|
def self.rhel
|
19
|
-
@rhel ||=
|
15
|
+
@rhel ||= Distro.new(:rhel, '/etc/redhat-release', ['red hat', 'centos'], LinuxAdmin::Rpm)
|
20
16
|
end
|
21
17
|
|
22
18
|
def self.fedora
|
23
|
-
@fedora ||=
|
19
|
+
@fedora ||= Distro.new(:fedora, "/etc/fedora-release", ['Fedora'], LinuxAdmin::Rpm)
|
24
20
|
end
|
25
21
|
|
26
22
|
def self.ubuntu
|
27
|
-
@ubuntu ||=
|
23
|
+
@ubuntu ||= Distro.new(:ubuntu, nil, ['ubuntu'], LinuxAdmin::Deb)
|
28
24
|
end
|
29
25
|
|
30
26
|
def self.all
|
31
|
-
|
27
|
+
@distros ||= [rhel, fedora, ubuntu, generic]
|
32
28
|
end
|
33
29
|
|
34
30
|
def self.local
|
35
|
-
|
31
|
+
@local ||= begin
|
32
|
+
Distros.all.detect(&:detected?) || Distros.generic
|
33
|
+
end
|
36
34
|
end
|
37
35
|
|
38
36
|
class Distro
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
attr_accessor :release_file, :etc_issue_keywords, :info_class
|
38
|
+
|
39
|
+
def initialize(id, release_file = nil, etc_issue_keywords = [], info_class = nil)
|
40
|
+
@id = id
|
41
|
+
@path = %w(/sbin /bin /usr/bin /usr/sbin)
|
42
|
+
@release_file = release_file
|
43
|
+
@etc_issue_keywords = etc_issue_keywords
|
44
|
+
@info_class = info_class
|
44
45
|
end
|
45
46
|
|
46
|
-
def
|
47
|
-
self::RELEASE_FILE
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.local
|
51
|
-
# this can be cleaned up..
|
52
|
-
@local ||= begin
|
53
|
-
result = nil
|
54
|
-
Distros.constants.each do |cdistro|
|
55
|
-
distro_method = cdistro.to_s.downcase.to_sym
|
56
|
-
distro = Distros.const_get(cdistro)
|
57
|
-
next unless distro < Distro
|
58
|
-
result = Distros.send(distro_method) if distro.detected?
|
59
|
-
end
|
60
|
-
result || Distros.generic
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.detected?
|
47
|
+
def detected?
|
65
48
|
detected_by_etc_issue? || detected_by_etc_release?
|
66
49
|
end
|
67
50
|
|
68
|
-
def
|
69
|
-
etc_issue_keywords.any? { |k| EtcIssue.instance.
|
51
|
+
def detected_by_etc_issue?
|
52
|
+
etc_issue_keywords && etc_issue_keywords.any? { |k| EtcIssue.instance.include?(k) }
|
70
53
|
end
|
71
54
|
|
72
|
-
def
|
73
|
-
File.exists?(release_file)
|
55
|
+
def detected_by_etc_release?
|
56
|
+
release_file && File.exists?(release_file)
|
74
57
|
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class Generic < Distro
|
78
|
-
COMMANDS = {}
|
79
58
|
|
80
|
-
def
|
81
|
-
@
|
59
|
+
def command(name)
|
60
|
+
@path.collect { |dir| "#{dir}/#{name}" }.detect { |cmd| File.exists?(cmd) }
|
82
61
|
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class RedHat < Distro
|
86
|
-
COMMANDS = {:service => '/sbin/service',
|
87
|
-
:chkconfig => '/sbin/chkconfig',
|
88
|
-
:parted => '/sbin/parted',
|
89
|
-
:mount => '/bin/mount',
|
90
|
-
:umount => '/bin/umount',
|
91
|
-
:shutdown => '/sbin/shutdown',
|
92
|
-
:mke2fs => '/sbin/mke2fs',
|
93
|
-
:fdisk => '/sbin/fdisk',
|
94
|
-
:dd => '/bin/dd',
|
95
|
-
:vgdisplay => '/sbin/vgdisplay',
|
96
|
-
:pvdisplay => '/sbin/pvdisplay',
|
97
|
-
:lvdisplay => '/sbin/lvdisplay',
|
98
|
-
:lvextend => '/sbin/lvextend',
|
99
|
-
:vgextend => '/sbin/vgextend',
|
100
|
-
:lvcreate => '/sbin/lvcreate',
|
101
|
-
:pvcreate => '/sbin/pvcreate',
|
102
|
-
:vgcreate => '/sbin/vgcreate'}
|
103
|
-
|
104
|
-
def initialize
|
105
|
-
@id = :redhat
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
class RHEL < RedHat
|
110
|
-
RELEASE_FILE = "/etc/redhat-release"
|
111
|
-
ETC_ISSUE_KEYWORDS = ['red hat', 'Red Hat', 'centos', 'CentOS']
|
112
|
-
|
113
|
-
COMMANDS = COMMANDS.merge(
|
114
|
-
:rpm => '/bin/rpm'
|
115
|
-
)
|
116
|
-
def initialize
|
117
|
-
@id = :rhel
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
class Fedora < RedHat
|
122
|
-
RELEASE_FILE = "/etc/fedora-release"
|
123
|
-
ETC_ISSUE_KEYWORDS = ['Fedora']
|
124
|
-
|
125
|
-
COMMANDS = COMMANDS.merge(
|
126
|
-
:rpm => '/usr/bin/rpm'
|
127
|
-
)
|
128
|
-
def initialize
|
129
|
-
@id = :fedora
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
class Ubuntu < Distro
|
134
|
-
ETC_ISSUE_KEYWORDS = ['ubuntu']
|
135
|
-
|
136
|
-
COMMANDS = {}
|
137
62
|
|
138
|
-
def
|
139
|
-
|
63
|
+
def info(pkg)
|
64
|
+
info_class ? info_class.info(pkg) : nil
|
140
65
|
end
|
141
66
|
end
|
142
67
|
end
|
@@ -11,18 +11,16 @@ class LinuxAdmin
|
|
11
11
|
|
12
12
|
PATH = '/etc/issue'
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def include?(osname)
|
15
|
+
data.downcase.include?(osname.to_s.downcase)
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
@data.
|
18
|
+
def data
|
19
|
+
@data ||= File.exists?(PATH) ? File.read(PATH) : ""
|
20
20
|
end
|
21
21
|
|
22
|
-
private
|
23
|
-
|
24
22
|
def refresh
|
25
|
-
@data =
|
23
|
+
@data = nil
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
data/lib/linux_admin/rpm.rb
CHANGED
data/lib/linux_admin/version.rb
CHANGED
data/spec/common_spec.rb
CHANGED
@@ -1,24 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LinuxAdmin::Common do
|
4
|
-
|
5
|
-
class TestClass
|
6
|
-
extend LinuxAdmin::Common
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
after do
|
11
|
-
Object.send(:remove_const, :TestClass)
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { TestClass }
|
4
|
+
subject { Class.new { include LinuxAdmin::Common }.new }
|
15
5
|
|
16
6
|
context "#cmd" do
|
17
7
|
it "looks up local command from id" do
|
18
|
-
|
19
|
-
d.class::COMMANDS = {:sh => '/bin/sh'}
|
20
|
-
LinuxAdmin::Distros::Distro.should_receive(:local).and_return(d)
|
21
|
-
subject.cmd(:sh).should == '/bin/sh'
|
8
|
+
expect(subject.cmd(:dd)).to match(/bin\/dd/)
|
22
9
|
end
|
23
10
|
end
|
24
11
|
|
data/spec/disk_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe LinuxAdmin::Disk do
|
4
4
|
describe "#local" do
|
5
5
|
it "returns local disks" do
|
6
|
-
Dir.should_receive(:glob).with('/dev/[vhs]d[a-z]').
|
6
|
+
Dir.should_receive(:glob).with(['/dev/[vhs]d[a-z]', '/dev/xvd[a-z]']).
|
7
7
|
and_return(['/dev/hda', '/dev/sda'])
|
8
8
|
disks = LinuxAdmin::Disk.local
|
9
9
|
paths = disks.collect { |disk| disk.path }
|
@@ -138,13 +138,13 @@ eos
|
|
138
138
|
end
|
139
139
|
|
140
140
|
it "uses parted" do
|
141
|
-
params = ['--script', '/dev/hda', 'mkpart', '-a opt', 'primary', 1024, 2048]
|
141
|
+
params = ['--script', '/dev/hda', 'mkpart', '-a', 'opt', 'primary', 1024, 2048]
|
142
142
|
@disk.should_receive(:run!).with(@disk.cmd(:parted), :params => { nil => params })
|
143
143
|
@disk.create_partition 'primary', 1024
|
144
144
|
end
|
145
145
|
|
146
146
|
it "accepts start/end params" do
|
147
|
-
params = ['--script', '/dev/hda', 'mkpart', '-a opt', 'primary', "0%", "50%"]
|
147
|
+
params = ['--script', '/dev/hda', 'mkpart', '-a', 'opt', 'primary', "0%", "50%"]
|
148
148
|
@disk.should_receive(:run!).with(@disk.cmd(:parted), :params => { nil => params })
|
149
149
|
@disk.create_partition 'primary', "0%", "50%"
|
150
150
|
end
|
data/spec/distro_spec.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe LinuxAdmin::Distros::Distro do
|
4
|
+
let(:subject) { LinuxAdmin::Distros.local }
|
4
5
|
describe "#local" do
|
6
|
+
before do
|
7
|
+
LinuxAdmin::Distros.unstub(:local)
|
8
|
+
end
|
9
|
+
|
5
10
|
[['ubuntu', :ubuntu],
|
6
11
|
['Fedora', :fedora],
|
7
12
|
['red hat', :rhel],
|
@@ -9,45 +14,66 @@ describe LinuxAdmin::Distros::Distro do
|
|
9
14
|
['centos', :rhel]].each do |i, d|
|
10
15
|
context "/etc/issue contains '#{i}'" do
|
11
16
|
before(:each) do
|
12
|
-
|
13
|
-
|
17
|
+
etc_issue_contains(i)
|
18
|
+
exists("/etc/fedora-release" => false, "/etc/redhat-release" => false)
|
14
19
|
end
|
15
20
|
|
16
21
|
it "returns Distros.#{d}" do
|
17
22
|
distro = LinuxAdmin::Distros.send(d)
|
18
|
-
|
23
|
+
expect(subject).to eq(distro)
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
28
|
context "/etc/issue did not match" do
|
24
29
|
before(:each) do
|
25
|
-
|
30
|
+
etc_issue_contains('')
|
26
31
|
end
|
27
32
|
|
28
33
|
context "/etc/redhat-release exists" do
|
29
34
|
it "returns Distros.rhel" do
|
30
|
-
|
31
|
-
LinuxAdmin::Distros
|
32
|
-
File.should_receive(:exists?).at_least(:once).and_call_original
|
33
|
-
described_class.local.should == LinuxAdmin::Distros.rhel
|
35
|
+
exists("/etc/fedora-release" => false, "/etc/redhat-release" => true)
|
36
|
+
expect(subject).to eq(LinuxAdmin::Distros.rhel)
|
34
37
|
end
|
35
38
|
end
|
36
39
|
|
37
40
|
context "/etc/fedora-release exists" do
|
38
41
|
it "returns Distros.fedora" do
|
39
|
-
|
40
|
-
|
41
|
-
File.should_receive(:exists?).at_least(:once).and_call_original
|
42
|
-
described_class.local.should == LinuxAdmin::Distros.fedora
|
42
|
+
exists("/etc/fedora-release" => true, "/etc/redhat-release" => false)
|
43
|
+
expect(subject).to eq(LinuxAdmin::Distros.fedora)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
46
47
|
|
47
48
|
it "returns Distros.generic" do
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
etc_issue_contains('')
|
50
|
+
exists("/etc/fedora-release" => false, "/etc/redhat-release" => false)
|
51
|
+
expect(subject).to eq(LinuxAdmin::Distros.generic)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#info" do
|
56
|
+
it "dispatches to redhat lookup mechanism" do
|
57
|
+
stub_distro(LinuxAdmin::Distros.rhel)
|
58
|
+
expect(LinuxAdmin::Rpm).to receive(:info).with('ruby')
|
59
|
+
LinuxAdmin::Distros.local.info 'ruby'
|
60
|
+
end
|
61
|
+
|
62
|
+
it "dispatches to ubuntu lookup mechanism" do
|
63
|
+
stub_distro(LinuxAdmin::Distros.ubuntu)
|
64
|
+
expect(LinuxAdmin::Deb).to receive(:info).with('ruby')
|
65
|
+
LinuxAdmin::Distros.local.info 'ruby'
|
66
|
+
end
|
67
|
+
|
68
|
+
it "dispatches to ubuntu lookup mechanism" do
|
69
|
+
stub_distro(LinuxAdmin::Distros.generic)
|
70
|
+
expect { LinuxAdmin::Distros.local.info 'ruby' }.not_to raise_error
|
51
71
|
end
|
52
72
|
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def exists(files)
|
77
|
+
files.each_pair { |file, value| allow(File).to receive(:exists?).with(file).and_return(value) }
|
78
|
+
end
|
53
79
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe LinuxAdmin::EtcIssue do
|
5
|
+
subject { described_class.instance }
|
6
|
+
before do
|
7
|
+
# Reset the singleton so subsequent tests get a new instance
|
8
|
+
subject.refresh
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not find the phrase when the file is missing" do
|
12
|
+
expect(File).to receive(:exists?).with('/etc/issue').at_least(:once).and_return(false)
|
13
|
+
expect(subject).not_to include("phrase")
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not find phrase when the file is empty" do
|
17
|
+
etc_issue_contains("")
|
18
|
+
expect(subject).not_to include("phrase")
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should not find phrase when the file has a different phrase" do
|
22
|
+
etc_issue_contains("something\nelse")
|
23
|
+
expect(subject).not_to include("phrase")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should find phrase in same case" do
|
27
|
+
etc_issue_contains("phrase")
|
28
|
+
expect(subject).to include("phrase")
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should find upper phrase in file" do
|
32
|
+
etc_issue_contains("PHRASE\nother")
|
33
|
+
expect(subject).to include("phrase")
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should find phrase when searching with upper" do
|
37
|
+
etc_issue_contains("other\nphrase")
|
38
|
+
expect(subject).to include("PHRASE")
|
39
|
+
end
|
40
|
+
end
|
data/spec/logical_volume_spec.rb
CHANGED
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LinuxAdmin::LogicalVolume do
|
4
4
|
before(:each) do
|
5
|
-
LinuxAdmin::Distros::Distro.stub(:local => LinuxAdmin::Distros::Test.new)
|
6
|
-
|
7
5
|
@logical_volumes = <<eos
|
8
6
|
/dev/vg_foobar/lv_swap:vg_foobar:3:1:-1:2:4128768:63:-1:0:-1:253:0
|
9
7
|
/dev/vg_foobar/lv_root:vg_foobar:3:1:-1:1:19988480:305:-1:0:-1:253:1
|
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LinuxAdmin::PhysicalVolume do
|
4
4
|
before(:each) do
|
5
|
-
LinuxAdmin::Distros::Distro.stub(:local => LinuxAdmin::Distros::Test.new)
|
6
|
-
|
7
5
|
@physical_volumes = <<eos
|
8
6
|
/dev/vda2:vg_foobar:24139776:-1:8:8:-1:32768:368:0:368:pxR32D-YkC2-PfHe-zOwb-eaGD-9Ar0-mAOl9u
|
9
7
|
eos
|
data/spec/service_spec.rb
CHANGED
@@ -2,10 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LinuxAdmin::Service do
|
4
4
|
before(:each) do
|
5
|
-
# stub distro.local to return test distro for command lookup
|
6
|
-
LinuxAdmin::Distros::Distro.stub(:local)
|
7
|
-
.and_return(LinuxAdmin::Distros::Test.new)
|
8
|
-
|
9
5
|
@service = LinuxAdmin::Service.new 'foo'
|
10
6
|
end
|
11
7
|
|
data/spec/spec_helper.rb
CHANGED
@@ -17,13 +17,15 @@ RSpec.configure do |config|
|
|
17
17
|
|
18
18
|
config.before do
|
19
19
|
Kernel.stub(:spawn).and_raise("Spawning is not permitted in specs. Please change your spec to use expectations/stubs.")
|
20
|
+
# by default, have it say it is running Red Hat linux
|
21
|
+
stub_distro
|
20
22
|
end
|
21
23
|
|
22
24
|
config.after do
|
23
25
|
clear_caches
|
24
26
|
|
25
27
|
# reset the distro, tested in various placed & used extensively
|
26
|
-
LinuxAdmin::Distros
|
28
|
+
LinuxAdmin::Distros.instance_variable_set(:@local, nil)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
@@ -35,6 +37,16 @@ end
|
|
35
37
|
|
36
38
|
require 'linux_admin'
|
37
39
|
|
40
|
+
def etc_issue_contains(contents)
|
41
|
+
LinuxAdmin::EtcIssue.instance.send(:refresh)
|
42
|
+
allow(File).to receive(:exists?).with('/etc/issue').at_least(:once).and_return(true)
|
43
|
+
allow(File).to receive(:read).with('/etc/issue').at_least(:once).and_return(contents)
|
44
|
+
end
|
45
|
+
|
46
|
+
def stub_distro(distro = LinuxAdmin::Distros.rhel)
|
47
|
+
# simply alias test distro to redhat distro for time being
|
48
|
+
LinuxAdmin::Distros.stub(:local => distro)
|
49
|
+
end
|
38
50
|
|
39
51
|
def data_file_path(to)
|
40
52
|
File.expand_path(to, File.join(File.dirname(__FILE__), "data"))
|
@@ -47,10 +59,3 @@ end
|
|
47
59
|
def clear_caches
|
48
60
|
LinuxAdmin::RegistrationSystem.instance_variable_set(:@registration_type, nil)
|
49
61
|
end
|
50
|
-
|
51
|
-
class LinuxAdmin
|
52
|
-
module Distros
|
53
|
-
# simply alias test distro to redhat distro for time being
|
54
|
-
Distros::Test = Distros::RedHat
|
55
|
-
end
|
56
|
-
end
|
data/spec/volume_group_spec.rb
CHANGED
@@ -2,8 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LinuxAdmin::VolumeGroup do
|
4
4
|
before(:each) do
|
5
|
-
LinuxAdmin::Distros::Distro.stub(:local => LinuxAdmin::Distros::Test.new)
|
6
|
-
|
7
5
|
@groups = <<eos
|
8
6
|
vg_foobar:r/w:772:-1:0:2:2:-1:0:1:1:12058624:32768:368:368:0:tILZUF-IspH-H90I-pT5j-vVFl-b76L-zWx3CW
|
9
7
|
eos
|
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.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,10 +10,11 @@ authors:
|
|
10
10
|
- Mo Morsi
|
11
11
|
- Joe Rafaniello
|
12
12
|
- Keenan Brock
|
13
|
+
- Thomas Wiest
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
|
-
date: 2014-
|
17
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
17
18
|
dependencies:
|
18
19
|
- !ruby/object:Gem::Dependency
|
19
20
|
name: bundler
|
@@ -134,7 +135,7 @@ dependencies:
|
|
134
135
|
requirements:
|
135
136
|
- - ~>
|
136
137
|
- !ruby/object:Gem::Version
|
137
|
-
version: 1.
|
138
|
+
version: '1.2'
|
138
139
|
type: :runtime
|
139
140
|
prerelease: false
|
140
141
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -142,7 +143,7 @@ dependencies:
|
|
142
143
|
requirements:
|
143
144
|
- - ~>
|
144
145
|
- !ruby/object:Gem::Version
|
145
|
-
version: 1.
|
146
|
+
version: '1.2'
|
146
147
|
- !ruby/object:Gem::Dependency
|
147
148
|
name: nokogiri
|
148
149
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,6 +175,7 @@ email:
|
|
174
175
|
- mmorsi@redhat.com
|
175
176
|
- jrafanie@redhat.com
|
176
177
|
- kbrock@redhat.com
|
178
|
+
- twiest@redhat.com
|
177
179
|
executables: []
|
178
180
|
extensions: []
|
179
181
|
extra_rdoc_files: []
|
@@ -189,7 +191,6 @@ files:
|
|
189
191
|
- lib/linux_admin/hosts.rb
|
190
192
|
- lib/linux_admin/logical_volume.rb
|
191
193
|
- lib/linux_admin/mountable.rb
|
192
|
-
- lib/linux_admin/package.rb
|
193
194
|
- lib/linux_admin/partition.rb
|
194
195
|
- lib/linux_admin/physical_volume.rb
|
195
196
|
- lib/linux_admin/registration_system.rb
|
@@ -224,12 +225,12 @@ files:
|
|
224
225
|
- spec/deb_spec.rb
|
225
226
|
- spec/disk_spec.rb
|
226
227
|
- spec/distro_spec.rb
|
228
|
+
- spec/etc_issue_spec.rb
|
227
229
|
- spec/fstab_spec.rb
|
228
230
|
- spec/hosts_spec.rb
|
229
231
|
- spec/linux_admin_spec.rb
|
230
232
|
- spec/logical_volume_spec.rb
|
231
233
|
- spec/mountable_spec.rb
|
232
|
-
- spec/package_spec.rb
|
233
234
|
- spec/partition_spec.rb
|
234
235
|
- spec/physical_volume_spec.rb
|
235
236
|
- spec/registration_system_spec.rb
|
@@ -262,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
263
|
version: '0'
|
263
264
|
requirements: []
|
264
265
|
rubyforge_project:
|
265
|
-
rubygems_version: 1.8.23
|
266
|
+
rubygems_version: 1.8.23.2
|
266
267
|
signing_key:
|
267
268
|
specification_version: 3
|
268
269
|
summary: LinuxAdmin is a module to simplify management of linux systems.
|
@@ -286,12 +287,12 @@ test_files:
|
|
286
287
|
- spec/deb_spec.rb
|
287
288
|
- spec/disk_spec.rb
|
288
289
|
- spec/distro_spec.rb
|
290
|
+
- spec/etc_issue_spec.rb
|
289
291
|
- spec/fstab_spec.rb
|
290
292
|
- spec/hosts_spec.rb
|
291
293
|
- spec/linux_admin_spec.rb
|
292
294
|
- spec/logical_volume_spec.rb
|
293
295
|
- spec/mountable_spec.rb
|
294
|
-
- spec/package_spec.rb
|
295
296
|
- spec/partition_spec.rb
|
296
297
|
- spec/physical_volume_spec.rb
|
297
298
|
- spec/registration_system_spec.rb
|
data/lib/linux_admin/package.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# LinuxAdmin Abstract Package Representation
|
2
|
-
#
|
3
|
-
# Copyright (C) 2013 Red Hat Inc.
|
4
|
-
# Licensed under the MIT License
|
5
|
-
|
6
|
-
class LinuxAdmin
|
7
|
-
class Package < LinuxAdmin
|
8
|
-
def self.info(pkg)
|
9
|
-
if Distros::Distro.local == Distros.redhat
|
10
|
-
return Rpm.info(pkg)
|
11
|
-
elsif Distros::Distro.local == Distros.ubuntu
|
12
|
-
return Deb.info(pkg)
|
13
|
-
end
|
14
|
-
|
15
|
-
nil
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/spec/package_spec.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe LinuxAdmin::Package do
|
4
|
-
describe "#info" do
|
5
|
-
it "dispatches to redhat lookup mechanism" do
|
6
|
-
LinuxAdmin::Distros::Distro.should_receive(:local).and_return(LinuxAdmin::Distros.redhat)
|
7
|
-
LinuxAdmin::Rpm.should_receive(:info).with('ruby')
|
8
|
-
described_class.info 'ruby'
|
9
|
-
end
|
10
|
-
|
11
|
-
it "dispatches to ubuntu lookup mechanism" do
|
12
|
-
LinuxAdmin::Distros::Distro.should_receive(:local).twice.and_return(LinuxAdmin::Distros.ubuntu)
|
13
|
-
LinuxAdmin::Deb.should_receive(:info).with('ruby')
|
14
|
-
described_class.info 'ruby'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|