Skip to content

Commit

Permalink
modify ohai plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
privateip committed Jul 10, 2013
1 parent 7670105 commit 58de2d4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions cookbooks/eos/files/default/ohai/eos.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Chef Cookbook : eos
# File : templates/defaults/eos.rb
#
# Copyright 2013 Arista Networks
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
provides "eos"
provides "eos/version"

eos Mash.new unless eos
eos[:version] = Mash.new unless eos[:version]

begin
cmd = "FastCli -c \"show version\""
status, stdout, stderr = run_command(:command => cmd)
lines = stdout.split("\n")

eos[:version][:os_name] = lines.shift
lines.each do |line|
next if line.empty?

k,v = line.split(':')
if v.nil?
Chef::Log.warn "Ohai eos version plugin - unparsable line 'line'"
else
k.downcase!
k.gsub!(' ','_')
eos[:version][k] = v.strip
end
end
rescue => e
Chef::Log.warn "Ohai eos version plugin failed with '#{e}'"
end

0 comments on commit 58de2d4

Please sign in to comment.