Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Brocade FOS-based SAN devices #254

Merged
merged 1 commit into from
Feb 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/train/platforms/detect/helpers/os_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ def unix_uname_m
@uname[:m] = command_output('uname -m')
end

def brocade_version
return @cache[:brocade] if @cache.key?(:brocade)
res = command_output('version')

m = res.match(/^Fabric OS:\s+v(\S+)$/)
unless m.nil?
return @cache[:brocade] = { version: m[1], type: 'fos' }
end

@cache[:brocade] = nil
end

def cisco_show_version
return @cache[:cisco] if @cache.key?(:cisco)
res = command_output('show version')
Expand Down
22 changes: 22 additions & 0 deletions lib/train/platforms/detect/specifications/os.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,13 @@ def self.load
end
}

# brocade family detected here if device responds to 'uname' command,
# happens when logging in as root
plat.family('brocade').title('Brocade Family').in_family('linux')
.detect {
!brocade_version.nil?
}

# genaric linux
# this should always be last in the linux family list
plat.name('linux').title('Genaric Linux').in_family('linux')
Expand Down Expand Up @@ -537,6 +544,21 @@ def self.load
@platform[:arch] = nil
true
}

# brocade family
plat.family('brocade').title('Brocade Family').in_family('os')
.detect {
!brocade_version.nil?
}

plat.name('brocade_fos').title('Brocade FOS').in_family('brocade')
.detect {
v = brocade_version
next unless v[:type] == 'fos'
@platform[:release] = v[:version]
@platform[:arch] = nil
true
}
end
end
end
12 changes: 12 additions & 0 deletions test/unit/platforms/os_detect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,16 @@ def debian_scan(id, version)
platform[:release].must_equal('5.2')
end
end

describe 'brocade' do
it 'recognizes Brocade FOS-based SAN switches' do
mock = Train::Transports::Mock::Connection.new
mock.mock_command('version', "Kernel: 2.6.14.2\nFabric OS: v7.4.2a\nMade on: Thu Jun 29 19:22:14 2017\nFlash: Sat Sep 9 17:30:42 2017\nBootProm: 1.0.11")
platform = Train::Platforms::Detect.scan(mock)

platform[:name].must_equal('brocade_fos')
platform[:family].must_equal('brocade')
platform[:release].must_equal('7.4.2a')
end
end
end