linux_admin 0.5.1 → 0.5.2

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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGNlMTBjZmY0NmY3MjcyMjlhM2FiMWM5YjM4MjZhODFiNWY3M2FmNQ==
5
+ data.tar.gz: !binary |-
6
+ NjQxOGE5NDA4ZDQ2ZDdlYWI1OGQ0MWQ2M2NiZDhkNjFmN2JmNTNhMw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NTk5NDA1MmM1MWY2ZGZjMzViNDQ3NGI1M2FjZjEzN2ZlYTA0ODIyMGZhMWY2
10
+ NjkxMWFiOTZkM2NhYzY4ZjhlMDZlYzE5NjdkYWY3ZTc0ZTk5M2M1YzAyMzIy
11
+ MDMwYTk2MDk4NDAwMjA2MzljMWYxYmIxMDMwNjVmYzQwMjdmNWE=
12
+ data.tar.gz: !binary |-
13
+ ZmNkNzQwZjE0NTNmZGFjMGMxMzMzMTA2ZjU5OTk3YjRmZjVhZDQ1ODJkZmU2
14
+ NDcyMWNjNGVkMDJhNGIzYmFkM2ZlNWUyOTdiN2Y4YTk5MWViNDllNzg1ZDM0
15
+ Y2I4Y2JlNjRiOGQ0NzhiOGFhYmQyMjQyMTVmOTRhMDg4OTJjNjA=
@@ -1,9 +1,14 @@
1
1
  class CommandResult
2
- attr_reader :output, :error, :exit_status
2
+ attr_reader :command_line, :output, :error, :exit_status
3
3
 
4
- def initialize(output, error, exit_status)
5
- @output = output
6
- @error = error
7
- @exit_status = exit_status
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}>"
8
13
  end
9
14
  end
@@ -12,12 +12,13 @@ class LinuxAdmin
12
12
  launch_params = {}
13
13
  launch_params[:chdir] = options[:chdir] if options[:chdir]
14
14
 
15
- output = ""
16
- error = ""
17
- status = nil
15
+ output = ""
16
+ error = ""
17
+ status = nil
18
+ command_line = build_cmd(cmd, params)
18
19
 
19
20
  begin
20
- output, error = launch(build_cmd(cmd, params), launch_params)
21
+ output, error = launch(command_line, launch_params)
21
22
  status = exitstatus
22
23
  ensure
23
24
  output ||= ""
@@ -28,7 +29,7 @@ class LinuxAdmin
28
29
  raise NoSuchFileError.new(err.message) if NoSuchFileError.detected?(err.message)
29
30
  raise
30
31
  else
31
- CommandResult.new(output, error, status)
32
+ CommandResult.new(command_line, output, error, status)
32
33
  end
33
34
 
34
35
  def run!(cmd, options = {})
@@ -0,0 +1,39 @@
1
+ # LinuxAdmin Deb Representation
2
+ #
3
+ # Copyright (C) 2013 Red Hat Inc.
4
+ # Licensed under the MIT License
5
+
6
+ class LinuxAdmin
7
+ class Deb < Package
8
+ APT_CACHE_CMD = '/usr/bin/apt-cache'
9
+
10
+ def self.from_line(apt_cache_line, in_description=false)
11
+ tag,value = apt_cache_line.split(':')
12
+ tag = tag.strip.downcase
13
+ [tag, value]
14
+ end
15
+
16
+ def self.from_string(apt_cache_string)
17
+ in_description = false
18
+ apt_cache_string.split("\n").each.with_object({}) do |line,deb|
19
+ tag,value = self.from_line(line)
20
+ if tag == 'description-en'
21
+ in_description = true
22
+ elsif tag == 'homepage'
23
+ in_description = false
24
+ end
25
+
26
+ if in_description && tag != 'description-en'
27
+ deb['description-en'] << line
28
+ else
29
+ deb[tag] = value.strip
30
+ end
31
+ end
32
+ end
33
+
34
+ def self.info(pkg)
35
+ self.from_string(run!(APT_CACHE_CMD, :params => ["show", pkg]).output)
36
+ end
37
+
38
+ end
39
+ end
@@ -70,4 +70,4 @@ class LinuxAdmin
70
70
  line.flatten.join(" ").strip
71
71
  end
72
72
  end
73
- end
73
+ end
@@ -3,8 +3,15 @@
3
3
  # Copyright (C) 2013 Red Hat Inc.
4
4
  # Licensed under the MIT License
5
5
 
6
+ require 'pathname'
7
+
6
8
  class LinuxAdmin
7
9
  class LogicalVolume < Volume
10
+ DEVICE_PATH = Pathname.new('/dev/')
11
+
12
+ # path to logical volume
13
+ attr_accessor :path
14
+
8
15
  # logical volume name
9
16
  attr_accessor :name
10
17
 
