Class: Fog::Scaleway::Compute::Server
- Inherits:
-
Compute::Server
- Object
- Compute::Server
- Fog::Scaleway::Compute::Server
- Defined in:
- lib/fog/scaleway/models/compute/server.rb
Instance Method Summary collapse
- #attach_volume(volume) ⇒ Object
- #bootscript=(value) ⇒ Object
- #destroy ⇒ Object
- #detach_volume(volume) ⇒ Object
- #execute_action(action, async = true) ⇒ Object
- #image=(value) ⇒ Object
- #poweroff(async = true) ⇒ Object
- #poweron(async = true) ⇒ Object
- #private_dns_name ⇒ Object
- #private_ip_address ⇒ Object
- #public_dns_name ⇒ Object
- #public_ip=(value) ⇒ Object
- #public_ip_address ⇒ Object
- #ready? ⇒ Boolean
- #reboot(async = true) ⇒ Object
- #save ⇒ Object
- #security_group=(value) ⇒ Object
- #terminate(async = true) ⇒ Object
- #volumes=(value) ⇒ Object
Instance Method Details
#attach_volume(volume) ⇒ Object
143 144 145 146 147 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 143 def attach_volume(volume) volumes[next_volume_index] = to_volume(volume) save if persisted? end |
#bootscript=(value) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 31 def bootscript=(value) attributes[:bootscript] = case value when Hash service.bootscripts.new(value) when String service.bootscripts.new(identity: value) else value end end |
#destroy ⇒ Object
99 100 101 102 103 104 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 99 def destroy requires :identity service.delete_server(identity) true end |
#detach_volume(volume) ⇒ Object
149 150 151 152 153 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 149 def detach_volume(volume) volumes.reject! { |_k, v| v == to_volume(volume) } save if persisted? end |
#execute_action(action, async = true) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 130 def execute_action(action, async = true) requires :identity if (task = service.execute_server_action(identity, action).body['task']) service.tasks.new(task).tap do |t| unless async t.wait_for { t.success? } reload end end end end |
#image=(value) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 42 def image=(value) attributes[:image] = case value when Hash service.images.new(value) when String service.images.new(identity: value) else value end end |
#poweroff(async = true) ⇒ Object
112 113 114 115 116 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 112 def poweroff(async = true) requires :identity execute_action('poweroff', async) end |
#poweron(async = true) ⇒ Object
106 107 108 109 110 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 106 def poweron(async = true) requires :identity execute_action('poweron', async) end |
#private_dns_name ⇒ Object
83 84 85 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 83 def private_dns_name "#{identity}.priv.cloud.scaleway.com" end |
#private_ip_address ⇒ Object
159 160 161 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 159 def private_ip_address private_ip end |
#public_dns_name ⇒ Object
79 80 81 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 79 def public_dns_name "#{identity}.pub.cloud.scaleway.com" end |
#public_ip=(value) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 53 def public_ip=(value) attributes[:public_ip] = case value when Hash service.ips.new(value) when String service.ips.new(identity: value) else value end end |
#public_ip_address ⇒ Object
155 156 157 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 155 def public_ip_address public_ip.address if public_ip end |
#ready? ⇒ Boolean
87 88 89 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 87 def ready? state == 'running' end |
#reboot(async = true) ⇒ Object
118 119 120 121 122 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 118 def reboot(async = true) requires :identity execute_action('reboot', async) end |
#save ⇒ Object
91 92 93 94 95 96 97 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 91 def save if persisted? update else create end end |
#security_group=(value) ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 64 def security_group=(value) attributes[:security_group] = case value when Hash service.security_groups.new(value) when String service.security_groups.new(identity: value) else value end end |
#terminate(async = true) ⇒ Object
124 125 126 127 128 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 124 def terminate(async = true) requires :identity execute_action('terminate', async) end |
#volumes=(value) ⇒ Object
75 76 77 |
# File 'lib/fog/scaleway/models/compute/server.rb', line 75 def volumes=(value) attributes[:volumes] = Hash[value.map { |i, v| [i, to_volume(v)] }] end |