Class: Fog::Hetznercloud::Compute::Servers
- Inherits:
-
Collection
- Object
- Collection
- Fog::Hetznercloud::Compute::Servers
- Defined in:
- lib/fog/hetznercloud/models/compute/servers.rb
Instance Method Summary collapse
- #all(filters = {}) ⇒ Object
- #bootstrap(bootstap_timeout: 120, new_attributes: {}, ssh_keys:) ⇒ Object
- #get(identity) ⇒ Object
Instance Method Details
#all(filters = {}) ⇒ Object
7 8 9 10 |
# File 'lib/fog/hetznercloud/models/compute/servers.rb', line 7 def all(filters = {}) servers = service.list_servers(filters).body['servers'] || [] load(servers) end |
#bootstrap(bootstap_timeout: 120, new_attributes: {}, ssh_keys:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/fog/hetznercloud/models/compute/servers.rb', line 20 def bootstrap(bootstap_timeout: 120, new_attributes: {}, ssh_keys:) require 'securerandom' defaults = { name: "hc-#{SecureRandom.hex(3)}", image: 'centos-7', server_type: 'cx11', ssh_keys: ssh_keys } server = create(defaults.merge(new_attributes)) status = false begin status = Timeout.timeout(bootstap_timeout) do server.wait_for { sshable?(auth_methods: %w[publickey]) } end rescue Timeout::Error => e server.destroy raise e end server end |
#get(identity) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/fog/hetznercloud/models/compute/servers.rb', line 12 def get(identity) if (server = service.get_server(identity).body['server']) new(server) end rescue Fog::Hetznercloud::Compute::UnknownResourceError nil end |