Class: Dcmgr::Scheduler::Network::PerInstance
- Inherits:
-
Dcmgr::Scheduler::NetworkScheduler
- Object
- Dcmgr::Scheduler::NetworkScheduler
- Dcmgr::Scheduler::Network::PerInstance
- Includes:
- Logger
- Defined in:
- lib/dcmgr/scheduler/network/per_instance.rb
Overview
Meta scheduler calls another scheduler specified by user.
Instance Method Summary collapse
Methods included from Logger
create, default_logdev, included
Methods inherited from Dcmgr::Scheduler::NetworkScheduler
Constructor Details
This class inherits a constructor from Dcmgr::Scheduler::NetworkScheduler
Instance Method Details
#schedule(instance) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/dcmgr/scheduler/network/per_instance.rb', line 10 def schedule(instance) sched_opts = .to_hash || {} sched_name = instance.request_params['network_scheduler'] if sched_name.nil? || sched_name == '' if sched_opts.has_key?(:default) sched_conf = .default else raise "Missing network_scheduler parameter from the request." end else if sched_opts.has_key?(sched_name.to_sym) sched_conf = .send(sched_name.to_sym) else raise "Unknown scheduler definition: #{sched_name} for the instance #{instance.canonical_uuid}" end end sched_class = Scheduler.scheduler_class(sched_conf.scheduler, ::Dcmgr::Scheduler::Network) sched = if sched_conf.respond_to?(:options) sched_class.new(sched_conf.) else sched_class.new end logger.info("Selected network scheduler: #{sched_name} #{sched_class} for the instance #{instance.canonical_uuid}") sched.schedule(instance) end |