fog-softlayer 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8e974e2bd69d7a85f5f75c30c58aab63c5feb4a
4
- data.tar.gz: 62a6c43e1da9592ba070e14269429a49e44c1afb
3
+ metadata.gz: 0f273615cb1121934f9304adf67d89e5d4cd5131
4
+ data.tar.gz: 3e30cbfadd7fee55a5106962e696806dea057ae9
5
5
  SHA512:
6
- metadata.gz: 567acc968851f508de336f89b888cdee138d061a365bec496d8f3b452321c0d0eaa9c9dfdd9d32c359fff754981a034bc0020d3e1aa5a06c8fb21b6571329919
7
- data.tar.gz: ef12acaa5e16d13049045aa31b59371542bdbfcabbd68694251b763fb0f46dbc17a59810f06d2c1add38db8b074d8d434c2b2a20b97323fd596be3fd8ff36a17
6
+ metadata.gz: d22e7af442f88af8155e6eab632312fe6bc6a7b6eb492e64365d2004c8fc0dcc644f6c361e3995c1ee5f75aea5d51c031ec085a578ce49afa889d4a1c717e89a
7
+ data.tar.gz: 84c7a75d908744796f5645eb72077ff46decc44f01ac08ce05680cfbe2d944207323d6feecfda41dde54979e474c14dc18b1864cb2c7444675d6531e835712fa
@@ -1,444 +1,450 @@
1
- ### Compute Examples
2
-
3
- If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
-
5
-
6
- #### Create a connection to SoftLayer Compute Service
7
-
8
- ```ruby
9
- require 'fog/softlayer'
10
- @sl = Fog::Compute[:softlayer]
11
- ```
12
-
13
- #### Use the Models
14
- 1. List all servers
15
-
16
- ```ruby
17
- @sl.servers # list all servers
18
- @sl.servers.size # get a count of all servers
19
- ```
20
-
21
- 1. Get a server's details
22
-
23
- ```ruby
24
- server = @sl.servers.get(<server id>)
25
- server.name # => 'hostname.example.com'
26
- server.created_at # => DateTime the server was created
27
- server.state # => 'Running', 'Stopped', 'Terminated', etc.
28
- ```
29
-
30
- 1. Get a server's details using ip address
31
-
32
- ```ruby
33
- server = @sl.servers.get_by_ip(<server ip>)
34
- server.name # => 'hostname.example.com'
35
- server.created_at # => DateTime the server was created
36
- server.state # => 'Running', 'Stopped', 'Terminated', etc.
37
- ```
38
-
39
- 1. Get all servers tagged with certain tags.
40
-
41
- ```ruby
42
- prod_fe_servers = @sl.servers.tagged_with(['production', 'frontend'])
43
- # => [ <Fog::Compute::Softlayer::Server>,
44
- # <Fog::Compute::Softlayer::Server>,
45
- # <Fog::Compute::Softlayer::Server>,
46
- # <Fog::Compute::Softlayer::Server>,
47
- # <Fog::Compute::Softlayer::Server>,]
48
- ```
49
-
50
- 1. Get a server's public/frontend VLAN
51
-
52
- ```ruby
53
- server = @sl.servers.get(12345)
54
- server.vlan
55
- # => <Fog::Network::Softlayer::Network
56
- # id=123456,
57
- # name='frontend-staging-vlan',
58
- # modify_date="2014-02-22T12:42:31-06:00",
59
- # note=nil,
60
- # tags=['sparkle', 'motion'],
61
- # type="STANDARD",
62
- # datacenter= <Fog::Network::Softlayer::Datacenter
63
- # id=168642,
64
- # long_name="San Jose 1",
65
- # name="sjc01"
66
- # >,
67
- # network_space="PUBLIC",
68
- # router={"hostname"=>"fcr01a.sjc01", "id"=>82412, "datacenter"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"}}
69
- # >
70
- ```
71
-
72
- 1. Get a server's private/backend VLAN
73
-
74
- ```ruby
75
- server = @sl.servers.get(12345)
76
- server.private_vlan
77
- # => <Fog::Network::Softlayer::Network
78
- # id=123456,
79
- # name='backend-staging-vlan',
80
- # modify_date="2014-02-22T12:42:33-06:00",
81
- # note=nil,
82
- # tags=[],
83
- # type="STANDARD",
84
- # datacenter= <Fog::Network::Softlayer::Datacenter
85
- # id=168642,
86
- # long_name="San Jose 1",
87
- # name="sjc01"
88
- # >,
89
- # network_space="PRIVATE",
90
- # router={"hostname"=>"bcr01a.sjc01", "id"=>82461, "datacenter"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"}}
91
- # >
92
-
93
- ```
94
-
95
- 1. Get a server's tags
96
-
97
- ```ruby
98
- server = @sl.servers.get(12345)
99
- server.tags
100
- # => ['production', 'frontend']
101
- ```
102
-
103
- 1. Add tags to a server
104
-
105
- ```ruby
106
- server = @sl.servers.get(12345)
107
- server.tags
108
- # => ['production', 'frontend']
109
- server.add_tags(['sparkle', 'motion']
110
- # => true
111
- server.tags
112
- # => ['production', 'frontend', 'sparkle', 'motion']
113
- ```
114
-
115
- 1. Delete tags from a server
116
-
117
- ```ruby
118
- server = @sl.servers.get(12345)
119
- server.tags
120
- # => ['production', 'frontend', 'sparkle', 'motion']
121
- server.delete_tags(['sparkle', 'motion']
122
- # => true
123
- server.tags
124
- # => ['production', 'frontend']
125
- ```
126
-
127
- 1. Provision a new VM with flavor (simple).
128
-
129
- ```ruby
130
- opts = {
131
- :flavor_id => "m1.small",
132
- :image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
133
- :name => "test",
134
- :datacenter => "ams01"
135
- }
136
- new_server = @sl.servers.create(opts)
137
- new_server.id # => 1337
138
- ```
139
-
140
- 1. Provision a new Bare Metal instance with flavor (simple).
141
-
142
- ```ruby
143
- opts = {
144
- :flavor_id => "m1.medium",
145
- :os_code => "UBUNTU_LATEST",
146
- :name => "test1",
147
- :datacenter => "ams01",
148
- :bare_metal => true
149
- }
150
- @sl.servers.create(opts)
151
- new_server.id # => 1338
152
- ```
153
-
154
- 1. Provision a *preset* Bare Metal instance (instant provisioning).
155
- 1. First get a list of available preset configuration keys:
156
-
157
- ```ruby
158
-
159
- ```
160
-
161
- ```ruby
162
- opts = {
163
- :domain => 'example.com',
164
- :name => 'my-test',
165
- :flavor_id => 'm1.small',
166
- :fixed_configuration_preset => '50_128GB_4X800GBSSD_RAID10',
167
- :os_code => 'UBUNTU_LATEST',
168
- :datacenter => 'wdc01'
169
- }
170
- ```
171
-
172
- 1. Provision a new VM without flavor.
173
-
174
- ```ruby
175
- opts = {
176
- :cpu => 2,
177
- :ram => 2048,
178
- :disk => [{'device' => 0, 'diskImage' => {'capacity' => 100 } }],
179
- :ephemeral_storage => true,
180
- :domain => "not-my-default.com",
181
- :name => "hostname",
182
- :os_code => "UBUNTU_LATEST",
183
- :name => "test2",
184
- :datacenter => "ams01"
185
- }
186
- ```
187
-
188
- 1. Provision a Bare Metal Instance without a flavor
189
-
190
- ```ruby
191
- opts = {
192
- :cpu => 8,
193
- :ram => 16348,
194
- :disk => {'capacity' => 500 },
195
- :ephemeral_storage => true,
196
- :domain => "not-my-default.com",
197
- :name => "hostname",
198
- :os_code => "UBUNTU_LATEST",
199
- :name => "test2",
200
- :datacenter => "ams01",
201
- :bare_metal => true
202
- }
203
- ```
204
-
205
- 1. Create a server with one or more key pairs (also see [key_pairs.md](./key_pairs.md) )
206
-
207
- ```ruby
208
- the_first_key = @sl.key_pairs.by_label('my-new-key')
209
- # => <Fog::Compute::Softlayer::KeyPair>
210
- the_second_key = @sl.key_pairs.by_label('my-other-new-key')
211
- # => <Fog::Compute::Softlayer::KeyPair>
212
-
213
- opts = {
214
- :flavor_id => 'm1.small',
215
- :os_code => 'UBUNTU_LATEST',
216
- :datacenter => 'hkg02',
217
- :name => 'cphrmky',
218
- :key_pairs => [ the_first_key, the_second_key ]
219
- }
220
- @sl.servers.create(opts)
221
- # => <Fog::Compute::Softlayer::Server>
222
- ```
223
-
224
-
225
- 1. Delete a VM or Bare Metal instance.
226
-
227
- ```ruby
228
- @sl.servers.get(<server id>).destroy
229
- ```
230
-
231
- 1. Provision a Server (works the same for VM and Bare Metal) into a specific VLAN
232
-
233
- ```ruby
234
- # I want to launch another server to hold docker containers into my existing staging VLANs
235
- # I'll start by getting a staging server so I can use its vlans as a reference.
236
- staging_server = @sl.servers.tagged_with(['staging', 'docker']).first # => <Fog::Compute::Softlayer::Server>
237
-
238
- opts = {
239
- :flavor_id => 'm1.large',
240
- :image_id => '23f7f05f-3657-4330-8772-329ed2e816bc', # Ubuntu Docker Image
241
- :domain => 'staging.example.com',
242
- :datacenter => 'ams01', # This needs to be the same datacenter as the target VLAN of course.
243
- :name => 'additional-docker-host',
244
- :vlan => staging.server.vlan, # Passing in a <Fog::Network::Softlayer::Network> object.
245
- :private_vlan => staging.server.private_vlan.id, # Passing in an Integer (the id of a network/vlan) works too.
246
- }
247
-
248
- new_staging_server = @sl.servers.create(opts)
249
- # => <Fog::Compute::Softlayer::Server>
250
-
251
-
252
- ```
253
-
254
- 1. Provision a Server with only a private network.
255
-
256
- ```ruby
257
- opts = {
258
- :flavor_id => 'm1.large',
259
- :os_code => 'UBUNTU_LATEST',
260
- :domain => 'example.com',
261
- :datacenter => 'ams01',
262
- :name => 'private-eye',
263
- :private_network_only => true
264
- }
265
-
266
- private_vm = @sl.servers.create(opts)
267
- # => <Fog::Compute::Softlayer::Server>
268
- ```
269
- 1. Provision a Server with 1Gbps network components.
270
-
271
- ```ruby
272
- opts = {
273
- :flavor_id => 'm1.large',
274
- :os_code => 'UBUNTU_LATEST',
275
- :domain => 'example.com',
276
- :datacenter => 'wdc01',
277
- :name => 'speedy-tubes',
278
- :network_components => [ {:speed => 1000 } ],
279
- }
280
-
281
- private_vm = @sl.servers.create(opts)
282
- # => <Fog::Compute::Softlayer::Server>
283
- ```
284
-
285
- 1. Provision a Server with user metadata.
286
-
287
- ```ruby
288
- opts = {
289
- :flavor_id => "m1.small",
290
- :image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
291
- :name => "test",
292
- :datacenter => "ams01",
293
- :user_data => "my-custom-user-metadata"
294
- }
295
-
296
- new_server = @sl.servers.create(opts)
297
- new_server.user_data # => "my-custom-user-metadata"
298
- new_server.user_data = "new-user-metadata"
299
- new_server.user_data # => "new-user-metadata"
300
- ```
301
-
302
- 1. Start, Stop, and Reboot a existing server (works the same for VMs and Bare Metal).
303
-
304
- ```ruby
305
- srvr = @sl.servers.get(123456)
306
- srvr.ready? # true
307
-
308
- srvr.reboot # true
309
-
310
- srvr.stop # true
311
- srvr.ready? # false
312
- srvr.state # "Halted"
313
-
314
- srvr.start # true
315
- srvr.ready # true
316
- srvr.state # "Running"
317
-
318
- ```
319
-
320
- 1. Get all options to create a bare metal.
321
-
322
- ```ruby
323
- @sl.servers.get_bm_create_options
324
- ```
325
-
326
- 1. Get all options to create a VM.
327
-
328
- ```ruby
329
- @sl.servers.get_vm_create_options
330
- ```
331
-
332
- 1. Get all active tickets of a server.
333
-
334
- ```ruby
335
- server = @sl.servers.get(123456)
336
- server.get_active_tickets
337
- ```
338
-
339
- 1. Get all users of a server.
340
-
341
- ```ruby
342
- server = @sl.servers.get(123456)
343
- server.get_users
344
- ```
345
-
346
- 1. Get all upgrade options of a server.
347
-
348
- ```ruby
349
- server = @sl.servers.get(123456)
350
- server.get_upgrade_options
351
- ```
352
-
353
- 1. Update a virtual guest server.
354
- Hash keys are the categories and the hash values are the capacity. You can retrieve them from upgrade options.
355
-
356
- ```ruby
357
- new_attributes = {
358
- :guest_core => 2,
359
- :ram => 1, # this value is in GBs
360
- :port_speed => 100, # this value is in MPBSs
361
- :time => Time.now + 5.minutes # if you don't specify, time will be equal to now
362
- }
363
-
364
- server = @sl.servers.get(123456)
365
- server.update(new_attributes)
366
- ```
367
-
368
- 1. Update a bare metal server.
369
- Hash keys are the categories and the hash values are the capacity. You can retrieve them from upgrade options.
370
-
371
- ```ruby
372
- new_attributes = {
373
- :ram => 4, # this value is in GBs
374
- :port_speed => 100, # this value is in MPBSs
375
- :maintenance_window => 1111 # should see examples/network "Get a datacenter maintenance windows."
376
- }
377
-
378
- server = @sl.servers.get(123456)
379
- server.update(new_attributes)
380
- ```
381
-
382
- 1. Generate an order template for VM with flavor (simple).
383
-
384
- ```ruby
385
- opts = {
386
- :flavor_id => "m1.small",
387
- :image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
388
- :name => "test",
389
- :datacenter => "ams01"
390
- }
391
- new_server = @sl.servers.new(opts)
392
- new_server.generate_order_template
393
- ```
394
-
395
- 1. Generate an order template for Bare Metal instance with flavor (simple).
396
-
397
- ```ruby
398
- opts = {
399
- :flavor_id => "m1.medium",
400
- :os_code => "UBUNTU_LATEST",
401
- :name => "test1",
402
- :datacenter => "ams01",
403
- :bare_metal => true
404
- }
405
- new_server = @sl.servers.new(opts)
406
- new_server.generate_order_template
407
- ```
408
-
409
- 1. Generate an order template for VM without flavor.
410
-
411
- ```ruby
412
- opts = {
413
- :cpu => 2,
414
- :ram => 2048,
415
- :disk => [{'device' => 0, 'diskImage' => {'capacity' => 100 } }],
416
- :ephemeral_storage => true,
417
- :domain => "not-my-default.com",
418
- :name => "hostname",
419
- :os_code => "UBUNTU_LATEST",
420
- :name => "test2",
421
- :datacenter => "ams01"
422
- }
423
- new_server = @sl.servers.new(opts)
424
- new_server.generate_order_template
425
- ```
426
-
427
- 1. Generate an order template for Bare Metal Instance without a flavor
428
-
429
- ```ruby
430
- opts = {
431
- :cpu => 8,
432
- :ram => 16348,
433
- :disk => {'capacity' => 500 },
434
- :ephemeral_storage => true,
435
- :domain => "not-my-default.com",
436
- :name => "hostname",
437
- :os_code => "UBUNTU_LATEST",
438
- :name => "test2",
439
- :datacenter => "ams01",
440
- :bare_metal => true
441
- }
442
- new_server = @sl.servers.new(opts)
443
- new_server.generate_order_template
444
- ```
1
+ ### Compute Examples
2
+
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
+
5
+
6
+ #### Create a connection to SoftLayer Compute Service
7
+
8
+ ```ruby
9
+ require 'fog/softlayer'
10
+ @sl = Fog::Compute[:softlayer]
11
+ ```
12
+
13
+ #### Use the Models
14
+ 1. List all servers
15
+
16
+ ```ruby
17
+ @sl.servers # list all servers
18
+ @sl.servers.size # get a count of all servers
19
+ ```
20
+
21
+ 1. Get a server's details
22
+
23
+ ```ruby
24
+ server = @sl.servers.get(<server id>)
25
+ server.name # => 'hostname.example.com'
26
+ server.created_at # => DateTime the server was created
27
+ server.state # => 'Running', 'Stopped', 'Terminated', etc.
28
+ ```
29
+
30
+ 1. Get a server's details using ip address
31
+
32
+ ```ruby
33
+ server = @sl.servers.get_by_ip(<server ip>)
34
+ server.name # => 'hostname.example.com'
35
+ server.created_at # => DateTime the server was created
36
+ server.state # => 'Running', 'Stopped', 'Terminated', etc.
37
+ ```
38
+
39
+ 1. Get all servers tagged with certain tags.
40
+
41
+ ```ruby
42
+ prod_fe_servers = @sl.servers.tagged_with(['production', 'frontend'])
43
+ # => [ <Fog::Compute::Softlayer::Server>,
44
+ # <Fog::Compute::Softlayer::Server>,
45
+ # <Fog::Compute::Softlayer::Server>,
46
+ # <Fog::Compute::Softlayer::Server>,
47
+ # <Fog::Compute::Softlayer::Server>,]
48
+ ```
49
+
50
+ 1. Get a server's public/frontend VLAN
51
+
52
+ ```ruby
53
+ server = @sl.servers.get(12345)
54
+ server.vlan
55
+ # => <Fog::Network::Softlayer::Network
56
+ # id=123456,
57
+ # name='frontend-staging-vlan',
58
+ # modify_date="2014-02-22T12:42:31-06:00",
59
+ # note=nil,
60
+ # tags=['sparkle', 'motion'],
61
+ # type="STANDARD",
62
+ # datacenter= <Fog::Network::Softlayer::Datacenter
63
+ # id=168642,
64
+ # long_name="San Jose 1",
65
+ # name="sjc01"
66
+ # >,
67
+ # network_space="PUBLIC",
68
+ # router={"hostname"=>"fcr01a.sjc01", "id"=>82412, "datacenter"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"}}
69
+ # >
70
+ ```
71
+
72
+ 1. Get a server's private/backend VLAN
73
+
74
+ ```ruby
75
+ server = @sl.servers.get(12345)
76
+ server.private_vlan
77
+ # => <Fog::Network::Softlayer::Network
78
+ # id=123456,
79
+ # name='backend-staging-vlan',
80
+ # modify_date="2014-02-22T12:42:33-06:00",
81
+ # note=nil,
82
+ # tags=[],
83
+ # type="STANDARD",
84
+ # datacenter= <Fog::Network::Softlayer::Datacenter
85
+ # id=168642,
86
+ # long_name="San Jose 1",
87
+ # name="sjc01"
88
+ # >,
89
+ # network_space="PRIVATE",
90
+ # router={"hostname"=>"bcr01a.sjc01", "id"=>82461, "datacenter"=>{"id"=>168642, "longName"=>"San Jose 1", "name"=>"sjc01"}}
91
+ # >
92
+
93
+ ```
94
+
95
+ 1. Get a server's tags
96
+
97
+ ```ruby
98
+ server = @sl.servers.get(12345)
99
+ server.tags
100
+ # => ['production', 'frontend']
101
+ ```
102
+
103
+ 1. Add tags to a server
104
+
105
+ ```ruby
106
+ server = @sl.servers.get(12345)
107
+ server.tags
108
+ # => ['production', 'frontend']
109
+ server.add_tags(['sparkle', 'motion']
110
+ # => true
111
+ server.tags
112
+ # => ['production', 'frontend', 'sparkle', 'motion']
113
+ ```
114
+
115
+ 1. Delete tags from a server
116
+
117
+ ```ruby
118
+ server = @sl.servers.get(12345)
119
+ server.tags
120
+ # => ['production', 'frontend', 'sparkle', 'motion']
121
+ server.delete_tags(['sparkle', 'motion']
122
+ # => true
123
+ server.tags
124
+ # => ['production', 'frontend']
125
+ ```
126
+
127
+ 1. Provision a new VM with flavor (simple).
128
+
129
+ ```ruby
130
+ opts = {
131
+ :flavor_id => "m1.small",
132
+ :image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
133
+ :name => "test",
134
+ :datacenter => "ams01"
135
+ }
136
+ new_server = @sl.servers.create(opts)
137
+ new_server.id # => 1337
138
+ ```
139
+
140
+ 1. Provision a new Bare Metal instance with flavor (simple).
141
+
142
+ ```ruby
143
+ opts = {
144
+ :flavor_id => "m1.medium",
145
+ :os_code => "UBUNTU_LATEST",
146
+ :name => "test1",
147
+ :datacenter => "ams01",
148
+ :bare_metal => true
149
+ }
150
+ @sl.servers.create(opts)
151
+ new_server.id # => 1338
152
+ ```
153
+
154
+ 1. Provision a *preset* Bare Metal instance (instant provisioning).
155
+ 1. First get a list of available preset configuration keys:
156
+
157
+ ```ruby
158
+ @sl.get_bare_metal_create_options.body["fixedConfigurationPresets"].each {|item| puts item["preset"]};nil
159
+
160
+ ```
161
+
162
+ ```ruby
163
+ opts = {
164
+ :domain => 'example.com',
165
+ :name => 'my-test',
166
+ :fixed_configuration_preset => '50_128GB_4X800GBSSD_RAID10',
167
+ :os_code => 'UBUNTU_LATEST',
168
+ :datacenter => 'wdc01'
169
+ }
170
+ new_server = @sl.servers.create(opts)
171
+ new_server.id # => 0
172
+ new_server.wait_for_id do |details|
173
+ puts details.inspect
174
+ end
175
+ new_server.id # => 1234
176
+ ```
177
+
178
+ 1. Provision a new VM without flavor.
179
+
180
+ ```ruby
181
+ opts = {
182
+ :cpu => 2,
183
+ :ram => 2048,
184
+ :disk => [{'device' => 0, 'diskImage' => {'capacity' => 100 } }],
185
+ :ephemeral_storage => true,
186
+ :domain => "not-my-default.com",
187
+ :name => "hostname",
188
+ :os_code => "UBUNTU_LATEST",
189
+ :name => "test2",
190
+ :datacenter => "ams01"
191
+ }
192
+ ```
193
+
194
+ 1. Provision a Bare Metal Instance without a flavor
195
+
196
+ ```ruby
197
+ opts = {
198
+ :cpu => 8,
199
+ :ram => 16348,
200
+ :disk => {'capacity' => 500 },
201
+ :ephemeral_storage => true,
202
+ :domain => "not-my-default.com",
203
+ :name => "hostname",
204
+ :os_code => "UBUNTU_LATEST",
205
+ :name => "test2",
206
+ :datacenter => "ams01",
207
+ :bare_metal => true
208
+ }
209
+ ```
210
+
211
+ 1. Create a server with one or more key pairs (also see [key_pairs.md](./key_pairs.md) )
212
+
213
+ ```ruby
214
+ the_first_key = @sl.key_pairs.by_label('my-new-key')
215
+ # => <Fog::Compute::Softlayer::KeyPair>
216
+ the_second_key = @sl.key_pairs.by_label('my-other-new-key')
217
+ # => <Fog::Compute::Softlayer::KeyPair>
218
+
219
+ opts = {
220
+ :flavor_id => 'm1.small',
221
+ :os_code => 'UBUNTU_LATEST',
222
+ :datacenter => 'hkg02',
223
+ :name => 'cphrmky',
224
+ :key_pairs => [ the_first_key, the_second_key ]
225
+ }
226
+ @sl.servers.create(opts)
227
+ # => <Fog::Compute::Softlayer::Server>
228
+ ```
229
+
230
+
231
+ 1. Delete a VM or Bare Metal instance.
232
+
233
+ ```ruby
234
+ @sl.servers.get(<server id>).destroy
235
+ ```
236
+
237
+ 1. Provision a Server (works the same for VM and Bare Metal) into a specific VLAN
238
+
239
+ ```ruby
240
+ # I want to launch another server to hold docker containers into my existing staging VLANs
241
+ # I'll start by getting a staging server so I can use its vlans as a reference.
242
+ staging_server = @sl.servers.tagged_with(['staging', 'docker']).first # => <Fog::Compute::Softlayer::Server>
243
+
244
+ opts = {
245
+ :flavor_id => 'm1.large',
246
+ :image_id => '23f7f05f-3657-4330-8772-329ed2e816bc', # Ubuntu Docker Image
247
+ :domain => 'staging.example.com',
248
+ :datacenter => 'ams01', # This needs to be the same datacenter as the target VLAN of course.
249
+ :name => 'additional-docker-host',
250
+ :vlan => staging.server.vlan, # Passing in a <Fog::Network::Softlayer::Network> object.
251
+ :private_vlan => staging.server.private_vlan.id, # Passing in an Integer (the id of a network/vlan) works too.
252
+ }
253
+
254
+ new_staging_server = @sl.servers.create(opts)
255
+ # => <Fog::Compute::Softlayer::Server>
256
+
257
+
258
+ ```
259
+
260
+ 1. Provision a Server with only a private network.
261
+
262
+ ```ruby
263
+ opts = {
264
+ :flavor_id => 'm1.large',
265
+ :os_code => 'UBUNTU_LATEST',
266
+ :domain => 'example.com',
267
+ :datacenter => 'ams01',
268
+ :name => 'private-eye',
269
+ :private_network_only => true
270
+ }
271
+
272
+ private_vm = @sl.servers.create(opts)
273
+ # => <Fog::Compute::Softlayer::Server>
274
+ ```
275
+ 1. Provision a Server with 1Gbps network components.
276
+
277
+ ```ruby
278
+ opts = {
279
+ :flavor_id => 'm1.large',
280
+ :os_code => 'UBUNTU_LATEST',
281
+ :domain => 'example.com',
282
+ :datacenter => 'wdc01',
283
+ :name => 'speedy-tubes',
284
+ :network_components => [ {:speed => 1000 } ],
285
+ }
286
+
287
+ private_vm = @sl.servers.create(opts)
288
+ # => <Fog::Compute::Softlayer::Server>
289
+ ```
290
+
291
+ 1. Provision a Server with user metadata.
292
+
293
+ ```ruby
294
+ opts = {
295
+ :flavor_id => "m1.small",
296
+ :image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
297
+ :name => "test",
298
+ :datacenter => "ams01",
299
+ :user_data => "my-custom-user-metadata"
300
+ }
301
+
302
+ new_server = @sl.servers.create(opts)
303
+ new_server.user_data # => "my-custom-user-metadata"
304
+ new_server.user_data = "new-user-metadata"
305
+ new_server.user_data # => "new-user-metadata"
306
+ ```
307
+
308
+ 1. Start, Stop, and Reboot a existing server (works the same for VMs and Bare Metal).
309
+
310
+ ```ruby
311
+ srvr = @sl.servers.get(123456)
312
+ srvr.ready? # true
313
+
314
+ srvr.reboot # true
315
+
316
+ srvr.stop # true
317
+ srvr.ready? # false
318
+ srvr.state # "Halted"
319
+
320
+ srvr.start # true
321
+ srvr.ready # true
322
+ srvr.state # "Running"
323
+
324
+ ```
325
+
326
+ 1. Get all options to create a bare metal.
327
+
328
+ ```ruby
329
+ @sl.servers.get_bm_create_options
330
+ ```
331
+
332
+ 1. Get all options to create a VM.
333
+
334
+ ```ruby
335
+ @sl.servers.get_vm_create_options
336
+ ```
337
+
338
+ 1. Get all active tickets of a server.
339
+
340
+ ```ruby
341
+ server = @sl.servers.get(123456)
342
+ server.get_active_tickets
343
+ ```
344
+
345
+ 1. Get all users of a server.
346
+
347
+ ```ruby
348
+ server = @sl.servers.get(123456)
349
+ server.get_users
350
+ ```
351
+
352
+ 1. Get all upgrade options of a server.
353
+
354
+ ```ruby
355
+ server = @sl.servers.get(123456)
356
+ server.get_upgrade_options
357
+ ```
358
+
359
+ 1. Update a virtual guest server.
360
+ Hash keys are the categories and the hash values are the capacity. You can retrieve them from upgrade options.
361
+
362
+ ```ruby
363
+ new_attributes = {
364
+ :guest_core => 2,
365
+ :ram => 1, # this value is in GBs
366
+ :port_speed => 100, # this value is in MPBSs
367
+ :time => Time.now + 5.minutes # if you don't specify, time will be equal to now
368
+ }
369
+
370
+ server = @sl.servers.get(123456)
371
+ server.update(new_attributes)
372
+ ```
373
+
374
+ 1. Update a bare metal server.
375
+ Hash keys are the categories and the hash values are the capacity. You can retrieve them from upgrade options.
376
+
377
+ ```ruby
378
+ new_attributes = {
379
+ :ram => 4, # this value is in GBs
380
+ :port_speed => 100, # this value is in MPBSs
381
+ :maintenance_window => 1111 # should see examples/network "Get a datacenter maintenance windows."
382
+ }
383
+
384
+ server = @sl.servers.get(123456)
385
+ server.update(new_attributes)
386
+ ```
387
+
388
+ 1. Generate an order template for VM with flavor (simple).
389
+
390
+ ```ruby
391
+ opts = {
392
+ :flavor_id => "m1.small",
393
+ :image_id => "23f7f05f-3657-4330-8772-329ed2e816bc",
394
+ :name => "test",
395
+ :datacenter => "ams01"
396
+ }
397
+ new_server = @sl.servers.new(opts)
398
+ new_server.generate_order_template
399
+ ```
400
+
401
+ 1. Generate an order template for Bare Metal instance with flavor (simple).
402
+
403
+ ```ruby
404
+ opts = {
405
+ :flavor_id => "m1.medium",
406
+ :os_code => "UBUNTU_LATEST",
407
+ :name => "test1",
408
+ :datacenter => "ams01",
409
+ :bare_metal => true
410
+ }
411
+ new_server = @sl.servers.new(opts)
412
+ new_server.generate_order_template
413
+ ```
414
+
415
+ 1. Generate an order template for VM without flavor.
416
+
417
+ ```ruby
418
+ opts = {
419
+ :cpu => 2,
420
+ :ram => 2048,
421
+ :disk => [{'device' => 0, 'diskImage' => {'capacity' => 100 } }],
422
+ :ephemeral_storage => true,
423
+ :domain => "not-my-default.com",
424
+ :name => "hostname",
425
+ :os_code => "UBUNTU_LATEST",
426
+ :name => "test2",
427
+ :datacenter => "ams01"
428
+ }
429
+ new_server = @sl.servers.new(opts)
430
+ new_server.generate_order_template
431
+ ```
432
+
433
+ 1. Generate an order template for Bare Metal Instance without a flavor
434
+
435
+ ```ruby
436
+ opts = {
437
+ :cpu => 8,
438
+ :ram => 16348,
439
+ :disk => {'capacity' => 500 },
440
+ :ephemeral_storage => true,
441
+ :domain => "not-my-default.com",
442
+ :name => "hostname",
443
+ :os_code => "UBUNTU_LATEST",
444
+ :name => "test2",
445
+ :datacenter => "ams01",
446
+ :bare_metal => true
447
+ }
448
+ new_server = @sl.servers.new(opts)
449
+ new_server.generate_order_template
450
+ ```