Module: Dcmgr::Scheduler

Defined in:
lib/dcmgr.rb,
lib/dcmgr/scheduler.rb,
lib/dcmgr/scheduler/network/flat_single.rb,
lib/dcmgr/scheduler/host_node/find_first.rb,
lib/dcmgr/scheduler/network/per_instance.rb,
lib/dcmgr/scheduler/network/vif_template.rb,
lib/dcmgr/scheduler/host_node/least_usage.rb,
lib/dcmgr/scheduler/host_node/exclude_same.rb,
lib/dcmgr/scheduler/host_node/per_instance.rb,
lib/dcmgr/scheduler/host_node/specify_node.rb,
lib/dcmgr/scheduler/network/nat_one_to_one.rb,
lib/dcmgr/scheduler/storage_node/find_first.rb,
lib/dcmgr/scheduler/storage_node/least_usage.rb

Defined Under Namespace

Modules: HostNode, Network, StorageNode Classes: HostNodeScheduler, HostNodeSchedulingError, NetworkScheduler, NetworkSchedulingError, SchedulerError, StorageNodeScheduler, StorageNodeSchedulingError

Class Method Summary collapse

Class Method Details

.host_nodeObject

Factory method for HostNode scheduler



14
15
16
17
18
19
20
21
# File 'lib/dcmgr/scheduler.rb', line 14

def self.host_node()
  c = scheduler_class(Dcmgr.conf.host_node_scheduler, ::Dcmgr::Scheduler::HostNode)
  if Dcmgr.conf.host_node_scheduler.respond_to?(:options)
    c.new(Dcmgr.conf.host_node_scheduler.options)
  else
    c.new
  end
end

.host_node_haObject

Factory method for HostNode scheduler for HA



24
25
26
27
28
29
30
31
# File 'lib/dcmgr/scheduler.rb', line 24

def self.host_node_ha()
  c = scheduler_class(Dcmgr.conf.host_node_ha_scheduler, ::Dcmgr::Scheduler::HostNode)
  if Dcmgr.conf.host_node_ha_scheduler.respond_to?(:options)
    c.new(Dcmgr.conf.host_node_ha_scheduler.options)
  else
    c.new
  end
end

.networkObject

Factory method for Network scheduler



44
45
46
47
48
49
50
51
# File 'lib/dcmgr/scheduler.rb', line 44

def self.network()
  c = scheduler_class(Dcmgr.conf.network_scheduler, ::Dcmgr::Scheduler::Network)
  if Dcmgr.conf.network_scheduler.respond_to?(:options)
    c.new(Dcmgr.conf.network_scheduler.options)
  else
    c.new
  end
end

.scheduler_class(input, namespace) ⇒ Object

common scheduler class finder

Raises:

  • (TypeError)


54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/dcmgr/scheduler.rb', line 54

def self.scheduler_class(input, namespace)
  c = case input
      when Symbol
        namespace.const_get(input)
      when ::Configuration
        if input.respond_to?(:scheduler)
          namespace.const_get(input.scheduler)
        else
          raise "Missing configuration key: scheduler"
        end
      else
        raise "Unknown #{namespace.to_s} scheduler: #{input}"
      end
  raise TypeError unless c < Module.find_const("#{namespace.to_s}Scheduler")
  c
end

.storage_nodeObject

Factory method for StorageNode scheduler



34
35
36
37
38
39
40
41
# File 'lib/dcmgr/scheduler.rb', line 34

def self.storage_node()
  c = scheduler_class(Dcmgr.conf.storage_node_scheduler, ::Dcmgr::Scheduler::StorageNode)
  if Dcmgr.conf.storage_node_scheduler.respond_to?(:options)
    c.new(Dcmgr.conf.storage_node_scheduler.options)
  else
    c.new
  end
end