-
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 openvms detection #159
Changes from 3 commits
c14774e
ea9da75
34df1f8
df89031
4c1071e
a4391c2
a5a8893
9599fd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
require 'train/extras/os_detect_windows' | ||
require 'train/extras/os_detect_esx' | ||
require 'train/extras/os_detect_arista_eos' | ||
require 'train/extras/os_detect_openvms' | ||
|
||
module Train::Extras | ||
class OSCommon | ||
|
@@ -23,6 +24,7 @@ class OSCommon | |
include Train::Extras::DetectWindows | ||
include Train::Extras::DetectEsx | ||
include Train::Extras::DetectAristaEos | ||
include Train::Extras::DetectOpenVMS | ||
|
||
attr_accessor :backend | ||
def initialize(backend, platform = nil) | ||
|
@@ -96,6 +98,8 @@ def detect_family | |
# TODO: extend base implementation for detecting the family type | ||
# to Windows and others | ||
case uname_s | ||
when /unrecognized command verb/ | ||
@platform[:family] = 'openvms' | ||
when /linux/i | ||
@platform[:family] = 'linux' | ||
when /./ | ||
|
@@ -105,8 +109,8 @@ def detect_family | |
@platform[:family] = nil | ||
end | ||
|
||
# try to detect the platform | ||
return nil unless @platform[:family].nil? | ||
# try to detect the platform if the platform is set to nil, otherwise this code will never work | ||
return nil if @platform[:family].nil? | ||
detect_family_type | ||
end | ||
|
||
|
@@ -116,6 +120,7 @@ def detect_family_type # rubocop:disable Metrics/CyclomaticComplexity, Metrics/P | |
return detect_windows if pf == 'windows' | ||
return detect_darwin if pf == 'darwin' | ||
return detect_esx if pf == 'esx' | ||
return detect_openvms if pf =="openvms" | ||
|
||
if %w{freebsd netbsd openbsd aix solaris2 hpux}.include?(pf) | ||
return detect_via_uname | ||
|
@@ -124,6 +129,7 @@ def detect_family_type # rubocop:disable Metrics/CyclomaticComplexity, Metrics/P | |
# unix based systems combine the above | ||
return true if pf == 'unix' and detect_darwin | ||
return true if pf == 'unix' and detect_esx | ||
#This is assuming that pf is set to unix, this should be if pf == 'linux' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can argue that arista should be in detect_linux There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @backend.run_command('show system/noprocess') will always return OpenVMS Vxx e.g. "OpenVMS V8.2 on node VS3B2 3-NOV-2016 21:41:10.97 Uptime 171 04:49:02 " |
||
return true if pf == 'unix' and detect_arista_eos | ||
return true if pf == 'unix' and detect_via_uname | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# encoding: utf-8 | ||
# author: Brian Doody (HPE) | ||
# This is heavily based on: | ||
# | ||
# OHAI https://github.com/chef/ohai | ||
# by Adam Jacob, Chef Software Inc | ||
# | ||
require 'train/extras/uname' | ||
|
||
module Train::Extras | ||
module DetectOpenVMS | ||
include Train::Extras::Uname | ||
|
||
def detect_openvms | ||
cmd = @backend.run_command('show system/noprocess') | ||
|
||
return false if cmd.exit_status != 0 | ||
return false if cmd.stdout.empty? | ||
|
||
@platform[:name] = cmd.stdout.downcase.split(" ")[0] | ||
cmd = @backend.run_command('write sys$output f$getsyi("VERSION")') | ||
@platform[:release] = cmd.stdout.downcase.split("\n")[1][1..-1] | ||
cmd = @backend.run_command('write sys$output f$getsyi("ARCH_NAME")') | ||
@platform[:arch] = cmd.stdout.downcase.split("\n")[1] | ||
|
||
true | ||
|
||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,7 @@ def to_s | |
|
||
class OS < OSCommon | ||
def initialize(backend) | ||
super(backend, { family: 'unix' }) | ||
super(backend) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just thinking if it is not easier to count openvms as a unix-like system as well? Not sure about that. This would allow us to just use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the original code and the problem there is that |
||
end | ||
end | ||
end | ||
|
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.
not sure if we can expect that every system that has not uname_s is openvms
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 just don't set any family then
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.
problem is that if we omit this part, it matches
when /./
@platform[:family] = 'unix'
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.
Its a pain because the uname_s command doesnt returns an error that can be detected by the command object (old os) but a message that says : %DCL-W-IVVERB, unrecognized command verb - check validity and spelling
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 we should create a method for detecting non-uname operating systems. Is there a reliable command that only works on openvms to detect the family?
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.
Okay, lets use this for now until we find any other
non-uname
operating system