mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
M #-: minor changes related with ZMQ endpoint (#903)
This commit is contained in:
parent
5ab76a3acb
commit
e5be998b43
@ -22,6 +22,10 @@
|
||||
#
|
||||
:one_xmlrpc: http://localhost:2633/RPC2
|
||||
|
||||
# :subscriber_endpoint to subscribe for OpenNebula events must match those in
|
||||
# oned.conf
|
||||
:subscriber_endpoint: 'tcp://localhost:2101'
|
||||
|
||||
# Time in seconds between each time scale rules are evaluated
|
||||
#
|
||||
:autoscaler_interval: 90
|
||||
|
@ -62,7 +62,6 @@ class EventManager
|
||||
# Default configuration options for the module
|
||||
# --------------------------------------------------------------------------
|
||||
DEFAULT_CONF = {
|
||||
:subscriber_endpoint => 'tcp://localhost:2101',
|
||||
:cloud_auth => nil,
|
||||
:am => nil
|
||||
}
|
||||
@ -74,8 +73,9 @@ class EventManager
|
||||
@lcm = options[:lcm]
|
||||
@am = ActionManager.new(@cloud_auth.conf[:concurrency], true)
|
||||
|
||||
@context = ZMQ::Context.new(1)
|
||||
@wait_timeout = @cloud_auth.conf[:wait_timeout]
|
||||
@context = ZMQ::Context.new(1)
|
||||
@wait_timeout = @cloud_auth.conf[:wait_timeout]
|
||||
@subscriber_endpoint = @cloud_auth.conf[:subscriber_endpoint]
|
||||
|
||||
# Register Action Manager actions
|
||||
@am.register_action(ACTIONS['WAIT_DEPLOY'],
|
||||
@ -549,7 +549,7 @@ class EventManager
|
||||
subscriber = @context.socket(ZMQ::SUB)
|
||||
# Set timeout (TODO add option for customize timeout)
|
||||
subscriber.setsockopt(ZMQ::RCVTIMEO, @wait_timeout * 10**3)
|
||||
subscriber.connect(@conf[:subscriber_endpoint])
|
||||
subscriber.connect(@subscriber_endpoint)
|
||||
|
||||
subscriber
|
||||
end
|
||||
|
@ -29,7 +29,6 @@ class ServiceWD
|
||||
LOG_COMP = 'WD'
|
||||
|
||||
DEFAULT_CONF = {
|
||||
:subscriber_endpoint => 'tcp://localhost:2101',
|
||||
:concurrency => 10,
|
||||
:cloud_auth => nil
|
||||
}
|
||||
@ -48,10 +47,11 @@ class ServiceWD
|
||||
def initialize(options)
|
||||
@conf = DEFAULT_CONF.merge(options)
|
||||
|
||||
@lcm = options[:lcm]
|
||||
@context = ZMQ::Context.new(1)
|
||||
@cloud_auth = @conf[:cloud_auth]
|
||||
@wait_timeout = @cloud_auth.conf[:wait_timeout]
|
||||
@lcm = options[:lcm]
|
||||
@context = ZMQ::Context.new(1)
|
||||
@cloud_auth = @conf[:cloud_auth]
|
||||
@wait_timeout = @cloud_auth.conf[:wait_timeout]
|
||||
@subscriber_endpoint = @cloud_auth.conf[:subscriber_endpoint]
|
||||
|
||||
# Array of running services to watch
|
||||
@mutex = Mutex.new
|
||||
@ -169,7 +169,7 @@ class ServiceWD
|
||||
|
||||
# Set timeout (TODO add option for customize timeout)
|
||||
subscriber.setsockopt(ZMQ::RCVTIMEO, @wait_timeout * 10**3)
|
||||
subscriber.connect(@conf[:subscriber_endpoint])
|
||||
subscriber.connect(@subscriber_endpoint)
|
||||
|
||||
subscriber
|
||||
end
|
||||
|
@ -88,7 +88,7 @@ module OpenNebula
|
||||
NO_ONE_AUTH_ERROR = "ONE_AUTH file not present"
|
||||
|
||||
attr_accessor :one_auth
|
||||
attr_reader :one_endpoint
|
||||
attr_reader :one_endpoint, :one_zmq
|
||||
|
||||
begin
|
||||
require 'xmlparser'
|
||||
@ -152,6 +152,12 @@ module OpenNebula
|
||||
|
||||
@async = !options[:sync]
|
||||
|
||||
if ENV["ONE_ZMQ"]
|
||||
@one_zmq = ENV["ONE_ZMQ"]
|
||||
else
|
||||
@one_zmq = 'tcp://localhost:2101'
|
||||
end
|
||||
|
||||
timeout=nil
|
||||
if options[:timeout]
|
||||
timeout = options[:timeout]
|
||||
|
@ -127,7 +127,7 @@ module OpenNebula::WaitExt
|
||||
|
||||
subscriber.setsockopt(ZMQ::RCVTIMEO, timeout * 1000)
|
||||
subscriber.setsockopt(ZMQ::SUBSCRIBE, event)
|
||||
subscriber.connect('tcp://localhost:2101')
|
||||
subscriber.connect(@client.one_zmq)
|
||||
|
||||
rc = subscriber.recv_string(key)
|
||||
rc = subscriber.recv_string(content) if rc != -1
|
||||
|
@ -71,27 +71,22 @@ module OneProvision
|
||||
@one.info
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Create new object
|
||||
def new_object
|
||||
@one = OpenNebula::Image.new(OpenNebula::Image.build_xml, @client)
|
||||
end
|
||||
|
||||
# Wait until the image is ready, retry if fail
|
||||
#
|
||||
# @return [Integer] Resource ID
|
||||
def ready?
|
||||
OneProvisionLogger.debug(
|
||||
"Waiting #{@type} #{@one.id} to be READY"
|
||||
)
|
||||
|
||||
Driver.retry_loop 'Fail to create image' do
|
||||
wait_state('READY', @p_template['timeout'])
|
||||
@one.wait_state('READY',
|
||||
(@p_template && @p_template['timeout']) || 60)
|
||||
|
||||
# check state after existing wait loop
|
||||
@one.info
|
||||
|
||||
case @one.state_str
|
||||
when 'LOCKED'
|
||||
# if locked, keep waiting
|
||||
ready?
|
||||
when 'ERROR'
|
||||
# if error, delete the image and try to create it again
|
||||
raise OneProvisionLoopException
|
||||
@ -102,6 +97,13 @@ module OneProvision
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Create new object
|
||||
def new_object
|
||||
@one = OpenNebula::Image.new(OpenNebula::Image.build_xml, @client)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -117,7 +117,7 @@ module OneProvision
|
||||
|
||||
return ret unless wait
|
||||
|
||||
@image.wait_state('READY', timeout)
|
||||
@image.ready?
|
||||
|
||||
ret
|
||||
end
|
||||
|
@ -64,27 +64,6 @@ module OneProvision
|
||||
|
||||
protected
|
||||
|
||||
# Wait until object reaches state
|
||||
#
|
||||
# @param state [String] State to wait
|
||||
# @param timeout [Integer] Timeout to wait
|
||||
def wait_state(state, timeout)
|
||||
t_start = Time.now
|
||||
timeout ||= DEFAULT_TIMEOUT
|
||||
|
||||
OneProvisionLogger.debug(
|
||||
"Waiting #{@type} #{@one.id} to be #{state}"
|
||||
)
|
||||
|
||||
while Time.now - t_start < timeout
|
||||
@one.info
|
||||
|
||||
break if @one.state_str == state
|
||||
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
|
||||
# Check wait mode
|
||||
#
|
||||
# @param wait [Boolean] Wait mode
|
||||
|
Loading…
x
Reference in New Issue
Block a user