mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Fix misbehavior around connection to slave node in pool
The idea behind this fix is following: if u connect to slave node its should notify u where is you master, then u reconnect to master and perform any actions in front this server
This commit is contained in:
parent
d4868d6fde
commit
09c33efabc
2 changed files with 18 additions and 0 deletions
|
@ -123,6 +123,11 @@ module Fog
|
|||
@defaults = options[:xenserver_defaults] || {}
|
||||
@timeout = options[:xenserver_timeout] || 30
|
||||
@connection = Fog::XenServer::Connection.new(@host, @timeout)
|
||||
host_master = @connection.find_pool_master(@username, @password)
|
||||
if host_master!= @host
|
||||
@host = host_master;
|
||||
@connection = Fog::XenServer::Connection.new(@host, @timeout)
|
||||
end
|
||||
@connection.authenticate(@username, @password)
|
||||
end
|
||||
|
||||
|
|
|
@ -22,6 +22,19 @@ module Fog
|
|||
@factory.timeout = timeout
|
||||
end
|
||||
|
||||
def find_pool_master( username, password )
|
||||
response = @factory.call('session.login_with_password', username.to_s, password.to_s)
|
||||
raise Fog::XenServer::InvalidLogin.new unless response["Status"] =~ /Success/
|
||||
@credentials = response["Value"]
|
||||
response = @factory.call('host.get_all_records', @credentials)
|
||||
if response['Status'] == "Failure"
|
||||
if response['ErrorDescription'][0] == "HOST_IS_SLAVE"
|
||||
response['ErrorDescription'][1]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def authenticate( username, password )
|
||||
response = @factory.call('session.login_with_password', username.to_s, password.to_s)
|
||||
raise Fog::XenServer::InvalidLogin.new unless response["Status"] =~ /Success/
|
||||
|
|
Loading…
Add table
Reference in a new issue