Module: FogExtensions::Cloudstack::Server
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/fog_extensions/cloudstack/server.rb
Instance Method Summary collapse
- #created_at ⇒ Object
- #flavor_with_object ⇒ Object
- #ip_address ⇒ Object
- #ip_addresses ⇒ Object
- #mac_address ⇒ Object
- #mac_addresses ⇒ Object
- #network ⇒ Object
- #pause ⇒ Object
- #reset ⇒ Object
- #security_group ⇒ Object
-
#security_groups_with_no_id ⇒ Object
the original method requires a server ID, however we want to be able to call this method on new instances too.
- #start ⇒ Object
- #stop ⇒ Object
- #tenant ⇒ Object
-
#to_s ⇒ Object
included do alias_method_chain :security_groups, :no_id attr_writer :security_group, :network # floating IP end.
- #vm_description ⇒ Object
Instance Method Details
#created_at ⇒ Object
63 64 65 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 63 def created_at Time.parse attributes['created'] end |
#flavor_with_object ⇒ Object
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_address ⇒ Object
23 24 25 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 23 def ip_address nics[0]["ipaddress"] end |
#ip_addresses ⇒ Object
27 28 29 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 27 def ip_addresses nics.map { |n| n.ipaddress } end |
#mac_address ⇒ Object
31 32 33 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 31 def mac_address nics[0]["macaddress"] end |
#mac_addresses ⇒ Object
35 36 37 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 35 def mac_addresses nics.map { |n| n.macaddress } end |
#network ⇒ Object
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 |
#pause ⇒ Object
51 52 53 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 51 def pause service.pause_server(id) end |
#reset ⇒ Object
86 87 88 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 86 def reset reboot('HARD') end |
#security_group ⇒ Object
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_id ⇒ Object
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 |
#start ⇒ Object
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 |
#stop ⇒ Object
47 48 49 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 47 def stop service.suspend_server(id) end |
#tenant ⇒ Object
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_s ⇒ Object
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_description ⇒ Object
90 91 92 |
# File 'app/models/concerns/fog_extensions/cloudstack/server.rb', line 90 def vm_description "" end |