mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
(cherry picked from commit 3d42b4461ba4b6dd0dcdf09f1b014c3cecb6e01f)
This commit is contained in:
parent
78d699561c
commit
b841f9e47d
@ -143,7 +143,7 @@ class CloudAuth
|
||||
retrieve_from_userpool(xpath)
|
||||
end
|
||||
|
||||
# Selects the username that matches the driver and evaluates to true the
|
||||
# Selects the username that matches the driver and evaluates to true the
|
||||
# block passed to the function
|
||||
# block:: { |user| true or false }
|
||||
# [return] the username or nil
|
||||
|
@ -395,10 +395,9 @@ class EventManager
|
||||
|
||||
def check_nodes_report(nodes)
|
||||
rc_nodes = { :successful => [], :failure => [] }
|
||||
client = @cloud_auth.client
|
||||
|
||||
nodes.delete_if do |node|
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(node, client)
|
||||
vm = OpenNebula::VirtualMachine.new_with_id(node, @cloud_auth.client)
|
||||
|
||||
vm.info
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ServiceLCM
|
||||
|
||||
@event_manager = EventManager.new(em_conf).am
|
||||
|
||||
@wd = ServiceWD.new(client, em_conf)
|
||||
@wd = ServiceWD.new(em_conf)
|
||||
|
||||
# Register Action Manager actions
|
||||
@am.register_action(ACTIONS['DEPLOY_CB'],
|
||||
@ -94,7 +94,6 @@ class ServiceLCM
|
||||
|
||||
Thread.new do
|
||||
auto_scaler = ServiceAutoScaler.new(@srv_pool,
|
||||
client,
|
||||
@cloud_auth,
|
||||
self)
|
||||
auto_scaler.start
|
||||
|
@ -23,23 +23,21 @@ class ServiceAutoScaler
|
||||
# Class constructor
|
||||
#
|
||||
# @param service_pool [OpenNebula::ServicePool] Service pool
|
||||
# @param clien [OpenNebula::Client] OpenNebula Client
|
||||
# @param cloud_auth [OpenNebula::CloudAuth] Cloud auth to get clients
|
||||
# @param lcm [LifeCycleManager] Lcm for flows
|
||||
def initialize(service_pool, client, cloud_auth, lcm)
|
||||
def initialize(service_pool, cloud_auth, lcm)
|
||||
@lcm = lcm
|
||||
@interval = cloud_auth.conf[:autoscaler_interval]
|
||||
@srv_pool = service_pool
|
||||
@vm_pool = VirtualMachinePool.new(cloud_auth.client)
|
||||
@cloud_auth = cloud_auth
|
||||
@client = client
|
||||
end
|
||||
|
||||
# Start auto scaler loop
|
||||
def start
|
||||
loop do
|
||||
@srv_pool.info
|
||||
@vm_pool.info_all_extended
|
||||
vm_pool = VirtualMachinePool.new(client)
|
||||
vm_pool.info_all_extended
|
||||
|
||||
@srv_pool.each do |service|
|
||||
# fill service roles information
|
||||
@ -51,7 +49,7 @@ class ServiceAutoScaler
|
||||
'Checking policies for ' \
|
||||
"service: #{service.id}"
|
||||
|
||||
apply_scaling_policies(service)
|
||||
apply_scaling_policies(service, vm_pool)
|
||||
end
|
||||
|
||||
sleep(@interval)
|
||||
@ -62,9 +60,6 @@ class ServiceAutoScaler
|
||||
|
||||
# Get OpenNebula client
|
||||
def client
|
||||
# If there's a client defined use it
|
||||
return @client unless @client.nil?
|
||||
|
||||
# If not, get one via cloud_auth
|
||||
@cloud_auth.client
|
||||
end
|
||||
@ -73,9 +68,9 @@ class ServiceAutoScaler
|
||||
# to SCALING. Only one role is set to scale.
|
||||
#
|
||||
# @param [OpenNebula::Service] service
|
||||
def apply_scaling_policies(service)
|
||||
def apply_scaling_policies(service, vm_pool)
|
||||
service.roles.each do |name, role|
|
||||
diff, cooldown_duration = role.scale?(@vm_pool)
|
||||
diff, cooldown_duration = role.scale?(vm_pool)
|
||||
|
||||
policies = {}
|
||||
policies['elasticity_policies'] = role.elasticity_policies
|
||||
|
@ -45,14 +45,13 @@ class ServiceWD
|
||||
# Class constructor
|
||||
#
|
||||
# @param options [Hash] event manager options
|
||||
def initialize(client, options)
|
||||
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]
|
||||
@client = client
|
||||
|
||||
# Array of running services to watch
|
||||
@mutex = Mutex.new
|
||||
@ -154,9 +153,6 @@ class ServiceWD
|
||||
|
||||
# Get OpenNebula client
|
||||
def client
|
||||
# If there's a client defined use it
|
||||
return @client unless @client.nil?
|
||||
|
||||
# If not, get one via cloud_auth
|
||||
@cloud_auth.client
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user