Class: Ey::Core::Client::Server

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/vendor/core/ey-core/models/server.rb

Instance Method Summary collapse

Methods included from Associations

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



62
63
64
65
66
67
68
# File 'lib/vendor/core/ey-core/models/server.rb', line 62

def destroy!
  requires :identity

  connection.requests.new(
    self.connection.destroy_server(self.identity).body["request"]
  )
end

#rebootObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/vendor/core/ey-core/models/server.rb', line 37

def reboot
  requires :identity

  params = {
    "url" => self.collection.url,
    "id"  => self.identity,
  }

  connection.requests.new(
    self.connection.reboot_server(params).body["request"]
  )
end

#save!Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/vendor/core/ey-core/models/server.rb', line 50

def save!
  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