@@ -26,10 +33,19 @@ class LinuxAdmin
26
33
  # major device number of logical volume
27
34
  # minor device number of logical volume
28
35
 
36
+ def path=(value)
37
+ @path = value.include?(File::SEPARATOR) ? value : DEVICE_PATH.join(@volume_group.name, value)
38
+ end
39
+
40
+ def name=(value)
41
+ @name = value.include?(File::SEPARATOR) ? value.split(File::SEPARATOR).last : value
42
+ end
43
+
29
44
  def initialize(args = {})
30
- @name = args[:name]
31
45
  @volume_group = args[:volume_group]
32
46
  @sectors = args[:sectors]
47
+ self.path = args[:name]
48
+ self.name = args[:name]
33
49
  end
34
50
 
35
51
  def extend_with(vg)
@@ -66,9 +82,10 @@ class LinuxAdmin
66
82
  params.merge!({'-L' => bytes_to_string(size)})
67
83
  end
68
84
  run!(cmd(:lvcreate), :params => params)
69
- lv = LogicalVolume.new :name => name,
85
+
86
+ lv = LogicalVolume.new(:name => name,
70
87
  :volume_group => vg,
71
- :sectors => size
88
+ :sectors => size)
72
89
  @lvs << lv
73
90
  lv
74
91
  end
@@ -0,0 +1,18 @@
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 Distro.local == Distros.redhat
10
+ return Rpm.info(pkg)
11
+ elsif Distro.local == Distros.ubuntu
12
+ return Deb.info(pkg)
13
+ end
14
+
15
+ nil
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,8 @@ require 'nokogiri'
2
2
 
3
3
  class LinuxAdmin
4
4
  class Rhn < RegistrationSystem
5
+ SATELLITE5_SERVER_CERT_PATH = "pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm"
6
+
5
7
  def registered?
6
8
  id = ""
7
9
  if File.exists?(systemid_file)
@@ -24,10 +26,13 @@ class LinuxAdmin
24
26
  raise ArgumentError, "activation key or username and password are required"
25
27
  end
26
28
 
29
+ install_server_certificate(options[:server_url], SATELLITE5_SERVER_CERT_PATH) if options[:server_url]
30
+
27
31
  params["--proxy="] = options[:proxy_address] if options[:proxy_address]
28
32
  params["--proxyUser="] = options[:proxy_username] if options[:proxy_username]
29
33
  params["--proxyPassword="] = options[:proxy_password] if options[:proxy_password]
30
34
  params["--serverUrl="] = options[:server_url] if options[:server_url]
35
+ params["--systemorgid="] = options[:org] if options[:server_url] && options[:org]
31
36
 
32
37
  run!(cmd, :params => params)
33
38
  end
@@ -9,6 +9,8 @@ class LinuxAdmin
9
9
  raise
10
10
  end
11
11
 
12
+ SATELLITE6_SERVER_CERT_PATH = "pub/candlepin-cert-consumer-latest.noarch.rpm"
13
+
12
14
  def validate_credentials(options)
13
15
  !!organizations(options)
14
16
  end
@@ -35,6 +37,9 @@ class LinuxAdmin
35
37
 
36
38
  def register(options)
37
39
  raise ArgumentError, "username and password are required" unless options[:username] && options[:password]
40
+
41
+ install_server_certificate(options[:server_url], SATELLITE6_SERVER_CERT_PATH) if options[:server_url]
42
+
38
43
  cmd = "subscription-manager register"
39
44
 
40
45
  params = {"--username=" => options[:username], "--password=" => options[:password]}
@@ -39,6 +39,12 @@ class LinuxAdmin
39
39
  end
40
40
  end
41
41
  private_class_method :white_list_methods
42
+
43
+ def install_server_certificate(server, cert_path)
44
+ host = server.start_with?("http") ? URI.parse(server).host : server
45
+
46
+ LinuxAdmin::Rpm.upgrade("http://#{host}/#{cert_path}")
47
+ end
42
48
  end
43
49
  end
44
50
 
@@ -1,5 +1,7 @@
1
1
  class LinuxAdmin
2
- class Rpm < LinuxAdmin
2
+ class Rpm < Package
3
+ RPM_CMD = '/usr/bin/rpm'
4
+
3
5
  def self.list_installed
4
6
  out = run!("rpm -qa --qf \"%{NAME} %{VERSION}-%{RELEASE}\n\"").output
5
7
  out.split("\n").each_with_object({}) do |line, pkg_hash|
@@ -8,6 +10,25 @@ class LinuxAdmin
8
10
  end
9
11
  end
10
12
 
