Skip to content

Commit

Permalink
Merge pull request thecodeteam#27 from aimers1975/VXFM-2907
Browse files Browse the repository at this point in the history
VXFM-2097 Be able to input the root creds for FlexOS gateway during discovery
  • Loading branch information
gavin-scott authored Oct 2, 2018
2 parents 3759c11 + f47ddb2 commit 9c99f9e
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion bin/discovery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "json"
require "timeout"
require "pathname"
require "asm/util"

puppet_dir = File.join(Pathname.new(__FILE__).parent.parent,'lib','puppet')
require "%s/scaleio/transport" % [puppet_dir]
Expand All @@ -13,6 +14,9 @@
opt :port, "ScaleIO gateway port", :default => 443
opt :username, "ScaleIO gateway username", :type => :string, :required => true
opt :password, "ScaleIO gateway password", :type => :string, :default => ENV["PASSWORD"]
opt :os_username, "", :type => :string, :required => true
opt :os_password_id, "Not used"
opt :os_password, "", :type => :string, :default => ENV["OS_PASSWORD"]
opt :timeout, "ScaleIO gateway connection timeout", :type => :integer, :default => 300, :required => false
opt :credential_id, "dummy value for ASM, not used"
opt :output, "Location of the file where facts file needs to be created", :type => :string, :required => false
Expand Down Expand Up @@ -41,6 +45,7 @@ def vxflexos_hostname
end

def collect_scaleio_facts
check_ssh_connection
facts = {:protection_domain_list => []}
facts[:certname] = "scaleio-%s" % [@opts[:server]]
facts[:name] = vxflexos_hostname
Expand Down Expand Up @@ -83,6 +88,17 @@ def collect_scaleio_facts
facts
end

def check_ssh_connection
puts "Attempting to ssh to verify root credentials."
begin
result = ASM::Util.execute_script_via_ssh(@opts[:server], @opts[:os_username], @opts[:os_password], "ls")
puts "SSH test result code: %s, result: %s, error msg: %s" % [result[:exit_code],result[:stdout],result[:stderr]] if result
rescue
puts "ERROR!! SSH test result code: %s, result: %s, error msg: %s" % [result[:exit_code],result[:stdout],result[:stderr]] if result
raise
end
end

def scaleio_systems
url = transport.get_url("/api/types/System/instances")
transport.post_request(url, {}, "get") || []
Expand Down Expand Up @@ -179,7 +195,7 @@ def scaleio_cookie
results ||= {}
scaleio_cache = "/opt/Dell/ASM/cache"
Dir.mkdir(scaleio_cache) unless Dir.exists? scaleio_cache
file_path = File.join(scaleio_cache, "#{opts[:server]}.json")
file_path = File.join(scaleio_cache, "#{@opts[:server]}.json")
File.write(file_path, results) unless results.empty?
end
end
Expand Down

0 comments on commit 9c99f9e

Please sign in to comment.