Class: Fog::Compute::Softlayer::Server
- Inherits:
-
Fog::Compute::Server
- Object
- Fog::Compute::Server
- Fog::Compute::Softlayer::Server
- Defined in:
- lib/fog/softlayer/models/compute/server.rb
Instance Method Summary collapse
- #bare_metal ⇒ Object
- #bare_metal=(set) ⇒ Object
- #bare_metal? ⇒ Boolean
- #destroy ⇒ Object
-
#dns_name ⇒ String
Returns the public DNS name of the server.
- #image_id ⇒ Object
- #image_id=(uuid) ⇒ Object
-
#initialize(attributes = {}) ⇒ Server
constructor
A new instance of Server.
- #name ⇒ Object
- #name=(set) ⇒ Object
- #pre_save ⇒ Object
- #ram=(set) ⇒ Object
- #ready? ⇒ Boolean
- #reboot(use_hard_reboot = true) ⇒ Object
-
#save ⇒ Object
Creates server * requires attributes: :name, :domain, and :flavor_id OR (:cpu_count && :ram && :disks).
- #shutdown ⇒ Object
-
#snapshot ⇒ Object
def ram.
- #ssh_password ⇒ Object
- #start ⇒ Object
- #state ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
45 46 47 48 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 45 def initialize(attributes = {}) super(attributes) set_defaults end |
Instance Method Details
#bare_metal ⇒ Object
65 66 67 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 65 def attributes[:bare_metal] === 1 ? true : false end |
#bare_metal=(set) ⇒ Object
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 54 def (set) attributes[:bare_metal] = case set when true, 'true', 1 1 when false, 'false', 0, nil 0 else raise ArgumentError, ":bare_metal cannot be #{set.class}" end end |
#bare_metal? ⇒ Boolean
50 51 52 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 50 def end |
#destroy ⇒ Object
124 125 126 127 128 129 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 124 def destroy requires :id request = ? :delete_bare_metal_server : :delete_vm response = service.send(request, self.id) response.body end |
#dns_name ⇒ String
Returns the public DNS name of the server
135 136 137 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 135 def dns_name fqdn end |
#image_id ⇒ Object
73 74 75 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 73 def image_id attributes[:image_id][:globalIdentifier] unless attributes[:image_id].nil? end |
#image_id=(uuid) ⇒ Object
69 70 71 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 69 def image_id=(uuid) attributes[:image_id] = {:globalIdentifier => uuid} end |
#name ⇒ Object
92 93 94 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 92 def name attributes[:hostname] end |
#name=(set) ⇒ Object
88 89 90 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 88 def name=(set) attributes[:hostname] = set end |
#pre_save ⇒ Object
180 181 182 183 184 185 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 180 def pre_save extract_flavor validate_attributes remap_attributes(attributes, attributes_mapping) clean_attributes end |
#ram=(set) ⇒ Object
81 82 83 84 85 86 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 81 def ram=(set) if set.is_a?(Array) and set.first['hardwareComponentModel'] set = 1024 * set.first['hardwareComponentModel']['capacity'].to_i end attributes[:ram] = set end |
#ready? ⇒ Boolean
148 149 150 151 152 153 154 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 148 def ready? if state == "on" else state == "Running" end end |
#reboot(use_hard_reboot = true) ⇒ Object
104 105 106 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 104 def reboot(use_hard_reboot = true) # TODO: implement end |
#save ⇒ Object
Note:
You should use servers.create to create servers instead calling this method directly
Creates server
-
requires attributes: :name, :domain, and :flavor_id OR (:cpu_count && :ram && :disks)
-
State Transitions
-
BUILD -> ACTIVE
-
BUILD -> ERROR (on error)
-
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 164 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? copy = self.dup copy.pre_save data = if service.(copy.attributes).body else service.create_vm(copy.attributes).body.first end merge_attributes(data) true end |
#shutdown ⇒ Object
120 121 122 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 120 def shutdown # TODO: implement end |
#snapshot ⇒ Object
def ram
end
100 101 102 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 100 def snapshot # TODO: implement end |
#ssh_password ⇒ Object
77 78 79 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 77 def ssh_password self.os['passwords'][0]['password'] if self.id end |
#start ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 108 def start # TODO: implement #requires :identity #service.start_server(identity) true end |
#state ⇒ Object
139 140 141 142 143 144 145 146 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 139 def state if service.request(:hardware_server, "#{id}/getServerPowerState").body else service.request(:virtual_guest, "#{id}/getPowerState").body['name'] end end |
#stop ⇒ Object
116 117 118 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 116 def stop # TODO: implement end |