Class: Dcmgr::Models::PhysicalHost
- Inherits:
-
Base
- Object
- Sequel::Model
- Base
- Dcmgr::Models::PhysicalHost
show all
- Defined in:
- lib/dcmgr/models/physical_host.rb
Instance Attribute Summary
#prefix_uuid
Class Method Summary
collapse
Instance Method Summary
collapse
#[], #set_prefix_uuid, #trim_uuid
#generate_uuid, #save, #setup_uuid, #to_s, #uuid
Class Method Details
.assign(instance) ⇒ Object
18
19
20
|
# File 'lib/dcmgr/models/physical_host.rb', line 18
def self.assign(instance)
Dcmgr::scheduler.assign_to_instance(enable_hosts, instance)
end
|
.enable_hosts ⇒ Object
14
15
16
|
# File 'lib/dcmgr/models/physical_host.rb', line 14
def self.enable_hosts
filter(~:id => TagMapping.filter(:target_type=>TagMapping::TYPE_PHYSICAL_HOST).select(:target_id)).order_by(:id).all
end
|
Instance Method Details
#after_create ⇒ Object
26
27
28
29
30
31
|
# File 'lib/dcmgr/models/physical_host.rb', line 26
def after_create
super
TagMapping.create(:tag_id=>Tag.system_tag(:STANDBY_INSTANCE).id,
:target_type=>TagMapping::TYPE_PHYSICAL_HOST,
:target_id=>self.id)
end
|
#before_create ⇒ Object
22
23
24
|
# File 'lib/dcmgr/models/physical_host.rb', line 22
def before_create
super
end
|
#create_location_tag(name, account) ⇒ Object
37
38
39
40
41
|
# File 'lib/dcmgr/models/physical_host.rb', line 37
def create_location_tag(name, account)
TagMapping.create(:tag_id=>Tag.create(:name=>name, :account=>account).id,
:target_type=>TagMapping::TYPE_PHYSICAL_HOST_LOCATION,
:target_id=>self.id)
end
|
#instances ⇒ Object
33
34
35
|
# File 'lib/dcmgr/models/physical_host.rb', line 33
def instances
self.hv_agents.map{|hva| hva.instances}.flatten
end
|
#setup_space ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/dcmgr/models/physical_host.rb', line 48
def setup_space
need_cpu_mhz = instances.inject(0) {|v, ins| v + ins.need_cpu_mhz}
space_cpu_mhz = cpu_mhz - need_cpu_mhz
@space_cpu_mhz = space_cpu_mhz * 0.9
need_memory = instances.inject(0) {|v, ins| v + ins.need_memory}
space_memory = memory - need_memory
@space_memory = space_memory * 0.9
end
|
#space_cpu_mhz ⇒ Object
43
44
45
46
|
# File 'lib/dcmgr/models/physical_host.rb', line 43
def space_cpu_mhz
setup_space unless @space_cpu_mhz
@space_cpu_mhz
end
|
#space_memory ⇒ Object
61
62
63
64
|
# File 'lib/dcmgr/models/physical_host.rb', line 61
def space_memory
setup_space unless @space_memory
@space_memory
end
|