summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-06-16 21:09:52 +0100
committerThom May <thom@may.lt>2015-06-16 21:09:52 +0100
commit31f6415c853f3070b0399ac2eb09094eb81939d2 (patch)
treeffed9c9a1eab52060dedaf810c0a72eb96a17fb1
parent65068e5df78261b42570b991a49e5fc45fe511ad (diff)
parenteb74f4a34335dbb9b176841729ab9ba25ca7a9a2 (diff)
downloadohai-31f6415c853f3070b0399ac2eb09094eb81939d2.tar.gz
Merge pull request #544 from mattray/nexus
add support for Wind River Linux and Cisco's Nexus platforms
-rw-r--r--lib/ohai/plugins/linux/platform.rb21
-rw-r--r--spec/unit/plugins/linux/platform_spec.rb14
2 files changed, 29 insertions, 6 deletions
diff --git a/lib/ohai/plugins/linux/platform.rb b/lib/ohai/plugins/linux/platform.rb
index b538d1da..c194afa8 100644
--- a/lib/ohai/plugins/linux/platform.rb
+++ b/lib/ohai/plugins/linux/platform.rb
@@ -1,6 +1,6 @@
#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# Author:: Adam Jacob (<adam@chef.io>)
+# Copyright:: Copyright (c) 2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -60,9 +60,20 @@ Ohai.plugin(:Platform) do
platform get_redhatish_platform(contents)
platform_version contents.match(/(\d\.\d\.\d)/)[0]
elsif File.exists?("/etc/redhat-release")
- contents = File.read("/etc/redhat-release").chomp
- platform get_redhatish_platform(contents)
- platform_version get_redhatish_version(contents)
+ if File.exists?('/etc/os-release') # check if Cisco
+ # don't clobber existing os-release properties, point to a different cisco file
+ contents = {}
+ File.read('/etc/os-release').split.collect {|x| x.split('=')}.each {|x| contents[x[0]] = x[1]}
+ if contents['CISCO_RELEASE_INFO'] && File.exists?(contents['CISCO_RELEASE_INFO'])
+ platform contents['ID']
+ platform_family contents['ID_LIKE']
+ platform_version contents['VERSION'] || ""
+ end
+ else
+ contents = File.read("/etc/redhat-release").chomp
+ platform get_redhatish_platform(contents)
+ platform_version get_redhatish_version(contents)
+ end
elsif File.exists?("/etc/system-release")
contents = File.read("/etc/system-release").chomp
platform get_redhatish_platform(contents)
diff --git a/spec/unit/plugins/linux/platform_spec.rb b/spec/unit/plugins/linux/platform_spec.rb
index a20b0c01..69dbc04e 100644
--- a/spec/unit/plugins/linux/platform_spec.rb
+++ b/spec/unit/plugins/linux/platform_spec.rb
@@ -37,6 +37,7 @@ describe Ohai::System, "Linux plugin platform" do
allow(File).to receive(:exists?).with("/etc/oracle-release").and_return(false)
allow(File).to receive(:exists?).with("/etc/parallels-release").and_return(false)
allow(File).to receive(:exists?).with("/usr/bin/raspi-config").and_return(false)
+ allow(File).to receive(:exists?).with("/etc/os-release").and_return(false)
end
describe "on lsb compliant distributions" do
@@ -175,7 +176,6 @@ describe Ohai::System, "Linux plugin platform" do
@plugin.run
expect(@plugin[:platform_version]).to eq('3.18.2-2-ARCH')
end
-
end
describe "on gentoo" do
@@ -510,4 +510,16 @@ describe Ohai::System, "Linux plugin platform" do
end
end
end
+
+ describe "on Wind River Linux for Cisco Nexus" do
+ it "should set platform to nexus and platform_family to wrlinux" do
+ @plugin.lsb = nil
+ allow(File).to receive(:exists?).with("/etc/redhat-release").and_return(true)
+ allow(File).to receive(:exists?).with("/etc/os-release").and_return(true)
+ expect(File).to receive(:read).with("/etc/os-release").and_return("ID_LIKE=wrlinux\nID=nexus\nCISCO_RELEASE_INFO=/etc/os-release")
+ @plugin.run
+ expect(@plugin[:platform]).to eq("nexus")
+ expect(@plugin[:platform_family]).to eq("wrlinux")
+ end
+ end
end