13
+ def self.info(pkg)
14
+ params = { "-qi" => pkg}
15
+ in_description = false
16
+ out = run!(RPM_CMD, :params => params).output
17
+ out.split("\n").each.with_object({}) do |line, rpm|
18
+ tag,value = line.split(':')
19
+ tag = tag.strip
20
+ if tag == 'Description'
21
+ in_description = true
22
+ elsif in_description
23
+ rpm['description'] ||= ""
24
+ rpm['description'] << line + " "
25
+ else
26
+ tag = tag.downcase.gsub(/\s/, '_')
27
+ rpm[tag] = value.strip
28
+ end
29
+ end
30
+ end
31
+
11
32
  def self.upgrade(pkg)
12
33
  cmd = "rpm -U"
13
34
  params = { nil => pkg }
@@ -1,3 +1,3 @@
1
1
  class LinuxAdmin
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
@@ -72,6 +72,16 @@ class LinuxAdmin
72
72
  end
73
73
  end
74
74
 
75
+ def self.repo_list(scope = "enabled")
76
+ # Scopes could be "enabled", "all"
77
+
78
+ cmd = "yum repolist"
79
+ params = {nil => scope}
80
+ output = run!(cmd, :params => params).output
81
+
82
+ parse_repo_list_output(output)
83
+ end
84
+
75
85
  private
76
86
 
77
87
  def self.parse_repo_dir(dir)
@@ -88,6 +98,22 @@ class LinuxAdmin
88
98
  int_keys.each { |k| data[k] = data[k].to_i if data.has_key?(k) }
89
99
  end
90
100
  end
101
+
102
+ def self.parse_repo_list_output(content)
103
+ collect_content = false
104
+ index_start = "repo id"
105
+ index_end = "repolist:"
106
+
107
+ content.split("\n").each_with_object([]) do |line, array|
108
+ collect_content = false if line.start_with?(index_end)
109
+ collect_content = true if line.start_with?(index_start)
110
+ next if line.start_with?(index_start)
111
+ next if !collect_content
112
+
113
+ repo_id, repo_name, status = line.split(/\s{2,}/)
114
+ array.push(repo_id)
115
+ end
116
+ end
91
117
  end
92
118
  end
93
119
 
data/lib/linux_admin.rb CHANGED
@@ -6,7 +6,9 @@ require 'linux_admin/registration_system'
6
6
  require 'linux_admin/common'
7
7
  require 'linux_admin/exceptions'
8
8
  require 'linux_admin/command_result'
9
+ require 'linux_admin/package'
9
10
  require 'linux_admin/rpm'
11
+ require 'linux_admin/deb'
10
12
  require 'linux_admin/version'
11
13
  require 'linux_admin/yum'
12
14
 
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,13 @@
1
+ Loaded plugins: product-id, rhnplugin, security, subscription-manager
2
+ This system is receiving updates from Red Hat Subscription Management.
3
+ This system is not registered with RHN Classic or RHN Satellite.
4
+ You can use rhn_register to register.
5
+ RHN Satellite or RHN Classic support will be disabled.
6
+ rhel-6-server-rpms | 3.7 kB 00:00
7
+ rhel-ha-for-rhel-6-server-rpms | 3.7 kB 00:00
8
+ rhel-lb-for-rhel-6-server-rpms | 3.7 kB 00:00
9
+ repo id repo name status
10
+ rhel-6-server-rpms Red Hat Enterprise Linux 6 Server (RPMs) 11,016
11
+ rhel-ha-for-rhel-6-server-rpms Red Hat Enterprise Linux High Availability (for RHEL 6 Server) (RPMs) 269
12
+ rhel-lb-for-rhel-6-server-rpms Red Hat Enterprise Linux Load Balancer (for RHEL 6 Server) (RPMs) 0
13
+ repolist: 11,909
data/spec/deb_spec.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin::Deb do
4
+ describe "#info" do
5
+ it "returns package metadata" do
6
+ # as output w/ apt-cache show ruby on ubuntu 13.04
7
+ data = <<EOS
8
+ Package: ruby
9
+ Priority: optional
10
+ Section: interpreters
11
+ Installed-Size: 31
12
+ Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
13
+ Original-Maintainer: akira yamada <akira@debian.org>
14
+ Architecture: all
15
+ Source: ruby-defaults
16
+ Version: 4.9
17
+ Replaces: irb, rdoc
18
+ Provides: irb, rdoc
19
+ Depends: ruby1.9.1 (>= 1.9.3.194-1)
20
+ Suggests: ri, ruby-dev
21
+ Conflicts: irb, rdoc
22
+ Filename: pool/main/r/ruby-defaults/ruby_4.9_all.deb
23
+ Size: 4896
24
+ MD5sum: b1991f2e0eafb04f5930ed242cfe1476
25
+ SHA1: a7c55fbb83dd8382631ea771b5555d989351f840
26
+ SHA256: 84d042e0273bd2f0082dd9e7dda0246267791fd09607041a35485bfff92f38d9
27
+ Description-en: Interpreter of object-oriented scripting language Ruby (default version)
28
+ Ruby is the interpreted scripting language for quick and easy
29
+ object-oriented programming. It has many features to process text
30
+ files and to do system management tasks (as in perl). It is simple,
31
+ straight-forward, and extensible.
32
+ .
33
+ This package is a dependency package, which depends on Debian's default Ruby
34
+ version (currently v1.9.3).
35
+ Homepage: http://www.ruby-lang.org/
36
+ Description-md5: da2991b37e3991230d79ba70f9c01682
37
+ Bugs: https://bugs.launchpad.net/ubuntu/+filebug
38
+ Origin: Ubuntu
39
+ Supported: 9m
40
+ Task: kubuntu-desktop, kubuntu-full, kubuntu-active, kubuntu-active-desktop, kubuntu-active-full, kubuntu-active, edubuntu-desktop-gnome, ubuntustudio-font-meta
41
+ EOS
42
+ described_class.should_receive(:run).
43
+ with(described_class::APT_CACHE_CMD, :params => ["show", "ruby"]).
44
+ and_return(CommandResult.new("", data, "", 0))
45
+ metadata = described_class.info("ruby")
46
+ metadata['package'].should == 'ruby'
47
+ metadata['priority'].should == 'optional'
48
+ metadata['section'].should == 'interpreters'
49
+ metadata['architecture'].should == 'all'
50
+ metadata['version'].should == '4.9'
51
+ metadata['origin'].should == 'Ubuntu'
52
+ end
53
+ end
54
+ end
@@ -23,8 +23,8 @@ eos
23
23
 
