1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-02-15 05:57:23 +03:00

B #5396: set ONEFLOW_ENDPOINT with onezone (#1790)

This commit is contained in:
Alejandro Huertas Herrero 2022-02-18 13:18:55 +01:00 committed by GitHub
parent e93530eff1
commit 10fd18d19c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 2 deletions

View File

@ -577,7 +577,23 @@ class OneZoneHelper < OpenNebulaHelper::OneHelper
puts "Endpoint changed to \"#{zone['TEMPLATE/ENDPOINT']}\" in " <<
"#{ENV['HOME']}/.one/one_endpoint"
end
return 0
return unless zone['TEMPLATE/ONEFLOW_ENDPOINT']
# Set ONEFLOW_ENDPOINT
if temporary_zone
puts "Type: export ONEFLOW_URL=#{zone['TEMPLATE/ONEFLOW_ENDPOINT']}"
else
File.open(ENV['HOME'] + '/.one/oneflow_endpoint', 'w') do |f|
f.puts zone['TEMPLATE/ONEFLOW_ENDPOINT']
end
puts 'OneFlow Endpoint changed to ' \
"\"#{zone['TEMPLATE/ONEFLOW_ENDPOINT']}\" in " <<
"#{ENV['HOME']}/.one/oneflow_endpoint"
end
0
end
private

View File

@ -319,10 +319,21 @@ module Service
class Client
def initialize(opts={})
endpoint = '/.one/oneflow_endpoint'
@username = opts[:username] || ENV['ONEFLOW_USER']
@password = opts[:password] || ENV['ONEFLOW_PASSWORD']
url = opts[:url] || ENV['ONEFLOW_URL'] || 'http://localhost:2474'
if opts[:url]
url = opts[:url]
elsif ENV['ONEFLOW_URL']
url = ENV['ONEFLOW_URL']
elsif ENV['HOME'] && File.exists?(ENV['HOME'] + endpoint)
url = File.read(ENV['HOME'] + endpoint).strip
elsif File.exists?('/var/lib/one/.one/oneflow_endpoint')
url = File.read('/var/lib/one/.one/oneflow_endpoint').strip
else
url = 'http://localhost:2474'
end
if @username.nil? && @password.nil?
if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and File.file?(ENV["ONE_AUTH"])