Class: Ey::Core::Client::Server
- Extended by:
- Associations
- Defined in:
- lib/ey-core/models/server.rb
Instance Attribute Summary collapse
-
#force ⇒ Object
Returns the value of attribute force.
-
#iops ⇒ Object
Returns the value of attribute iops.
-
#mnt_volume_size ⇒ Object
Returns the value of attribute mnt_volume_size.
-
#snapshot_id ⇒ Object
Returns the value of attribute snapshot_id.
-
#volume_size ⇒ Object
Returns the value of attribute volume_size.
Instance Method Summary collapse
- #apply(type = "main") ⇒ Object
- #destroy! ⇒ Object
- #latest_custom_log ⇒ Object
- #latest_main_log ⇒ Object
- #reboot ⇒ Object
- #save! ⇒ Object
Methods included from Associations
assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader
Methods inherited from Model
#destroy, range_parser, #save, #to_s, #update!, #url
Instance Attribute Details
#force ⇒ Object
Returns the value of attribute force.
38 39 40 |
# File 'lib/ey-core/models/server.rb', line 38 def force @force end |
#iops ⇒ Object
Returns the value of attribute iops.
38 39 40 |
# File 'lib/ey-core/models/server.rb', line 38 def iops @iops end |
#mnt_volume_size ⇒ Object
Returns the value of attribute mnt_volume_size.
38 39 40 |
# File 'lib/ey-core/models/server.rb', line 38 def mnt_volume_size @mnt_volume_size end |
#snapshot_id ⇒ Object
Returns the value of attribute snapshot_id.
38 39 40 |
# File 'lib/ey-core/models/server.rb', line 38 def snapshot_id @snapshot_id end |
#volume_size ⇒ Object
Returns the value of attribute volume_size.
38 39 40 |
# File 'lib/ey-core/models/server.rb', line 38 def volume_size @volume_size end |
Instance Method Details
#apply(type = "main") ⇒ Object
40 41 42 43 44 |
# File 'lib/ey-core/models/server.rb', line 40 def apply(type="main") requires :identity connection.requests.new(self.connection.apply_server_updates("id" => self.identity, "type" => type).body["request"]) end |
#destroy! ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ey-core/models/server.rb', line 94 def destroy! if environment.servers.count == 1 raise Ey::Core::Client::NotPermitted, "Terminating the last server in an environment is not allowed. You must deprovision or destroy the environment instead." end requires :identity connection.requests.new( self.connection.destroy_server(self.identity).body["request"] ) end |
#latest_custom_log ⇒ Object
50 51 52 |
# File 'lib/ey-core/models/server.rb', line 50 def latest_custom_log logs.select{|l| l.filename.match(/custom/)}.sort_by(&:created_at).last end |
#latest_main_log ⇒ Object
46 47 48 |
# File 'lib/ey-core/models/server.rb', line 46 def latest_main_log logs.select{|l| l.filename.match(/main/)}.sort_by(&:created_at).last end |
#reboot ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/ey-core/models/server.rb', line 54 def reboot requires :identity connection.requests.new( self.connection.reboot_server("id" => self.identity).body["request"] ) end |
#save! ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ey-core/models/server.rb', line 62 def save! if new_record? requires :flavor_id, :role, :environment server_attributes = { "environment" => environment.id, "wait_for_chef" => self.wait_for_chef, "snapshot" => self.snapshot_id, "force" => self.force, "server" => { "flavor" => self.flavor_id, "iops" => self.iops, "location" => self.location || environment.region, "mnt_volume_size" => self.mnt_volume_size, "name" => self.name, "role" => self.role, "volume_size" => self.volume_size, "release_label" => self.release_label, } } connection.requests.new(connection.create_server(server_attributes).body["request"]) else requires :identity server_attributes = Cistern::Hash.slice(Cistern::Hash.stringify_keys(self.attributes), "provisioned_at", "deprovisioned_at", "disappeared_at") server_attributes.merge!("status" => self.state) if self.state connection.update_server( "id" => self.identity, "server" => server_attributes, ) end end |