24
24
  describe "#extend_with" do
25
25
  it "uses lvextend" do
26
- lv = described_class.new :name => 'lv'
27
26
  vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
27
+ lv = described_class.new :name => 'lv', :volume_group => vg
28
28
  lv.should_receive(:run!).
29
29
  with(vg.cmd(:lvextend),
30
30
  :params => ['lv', 'vg'])
@@ -32,8 +32,8 @@ eos
32
32
  end
33
33
 
34
34
  it "returns self" do
35
- lv = described_class.new :name => 'lv'
36
35
  vg = LinuxAdmin::VolumeGroup.new :name => 'vg'
36
+ lv = described_class.new :name => 'lv', :volume_group => vg
37
37
  lv.stub(:run!)
38
38
  lv.extend_with(vg).should == lv
39
39
  end
@@ -86,6 +86,24 @@ eos
86
86
  lv.name.should == 'lv'
87
87
  end
88
88
 
89
+ context "name is specified" do
90
+ it "sets path under volume group" do
91
+ LinuxAdmin::VolumeGroup.stub(:run! => double(:output => ""))
92
+ described_class.stub(:run! => double(:output => ""))
93
+ lv = described_class.create 'lv', @vg, 256.gigabytes
94
+ lv.path.to_s.should == "#{described_class::DEVICE_PATH}#{@vg.name}/lv"
95
+ end
96
+ end
97
+
98
+ context "path is specified" do
99
+ it "sets name" do
100
+ LinuxAdmin::VolumeGroup.stub(:run! => double(:output => ""))
101
+ described_class.stub(:run! => double(:output => ""))
102
+ lv = described_class.create '/dev/lv', @vg, 256.gigabytes
103
+ lv.name.should == "lv"
104
+ end
105
+ end
106
+
89
107
  it "adds logical volume to local registry" do
90
108
  LinuxAdmin::VolumeGroup.stub(:run! => double(:output => ""))
91
109
  described_class.stub(:run! => double(:output => ""))
@@ -110,11 +128,13 @@ eos
110
128
  lvs = described_class.scan
111
129
 
112
130
  lvs[0].should be_an_instance_of(described_class)
113
- lvs[0].name.should == '/dev/vg_foobar/lv_swap'
131
+ lvs[0].path.should == '/dev/vg_foobar/lv_swap'
132
+ lvs[0].name.should == 'lv_swap'
114
133
  lvs[0].sectors.should == 4128768
115
134
 
116
135
  lvs[1].should be_an_instance_of(described_class)
117
- lvs[1].name.should == '/dev/vg_foobar/lv_root'
136
+ lvs[1].path.should == '/dev/vg_foobar/lv_root'
137
+ lvs[1].name.should == 'lv_root'
118
138
  lvs[1].sectors.should == 19988480
119
139
  end
120
140
 
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin::Package do
4
+ describe "#info" do
5
+ it "dispatches to redhat lookup mechanism" do
6
+ LinuxAdmin::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::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
data/spec/rhn_spec.rb CHANGED
@@ -23,26 +23,43 @@ describe LinuxAdmin::Rhn do
23
23
  expect { described_class.new.register({}) }.to raise_error(ArgumentError)
24
24
  end
25
25
 
