Class: Dcmgr::Scheduler::StorageNodeScheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/dcmgr/scheduler.rb

Overview

Allocate StorageNode to Volume object.

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ StorageNodeScheduler

Returns a new instance of StorageNodeScheduler.



86
87
88
# File 'lib/dcmgr/scheduler.rb', line 86

def initialize(options=nil)
  @options = options
end

Instance Method Details

#schedule(volume) ⇒ Object

Returns nil.

Parameters:

  • Models::Volume

    volume

Returns:

  • nil

Raises:



92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/dcmgr/scheduler.rb', line 92

def schedule(volume)
  if volume.snapshot_id
    # use same same storage node if it is local snapshot.
    if volume.snapshot.destination == 'local'
      volume.storage_node = Models::StorageNode[volume.snapshot.storage_node_id]
    else
      schedule_node(volume)
    end
  else
    schedule_node(volume)
  end
  raise StorageNodeSchedulingError if volume.storage_node.nil?
end