Class: Dcmgr::Scheduler::HostNode::ExcludeSame

Inherits:
Dcmgr::Scheduler::HostNodeScheduler show all
Includes:
Logger
Defined in:
lib/dcmgr/scheduler/host_node/exclude_same.rb

Instance Method Summary collapse

Methods included from Logger

create, default_logdev, included

Methods inherited from Dcmgr::Scheduler::HostNodeScheduler

#initialize

Constructor Details

This class inherits a constructor from Dcmgr::Scheduler::HostNodeScheduler

Instance Method Details

#schedule(instance) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dcmgr/scheduler/host_node/exclude_same.rb', line 10

def schedule(instance)
  ds = Models::HostNode.online_nodes.filter(:arch=>instance.spec.arch,
                                            :hypervisor=>instance.spec.hypervisor)

  host_node = ds.all.find_all { |hn|
    hn.node_id != instance.host_node.node_id
  }.first

  raise HostNodeSchedulingError if host_node.nil?
  instance.host_node = host_node
end