26
- it "with username and password" do
27
- described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", {:params=>{"--username="=>"SomeUser", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}})
28
- described_class.new.register(
29
- :username => "SomeUser",
30
- :password => "SomePass",
31
- :proxy_address => "1.2.3.4",
32
- :proxy_username => "ProxyUser",
33
- :proxy_password => "ProxyPass",
34
- :server_url => "192.168.1.1",
35
- )
26
+ context "with username and password" do
27
+ let(:base_options) { {:username => "SomeUser@SomeDomain.org",
28
+ :password => "SomePass",
29
+ :org => "2",
30
+ :proxy_address => "1.2.3.4",
31
+ :proxy_username => "ProxyUser",
32
+ :proxy_password => "ProxyPass",
33
+ }
34
+ }
35
+ let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass"}} }
36
+
37
+ it "with server_url" do
38
+ run_params.store_path(:params, "--systemorgid=", "2")
39
+ run_params.store_path(:params, "--serverUrl=", "https://server.url")
40
+ base_options.store_path(:server_url, "https://server.url")
41
+
42
+ described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", run_params)
43
+ LinuxAdmin::Rpm.should_receive(:upgrade).with("http://server.url/pub/rhn-org-trusted-ssl-cert-1.0-1.noarch.rpm")
44
+
45
+ described_class.new.register(base_options)
46
+ end
47
+
48
+ it "without server_url" do
49
+ described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", run_params)
50
+ described_class.any_instance.should_not_receive(:install_server_certificate)
51
+
52
+ described_class.new.register(base_options)
53
+ end
36
54
  end
37
55
 
38
56
  it "with activation key" do
39
- described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass", "--serverUrl="=>"192.168.1.1"}})
57
+ described_class.any_instance.should_receive(:run!).once.with("rhnreg_ks", {:params=>{"--activationkey="=>"123abc", "--proxy="=>"1.2.3.4", "--proxyUser="=>"ProxyUser", "--proxyPassword="=>"ProxyPass"}})
40
58
  described_class.new.register(
41
59
  :activationkey => "123abc",
42
60
  :proxy_address => "1.2.3.4",
43
61
  :proxy_username => "ProxyUser",
44
62
  :proxy_password => "ProxyPass",
45
- :server_url => "192.168.1.1",
46
63
  )
47
64
  end
48
65
  end
data/spec/rpm_spec.rb CHANGED
@@ -27,8 +27,54 @@ describe LinuxAdmin::Rpm do
27
27
  })
28
28
  end
29
29
 
30
+ describe "#info" do
31
+ it "returns package metadata" do
32
+ # as output w/ rpm -qi ruby on F19
33
+ data = <<EOS
34
+ Name : ruby
35
+ Version : 2.0.0.247
36
+ Release : 15.fc19
37
+ Architecture: x86_64
38
+ Install Date: Sat 19 Oct 2013 08:17:20 PM EDT
39
+ Group : Development/Languages
40
+ Size : 64473
41
+ License : (Ruby or BSD) and Public Domain
42
+ Signature : RSA/SHA256, Thu 01 Aug 2013 02:07:03 PM EDT, Key ID 07477e65fb4b18e6
43
+ Source RPM : ruby-2.0.0.247-15.fc19.src.rpm
44
+ Build Date : Wed 31 Jul 2013 08:26:49 AM EDT
45
+ Build Host : buildvm-16.phx2.fedoraproject.org
46
+ Relocations : (not relocatable)
47
+ Packager : Fedora Project
48
+ Vendor : Fedora Project
49
+ URL : http://ruby-lang.org/
50
+ Summary : An interpreter of object-oriented scripting language
51
+ Description :
52
+ Ruby is the interpreted scripting language for quick and easy
53
+ object-oriented programming. It has many features to process text
54
+ files and to do system management tasks (as in Perl). It is simple,
55
+ straight-forward, and extensible.
56
+ EOS
57
+ described_class.should_receive(:run).
58
+ with(described_class::RPM_CMD, :params => {"-qi" => "ruby"}).
59
+ and_return(CommandResult.new("", data, "", 0))
60
+ metadata = described_class.info("ruby")
61
+ metadata['name'].should == 'ruby'
62
+ metadata['version'].should == '2.0.0.247'
63
+ metadata['release'].should == '15.fc19'
64
+ metadata['architecture'].should == 'x86_64'
65
+ metadata['group'].should == 'Development/Languages'
66
+ metadata['size'].should == '64473'
67
+ metadata['license'].should == '(Ruby or BSD) and Public Domain'
68
+ metadata['source_rpm'].should == 'ruby-2.0.0.247-15.fc19.src.rpm'
69
+ metadata['build_host'].should == 'buildvm-16.phx2.fedoraproject.org'
70
+ metadata['packager'].should == 'Fedora Project'
71
+ metadata['vendor'].should == 'Fedora Project'
72
+ metadata['summary'].should == 'An interpreter of object-oriented scripting language'
73
+ end
74
+ end
75
+
30
76
  it ".upgrade" do
