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 +4 -4
- data/examples/compute.md +450 -444
- data/lib/fog/softlayer/models/compute/server.rb +628 -628
- data/lib/fog/softlayer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f273615cb1121934f9304adf67d89e5d4cd5131
|
4
|
+
data.tar.gz: 3e30cbfadd7fee55a5106962e696806dea057ae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d22e7af442f88af8155e6eab632312fe6bc6a7b6eb492e64365d2004c8fc0dcc644f6c361e3995c1ee5f75aea5d51c031ec085a578ce49afa889d4a1c717e89a
|
7
|
+
data.tar.gz: 84c7a75d908744796f5645eb72077ff46decc44f01ac08ce05680cfbe2d944207323d6feecfda41dde54979e474c14dc18b1864cb2c7444675d6531e835712fa
|
data/examples/compute.md
CHANGED
@@ -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
|
-
|
162
|
-
|
163
|
-
|
164
|
-
:
|
165
|
-
:
|
166
|
-
:fixed_configuration_preset => '50_128GB_4X800GBSSD_RAID10',
|
167
|
-
:os_code => 'UBUNTU_LATEST',
|
168
|
-
:datacenter => 'wdc01'
|
169
|
-
}
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
:
|
199
|
-
:
|
200
|
-
:
|
201
|
-
:
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
1.
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
:
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
srvr
|
312
|
-
srvr.
|
313
|
-
|
314
|
-
srvr.
|
315
|
-
|
316
|
-
srvr.
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
1. Get all options to create a
|
327
|
-
|
328
|
-
```ruby
|
329
|
-
@sl.servers.
|
330
|
-
```
|
331
|
-
|
332
|
-
1. Get all
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
server
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
server
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
:
|
420
|
-
:
|
421
|
-
:
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
:
|
438
|
-
:
|
439
|
-
:
|
440
|
-
:
|
441
|
-
|
442
|
-
|
443
|
-
|
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
|
+
```
|