Class: Dcmgr::Tags::HostPool

Inherits:
Models::Tag show all
Defined in:
lib/dcmgr/tags.rb

Constant Summary

Constants inherited from Models::BaseNew

Models::BaseNew::LOCK_TABLES_KEY

Instance Method Summary collapse

Methods inherited from Models::Tag

#before_destroy, find_tag_class, #label, #labeled?, #lable_ifnot, lock!, #to_api_document, #unlabel

Methods inherited from Models::AccountResource

#account

Methods inherited from Models::BaseNew

Proxy, dataset, default_row_lock_mode=, install_data, install_data_hooks, lock!, #to_hash, unlock!, #with_timestamps?

Instance Method Details

#accept_mapping?(to) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/dcmgr/tags.rb', line 34

def accept_mapping?(to)
  to.is_a?(Dcmgr::Models::HostNode)
end

#pick(spec) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/dcmgr/tags.rb', line 38

def pick(spec)
  mapped_uuids.map { |t|
    Dcmgr::Models::HostNode[t.uuid]
  }.find_all { |h|
    h.check_capacity(spec)
  }.sort_by { |h|
    h.instances.count
  }.reverse.first
end