Class: Dcmgr::Scheduler::StorageNode::LeastUsage

Inherits:
Dcmgr::Scheduler::StorageNodeScheduler show all
Includes:
Logger
Defined in:
lib/dcmgr/scheduler/storage_node/least_usage.rb

Overview

Find storage node which has the largest available disk space.

Instance Method Summary collapse

Methods included from Logger

create, default_logdev, included

Methods inherited from Dcmgr::Scheduler::StorageNodeScheduler

#initialize

Constructor Details

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

Instance Method Details

#schedule(volume) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/dcmgr/scheduler/storage_node/least_usage.rb', line 11

def schedule(volume)
  storage_node = Models::StorageNode.online_nodes.all.find_all { |s|
    s.free_disk_space >= volume.size
  }.sort_by { |s|
    s.free_disk_space
  }.reverse.first
  raise StorageNodeSchedulingError if storage_node.nil?
  volume.storage_node = storage_node
end