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.
- #start ⇒ Object
- #state ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Server
Returns a new instance of Server.
44 45 46 47 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 44 def initialize(attributes = {}) super(attributes) set_defaults end |
Instance Method Details
#bare_metal ⇒ Object
64 65 66 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 64 def attributes[:bare_metal] === 1 ? true : false end |
#bare_metal=(set) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 53 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
49 50 51 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 49 def end |
#destroy ⇒ Object
119 120 121 122 123 124 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 119 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
130 131 132 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 130 def dns_name fqdn end |
#image_id ⇒ Object
72 73 74 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 72 def image_id attributes[:image_id][:globalIdentifier] unless attributes[:image_id].nil? end |
#image_id=(uuid) ⇒ Object
68 69 70 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 68 def image_id=(uuid) attributes[:image_id] = {:globalIdentifier => uuid} end |
#name ⇒ Object
87 88 89 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 87 def name attributes[:hostname] end |
#name=(set) ⇒ Object
83 84 85 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 83 def name=(set) attributes[:hostname] = set end |
#pre_save ⇒ Object
175 176 177 178 179 180 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 175 def pre_save extract_flavor validate_attributes remap_attributes(attributes, attributes_mapping) clean_attributes end |
#ram=(set) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 76 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
143 144 145 146 147 148 149 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 143 def ready? if state == "on" else state == "Running" end end |
#reboot(use_hard_reboot = true) ⇒ Object
99 100 101 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 99 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)
-
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 159 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
115 116 117 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 115 def shutdown # TODO: implement end |
#snapshot ⇒ Object
def ram
end
95 96 97 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 95 def snapshot # TODO: implement end |
#start ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 103 def start # TODO: implement #requires :identity #service.start_server(identity) true end |
#state ⇒ Object
134 135 136 137 138 139 140 141 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 134 def state if service.request(:hardware_server, "#{id}/getServerPowerState").body else service.request(:virtual_guest, "#{id}/getPowerState").body['name'] end end |
#stop ⇒ Object
111 112 113 |
# File 'lib/fog/softlayer/models/compute/server.rb', line 111 def stop # TODO: implement end |