Class: Fog::Compute::DigitalOcean::Servers
- Inherits:
-
Fog::Collection
- Object
- Array
- Fog::Collection
- Fog::Compute::DigitalOcean::Servers
- Defined in:
- lib/fog/digitalocean/models/compute/servers.rb
Instance Attribute Summary
Attributes inherited from Fog::Collection
Instance Method Summary collapse
Methods inherited from Fog::Collection
#clear, #create, #destroy, #initialize, #inspect, #load, model, #model, #new, #reload, #table, #to_json
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Fog::Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
This class inherits a constructor from Fog::Collection
Instance Method Details
#all(filters = {}) ⇒ Object
12 13 14 15 |
# File 'lib/fog/digitalocean/models/compute/servers.rb', line 12 def all(filters = {}) data = service.list_servers.body['droplets'] load(data) end |
#bootstrap(new_attributes = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/digitalocean/models/compute/servers.rb', line 17 def bootstrap(new_attributes = {}) server = new(new_attributes) raise(ArgumentError, "public_key_path is required to configure the server.") unless new_attributes[:public_key_path] raise(ArgumentError, "private_key_path is required to configure the server.") unless new_attributes[:private_key_path] credential = Fog.respond_to?(:credential) && Fog.credential || :default name = "fog_#{credential}" ssh_key = service.ssh_keys.detect { |key| key.name == name } if ssh_key.nil? ssh_key = service.ssh_keys.create( :name => name, :ssh_pub_key => File.read(new_attributes[:public_key_path]) ) end server.ssh_keys = [ssh_key] server.save server.wait_for { ready? } server.setup :keys => [new_attributes[:private_key_path]] server end |