31
- described_class.should_receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(CommandResult.new("", "", 0))
77
+ described_class.should_receive(:run).with("rpm -U", {:params=>{nil=>"abc"}}).and_return(CommandResult.new("", "", "", 0))
32
78
  expect(described_class.upgrade("abc")).to be_true
33
79
  end
34
- end
80
+ end
@@ -23,18 +23,34 @@ describe LinuxAdmin::SubscriptionManager do
23
23
  expect { described_class.new.register }.to raise_error(ArgumentError)
24
24
  end
25
25
 
26
- it "with username and password" do
27
- run_options = ["subscription-manager register", {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--org="=>"IT", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass", "--serverurl="=>"192.168.1.1"}}]
28
- described_class.any_instance.should_receive(:run!).once.with(*run_options)
29
- described_class.new.register(
30
- :username => "SomeUser@SomeDomain.org",
31
- :password => "SomePass",
32
- :org => "IT",
33
- :proxy_address => "1.2.3.4",
34
- :proxy_username => "ProxyUser",
35
- :proxy_password => "ProxyPass",
36
- :server_url => "192.168.1.1",
37
- )
26
+ context "with username and password" do
27
+ let(:base_options) { {:username => "SomeUser@SomeDomain.org",
28
+ :password => "SomePass",
29
+ :org => "IT",
30
+ :proxy_address => "1.2.3.4",
31
+ :proxy_username => "ProxyUser",
32
+ :proxy_password => "ProxyPass",
33
+ }
34
+ }
35
+ let(:run_params) { {:params=>{"--username="=>"SomeUser@SomeDomain.org", "--password="=>"SomePass", "--proxy="=>"1.2.3.4", "--proxyuser="=>"ProxyUser", "--proxypassword="=>"ProxyPass"}} }
36
+
37
+ it "with server_url" do
38
+ run_params.store_path(:params, "--org=", "IT")
39
+ run_params.store_path(:params, "--serverurl=", "https://server.url")
40
+ base_options.store_path(:server_url, "https://server.url")
41
+
42
+ described_class.any_instance.should_receive(:run!).once.with("subscription-manager register", run_params)
43
+ LinuxAdmin::Rpm.should_receive(:upgrade).with("http://server.url/pub/candlepin-cert-consumer-latest.noarch.rpm")
44
+
45
+ described_class.new.register(base_options)
46
+ end
47
+
48
+ it "without server_url" do
49
+ described_class.any_instance.should_receive(:run!).once.with("subscription-manager register", run_params)
50
+ described_class.any_instance.should_not_receive(:install_server_certificate)
51
+
52
+ described_class.new.register(base_options)
53
+ end
38
54
  end
39
55
  end
40
56
 
@@ -121,7 +137,7 @@ describe LinuxAdmin::SubscriptionManager do
121
137
 
122
138
  it "with invalid credentials" do
123
139
  run_options = ["subscription-manager orgs", {:params=>{"--username="=>"BadUser", "--password="=>"BadPass"}}]
124
- described_class.any_instance.should_receive(:run).once.with(*run_options).and_return(CommandResult.new("", "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html", 255))
140
+ described_class.any_instance.should_receive(:run).once.with(*run_options).and_return(CommandResult.new("", "", "Invalid username or password. To create a login, please visit https://www.redhat.com/wapps/ugc/register.html", 255))
125
141
  expect { described_class.new.organizations({:username=>"BadUser", :password=>"BadPass"}) }.to raise_error(LinuxAdmin::CredentialError)
126
142
  end
127
143
  end
@@ -18,8 +18,8 @@ eos
18
18
 
19
19
  describe "#attach_to" do
20
20
  it "uses lvextend" do
21
- lv = LinuxAdmin::LogicalVolume.new :name => 'lv'
22
21
  vg = described_class.new :name => 'vg'
22
+ lv = LinuxAdmin::LogicalVolume.new :name => 'lv', :volume_group => vg
23
23
  vg.should_receive(:run!).
24
24
  with(vg.cmd(:lvextend),
25
25
  :params => ['lv', 'vg'])
@@ -27,8 +27,8 @@ eos
27
27
  end
28
28
 
29
29
  it "returns self" do
30
- lv = LinuxAdmin::LogicalVolume.new :name => 'lv'
31
30
  vg = described_class.new :name => 'vg'
31
+ lv = LinuxAdmin::LogicalVolume.new :name => 'lv', :volume_group => vg
32
32
  vg.stub(:run!)
33
33
  vg.attach_to(lv).should == vg
34
34
  end
data/spec/yum_spec.rb CHANGED
@@ -124,4 +124,16 @@ describe LinuxAdmin::Yum do
124
124
  })
