linux_admin 0.5.4 → 0.5.5
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.
- checksums.yaml +8 -8
- data/lib/linux_admin/fstab.rb +50 -12
- data/lib/linux_admin/logical_volume.rb +6 -0
- data/lib/linux_admin/mountable.rb +47 -0
- data/lib/linux_admin/partition.rb +4 -20
- data/lib/linux_admin/registration_system/rhn.rb +1 -0
- data/lib/linux_admin/version.rb +1 -1
- data/lib/linux_admin.rb +1 -0
- data/spec/fstab_spec.rb +25 -17
- data/spec/logical_volume_spec.rb +8 -0
- data/spec/mountable_spec.rb +130 -0
- data/spec/partition_spec.rb +6 -47
- data/spec/rhn_spec.rb +2 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzkxZDkxZDkxMDNiNzlkMTkxNDY2MDExZDVlNzgwZGU3YTMyNDhkOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzQyODliMjBlMzMwMzY0NGM2YmI5YjdhYWYyYzNmMjgwNzJjYTExNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjZhZjg4NjczY2I3NGIxNjExNTI0Y2EwZDY5ZjNiMjE0ODcxZmU3NzkwM2Nj
|
10
|
+
NWMyMWI0NTAxNzA4N2FmNmJmNmM2NmFmMWJhNTgzODVlOGRjMzk0MDNhZDhi
|
11
|
+
YmE4ZDk5ZTNlZTgwMDI3OGM2MmQ4ZjBjOWYxODRkZDUwMzAzYTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGVkMmEzNjAxNTQ4ZTZmZTQ1YjVjMDMxMjZmYzI2NDA4N2RiMDllYzdlZmU5
|
14
|
+
MzI3YzU3MTQ0ZWQ0ZWVjZDEwY2I0NDQ3Y2IyOGM3NTk5MjhlYWRhZmJkMmY3
|
15
|
+
MDFjODIzMzJlODA4OTg1MDI3MGIyZjY4ZmI4NmFmMDljNTg5NGE=
|
data/lib/linux_admin/fstab.rb
CHANGED
@@ -13,25 +13,48 @@ class LinuxAdmin
|
|
13
13
|
attr_accessor :mount_options
|
14
14
|
attr_accessor :dumpable
|
15
15
|
attr_accessor :fsck_order
|
16
|
+
attr_accessor :comment
|
16
17
|
|
17
18
|
def initialize(args = {})
|
18
19
|
@device = args[:device]
|
19
20
|
@mount_point = args[:mount_point]
|
20
21
|
@fs_type = args[:fs_type]
|
21
22
|
@mount_options = args[:mount_options]
|
22
|
-
@dumpable = args[:dumpable]
|
23
|
-
@fsck_order = args[:fsck_order]
|
23
|
+
@dumpable = args[:dumpable].to_i unless args[:dumpable].nil?
|
24
|
+
@fsck_order = args[:fsck_order].to_i unless args[:fsck_order].nil?
|
25
|
+
@comment = args[:comment]
|
24
26
|
end
|
25
27
|
|
26
28
|
def self.from_line(fstab_line)
|
27
|
-
columns = fstab_line.
|
29
|
+
columns, comment = fstab_line.split('#')
|
30
|
+
comment = "##{comment}" unless comment.blank?
|
31
|
+
columns = columns.chomp.split
|
32
|
+
|
28
33
|
FSTabEntry.new :device => columns[0],
|
29
34
|
:mount_point => columns[1],
|
30
35
|
:fs_type => columns[2],
|
31
36
|
:mount_options => columns[3],
|
32
|
-
:dumpable => columns[4]
|
33
|
-
:fsck_order => columns[5]
|
34
|
-
|
37
|
+
:dumpable => columns[4],
|
38
|
+
:fsck_order => columns[5],
|
39
|
+
:comment => comment
|
40
|
+
end
|
41
|
+
|
42
|
+
def has_content?
|
43
|
+
!self.columns.first.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
def columns
|
47
|
+
[self.device, self.mount_point, self.fs_type,
|
48
|
+
self.mount_options, self.dumpable, self.fsck_order, self.comment]
|
49
|
+
end
|
50
|
+
|
51
|
+
def column_lengths
|
52
|
+
self.columns.collect { |c| c ? c.size : 0 }
|
53
|
+
end
|
54
|
+
|
55
|
+
def formatted_columns(max_lengths)
|
56
|
+
self.columns.collect.
|
57
|
+
with_index { |col, i| col.to_s.rjust(max_lengths[i]) }.join(" ")
|
35
58
|
end
|
36
59
|
end
|
37
60
|
|
@@ -39,6 +62,7 @@ class LinuxAdmin
|
|
39
62
|
include Singleton
|
40
63
|
|
41
64
|
attr_accessor :entries
|
65
|
+
attr_accessor :maximum_column_lengths
|
42
66
|
|
43
67
|
def initialize
|
44
68
|
refresh
|
@@ -46,9 +70,15 @@ class LinuxAdmin
|
|
46
70
|
|
47
71
|
def write!
|
48
72
|
content = ''
|
73
|
+
comment_index = 0
|
49
74
|
@entries.each do |entry|
|
50
|
-
|
75
|
+
if entry.has_content?
|
76
|
+
content << entry.formatted_columns(@maximum_column_lengths) << "\n"
|
77
|
+
else
|
78
|
+
content << "#{entry.comment}"
|
79
|
+
end
|
51
80
|
end
|
81
|
+
|
52
82
|
File.write('/etc/fstab', content)
|
53
83
|
self
|
54
84
|
end
|
@@ -56,14 +86,22 @@ class LinuxAdmin
|
|
56
86
|
private
|
57
87
|
|
58
88
|
def read
|
59
|
-
File.read('/etc/fstab').lines
|
89
|
+
File.read('/etc/fstab').lines
|
60
90
|
end
|
61
91
|
|
62
92
|
def refresh
|
63
|
-
@entries
|
64
|
-
|
65
|
-
|
66
|
-
|
93
|
+
@entries = []
|
94
|
+
@maximum_column_lengths = Array.new(7, 0) # # of columns
|
95
|
+
read.each do |line|
|
96
|
+
entry = FSTabEntry.from_line(line)
|
97
|
+
@entries << entry
|
98
|
+
|
99
|
+
lengths = entry.column_lengths
|
100
|
+
lengths.each_index do |i|
|
101
|
+
@maximum_column_lengths[i] =
|
102
|
+
lengths[i] if lengths[i] > @maximum_column_lengths[i]
|
103
|
+
end
|
104
|
+
end
|
67
105
|
end
|
68
106
|
end
|
69
107
|
end
|
@@ -7,6 +7,8 @@ require 'pathname'
|
|
7
7
|
|
8
8
|
class LinuxAdmin
|
9
9
|
class LogicalVolume < Volume
|
10
|
+
include Mountable
|
11
|
+
|
10
12
|
DEVICE_PATH = Pathname.new('/dev/')
|
11
13
|
|
12
14
|
# path to logical volume
|
@@ -55,6 +57,10 @@ class LinuxAdmin
|
|
55
57
|
self
|
56
58
|
end
|
57
59
|
|
60
|
+
def path
|
61
|
+
"/dev/#{self.volume_group.name}/#{self.name}"
|
62
|
+
end
|
63
|
+
|
58
64
|
private
|
59
65
|
|
60
66
|
def self.bytes_to_string(bytes)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# LinuxAdmin Mountable Disk Mixin
|
2
|
+
#
|
3
|
+
# Copyright (C) 2013 Red Hat Inc.
|
4
|
+
# Licensed under the MIT License
|
5
|
+
|
6
|
+
class LinuxAdmin
|
7
|
+
module Mountable
|
8
|
+
attr_accessor :fs_type
|
9
|
+
attr_accessor :mount_point
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def mount_point_exists?(mount_point)
|
13
|
+
result = self.run!(cmd(:mount))
|
14
|
+
result.output.split("\n").any? { |line| line.split[2] == mount_point }
|
15
|
+
end
|
16
|
+
|
17
|
+
def mount_point_available?(mount_point)
|
18
|
+
!mount_point_exists?(mount_point)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.included(base)
|
23
|
+
base.extend(ClassMethods)
|
24
|
+
end
|
25
|
+
|
26
|
+
def format_to(filesystem)
|
27
|
+
run!(cmd(:mke2fs),
|
28
|
+
:params => { '-t' => filesystem, nil => self.path})
|
29
|
+
@fs_type = filesystem
|
30
|
+
end
|
31
|
+
|
32
|
+
def mount(mount_point)
|
33
|
+
FileUtils.mkdir(mount_point) unless File.directory?(mount_point)
|
34
|
+
|
35
|
+
if self.class.mount_point_exists?(mount_point)
|
36
|
+
raise ArgumentError, "disk already mounted at #{mount_point}"
|
37
|
+
end
|
38
|
+
|
39
|
+
run!(cmd(:mount), :params => { nil => [self.path, mount_point] })
|
40
|
+
@mount_point = mount_point
|
41
|
+
end
|
42
|
+
|
43
|
+
def umount
|
44
|
+
run!(cmd(:umount), :params => { nil => [@mount_point] })
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -7,14 +7,14 @@ require 'fileutils'
|
|
7
7
|
|
8
8
|
class LinuxAdmin
|
9
9
|
class Partition < LinuxAdmin
|
10
|
+
include Mountable
|
11
|
+
|
10
12
|
attr_accessor :id
|
11
13
|
attr_accessor :partition_type
|
12
|
-
attr_accessor :fs_type
|
13
14
|
attr_accessor :start_sector
|
14
15
|
attr_accessor :end_sector
|
15
16
|
attr_accessor :size
|
16
17
|
attr_accessor :disk
|
17
|
-
attr_accessor :mount_point
|
18
18
|
|
19
19
|
def initialize(args={})
|
20
20
|
@id = args[:id]
|
@@ -30,25 +30,9 @@ class LinuxAdmin
|
|
30
30
|
"#{disk.path}#{id}"
|
31
31
|
end
|
32
32
|
|
33
|
-
def format_to(filesystem)
|
34
|
-
run!(cmd(:mke2fs),
|
35
|
-
:params => { '-t' => filesystem, nil => self.path})
|
36
|
-
@fs_type = filesystem
|
37
|
-
end
|
38
|
-
|
39
33
|
def mount(mount_point=nil)
|
40
|
-
|
41
|
-
|
42
|
-
"/mnt/#{disk.path.split(File::SEPARATOR).last}#{id}" if mount_point.nil?
|
43
|
-
FileUtils.mkdir(@mount_point) unless File.directory?(@mount_point)
|
44
|
-
|
45
|
-
run!(cmd(:mount),
|
46
|
-
:params => { nil => [self.path, @mount_point] })
|
47
|
-
end
|
48
|
-
|
49
|
-
def umount
|
50
|
-
run!(cmd(:umount),
|
51
|
-
:params => { nil => [@mount_point] })
|
34
|
+
mount_point ||= "/mnt/#{disk.path.split(File::SEPARATOR).last}#{id}"
|
35
|
+
super(mount_point)
|
52
36
|
end
|
53
37
|
end
|
54
38
|
end
|
@@ -33,6 +33,7 @@ class LinuxAdmin
|
|
33
33
|
params["--proxyPassword="] = options[:proxy_password] if options[:proxy_password]
|
34
34
|
params["--serverUrl="] = options[:server_url] if options[:server_url]
|
35
35
|
params["--systemorgid="] = options[:org] if options[:server_url] && options[:org]
|
36
|
+
params["--sslCACert="] = options[:server_cert] if options[:server_cert]
|
36
37
|
|
37
38
|
run!(cmd, :params => params)
|
38
39
|
end
|
data/lib/linux_admin/version.rb
CHANGED
data/lib/linux_admin.rb
CHANGED
data/spec/fstab_spec.rb
CHANGED
@@ -7,14 +7,15 @@ describe LinuxAdmin::FSTab do
|
|
7
7
|
Singleton.send :__init__, LinuxAdmin::FSTab
|
8
8
|
end
|
9
9
|
|
10
|
-
it "newline, single spaces, tab" do
|
10
|
+
it "has newline, single spaces, tab" do
|
11
11
|
fstab = <<eos
|
12
12
|
|
13
13
|
|
14
14
|
|
15
15
|
eos
|
16
16
|
File.should_receive(:read).with('/etc/fstab').and_return(fstab)
|
17
|
-
LinuxAdmin::FSTab.instance.entries.size.should ==
|
17
|
+
LinuxAdmin::FSTab.instance.entries.size.should == 3
|
18
|
+
LinuxAdmin::FSTab.instance.entries.any? { |e| e.has_content? }.should be_false
|
18
19
|
end
|
19
20
|
|
20
21
|
it "creates FSTabEntry for each line in fstab" do
|
@@ -22,26 +23,31 @@ eos
|
|
22
23
|
# Comment, indented comment, comment with device information
|
23
24
|
# /dev/sda1 / ext4 defaults 1 1
|
24
25
|
# /dev/sda1 / ext4 defaults 1 1
|
26
|
+
|
25
27
|
/dev/sda1 / ext4 defaults 1 1
|
26
28
|
/dev/sda2 swap swap defaults 0 0
|
27
29
|
eos
|
28
30
|
File.should_receive(:read).with('/etc/fstab').and_return(fstab)
|
29
31
|
entries = LinuxAdmin::FSTab.instance.entries
|
30
|
-
entries.size.should ==
|
32
|
+
entries.size.should == 6
|
31
33
|
|
32
|
-
entries[0].
|
33
|
-
entries[
|
34
|
-
entries[
|
35
|
-
entries[
|
36
|
-
entries[
|
37
|
-
entries[
|
34
|
+
entries[0].comment.should == "# Comment, indented comment, comment with device information\n"
|
35
|
+
entries[1].comment.should == "# /dev/sda1 / ext4 defaults 1 1\n"
|
36
|
+
entries[2].comment.should == "# /dev/sda1 / ext4 defaults 1 1\n"
|
37
|
+
entries[3].comment.should == nil
|
38
|
+
entries[4].device.should == '/dev/sda1'
|
39
|
+
entries[4].mount_point.should == '/'
|
40
|
+
entries[4].fs_type.should == 'ext4'
|
41
|
+
entries[4].mount_options.should == 'defaults'
|
42
|
+
entries[4].dumpable.should == 1
|
43
|
+
entries[4].fsck_order.should == 1
|
38
44
|
|
39
|
-
entries[
|
40
|
-
entries[
|
41
|
-
entries[
|
42
|
-
entries[
|
43
|
-
entries[
|
44
|
-
entries[
|
45
|
+
entries[5].device.should == '/dev/sda2'
|
46
|
+
entries[5].mount_point.should == 'swap'
|
47
|
+
entries[5].fs_type.should == 'swap'
|
48
|
+
entries[5].mount_options.should == 'defaults'
|
49
|
+
entries[5].dumpable.should == 0
|
50
|
+
entries[5].fsck_order.should == 0
|
45
51
|
end
|
46
52
|
|
47
53
|
describe "#write!" do
|
@@ -54,10 +60,12 @@ eos
|
|
54
60
|
entry.mount_options = 'defaults'
|
55
61
|
entry.dumpable = 1
|
56
62
|
entry.fsck_order = 1
|
63
|
+
entry.comment = "# more"
|
57
64
|
LinuxAdmin::FSTab.any_instance.stub(:refresh) # don't read /etc/fstab
|
58
|
-
LinuxAdmin::FSTab.instance.
|
65
|
+
LinuxAdmin::FSTab.instance.maximum_column_lengths = [9, 1, 4, 8, 1, 1, 1]
|
66
|
+
LinuxAdmin::FSTab.instance.entries = [entry]
|
59
67
|
|
60
|
-
File.should_receive(:write).with('/etc/fstab', "/dev/sda1 / ext4 defaults 1 1\n")
|
68
|
+
File.should_receive(:write).with('/etc/fstab', "/dev/sda1 / ext4 defaults 1 1 # more\n")
|
61
69
|
LinuxAdmin::FSTab.instance.write!
|
62
70
|
end
|
63
71
|
end
|
data/spec/logical_volume_spec.rb
CHANGED
@@ -39,6 +39,14 @@ eos
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
describe "#path" do
|
43
|
+
it "returns /dev/vgname/lvname" do
|
44
|
+
vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
|
45
|
+
lv = described_class.new :name => 'lv', :volume_group => vg
|
46
|
+
lv.path.should == '/dev/vg/lv'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
describe "#create" do
|
43
51
|
before(:each) do
|
44
52
|
@vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestMountable < LinuxAdmin
|
4
|
+
include LinuxAdmin::Mountable
|
5
|
+
|
6
|
+
def path
|
7
|
+
"/dev/foo"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe LinuxAdmin::Mountable do
|
12
|
+
before(:each) do
|
13
|
+
@mountable = TestMountable.new
|
14
|
+
|
15
|
+
# stub out calls that modify system
|
16
|
+
FileUtils.stub(:mkdir)
|
17
|
+
@mountable.stub(:run!)
|
18
|
+
|
19
|
+
@mount_out1 = <<eos
|
20
|
+
/dev/sda on /mnt/usb type vfat (rw)
|
21
|
+
eos
|
22
|
+
@mount_out2 = <<eos
|
23
|
+
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
|
24
|
+
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=26,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
|
25
|
+
eos
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#mount_point_exists?" do
|
29
|
+
it "uses mount" do
|
30
|
+
TestMountable.should_receive(:run!).with(TestMountable.cmd(:mount)).and_return(CommandResult.new("", "", "", 0))
|
31
|
+
TestMountable.mount_point_exists?('/mnt/usb')
|
32
|
+
end
|
33
|
+
|
34
|
+
context "disk mounted at specified location" do
|
35
|
+
it "returns true" do
|
36
|
+
TestMountable.should_receive(:run!).and_return(CommandResult.new("", @mount_out1, "", 0))
|
37
|
+
TestMountable.mount_point_exists?('/mnt/usb').should be_true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "no disk mounted at specified location" do
|
42
|
+
it "returns false" do
|
43
|
+
TestMountable.should_receive(:run!).and_return(CommandResult.new("", @mount_out2, "", 0))
|
44
|
+
TestMountable.mount_point_exists?('/mnt/usb').should be_false
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#mount_point_available?" do
|
50
|
+
it "uses mount" do
|
51
|
+
TestMountable.should_receive(:run!).with(TestMountable.cmd(:mount)).and_return(CommandResult.new("", "", "", 0))
|
52
|
+
TestMountable.mount_point_available?('/mnt/usb')
|
53
|
+
end
|
54
|
+
|
55
|
+
context "disk mounted at specified location" do
|
56
|
+
it "returns false" do
|
57
|
+
TestMountable.should_receive(:run!).and_return(CommandResult.new("", @mount_out1, "", 0))
|
58
|
+
TestMountable.mount_point_available?('/mnt/usb').should be_false
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "no disk mounted at specified location" do
|
63
|
+
it "returns true" do
|
64
|
+
TestMountable.should_receive(:run!).and_return(CommandResult.new("", @mount_out2, "", 0))
|
65
|
+
TestMountable.mount_point_available?('/mnt/usb').should be_true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#format_to" do
|
71
|
+
it "uses mke2fs" do
|
72
|
+
@mountable.should_receive(:run!).
|
73
|
+
with(@mountable.cmd(:mke2fs),
|
74
|
+
:params => { '-t' => 'ext4', nil => '/dev/foo'})
|
75
|
+
@mountable.format_to('ext4')
|
76
|
+
end
|
77
|
+
|
78
|
+
it "sets fs type" do
|
79
|
+
@mountable.should_receive(:run!) # ignore actual formatting cmd
|
80
|
+
@mountable.format_to('ext4')
|
81
|
+
@mountable.fs_type.should == 'ext4'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "#mount" do
|
86
|
+
it "sets mount point" do
|
87
|
+
# ignore actual mount cmds
|
88
|
+
@mountable.should_receive(:run!).and_return(CommandResult.new("", "", "", ""))
|
89
|
+
TestMountable.should_receive(:run!).and_return(CommandResult.new("", "", "", ""))
|
90
|
+
|
91
|
+
@mountable.mount('/mnt/sda2').should == '/mnt/sda2'
|
92
|
+
@mountable.mount_point.should == '/mnt/sda2'
|
93
|
+
end
|
94
|
+
|
95
|
+
context "mountpoint does not exist" do
|
96
|
+
it "creates mountpoint" do
|
97
|
+
TestMountable.should_receive(:mount_point_exists?).and_return(false)
|
98
|
+
File.should_receive(:directory?).with('/mnt/sda2').and_return(false)
|
99
|
+
FileUtils.should_receive(:mkdir).with('/mnt/sda2')
|
100
|
+
@mountable.should_receive(:run!) # ignore actual mount cmd
|
101
|
+
@mountable.mount '/mnt/sda2'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
context "disk mounted at mountpoint" do
|
106
|
+
it "raises argument error" do
|
107
|
+
TestMountable.should_receive(:mount_point_exists?).and_return(true)
|
108
|
+
File.should_receive(:directory?).with('/mnt/sda2').and_return(true)
|
109
|
+
expect { @mountable.mount '/mnt/sda2' }.to raise_error(ArgumentError, "disk already mounted at /mnt/sda2")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
it "mounts partition" do
|
114
|
+
TestMountable.should_receive(:mount_point_exists?).and_return(false)
|
115
|
+
@mountable.should_receive(:run!).
|
116
|
+
with(@mountable.cmd(:mount),
|
117
|
+
:params => { nil => ['/dev/foo', '/mnt/sda2']})
|
118
|
+
@mountable.mount '/mnt/sda2'
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "#umount" do
|
123
|
+
it "unmounts partition" do
|
124
|
+
@mountable.mount_point = '/mnt/sda2'
|
125
|
+
@mountable.should_receive(:run!).with(@mountable.cmd(:umount), :params => { nil => ['/mnt/sda2']})
|
126
|
+
@mountable.umount
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
data/spec/partition_spec.rb
CHANGED
@@ -4,10 +4,6 @@ describe LinuxAdmin::Partition do
|
|
4
4
|
before(:each) do
|
5
5
|
@disk = LinuxAdmin::Disk.new :path => '/dev/sda'
|
6
6
|
@partition = LinuxAdmin::Partition.new :disk => @disk, :id => 2
|
7
|
-
|
8
|
-
# stub out calls that modify system
|
9
|
-
FileUtils.stub(:mkdir)
|
10
|
-
@partition.stub(:run!)
|
11
7
|
end
|
12
8
|
|
13
9
|
describe "#path" do
|
@@ -16,52 +12,15 @@ describe LinuxAdmin::Partition do
|
|
16
12
|
end
|
17
13
|
end
|
18
14
|
|
19
|
-
describe "#format_to" do
|
20
|
-
it "uses mke2fs" do
|
21
|
-
@partition.should_receive(:run!).
|
22
|
-
with(@partition.cmd(:mke2fs),
|
23
|
-
:params => { '-t' => 'ext4', nil => '/dev/sda2'})
|
24
|
-
@partition.format_to('ext4')
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets fs type" do
|
28
|
-
@partition.should_receive(:run!) # ignore actual formatting cmd
|
29
|
-
@partition.format_to('ext4')
|
30
|
-
@partition.fs_type.should == 'ext4'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
15
|
describe "#mount" do
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
context "mountpoint does not exist" do
|
42
|
-
it "creates mountpoint" do
|
43
|
-
File.should_receive(:directory?).with('/mnt/sda2').and_return(false)
|
44
|
-
FileUtils.should_receive(:mkdir).with('/mnt/sda2')
|
45
|
-
@partition.should_receive(:run!) # ignore actual mount cmd
|
16
|
+
context "mount_point not specified" do
|
17
|
+
it "sets default mount_point" do
|
18
|
+
described_class.should_receive(:mount_point_exists?).and_return(false)
|
19
|
+
File.should_receive(:directory?).with('/mnt/sda2').and_return(true)
|
20
|
+
@partition.should_receive(:run!)
|
46
21
|
@partition.mount
|
22
|
+
@partition.mount_point.should == '/mnt/sda2'
|
47
23
|
end
|
48
24
|
end
|
49
|
-
|
50
|
-
it "mounts partition" do
|
51
|
-
@partition.should_receive(:run!).
|
52
|
-
with(@partition.cmd(:mount),
|
53
|
-
:params => { nil => ['/dev/sda2', '/mnt/sda2']})
|
54
|
-
@partition.mount
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "#umount" do
|
59
|
-
it "unmounts partition" do
|
60
|
-
@partition.mount_point = '/mnt/sda2'
|
61
|
-
@partition.should_receive(:run!).
|
62
|
-
with(@partition.cmd(:umount),
|
63
|
-
:params => { nil => ['/mnt/sda2']})
|
64
|
-
@partition.umount
|
65
|
-
end
|
66
25
|
end
|
67
26
|
end
|
data/spec/rhn_spec.rb
CHANGED
@@ -30,9 +30,10 @@ describe LinuxAdmin::Rhn do
|
|
30
30
|
:proxy_address => "1.2.3.4",
|
31
31
|
:proxy_username => "ProxyUser",
|
32
32
|
:proxy_password => "ProxyPass",
|
33
|
+
:server_cert => "/path/to/cert",
|
33
34
|
}
|
34
35
|
}
|
35
|
-
let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass"}} }
|
36
|
+
let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--sslCACert="=>"/path/to/cert"}} }
|
36
37
|
|
37
38
|
it "with server_url" do
|
38
39
|
run_params.store_path(:params, "--systemorgid=", "2")
|
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.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brandon Dunne
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -160,6 +160,7 @@ files:
|
|
160
160
|
- lib/linux_admin/fstab.rb
|
161
161
|
- lib/linux_admin/hosts.rb
|
162
162
|
- lib/linux_admin/logical_volume.rb
|
163
|
+
- lib/linux_admin/mountable.rb
|
163
164
|
- lib/linux_admin/package.rb
|
164
165
|
- lib/linux_admin/partition.rb
|
165
166
|
- lib/linux_admin/physical_volume.rb
|
@@ -197,6 +198,7 @@ files:
|
|
197
198
|
- spec/hosts_spec.rb
|
198
199
|
- spec/linux_admin_spec.rb
|
199
200
|
- spec/logical_volume_spec.rb
|
201
|
+
- spec/mountable_spec.rb
|
200
202
|
- spec/package_spec.rb
|
201
203
|
- spec/partition_spec.rb
|
202
204
|
- spec/physical_volume_spec.rb
|
@@ -256,6 +258,7 @@ test_files:
|
|
256
258
|
- spec/hosts_spec.rb
|
257
259
|
- spec/linux_admin_spec.rb
|
258
260
|
- spec/logical_volume_spec.rb
|
261
|
+
- spec/mountable_spec.rb
|
259
262
|
- spec/package_spec.rb
|
260
263
|
- spec/partition_spec.rb
|
261
264
|
- spec/physical_volume_spec.rb
|