linux_admin 1.2.1 → 2.0.1
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 +4 -4
- data/README.md +1 -1
- data/lib/linux_admin.rb +0 -8
- data/lib/linux_admin/chrony.rb +1 -0
- data/lib/linux_admin/disk.rb +31 -7
- data/lib/linux_admin/fstab.rb +29 -14
- data/lib/linux_admin/partition.rb +1 -1
- data/lib/linux_admin/registration_system.rb +8 -4
- data/lib/linux_admin/scap.rb +1 -1
- data/lib/linux_admin/service/sys_v_init_service.rb +2 -1
- data/lib/linux_admin/service/systemd_service.rb +6 -2
- data/lib/linux_admin/version.rb +1 -1
- metadata +36 -120
- data/lib/linux_admin/registration_system/rhn.rb +0 -111
- data/spec/chrony_spec.rb +0 -64
- data/spec/common_spec.rb +0 -37
- data/spec/data/rhn/output_rhn-channel_list +0 -2
- data/spec/data/rhn/output_rhn-channel_list_available +0 -4
- data/spec/data/rhn/systemid +0 -57
- data/spec/data/rhn/systemid.missing_system_id +0 -57
- data/spec/data/rpm/cmd_output_for_list_installed +0 -20
- data/spec/data/subscription_manager/output_list_all_available +0 -42
- data/spec/data/subscription_manager/output_list_installed_not_subscribed +0 -19
- data/spec/data/subscription_manager/output_list_installed_subscribed +0 -19
- data/spec/data/subscription_manager/output_orgs +0 -6
- data/spec/data/subscription_manager/output_repos +0 -18
- data/spec/data/time_date/timedatectl_output +0 -14
- data/spec/data/yum/first.repo +0 -19
- data/spec/data/yum/output_repo_list +0 -13
- data/spec/data/yum/output_repoquery_multiple +0 -3
- data/spec/data/yum/output_repoquery_single +0 -1
- data/spec/data/yum/second.repo +0 -9
- data/spec/deb_spec.rb +0 -52
- data/spec/disk_spec.rb +0 -244
- data/spec/distro_spec.rb +0 -77
- data/spec/dns_spec.rb +0 -105
- data/spec/etc_issue_spec.rb +0 -37
- data/spec/fstab_spec.rb +0 -66
- data/spec/hardware_spec.rb +0 -46
- data/spec/hosts_spec.rb +0 -150
- data/spec/ip_address_spec.rb +0 -148
- data/spec/logical_volume_spec.rb +0 -166
- data/spec/mountable_spec.rb +0 -182
- data/spec/network_interface/network_interface_rh_spec.rb +0 -291
- data/spec/network_interface_spec.rb +0 -284
- data/spec/partition_spec.rb +0 -24
- data/spec/physical_volume_spec.rb +0 -101
- data/spec/registration_system_spec.rb +0 -85
- data/spec/rhn_spec.rb +0 -144
- data/spec/rpm_spec.rb +0 -85
- data/spec/scap_spec.rb +0 -48
- data/spec/service/sys_v_init_service_spec.rb +0 -127
- data/spec/service/systemd_service_spec.rb +0 -133
- data/spec/service_spec.rb +0 -54
- data/spec/spec_helper.rb +0 -116
- data/spec/ssh_spec.rb +0 -53
- data/spec/subscription_manager_spec.rb +0 -228
- data/spec/system_spec.rb +0 -15
- data/spec/time_date_spec.rb +0 -106
- data/spec/volume_group_spec.rb +0 -99
- data/spec/yum_spec.rb +0 -155
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'nokogiri'
|
2
|
-
|
3
|
-
module LinuxAdmin
|
4
|
-
class Rhn < RegistrationSystem
|
5
|
-
SATELLITE5_SERVER_CERT_PATH = "pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm"
|
6
|
-
INSTALLED_SERVER_CERT_PATH = "/usr/share/rhn/RHN-ORG-TRUSTED-SSL-CERT"
|
7
|
-
|
8
|
-
def initialize
|
9
|
-
warn("[DEPRECATION] 'LinuxAdmin::Rhn' is deprecated. Please use 'LinuxAdmin::SubscriptionManager' instead.")
|
10
|
-
end
|
11
|
-
|
12
|
-
def registered?(_options = nil)
|
13
|
-
id = ""
|
14
|
-
if File.exist?(systemid_file)
|
15
|
-
xml = Nokogiri.XML(File.read(systemid_file))
|
16
|
-
id = xml.xpath('/params/param/value/struct/member[name="system_id"]/value/string').text
|
17
|
-
end
|
18
|
-
id.length > 0
|
19
|
-
end
|
20
|
-
|
21
|
-
def register(options)
|
22
|
-
cmd = "rhnreg_ks"
|
23
|
-
params = {}
|
24
|
-
|
25
|
-
if options[:activationkey]
|
26
|
-
params["--activationkey="] = options[:activationkey]
|
27
|
-
elsif options[:username] && options[:password]
|
28
|
-
params["--username="] = options[:username]
|
29
|
-
params["--password="] = options[:password]
|
30
|
-
else
|
31
|
-
raise ArgumentError, "activation key or username and password are required"
|
32
|
-
end
|
33
|
-
|
34
|
-
install_server_certificate(options[:server_url], SATELLITE5_SERVER_CERT_PATH) if options[:server_url]
|
35
|
-
certificate_installed = LinuxAdmin::Rpm.list_installed["rhn-org-trusted-ssl-cert"]
|
36
|
-
|
37
|
-
params["--proxy="] = options[:proxy_address] if options[:proxy_address]
|
38
|
-
params["--proxyUser="] = options[:proxy_username] if options[:proxy_username]
|
39
|
-
params["--proxyPassword="] = options[:proxy_password] if options[:proxy_password]
|
40
|
-
params["--serverUrl="] = options[:server_url] if options[:server_url]
|
41
|
-
params["--systemorgid="] = options[:org] if options[:server_url] && options[:org]
|
42
|
-
params["--sslCACert="] = INSTALLED_SERVER_CERT_PATH if certificate_installed
|
43
|
-
|
44
|
-
Common.run!(cmd, :params => params)
|
45
|
-
end
|
46
|
-
|
47
|
-
def enable_channel(repo, options)
|
48
|
-
cmd = "rhn-channel -a"
|
49
|
-
params = user_pwd(options).merge("--channel=" => repo)
|
50
|
-
|
51
|
-
logger.info("#{self.class.name}##{__method__} Enabling channel: #{repo}")
|
52
|
-
Common.run!(cmd, :params => params)
|
53
|
-
end
|
54
|
-
alias_method :subscribe, :enable_channel
|
55
|
-
alias_method :enable_repo, :enable_channel
|
56
|
-
|
57
|
-
def disable_channel(repo, options)
|
58
|
-
cmd = "rhn-channel -r"
|
59
|
-
params = user_pwd(options).merge("--channel=" => repo)
|
60
|
-
|
61
|
-
Common.run!(cmd, :params => params)
|
62
|
-
end
|
63
|
-
alias_method :disable_repo, :disable_channel
|
64
|
-
|
65
|
-
def enabled_channels
|
66
|
-
cmd = "rhn-channel -l"
|
67
|
-
|
68
|
-
Common.run!(cmd).output.split("\n").compact
|
69
|
-
end
|
70
|
-
alias_method :enabled_repos, :enabled_channels
|
71
|
-
alias_method :subscribed_products, :enabled_channels
|
72
|
-
|
73
|
-
def available_channels(options)
|
74
|
-
cmd = "rhn-channel -L"
|
75
|
-
params = user_pwd(options)
|
76
|
-
|
77
|
-
Common.run!(cmd, :params => params).output.chomp.split("\n").compact
|
78
|
-
end
|
79
|
-
|
80
|
-
def all_repos(options)
|
81
|
-
available = available_channels_with_status(options)
|
82
|
-
merge_enabled_channels_with_status(available)
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
86
|
-
|
87
|
-
def available_channels_with_status(options)
|
88
|
-
available_channels(options).collect { |ac| {:repo_id => ac, :enabled => false} }
|
89
|
-
end
|
90
|
-
|
91
|
-
def merge_enabled_channels_with_status(available)
|
92
|
-
enabled_channels.each_with_object(available) do |enabled, all|
|
93
|
-
if repo = all.detect { |i| i[:repo_id] == enabled }
|
94
|
-
repo[:enabled] = true
|
95
|
-
else
|
96
|
-
all.push({:repo_id => enabled, :enabled => true})
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def user_pwd(options)
|
102
|
-
raise ArgumentError, "username and password are required" if options[:username].blank? || options[:password].blank?
|
103
|
-
|
104
|
-
{"--user=" => options[:username], "--password=" => options[:password]}
|
105
|
-
end
|
106
|
-
|
107
|
-
def systemid_file
|
108
|
-
"/etc/sysconfig/rhn/systemid"
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
data/spec/chrony_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Chrony do
|
2
|
-
CHRONY_CONF = <<-EOF
|
3
|
-
# commented server baz.example.net
|
4
|
-
server foo.example.net
|
5
|
-
server bar.example.net iburst
|
6
|
-
driftfile /var/lib/chrony/drift
|
7
|
-
makestep 10 3
|
8
|
-
rtcsync
|
9
|
-
EOF
|
10
|
-
|
11
|
-
subject do
|
12
|
-
allow(File).to receive(:exist?).and_return(true)
|
13
|
-
described_class.new
|
14
|
-
end
|
15
|
-
|
16
|
-
describe ".new" do
|
17
|
-
it "raises when the given config file doesn't exist" do
|
18
|
-
expect { described_class.new("nonsense/file") }.to raise_error(LinuxAdmin::MissingConfigurationFileError)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#clear_servers" do
|
23
|
-
it "removes all the server lines from the conf file" do
|
24
|
-
allow(File).to receive(:read).and_return(CHRONY_CONF.dup)
|
25
|
-
expect(File).to receive(:write) do |_file, contents|
|
26
|
-
expect(contents).to eq "# commented server baz.example.net\ndriftfile /var/lib/chrony/drift\nmakestep 10 3\nrtcsync\n"
|
27
|
-
end
|
28
|
-
subject.clear_servers
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#add_servers" do
|
33
|
-
it "adds server lines to the conf file" do
|
34
|
-
allow(File).to receive(:read).and_return(CHRONY_CONF.dup)
|
35
|
-
expect(File).to receive(:write) do |_file, contents|
|
36
|
-
expect(contents).to eq(CHRONY_CONF + "server baz.example.net iburst\nserver foo.bar.example.com iburst\n")
|
37
|
-
end
|
38
|
-
allow(subject).to receive(:restart_service_if_running)
|
39
|
-
subject.add_servers("baz.example.net", "foo.bar.example.com")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "restarts the service if it is running" do
|
43
|
-
allow(File).to receive(:read).and_return(CHRONY_CONF.dup)
|
44
|
-
allow(File).to receive(:write)
|
45
|
-
|
46
|
-
chronyd_service = double
|
47
|
-
expect(LinuxAdmin::Service).to receive(:new).with("chronyd").and_return(chronyd_service)
|
48
|
-
expect(chronyd_service).to receive(:running?).and_return true
|
49
|
-
expect(chronyd_service).to receive(:restart)
|
50
|
-
subject.add_servers("baz.example.net", "foo.bar.example.com")
|
51
|
-
end
|
52
|
-
|
53
|
-
it "doesn't restart the service if it is not running" do
|
54
|
-
allow(File).to receive(:read).and_return(CHRONY_CONF.dup)
|
55
|
-
allow(File).to receive(:write)
|
56
|
-
|
57
|
-
chronyd_service = double
|
58
|
-
expect(LinuxAdmin::Service).to receive(:new).with("chronyd").and_return(chronyd_service)
|
59
|
-
expect(chronyd_service).to receive(:running?).and_return false
|
60
|
-
expect(chronyd_service).not_to receive(:restart)
|
61
|
-
subject.add_servers("baz.example.net", "foo.bar.example.com")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
data/spec/common_spec.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
describe LinuxAdmin::Common do
|
2
|
-
describe "#cmd" do
|
3
|
-
it "looks up local command from id" do
|
4
|
-
expect(described_class.cmd(:dd)).to match(%r{bin/dd})
|
5
|
-
end
|
6
|
-
|
7
|
-
it "returns nil when it can't find the command" do
|
8
|
-
expect(described_class.cmd(:kasgbdlcvjhals)).to be_nil
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#cmd?" do
|
13
|
-
it "returns true when the command exists" do
|
14
|
-
expect(described_class.cmd?(:dd)).to be true
|
15
|
-
end
|
16
|
-
|
17
|
-
it "returns false when the command doesn't exist" do
|
18
|
-
expect(described_class.cmd?(:kasgbdlcvjhals)).to be false
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
[described_class, LinuxAdmin].each do |klass|
|
23
|
-
describe "#{klass}.run" do
|
24
|
-
it "runs a command with AwesomeSpawn.run" do
|
25
|
-
expect(AwesomeSpawn).to receive(:run).with("echo", nil => "test")
|
26
|
-
klass.run("echo", nil => "test")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#{klass}.run!" do
|
31
|
-
it "runs a command with AwesomeSpawn.run!" do
|
32
|
-
expect(AwesomeSpawn).to receive(:run!).with("echo", nil => "test")
|
33
|
-
klass.run!("echo", nil => "test")
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
data/spec/data/rhn/systemid
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
<params>
|
3
|
-
<param>
|
4
|
-
<value><struct>
|
5
|
-
<member>
|
6
|
-
<name>username</name>
|
7
|
-
<value><string>SomeUsername</string></value>
|
8
|
-
</member>
|
9
|
-
<member>
|
10
|
-
<name>operating_system</name>
|
11
|
-
<value><string>redhat-release-server</string></value>
|
12
|
-
</member>
|
13
|
-
<member>
|
14
|
-
<name>description</name>
|
15
|
-
<value><string>Initial Registration Parameters:
|
16
|
-
OS: redhat-release-server
|
17
|
-
Release: 6Server
|
18
|
-
CPU Arch: x86_64</string></value>
|
19
|
-
</member>
|
20
|
-
<member>
|
21
|
-
<name>checksum</name>
|
22
|
-
<value><string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string></value>
|
23
|
-
</member>
|
24
|
-
<member>
|
25
|
-
<name>profile_name</name>
|
26
|
-
<value><string>SomeProfileName</string></value>
|
27
|
-
</member>
|
28
|
-
<member>
|
29
|
-
<name>system_id</name>
|
30
|
-
<value><string>ID-0123456789</string></value>
|
31
|
-
</member>
|
32
|
-
<member>
|
33
|
-
<name>architecture</name>
|
34
|
-
<value><string>x86_64</string></value>
|
35
|
-
</member>
|
36
|
-
<member>
|
37
|
-
<name>os_release</name>
|
38
|
-
<value><string>6Server</string></value>
|
39
|
-
</member>
|
40
|
-
<member>
|
41
|
-
<name>fields</name>
|
42
|
-
<value><array><data>
|
43
|
-
<value><string>system_id</string></value>
|
44
|
-
<value><string>os_release</string></value>
|
45
|
-
<value><string>operating_system</string></value>
|
46
|
-
<value><string>architecture</string></value>
|
47
|
-
<value><string>username</string></value>
|
48
|
-
<value><string>type</string></value>
|
49
|
-
</data></array></value>
|
50
|
-
</member>
|
51
|
-
<member>
|
52
|
-
<name>type</name>
|
53
|
-
<value><string>REAL</string></value>
|
54
|
-
</member>
|
55
|
-
</struct></value>
|
56
|
-
</param>
|
57
|
-
</params>
|
@@ -1,57 +0,0 @@
|
|
1
|
-
<?xml version="1.0"?>
|
2
|
-
<params>
|
3
|
-
<param>
|
4
|
-
<value><struct>
|
5
|
-
<member>
|
6
|
-
<name>username</name>
|
7
|
-
<value><string>SomeUsername</string></value>
|
8
|
-
</member>
|
9
|
-
<member>
|
10
|
-
<name>operating_system</name>
|
11
|
-
<value><string>redhat-release-server</string></value>
|
12
|
-
</member>
|
13
|
-
<member>
|
14
|
-
<name>description</name>
|
15
|
-
<value><string>Initial Registration Parameters:
|
16
|
-
OS: redhat-release-server
|
17
|
-
Release: 6Server
|
18
|
-
CPU Arch: x86_64</string></value>
|
19
|
-
</member>
|
20
|
-
<member>
|
21
|
-
<name>checksum</name>
|
22
|
-
<value><string>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</string></value>
|
23
|
-
</member>
|
24
|
-
<member>
|
25
|
-
<name>profile_name</name>
|
26
|
-
<value><string>SomeProfileName</string></value>
|
27
|
-
</member>
|
28
|
-
<member>
|
29
|
-
<name>system_id</name>
|
30
|
-
<value><string></string></value>
|
31
|
-
</member>
|
32
|
-
<member>
|
33
|
-
<name>architecture</name>
|
34
|
-
<value><string>x86_64</string></value>
|
35
|
-
</member>
|
36
|
-
<member>
|
37
|
-
<name>os_release</name>
|
38
|
-
<value><string>6Server</string></value>
|
39
|
-
</member>
|
40
|
-
<member>
|
41
|
-
<name>fields</name>
|
42
|
-
<value><array><data>
|
43
|
-
<value><string>system_id</string></value>
|
44
|
-
<value><string>os_release</string></value>
|
45
|
-
<value><string>operating_system</string></value>
|
46
|
-
<value><string>architecture</string></value>
|
47
|
-
<value><string>username</string></value>
|
48
|
-
<value><string>type</string></value>
|
49
|
-
</data></array></value>
|
50
|
-
</member>
|
51
|
-
<member>
|
52
|
-
<name>type</name>
|
53
|
-
<value><string>REAL</string></value>
|
54
|
-
</member>
|
55
|
-
</struct></value>
|
56
|
-
</param>
|
57
|
-
</params>
|
@@ -1,20 +0,0 @@
|
|
1
|
-
ruby193-rubygem-some_really_long_name 1.0.7-1.el6
|
2
|
-
fipscheck-lib 1.2.0-7.el6
|
3
|
-
aic94xx-firmware 30-2.el6
|
4
|
-
latencytop-common 0.5-9.el6
|
5
|
-
uuid 1.6.1-10.el6
|
6
|
-
ConsoleKit 0.4.1-3.el6
|
7
|
-
cpuspeed 1.5-19.el6
|
8
|
-
mailcap 2.1.31-2.el6
|
9
|
-
freetds 0.82-7.1.el6cf
|
10
|
-
elinks 0.12-0.21.pre5.el6_3
|
11
|
-
abrt-cli 2.0.8-15.el6
|
12
|
-
libattr 2.4.44-7.el6
|
13
|
-
passwd 0.77-4.el6_2.2
|
14
|
-
vim-enhanced 7.2.411-1.8.el6
|
15
|
-
popt 1.13-7.el6
|
16
|
-
hesiod 3.1.0-19.el6
|
17
|
-
pinfo 0.6.9-12.el6
|
18
|
-
libpng 1.2.49-1.el6_2
|
19
|
-
libdhash 0.4.2-9.el6
|
20
|
-
zlib-devel 1.2.3-29.el6
|
@@ -1,42 +0,0 @@
|
|
1
|
-
+-------------------------------------------+
|
2
|
-
Available Subscriptions
|
3
|
-
+-------------------------------------------+
|
4
|
-
Subscription Name: Example Subscription
|
5
|
-
SKU: SER0123
|
6
|
-
Pool Id: 82c042fca983889b10178893f29b06e3
|
7
|
-
Quantity: 1690
|
8
|
-
Service Level: None
|
9
|
-
Service Type: None
|
10
|
-
Multi-Entitlement: No
|
11
|
-
Ends: 01/01/2022
|
12
|
-
System Type: Physical
|
13
|
-
|
14
|
-
Subscription Name: My Private Subscription
|
15
|
-
SKU: SER9876
|
16
|
-
Pool Id: 4f738052ec866192c775c62f408ab868
|
17
|
-
Quantity: Unlimited
|
18
|
-
Service Level: None
|
19
|
-
Service Type: None
|
20
|
-
Multi-Entitlement: No
|
21
|
-
Ends: 06/04/2013
|
22
|
-
System Type: Virtual
|
23
|
-
|
24
|
-
Subscription Name: Shared Subscription - With other characters, (2 sockets) (Up to 1 guest)
|
25
|
-
SKU: RH0123456
|
26
|
-
Pool Id: 3d81297f352305b9a3521981029d7d83
|
27
|
-
Quantity: 1
|
28
|
-
Service Level: Self-support
|
29
|
-
Service Type: L1-L3
|
30
|
-
Multi-Entitlement: No
|
31
|
-
Ends: 05/15/2013
|
32
|
-
System Type: Virtual
|
33
|
-
|
34
|
-
Subscription Name: Example Subscription, Premium (up to 2 sockets) 3 year
|
35
|
-
SKU: MCT0123A9
|
36
|
-
Pool Id: 87cefe63b67984d5c7e401d833d2f87f
|
37
|
-
Quantity: 1
|
38
|
-
Service Level: Premium
|
39
|
-
Service Type: L1-L3
|
40
|
-
Multi-Entitlement: No
|
41
|
-
Ends: 07/05/2013
|
42
|
-
System Type: Virtual
|
@@ -1,19 +0,0 @@
|
|
1
|
-
+-------------------------------------------+
|
2
|
-
Installed Product Status
|
3
|
-
+-------------------------------------------+
|
4
|
-
Product Name: Red Hat Enterprise Linux Server
|
5
|
-
Product ID: 69
|
6
|
-
Version: 6.3
|
7
|
-
Arch: x86_64
|
8
|
-
Status: Not Subscribed
|
9
|
-
Starts: 09/27/2012
|
10
|
-
Ends: 09/26/2013
|
11
|
-
|
12
|
-
Product Name: Red Hat CloudForms
|
13
|
-
Product ID: 167
|
14
|
-
Version: 2.1
|
15
|
-
Arch: x86_64
|
16
|
-
Status: Subscribed
|
17
|
-
Starts: 01/03/2013
|
18
|
-
Ends:
|
19
|
-
|
@@ -1,19 +0,0 @@
|
|
1
|
-
+-------------------------------------------+
|
2
|
-
Installed Product Status
|
3
|
-
+-------------------------------------------+
|
4
|
-
Product Name: Red Hat Enterprise Linux Server
|
5
|
-
Product ID: 69
|
6
|
-
Version: 6.3
|
7
|
-
Arch: x86_64
|
8
|
-
Status: Subscribed
|
9
|
-
Starts: 09/27/2012
|
10
|
-
Ends: 09/26/2013
|
11
|
-
|
12
|
-
Product Name: Red Hat CloudForms
|
13
|
-
Product ID: 167
|
14
|
-
Version: 2.1
|
15
|
-
Arch: x86_64
|
16
|
-
Status: Subscribed
|
17
|
-
Starts: 01/03/2013
|
18
|
-
Ends: 01/03/2014
|
19
|
-
|