125
125
  end
126
126
  end
127
+
128
+ context ".repo_list" do
129
+ it "with no arguments" do
130
+ described_class.should_receive(:run!).with("yum repolist", {:params=>{nil=>"enabled"}}).and_return(double(:output => sample_output("yum/output_repo_list")))
131
+ expect(described_class.repo_list).to eq(["rhel-6-server-rpms", "rhel-ha-for-rhel-6-server-rpms", "rhel-lb-for-rhel-6-server-rpms"])
132
+ end
133
+
134
+ it "with argument" do
135
+ described_class.should_receive(:run!).with("yum repolist", {:params=>{nil=>"enabled"}}).and_return(double(:output => sample_output("yum/output_repo_list")))
136
+ expect(described_class.repo_list("enabled")).to eq(["rhel-6-server-rpms", "rhel-ha-for-rhel-6-server-rpms", "rhel-lb-for-rhel-6-server-rpms"])
137
+ end
138
+ end
127
139
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linux_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
5
- prerelease:
4
+ version: 0.5.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brandon Dunne
@@ -12,12 +11,11 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-10-10 00:00:00.000000000 Z
14
+ date: 2013-11-13 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: bundler
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
20
  - - ~>
23
21
  - !ruby/object:Gem::Version
@@ -25,7 +23,6 @@ dependencies:
25
23
  type: :development
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
27
  - - ~>
31
28
  - !ruby/object:Gem::Version
@@ -33,7 +30,6 @@ dependencies:
33
30
  - !ruby/object:Gem::Dependency
34
31
  name: rake
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
34
  - - ! '>='
39
35
  - !ruby/object:Gem::Version
@@ -41,7 +37,6 @@ dependencies:
41
37
  type: :development
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
41
  - - ! '>='
47
42
  - !ruby/object:Gem::Version
@@ -49,7 +44,6 @@ dependencies:
49
44
  - !ruby/object:Gem::Dependency
50
45
  name: rspec
51
46
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
47
  requirements:
54
48
  - - ~>
55
49
  - !ruby/object:Gem::Version
@@ -57,7 +51,6 @@ dependencies:
57
51
  type: :development
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
54
  requirements:
62
55
  - - ~>
63
56
  - !ruby/object:Gem::Version
@@ -65,7 +58,6 @@ dependencies:
65
58
  - !ruby/object:Gem::Dependency
66
59
  name: coveralls
67
60
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
61
  requirements:
70
62
  - - ! '>='
71
63
  - !ruby/object:Gem::Version
@@ -73,7 +65,6 @@ dependencies:
73
65
  type: :development
74
66
  prerelease: false
75
67
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
68
  requirements:
78
69
  - - ! '>='
79
70
  - !ruby/object:Gem::Version
@@ -81,7 +72,6 @@ dependencies:
81
72
  - !ruby/object:Gem::Dependency
82
73
  name: activesupport
83
74
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
75
  requirements:
86
76
  - - <
87
77
  - !ruby/object:Gem::Version
@@ -89,7 +79,6 @@ dependencies:
89
79
  type: :runtime
90
80
  prerelease: false
91
81
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
82
  requirements:
94
83
  - - <
95
84
  - !ruby/object:Gem::Version
@@ -97,7 +86,6 @@ dependencies:
97
86
  - !ruby/object:Gem::Dependency
98
87
  name: inifile
99
88
  requirement: !ruby/object:Gem::Requirement
100
- none: false
101
89
  requirements:
102
90
  - - ~>
103
91
  - !ruby/object:Gem::Version
@@ -105,7 +93,6 @@ dependencies:
105
93
  type: :runtime
106
94
  prerelease: false
107
95
  version_requirements: !ruby/object:Gem::Requirement
108
- none: false
109
96
  requirements:
110
97
  - - ~>
111
98
  - !ruby/object:Gem::Version
@@ -113,7 +100,6 @@ dependencies:
113
100
  - !ruby/object:Gem::Dependency
114
101
  name: more_core_extensions
115
102
  requirement: !ruby/object:Gem::Requirement
116
- none: false
117
103
  requirements:
118
104
  - - ~>
119
105
  - !ruby/object:Gem::Version
@@ -121,7 +107,6 @@ dependencies:
121
107
  type: :runtime
122
108
  prerelease: false
123
109
  version_requirements: !ruby/object:Gem::Requirement
124
- none: false
125
110
  requirements:
126
111
  - - ~>
127
112
  - !ruby/object:Gem::Version
@@ -129,7 +114,6 @@ dependencies:
129
114
  - !ruby/object:Gem::Dependency
130
115
  name: nokogiri
131
116
  requirement: !ruby/object:Gem::Requirement
132
- none: false
133
117
  requirements:
134
118
  - - ! '>='
