Module: FogExtensions::Cloudstack::Server

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/fog_extensions/cloudstack/server.rb

Instance Method Summary collapse

Instance Method Details

#created_atObject



63
64
65
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 63

def created_at
	Time.parse attributes['created']
end

#flavor_with_objectObject



59
60
61
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 59

def flavor_with_object
	service.flavors.get attributes[:flavor]['id']
end

#ip_addressObject



23
24
25
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 23

def ip_address
    nics[0]["ipaddress"]
end

#ip_addressesObject



27
28
29
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 27

def ip_addresses
    nics.map { |n| n.ipaddress }
end

#mac_addressObject



31
32
33
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 31

def mac_address
    nics[0]["macaddress"]
end

#mac_addressesObject



35
36
37
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 35

def mac_addresses
    nics.map { |n| n.macaddress }
end

#networkObject



74
75
76
77
78
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 74

def network
	return @network if @network # in case we didnt submitting the form again after an error.
	return networks.try(:first).try(:name) if persisted?
	nil
end

#pauseObject



51
52
53
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 51

def pause
	service.pause_server(id)
end

#resetObject



86
87
88
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 86

def reset
	reboot('HARD')
end

#security_groupObject



80
81
82
83
84
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 80

def security_group
	return @security_group if @security_group # in case we didnt submitting the form again after an error.
	return security_groups.try(:first).try(:name) if persisted?
	nil
end

#security_groups_with_no_idObject

the original method requires a server ID, however we want to be able to call this method on new instances too



68
69
70
71
72
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 68

def security_groups_with_no_id
	return [] if id.nil?

	security_groups_without_no_id
end

#startObject



39
40
41
42
43
44
45
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 39

def start
	if state.downcase == 'paused'
		service.unpause_server(id)
	else
		service.resume_server(id)
	end
end

#stopObject



47
48
49
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 47

def stop
	service.suspend_server(id)
end

#tenantObject



55
56
57
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 55

def tenant
	service.tenants.detect{|t| t.id == tenant_id }
end

#to_sObject

included do alias_method_chain :security_groups, :no_id attr_writer :security_group, :network # floating IP end



19
20
21
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 19

def to_s
	name
end

#vm_descriptionObject



90
91
92
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 90

def vm_description
	""
end