Class: Fog::Compute::DigitalOcean::Server

Inherits:
Server
  • Object
show all
Defined in:
lib/fog/compute/digitalocean/models/server.rb

Overview

A DigitalOcean Droplet

Instance Method Summary collapse

Instance Method Details

#action(action_id) ⇒ Object



89
90
91
92
93
# File 'lib/fog/compute/digitalocean/models/server.rb', line 89

def action(action_id)
  requires :id
  response = service.get_droplet_action(id, action_id)
  response.body
end

#actionsObject



83
84
85
86
87
# File 'lib/fog/compute/digitalocean/models/server.rb', line 83

def actions
  requires :id
  response = service.list_droplet_actions id
  response.body
end

#change_kernel(kernel) ⇒ Object



139
140
141
# File 'lib/fog/compute/digitalocean/models/server.rb', line 139

def change_kernel(kernel)
  perform_action :change_kernel, kernel
end

#deleteObject



69
70
71
72
73
# File 'lib/fog/compute/digitalocean/models/server.rb', line 69

def delete
  requires :id
  response = service.delete_server id
  response.body
end

#disable_backupsObject



99
100
101
# File 'lib/fog/compute/digitalocean/models/server.rb', line 99

def disable_backups
  perform_action :disable_backups
end

#enable_ipv6Object



143
144
145
# File 'lib/fog/compute/digitalocean/models/server.rb', line 143

def enable_ipv6
  perform_action :enable_ipv6
end

#enable_private_networkingObject



147
148
149
# File 'lib/fog/compute/digitalocean/models/server.rb', line 147

def enable_private_networking
  perform_action :enable_private_networking
end

#ipv4_addressObject



42
43
44
45
46
# File 'lib/fog/compute/digitalocean/models/server.rb', line 42

def ipv4_address
  if (net = networks['v4'].find { |n| n['type'] == 'public' })
    net['ip_address']
  end
end

#ipv6_addressObject



36
37
38
39
40
# File 'lib/fog/compute/digitalocean/models/server.rb', line 36

def ipv6_address
  if (net = networks['v6'].find { |n| n['type'] == 'public' })
    net['ip_address']
  end
end

#locked?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/fog/compute/digitalocean/models/server.rb', line 79

def locked?
  locked
end

#password_resetObject



123
124
125
# File 'lib/fog/compute/digitalocean/models/server.rb', line 123

def password_reset
  perform_action :password_reset
end

#power_cycleObject



103
104
105
# File 'lib/fog/compute/digitalocean/models/server.rb', line 103

def power_cycle
  perform_action :power_cycle
end

#power_offObject



111
112
113
# File 'lib/fog/compute/digitalocean/models/server.rb', line 111

def power_off
  perform_action :power_off
end

#power_onObject



115
116
117
# File 'lib/fog/compute/digitalocean/models/server.rb', line 115

def power_on
  perform_action :power_on
end

#public_ip_addressObject



32
33
34
# File 'lib/fog/compute/digitalocean/models/server.rb', line 32

def public_ip_address
  ipv4_address
end

#ready?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/fog/compute/digitalocean/models/server.rb', line 75

def ready?
  status == 'active'
end

#rebootObject



95
96
97
# File 'lib/fog/compute/digitalocean/models/server.rb', line 95

def reboot
  perform_action :reboot_server
end

#rebuild(image) ⇒ Object



131
132
133
# File 'lib/fog/compute/digitalocean/models/server.rb', line 131

def rebuild(image)
  perform_action :rebuild, image
end

#rename(name) ⇒ Object



135
136
137
# File 'lib/fog/compute/digitalocean/models/server.rb', line 135

def rename(name)
  perform_action :rename, name
end

#resize(resize_disk, size) ⇒ Object



127
128
129
# File 'lib/fog/compute/digitalocean/models/server.rb', line 127

def resize(resize_disk, size)
  perform_action :resize, resize_disk, size
end

#restore(image) ⇒ Object



119
120
121
# File 'lib/fog/compute/digitalocean/models/server.rb', line 119

def restore(image)
  perform_action :restore, image
end

#saveObject

Raises:

  • (Fog::Errors::Error)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/compute/digitalocean/models/server.rb', line 48

def save
  raise Fog::Errors::Error.new('Re-saving an existing object may create a duplicate') if persisted?
  requires :name, :region, :size, :image

  options = {}
  if attributes[:ssh_keys]
    options[:ssh_keys] = attributes[:ssh_keys]
  elsif @ssh_keys
    options[:ssh_keys] = @ssh_keys.map(&:id)
  end

  options[:private_networking] = private_networking
  options[:backups]            = backups
  options[:ipv6]               = ipv6

  data = service.create_server(name, size, image, region, options)

  merge_attributes(data.body['droplet'])
  true
end

#shutdownObject



107
108
109
# File 'lib/fog/compute/digitalocean/models/server.rb', line 107

def shutdown
  perform_action :shutdown
end

#snapshot(name) ⇒ Object



151
152
153
# File 'lib/fog/compute/digitalocean/models/server.rb', line 151

def snapshot(name)
  perform_action :snapshot, name
end

#upgradeObject



155
156
157
# File 'lib/fog/compute/digitalocean/models/server.rb', line 155

def upgrade
  perform_action :upgrade
end