-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add detection for Arista EOS #158
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# encoding: utf-8 | ||
# author: Jere Julian | ||
# | ||
# Arista EOS has 2 modes. Most compliance tests will use the network CLI | ||
# but when working with vagrant, its common to encounter the raw bash shell. | ||
require 'json' | ||
|
||
module Train::Extras | ||
module DetectAristaEos | ||
def detect_arista_eos | ||
if unix_file?('/usr/bin/FastCli') | ||
output = @backend.run_command('FastCli -p 15 -c "show version | json"').stdout | ||
@platform[:name] = 'arista_eos_bash' | ||
family = 'fedora' | ||
else | ||
output = @backend.run_command('show version | json').stdout | ||
end | ||
|
||
unless output.empty? | ||
eos_ver = JSON.parse(output) | ||
@platform[:name] = @platform[:name] || 'arista_eos' | ||
family ||= 'arista_eos' | ||
@platform[:family] = family | ||
@platform[:release] = eos_ver['version'] | ||
@platform[:arch] = eos_ver['architecture'] | ||
true | ||
end | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not using
fedora
in this case?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you are in the bash shell, then you can do all the fedora things. However, when you login the way you would to a typical running switch, you are in a custom EOS CLI. You can still prefix linux commands with 'bash' from this mode but common commands are things like 'show running-config', 'show interfaces status', etc. Thus, things that expect to be in a regular linux shell will need special handling.
I'm definitely willing to go another route, if appropriate.
You can test yourself by registering at http://Arista.com/, then going to Software Downloads --> vEOS and downloading the files for your preferred hypervisor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use
arista_eos
as the family for both instead of fedora?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that more resources would adapt their behavior based on :family but since that's not the case, I'm fine with setting both to
arista_eos
if you think that's best.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we want to count EOS as linux, we should also add it to https://github.com/chef/train/blob/master/lib/train/extras/os_common.rb#L68 because most resources go with
inspec.os.linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about this a bit. If we always mark EOS as family: arista_eos and include that as "linux", then resources will fail instead of skipping when we're in the usual CLI mode unless from the os detection I can specify to default to prefixing all linux commands with
bash
to drop to a linux shell (Ex:bash uname -a
orbash sudo cat /etc/passwd
).Alternatively, I could just patch up the resources as we make use of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we make
bash
default and use the EOS CLI only withinEOS specific InSpec resources. Is bash available on all devices?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could achieve that by implementing a specific command wrapper for eos https://github.com/chef/train/blob/master/lib/train/extras/command_wrapper.rb#L164-L175
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that will work. I'm not sure I'll get the wrapper in by Friday but I don't think that needs to hold up the initial platform support. So, to recap, I'll set the family to
arista_eos
for both cases and we can improve handling the differences with a command wrapper.