linux_admin 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in linux_admin.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Red Hat, Inc.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # LinuxAdmin
2
+ [![Build Status](https://travis-ci.org/ManageIQ/linux_admin.png)](https://travis-ci.org/ManageIQ/linux_admin)
3
+ [![Code Climate](https://codeclimate.com/github/ManageIQ/linux_admin.png)](https://codeclimate.com/github/ManageIQ/linux_admin)
4
+ [![Coverage Status](https://coveralls.io/repos/ManageIQ/linux_admin/badge.png?branch=master)](https://coveralls.io/r/ManageIQ/linux_admin)
5
+ [![Dependency Status](https://gemnasium.com/ManageIQ/linux_admin.png)](https://gemnasium.com/ManageIQ/linux_admin)
6
+
7
+ LinuxAdmin is a module to simplify management of linux systems.
8
+ It should be a single place to manage various system level configurations,
9
+ registration, updates, etc.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'linux_admin'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install linux_admin
24
+
25
+ ## Usage
26
+
27
+ TODO: Write usage instructions here
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new('spec')
5
+ task :test => :spec
6
+ task :default => :spec
@@ -0,0 +1,25 @@
1
+ $:.push("../lib")
2
+ require 'linux_admin'
3
+
4
+ username = "MyUsername"
5
+ password = "MyPassword"
6
+
7
+
8
+ reg_status = LinuxAdmin.registered?
9
+ puts "Registration Status: #{reg_status.to_s}"
10
+
11
+ unless reg_status
12
+ puts "Registering to Subscription Manager..."
13
+ LinuxAdmin::SubscriptionManager.register(:username => username, :password => password)
14
+ end
15
+
16
+ reg_type = LinuxAdmin.registration_type
17
+ puts "Registration System: #{reg_type}"
18
+
19
+ puts "Subscribing to channels..."
20
+ reg_type.subscribe(reg_type.available_subscriptions.keys.first)
21
+ puts "Checking for updates..."
22
+ if LinuxAdmin::Yum.updates_available?
23
+ puts "Updates Available \n Updating..."
24
+ puts "Updates Applied" if LinuxAdmin::Yum.update
25
+ end
@@ -0,0 +1,21 @@
1
+ require 'linux_admin/common'
2
+ require 'linux_admin/rhn'
3
+ require 'linux_admin/subscription_manager'
4
+ require 'linux_admin/version'
5
+ require 'linux_admin/yum'
6
+
7
+ module LinuxAdmin
8
+ def self.registered?
9
+ !!self.registration_type
10
+ end
11
+
12
+ def self.registration_type
13
+ if SubscriptionManager.registered?
14
+ SubscriptionManager
15
+ elsif Rhn.registered?
16
+ Rhn
17
+ else
18
+ nil
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ module LinuxAdmin
2
+ module Common
3
+ def self.run(cmd, options = {})
4
+ begin
5
+ r, w = IO.pipe
6
+ pid, status = Process.wait2(Kernel.spawn(cmd, :err => [:child, :out], :out => w))
7
+ w.close
8
+ if options[:return_output] && status.exitstatus == 0
9
+ r.read
10
+ elsif options[:return_exitstatus] || status.exitstatus == 0
11
+ status.exitstatus
12
+ else
13
+ raise "Error: Exit Code #{status.exitstatus}"
14
+ end
15
+ rescue
16
+ return nil if options[:return_exitstatus]
17
+ raise
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ require 'nokogiri'
2
+
3
+ module LinuxAdmin
4
+ module Rhn
5
+ def self.systemid_file
6
+ "/etc/sysconfig/rhn/systemid"
7
+ end
8
+
9
+ def self.registered?
10
+ id = ""
11
+ if File.exists?(systemid_file)
12
+ xml = Nokogiri.XML(File.read(systemid_file))
13
+ id = xml.xpath('/params/param/value/struct/member[name="system_id"]/value/string').text
14
+ end
15
+ id.length > 0
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,40 @@
1
+ require 'date'
2
+
3
+ module LinuxAdmin
4
+ module SubscriptionManager
5
+ def self.registered?
6
+ Common.run("subscription-manager identity", :return_exitstatus => true) == 0
7
+ end
8
+
9
+ def self.refresh
10
+ Common.run("subscription-manager refresh")
11
+ end
12
+
13
+ def self.register(options = {})
14
+ cmd = "subscription-manager register"
15
+ cmd << " --username=#{options[:username]} --password=#{options[:password]}" if options[:username] && options[:password]
16
+ Common.run(cmd)
17
+ end
18
+
19
+ def self.subscribe(pool_id)
20
+ Common.run("subscription-manager attach --pool #{pool_id}")
21
+ end
22
+
23
+ def self.available_subscriptions
24
+ output = Common.run("subscription-manager list --all --available", :return_output => true)
25
+ output.split("\n\n").each_with_object({}) do |subscription, subscriptions_hash|
26
+ hash = {}
27
+ subscription.each_line do |line|
28
+ # Strip the header lines if they exist
29
+ next if (line.start_with?("+---") && line.end_with?("---+\n")) || line.strip == "Available Subscriptions"
30
+
31
+ key, value = line.split(":", 2)
32
+ hash[key.strip.downcase.tr(" -", "_").to_sym] = value.strip
33
+ end
34
+ hash[:ends] = Date.strptime(hash[:ends], "%m/%d/%Y")
35
+
36
+ subscriptions_hash[hash[:pool_id]] = hash
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module LinuxAdmin
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,16 @@
1
+ module LinuxAdmin
2
+ module Yum
3
+ def self.updates_available?
4
+ exitstatus = Common.run("yum check-update", :return_exitstatus => true)
5
+ case exitstatus
6
+ when 0; false
7
+ when 100; true
8
+ else raise "Error: Exit Code #{exitstatus}"
9
+ end
10
+ end
11
+
12
+ def self.update
13
+ Common.run("yum -y update")
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'linux_admin/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "linux_admin"
8
+ spec.version = LinuxAdmin::VERSION
9
+ spec.authors = ["Brandon Dunne"]
10
+ spec.email = ["brandondunne@hotmail.com"]
11
+ spec.description = %q{
12
+ LinuxAdmin is a module to simplify management of linux systems.
13
+ It should be a single place to manage various system level configurations,
14
+ registration, updates, etc.
15
+ }
16
+ spec.summary = %q{LinuxAdmin is a module to simplify management of linux systems.}
17
+ spec.homepage = "http://github.com/ManageIQ/linux_admin"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files`.split($/)
21
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency "rspec", "~> 2.13"
28
+ spec.add_development_dependency "coveralls"
29
+
30
+ spec.add_dependency "nokogiri"
31
+ end
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin::Common do
4
+ context ".run" do
5
+ it "command ok exit ok" do
6
+ expect(described_class.run("true")).to be_true
7
+ end
8
+
9
+ it "command ok exit bad" do
10
+ expect { described_class.run("false") }.to raise_error
11
+ end
12
+
13
+ it "command bad" do
14
+ expect { described_class.run("XXXXX") }.to raise_error
15
+ end
16
+
17
+ context "with :return_exitstatus => true" do
18
+ it "command ok exit ok" do
19
+ expect(described_class.run("true", :return_exitstatus => true)).to eq(0)
20
+ end
21
+
22
+ it "command ok exit bad" do
23
+ expect(described_class.run("false", :return_exitstatus => true)).to eq(1)
24
+ end
25
+
26
+ it "command bad" do
27
+ expect(described_class.run("XXXXX", :return_exitstatus => true)).to be_nil
28
+ end
29
+ end
30
+
31
+ context "with :return_output => true" do
32
+ it "command ok exit ok" do
33
+ expect(described_class.run("echo \"Hello World\"", :return_output => true)).to eq("Hello World\n")
34
+ end
35
+
36
+ it "command ok exit bad" do
37
+ expect { described_class.run("false", :return_output => true) }.to raise_error
38
+ end
39
+
40
+ it "command bad" do
41
+ expect { described_class.run("XXXXX", :return_output => true) }.to raise_error
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,57 @@
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>
@@ -0,0 +1,57 @@
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>
@@ -0,0 +1,42 @@
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
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin do
4
+ context ".registered?" do
5
+ it "when registered Subscription Manager" do
6
+ stub_registered_to_system(:sm)
7
+ expect(described_class.registered?).to be_true
8
+ end
9
+
10
+ it "when registered RHN" do
11
+ stub_registered_to_system(:rhn)
12
+ expect(described_class.registered?).to be_true
13
+ end
14
+
15
+ it "when unregistered" do
16
+ stub_registered_to_system(nil)
17
+ expect(described_class.registered?).to be_false
18
+ end
19
+ end
20
+
21
+ context ".registration_type" do
22
+ it "when registered Subscription Manager" do
23
+ stub_registered_to_system(:sm)
24
+ expect(described_class.registration_type).to eq(LinuxAdmin::SubscriptionManager)
25
+ end
26
+
27
+ it "when registered RHN" do
28
+ stub_registered_to_system(:rhn)
29
+ expect(described_class.registration_type).to eq(LinuxAdmin::Rhn)
30
+ end
31
+
32
+ it "when unregistered" do
33
+ stub_registered_to_system(nil)
34
+ expect(described_class.registration_type).to be_nil
35
+ end
36
+ end
37
+
38
+ def stub_registered_to_system(system)
39
+ described_class::SubscriptionManager.stub(:registered? => (system == :sm))
40
+ described_class::Rhn.stub(:registered? => (system == :rhn))
41
+ end
42
+ end
data/spec/rhn_spec.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin::Rhn do
4
+ it ".systemid_file" do
5
+ expect(described_class.systemid_file).to be_kind_of(String)
6
+ end
7
+
8
+ context ".registered?" do
9
+ it "with registered system_id" do
10
+ described_class.stub(:systemid_file => data_file_path("rhn/systemid"))
11
+ expect(described_class).to be_registered
12
+ end
13
+
14
+ it "with unregistered system_id" do
15
+ described_class.stub(:systemid_file => data_file_path("rhn/systemid.missing_system_id"))
16
+ expect(described_class).to_not be_registered
17
+ end
18
+
19
+ it "with missing systemid file" do
20
+ described_class.stub(:systemid_file => data_file_path("rhn/systemid.missing_file"))
21
+ expect(described_class).to_not be_registered
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,29 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
4
+ require 'linux_admin'
5
+ # This file was generated by the `rspec --init` command. Conventionally, all
6
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
7
+ # Require this file using `require "spec_helper"` to ensure that it is only
8
+ # loaded once.
9
+ #
10
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
11
+ RSpec.configure do |config|
12
+ config.treat_symbols_as_metadata_keys_with_true_values = true
13
+ config.run_all_when_everything_filtered = true
14
+ # config.filter_run :focus
15
+
16
+ # Run specs in random order to surface order dependencies. If you find an
17
+ # order dependency and want to debug it, you can fix the order by providing
18
+ # the seed, which is printed after each run.
19
+ # --seed 1234
20
+ config.order = 'random'
21
+ end
22
+
23
+ def data_file_path(to)
24
+ File.expand_path(to, File.join(File.dirname(__FILE__), "data"))
25
+ end
26
+
27
+ def sample_output(to)
28
+ File.read(data_file_path(to))
29
+ end
@@ -0,0 +1,87 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin::SubscriptionManager do
4
+ context ".registered?" do
5
+ it "system with subscription-manager commands" do
6
+ LinuxAdmin::Common.stub(:run => 0)
7
+ expect(described_class.registered?).to be_true
8
+ end
9
+
10
+ it "system without subscription-manager commands" do
11
+ LinuxAdmin::Common.stub(:run => 255)
12
+ expect(described_class.registered?).to be_false
13
+ end
14
+ end
15
+
16
+ it ".refresh" do
17
+ LinuxAdmin::Common.should_receive(:run).once
18
+ described_class.refresh
19
+ end
20
+
21
+ context ".register" do
22
+ it "no username" do
23
+ LinuxAdmin::Common.should_receive(:run).once.with("subscription-manager register")
24
+ described_class.register
25
+ end
26
+
27
+ it "with username and password" do
28
+ LinuxAdmin::Common.should_receive(:run).once.with("subscription-manager register --username=SomeUser --password=SomePass")
29
+ described_class.register(:username => "SomeUser", :password => "SomePass")
30
+ end
31
+ end
32
+
33
+ it ".subscribe" do
34
+ LinuxAdmin::Common.should_receive(:run).once
35
+ described_class.subscribe(nil)
36
+ end
37
+
38
+ it ".available_subscriptions" do
39
+ LinuxAdmin::Common.stub(:run => sample_output("subscription_manager/output_list_all_available"))
40
+ expect(described_class.available_subscriptions).to eq({
41
+ "82c042fca983889b10178893f29b06e3" => {
42
+ :subscription_name => "Example Subscription",
43
+ :sku => "SER0123",
44
+ :pool_id => "82c042fca983889b10178893f29b06e3",
45
+ :quantity => "1690",
46
+ :service_level => "None",
47
+ :service_type => "None",
48
+ :multi_entitlement => "No",
49
+ :ends => Date.parse("2022-01-01"),
50
+ :system_type => "Physical",
51
+ },
52
+ "4f738052ec866192c775c62f408ab868" => {
53
+ :subscription_name => "My Private Subscription",
54
+ :sku => "SER9876",
55
+ :pool_id => "4f738052ec866192c775c62f408ab868",
56
+ :quantity => "Unlimited",
57
+ :service_level => "None",
58
+ :service_type => "None",
59
+ :multi_entitlement => "No",
60
+ :ends => Date.parse("2013-06-04"),
61
+ :system_type => "Virtual",
62
+ },
63
+ "3d81297f352305b9a3521981029d7d83" => {
64
+ :subscription_name => "Shared Subscription - With other characters, (2 sockets) (Up to 1 guest)",
65
+ :sku => "RH0123456",
66
+ :pool_id => "3d81297f352305b9a3521981029d7d83",
67
+ :quantity => "1",
68
+ :service_level => "Self-support",
69
+ :service_type => "L1-L3",
70
+ :multi_entitlement => "No",
71
+ :ends => Date.parse("2013-05-15"),
72
+ :system_type => "Virtual",
73
+ },
74
+ "87cefe63b67984d5c7e401d833d2f87f" => {
75
+ :subscription_name => "Example Subscription, Premium (up to 2 sockets) 3 year",
76
+ :sku => "MCT0123A9",
77
+ :pool_id => "87cefe63b67984d5c7e401d833d2f87f",
78
+ :quantity => "1",
79
+ :service_level => "Premium",
80
+ :service_type => "L1-L3",
81
+ :multi_entitlement => "No",
82
+ :ends => Date.parse("2013-07-05"),
83
+ :system_type => "Virtual",
84
+ },
85
+ })
86
+ end
87
+ end
data/spec/yum_spec.rb ADDED
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe LinuxAdmin::Yum do
4
+ context ".updates_available?" do
5
+ it "updates are available" do
6
+ LinuxAdmin::Common.stub(:run => 100)
7
+ expect(described_class.updates_available?).to be_true
8
+ end
9
+
10
+ it "updates not available" do
11
+ LinuxAdmin::Common.stub(:run => 0)
12
+ expect(described_class.updates_available?).to be_false
13
+ end
14
+
15
+ it "other exit code" do
16
+ LinuxAdmin::Common.stub(:run => 255)
17
+ expect { described_class.updates_available? }.to raise_error
18
+ end
19
+
20
+ it "other error" do
21
+ LinuxAdmin::Common.stub(:run).and_raise(RuntimeError)
22
+ expect { described_class.updates_available? }.to raise_error
23
+ end
24
+ end
25
+
26
+ it ".update" do
27
+ LinuxAdmin::Common.should_receive(:run).once
28
+ described_class.update
29
+ end
30
+ end
data/travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - jruby-18mode # JRuby in 1.8 mode
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+ - rbx-18mode
9
+ - rbx-19mode
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: linux_admin
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brandon Dunne
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.13'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.13'
62
+ - !ruby/object:Gem::Dependency
63
+ name: coveralls
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: nokogiri
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! '
95
+
96
+ LinuxAdmin is a module to simplify management of linux systems.
97
+
98
+ It should be a single place to manage various system level configurations,
99
+
100
+ registration, updates, etc.
101
+
102
+ '
103
+ email:
104
+ - brandondunne@hotmail.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - .gitignore
110
+ - Gemfile
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - examples/subscription_manager_hosted.rb
115
+ - lib/linux_admin.rb
116
+ - lib/linux_admin/common.rb
117
+ - lib/linux_admin/rhn.rb
118
+ - lib/linux_admin/subscription_manager.rb
119
+ - lib/linux_admin/version.rb
120
+ - lib/linux_admin/yum.rb
121
+ - linux_admin.gemspec
122
+ - spec/common_spec.rb
123
+ - spec/data/rhn/systemid
124
+ - spec/data/rhn/systemid.missing_system_id
125
+ - spec/data/subscription_manager/output_list_all_available
126
+ - spec/linux_admin_spec.rb
127
+ - spec/rhn_spec.rb
128
+ - spec/spec_helper.rb
129
+ - spec/subscription_manager_spec.rb
130
+ - spec/yum_spec.rb
131
+ - travis.yml
132
+ homepage: http://github.com/ManageIQ/linux_admin
133
+ licenses:
134
+ - MIT
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ segments:
146
+ - 0
147
+ hash: 433652015813949549
148
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
155
+ - 0
156
+ hash: 433652015813949549
157
+ requirements: []
158
+ rubyforge_project:
159
+ rubygems_version: 1.8.24
160
+ signing_key:
161
+ specification_version: 3
162
+ summary: LinuxAdmin is a module to simplify management of linux systems.
163
+ test_files:
164
+ - spec/common_spec.rb
165
+ - spec/data/rhn/systemid
166
+ - spec/data/rhn/systemid.missing_system_id
167
+ - spec/data/subscription_manager/output_list_all_available
168
+ - spec/linux_admin_spec.rb
169
+ - spec/rhn_spec.rb
170
+ - spec/spec_helper.rb
171
+ - spec/subscription_manager_spec.rb
172
+ - spec/yum_spec.rb