Class: Ey::Core::Client::Server
Instance Method Summary
collapse
assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader
Methods inherited from Model
#destroy, range_parser, #save, #update!, #url
Instance Method Details
#destroy! ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/ey-core/models/server.rb', line 65
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
|
#reboot ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/ey-core/models/server.rb', line 35
def reboot
requires :identity
connection.requests.new(
self.connection.reboot_server("id" => self.identity).body["request"]
)
end
|
#save! ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/ey-core/models/server.rb', line 43
def save!
if new_record?
raise "adding servers is not yet implemented"
requires :flavor_id, :role, :environment
server_attributes = {
"flavor" => self.flavor_id,
"role" => self.role,
}
server_attributes.merge!("location" => self.location)
connection.create_server(server_attributes)
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
|