135
119
  - !ruby/object:Gem::Version
@@ -137,7 +121,6 @@ dependencies:
137
121
  type: :runtime
138
122
  prerelease: false
139
123
  version_requirements: !ruby/object:Gem::Requirement
140
- none: false
141
124
  requirements:
142
125
  - - ! '>='
143
126
  - !ruby/object:Gem::Version
@@ -170,12 +153,14 @@ files:
170
153
  - lib/linux_admin.rb
171
154
  - lib/linux_admin/command_result.rb
172
155
  - lib/linux_admin/common.rb
156
+ - lib/linux_admin/deb.rb
173
157
  - lib/linux_admin/disk.rb
174
158
  - lib/linux_admin/distro.rb
175
159
  - lib/linux_admin/exceptions.rb
176
160
  - lib/linux_admin/fstab.rb
177
161
  - lib/linux_admin/hosts.rb
178
162
  - lib/linux_admin/logical_volume.rb
163
+ - lib/linux_admin/package.rb
179
164
  - lib/linux_admin/partition.rb
180
165
  - lib/linux_admin/physical_volume.rb
181
166
  - lib/linux_admin/registration_system.rb
@@ -190,6 +175,7 @@ files:
190
175
  - lib/linux_admin/yum.rb
191
176
  - lib/linux_admin/yum/repo_file.rb
192
177
  - linux_admin.gemspec
178
+ - spec/command_result_spec.rb
193
179
  - spec/common_spec.rb
194
180
  - spec/data/rhn/output_rhn-channel_list
195
181
  - spec/data/rhn/systemid
@@ -200,15 +186,18 @@ files:
200
186
  - spec/data/subscription_manager/output_list_installed_subscribed
201
187
  - spec/data/subscription_manager/output_orgs
202
188
  - spec/data/yum/first.repo
189
+ - spec/data/yum/output_repo_list
203
190
  - spec/data/yum/output_repoquery_multiple
204
191
  - spec/data/yum/output_repoquery_single
205
192
  - spec/data/yum/second.repo
193
+ - spec/deb_spec.rb
206
194
  - spec/disk_spec.rb
207
195
  - spec/distro_spec.rb
208
196
  - spec/fstab_spec.rb
209
197
  - spec/hosts_spec.rb
210
198
  - spec/linux_admin_spec.rb
211
199
  - spec/logical_volume_spec.rb
200
+ - spec/package_spec.rb
212
201
  - spec/partition_spec.rb
213
202
  - spec/physical_volume_spec.rb
214
203
  - spec/registration_system_spec.rb
@@ -223,29 +212,29 @@ files:
223
212
  homepage: http://github.com/ManageIQ/linux_admin
224
213
  licenses:
225
214
  - MIT
215
+ metadata: {}
226
216
  post_install_message:
227
217
  rdoc_options: []
228
218
  require_paths:
229
219
  - lib
230
220
  required_ruby_version: !ruby/object:Gem::Requirement
231
- none: false
232
221
  requirements:
233
222
  - - ! '>='
234
223
  - !ruby/object:Gem::Version
235
224
  version: '0'
236
225
  required_rubygems_version: !ruby/object:Gem::Requirement
237
- none: false
238
226
  requirements:
239
227
  - - ! '>='
240
228
  - !ruby/object:Gem::Version
241
229
  version: '0'
242
230
  requirements: []
243
231
  rubyforge_project:
244
- rubygems_version: 1.8.25
232
+ rubygems_version: 2.1.10
245
233
  signing_key:
246
- specification_version: 3
234
+ specification_version: 4
247
235
  summary: LinuxAdmin is a module to simplify management of linux systems.
248
236
  test_files:
237
+ - spec/command_result_spec.rb
249
238
  - spec/common_spec.rb
250
239
  - spec/data/rhn/output_rhn-channel_list
251
240
  - spec/data/rhn/systemid
@@ -256,15 +245,18 @@ test_files:
256
245
  - spec/data/subscription_manager/output_list_installed_subscribed
257
246
  - spec/data/subscription_manager/output_orgs
258
247
  - spec/data/yum/first.repo
248
+ - spec/data/yum/output_repo_list
259
249
  - spec/data/yum/output_repoquery_multiple
260
250
  - spec/data/yum/output_repoquery_single
261
251
  - spec/data/yum/second.repo
252
+ - spec/deb_spec.rb
262
253
  - spec/disk_spec.rb
263
254
  - spec/distro_spec.rb
264
255
  - spec/fstab_spec.rb
265
256
  - spec/hosts_spec.rb
266
257
  - spec/linux_admin_spec.rb
267
258
  - spec/logical_volume_spec.rb
259
+ - spec/package_spec.rb
268
260
  - spec/partition_spec.rb
269
261
  - spec/physical_volume_spec.rb
270
262
  - spec/registration_system_spec.rb