fog-softlayer 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzU2YmI4NDA4Y2JkMDY3Nzk5ZGE1MzU1MzEwN2EwOTE5YTI5Y2M2Nw==
4
+ ZWZlNDk1ZDg4MzRiOGRhMDhkZDg4ZDQ3ODM5NDAyNTA3NTQxNmVmYQ==
5
5
  data.tar.gz: !binary |-
6
- M2EyZjc5ZDk5YzdhOGY1Mzk0ZWNiODk5YmEzOTJjNDExNjVkMTc3Zg==
6
+ OGNlNmM5OTJhNDU3YzA5MTg1MGYxOWJkMjMwNGZiMGQ2ZDQ3MmJjZg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjUyZjQ1OTI5OGQ3Y2Y0NTJiMzhlZDU4ZTlkMjY0MDA0ODE1OWI3ZmI0OWFl
10
- YzQ1YzAyZDU1MWVjZmEwOTA2N2IxMDI3MWE1MzU3MzVmOWJlOTYyZGQ0ZTIz
11
- NzRmNTA1YTBjOGNiNWQwZjBiYzgxYWUyY2M5MWFhZDUwNmY1YTU=
9
+ ZmY5ZTA5OGFkZDI0YjVhYTVlMzA4N2QyNmEyZWRkMDc1OGU1OGFkNjc4MjRl
10
+ M2NjMjJlOTc5ODg4MTY0MzBjNDdjYzYzMGRkOGY1ZTA3YjljNTk1MmIwM2Nj
11
+ ZDIxMzhlMGUzNGZmZDJkZmUyYzAzNDc5ZGFkY2I5MDY4MzQyMjc=
12
12
  data.tar.gz: !binary |-
13
- MDViOTJmMzU5M2Q2ZTRlMTc4ZWYxNDE4ZDgxYjQ0OGYxN2M0ZmU0OWJkMzg2
14
- ZWI1MDhhMTJmNDFmMjJlZjQ3NzdkNTJmMDkyZjBhOWQwNTM5ZDg0Mjk0ZDA1
15
- ZWQwZmE3OGM0NjI1NTRiMzhjMmMxNzE3ZGFkZDdhNTgzNGYzZmY=
13
+ MDk5YjRlZjNlMDY5ZmI4ZWQ5NDlhNDUwMDRmMzA1Mjg3MTgwZTE4MTZiNjQw
14
+ Y2ExMWQwODU1YWM3N2Y1YTQzZWQzZWNlOTI4YjUyZDdlZDNkYzIyOTRhODk3
15
+ YzE4MTY2ZjYyMDYzYzBlZTk3YzQ0ZTdlNmVkNGJjZTI1ODg5ZjA=
data/CONTRIBUTORS.md CHANGED
@@ -1,7 +1,9 @@
1
1
  * Akira Matsuda <ronnie@dio.jp>
2
+ * Bryan Paxton <starbelly@pobox.com>
2
3
  * Celso Fernandes <fernandes@zertico.com>
3
4
  * Hiroyuki Urasoko <ura.58.58@gmail.com>
4
5
  * Konstantin Krauss <konstantin@propertybase.com>
6
+ * Manuel Franco <mfranco@flexiant.com>
5
7
  * Matt Eldridge <matt.eldridge@us.ibm.com>
6
8
  * Paulo Henrique Lopes Ribeiro <paulo@majority.co>
7
9
  * geemus <geemus@gmail.com>
data/examples/README.md CHANGED
@@ -1,11 +1,16 @@
1
1
  Welcome to the fog-softlayer examples!
2
2
 
3
+ ## Getting Started
4
+
5
+ Not sure how to start using fog-softlayer? check our [Getting Started](getting_started.md) guide.
6
+
3
7
  ## SoftLayer Services
4
8
 
5
9
  * [Compute](compute.md)
6
10
  * [DNS](dns.md)
7
11
  * [Global IP Address](global_ip_address.md)
8
12
  * [Key Pairs](key_pairs.md)
9
- * [Network](Network.md)
13
+ * [Network](network.md)
14
+ * [Product](product.md)
10
15
  * [Storage](storage.md)
11
16
  * [Tags](tags.md)
data/examples/compute.md CHANGED
@@ -1,13 +1,7 @@
1
1
  ### Compute Examples
2
2
 
3
- These examples all assume you have `~/.fog` which contains the following
4
-
5
- ```yaml
6
- default:
7
- softlayer_username: example-username
8
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
9
- softlayer_default_domain: example.com
10
- ```
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
+
11
5
 
12
6
  #### Create a connection to SoftLayer Compute Service
13
7
 
@@ -277,3 +271,21 @@ default:
277
271
  new_server.user_data = "new-user-metadata"
278
272
  new_server.user_data # => "new-user-metadata"
279
273
  ```
274
+
275
+ 1. Start, Stop, and Reboot a existing server (works the same for VMs and Bare Metal).
276
+
277
+ ```ruby
278
+ srvr = @sl.servers.get(123456)
279
+ srvr.ready? # true
280
+
281
+ srvr.reboot # true
282
+
283
+ srvr.stop # true
284
+ srvr.ready? # false
285
+ srvr.state # "Halted"
286
+
287
+ srvr.start # true
288
+ srvr.ready # true
289
+ srvr.state # "Running"
290
+
291
+ ```
data/examples/dns.md CHANGED
@@ -1,14 +1,8 @@
1
1
  ### DNS Examples
2
2
 
3
- These examples all assume you have `~/.fog` which contains the following
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
4
 
5
5
 
6
- ```yaml
7
- default:
8
- softlayer_username: example-username
9
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
10
- ```
11
-
12
6
  #### Create a connection to SoftLayer DNS Service
13
7
 
14
8
  ```ruby
@@ -0,0 +1,49 @@
1
+ # Getting Started
2
+
3
+ This is a quick how-to on getting started with fog-softlayer covering all aspects from zero to hero using this library.
4
+
5
+ ## Installation
6
+
7
+ You can just use as a gem on your system install as a global gem:
8
+
9
+ ```bash
10
+ gem install fog-softlayer
11
+ ```
12
+
13
+ or you can add to your Gemfile
14
+
15
+ ```ruby
16
+ gem 'fog-softlayer
17
+ ```
18
+
19
+ This is the only necessary step, after configuring your credentials in fog file (see how next on usage section) you can test your setup by executing the contents according to this [gist](https://gist.github.com/fernandes/58908649f25b218cc4a7)
20
+
21
+ ## Usage
22
+
23
+ The first step to get into fog-softlayer is to configure your __~/.fog__ file. This is useful so that you do not have to retype credentials on every fog-softlayer use.
24
+
25
+ If you do not configure .fog, you will have to manually enter:
26
+
27
+ ```ruby
28
+ @sl = Fog::Compute.new(provider: "softlayer", softlayer_username: "SLUSERNAME", softlayer_api_key: '860e03c168c3aef304341b492ba9984ac1080bb5')
29
+ ```
30
+
31
+ This is not recommended since credentials or api-keys could be leaked.
32
+
33
+ Write a configure file like this under __~/.fog__
34
+
35
+ ```yaml
36
+ default:
37
+ softlayer_username: example-username
38
+ softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
39
+ softlayer_default_domain: example.com
40
+ softlayer_cluster: cluster # needed for storage access
41
+ ```
42
+
43
+ After this file is configured you just need to use:
44
+
45
+ ```ruby
46
+ @sl = Fog::Compute[:softlayer]
47
+ ```
48
+
49
+ Remember, you can always specify the username and api key to connect using another credential.
@@ -1,13 +1,6 @@
1
1
  #### Global IP Address examples
2
2
 
3
- These examples all assume you have `~/.fog` which contains the following:
4
-
5
-
6
- ```yaml
7
- default:
8
- softlayer_username: example-username
9
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
10
- ```
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
11
4
 
12
5
  ##### Create a connection to SoftLayer network
13
6
 
@@ -1,13 +1,7 @@
1
1
  ### Key Pair Examples
2
2
 
3
- These examples all assume you have `~/.fog` which contains the following
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
4
 
5
- ```yaml
6
- default:
7
- softlayer_username: example-username
8
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
9
- softlayer_default_domain: example.com
10
- ```
11
5
 
12
6
  #### Create a connection to SoftLayer Compute Service
13
7
 
data/examples/network.md CHANGED
@@ -1,17 +1,8 @@
1
1
  ### Network Examples
2
2
 
3
- Note that SoftLayer uses the term `VLAN`. The Fog project tries to keep things provider independent, and we'll be referring to them as `networks`.
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
4
 
5
5
 
6
- These examples all assume you have `~/.fog` which contains the following
7
-
8
-
9
- ```yaml
10
- default:
11
- softlayer_username: example-username
12
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
13
- ```
14
-
15
6
  #### Create a connection to SoftLayer Network
16
7
 
17
8
  ```ruby
@@ -0,0 +1,65 @@
1
+ ### Product Examples
2
+
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
+
5
+ #### Product Service
6
+
7
+ SoftLayer has Product Service that is used for complex ordering process, so we support getting information on packages and items.
8
+
9
+ All data available on the real api is available using the Fog.mock! so you can provide a real experience using mocks.
10
+
11
+ This is the first version of this service and our intention is to support more feature and allow reuse on the buying process.
12
+
13
+ #### Create a connection to SoftLayer Product Service
14
+
15
+ ```ruby
16
+ require 'fog/softlayer'
17
+ @sl = Fog::Softlayer[:product]
18
+ ```
19
+
20
+ #### Use the Models
21
+ 1. List all packages
22
+
23
+ ```ruby
24
+ @sl.packages # list all packages
25
+ ```
26
+
27
+ 1. Get first package
28
+
29
+ ```ruby
30
+ pkg = @sl.packages.first
31
+ # => <Fog::Softlayer::Product::Package
32
+ # id=0,
33
+ # description=nil,
34
+ # first_order_step_id=1,
35
+ # is_active=1,
36
+ # name="Additional Products",
37
+ # sub_description=nil,
38
+ # unit_size=0
39
+ # >
40
+ ```
41
+
42
+ 1. Get items for a package.
43
+
44
+ ```ruby
45
+ items = @sl.packages.first.items
46
+ ```
47
+ items will be a collection of Fog::Softlayer::Product::Item models.
48
+
49
+ 1. Get a specific item
50
+
51
+ ```ruby
52
+ @sl.packages.first.items.get(559)
53
+ # => <Fog::Softlayer::Product::Item
54
+ # id=559,
55
+ # capacity=40.0,
56
+ # description="40GB EVault Disk to Disk Enterprise Backup",
57
+ # item_tax_category_id=166,
58
+ # key_name="EVAULT_40_GB",
59
+ # long_description=nil,
60
+ # software_description_id=159,
61
+ # units="GIGABYTE",
62
+ # upgrade_item_id=3784
63
+ ```
64
+
65
+ We need to make this nested call because we need package id on our items model, because items are related to packages.
data/examples/storage.md CHANGED
@@ -1,15 +1,8 @@
1
1
  ### Storage Examples
2
2
 
3
- These examples all assume you have `~/.fog` which contains the following
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
4
 
5
5
 
6
- ```yaml
7
- default:
8
- softlayer_username: example-username
9
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
10
- softlayer_cluster: cluster # currently supported clusters are dal05, sng01, ams01
11
- ```
12
-
13
6
  #### Create a connection to SoftLayer Object Storage
14
7
 
15
8
  ```ruby
data/examples/tags.md CHANGED
@@ -1,13 +1,7 @@
1
1
  ### Tags Examples
2
2
 
3
- These examples all assume you have `~/.fog` which contains the following
4
-
5
- ```yaml
6
- default:
7
- softlayer_username: example-username
8
- softlayer_api_key: 1a1a1a1a1a1a1a1a1a11a1a1a1a1a1a1a1a1a1
9
- softlayer_default_domain: example.com
10
- ```
3
+ If you are unfamiliar with fog, we recommend reading our [getting started](getting_started.md) guide.
4
+
11
5
 
12
6
  #### Create a connection to SoftLayer Compute Service
13
7
 
@@ -57,6 +57,12 @@ module Fog
57
57
  request :get_vm_tags
58
58
  request :get_vm
59
59
  request :get_vms
60
+ request :power_off_bare_metal_server
61
+ request :power_off_vm
62
+ request :power_on_bare_metal_server
63
+ request :power_on_vm
64
+ request :reboot_bare_metal_server
65
+ request :reboot_vm
60
66
  request :update_key_pair
61
67
 
62
68
  # The Mock Service allows you to run a fake instance of the Service
@@ -259,7 +259,13 @@ module Fog
259
259
  end
260
260
 
261
261
  def reboot(use_hard_reboot = true)
262
- # TODO: implement
262
+ requires :id
263
+ if bare_metal?
264
+ service.reboot_bare_metal_server(id, use_hard_reboot)
265
+ else
266
+ service.reboot_vm(id, use_hard_reboot)
267
+ end
268
+ true
263
269
  end
264
270
 
265
271
  def ssh_password
@@ -274,19 +280,35 @@ module Fog
274
280
  end
275
281
 
276
282
  def start
277
- # TODO: implement
278
-
279
- #requires :identity
280
- #service.start_server(identity)
283
+ requires :id
284
+ if bare_metal?
285
+ service.power_on_bare_metal_server(id)
286
+ else
287
+ service.power_on_vm(id)
288
+ end
281
289
  true
282
290
  end
283
291
 
292
+ # Hard power off
284
293
  def stop
285
- # TODO: implement
294
+ requires :id
295
+ if bare_metal?
296
+ service.power_off_bare_metal_server(id)
297
+ else
298
+ service.power_off_vm(id, true)
299
+ end
300
+ true
286
301
  end
287
302
 
303
+ # Soft power off
288
304
  def shutdown
289
- # TODO: implement
305
+ requires :id
306
+ if bare_metal?
307
+ raise Fog::Errors::Error.new('Shutdown not supported on baremetal servers. Use #stop.')
308
+ else
309
+ service.power_off_vm(id, false)
310
+ end
311
+ true
290
312
  end
291
313
 
292
314
  def state
@@ -0,0 +1,42 @@
1
+ #
2
+ # Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+
11
+ class Mock
12
+
13
+ # Stop a BM server
14
+ # @param [Integer] id
15
+ # @return [Excon::Response]
16
+ def power_off_bare_metal_server(id)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ found = self.get_bare_metal_servers.body.map{|server| server['id']}.include?(id)
20
+ if not found
21
+ response.status = 404
22
+ response.body = {
23
+ "error" => "Unable to find object with id of '#{id}'.",
24
+ "code" => "SoftLayer_Exception_ObjectNotFound"
25
+ }
26
+ else
27
+ response.body = true
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ class Real
34
+
35
+ def power_off_bare_metal_server(id)
36
+ request(:hardware_server, "#{id.to_s}/powerOff", :http_method => :GET)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+
11
+ class Mock
12
+
13
+ # Stop a VM
14
+ # @param [Integer] id
15
+ # @return [Excon::Response]
16
+ def power_off_vm(id, use_hard_poweroff)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ found = self.get_vms.body.map{|server| server['id']}.include?(id)
20
+ if not found
21
+ response.status = 404
22
+ response.body = {
23
+ "error" => "Unable to find object with id of '#{id}'.",
24
+ "code" => "SoftLayer_Exception_ObjectNotFound"
25
+ }
26
+ else
27
+ response.body = true
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ class Real
34
+
35
+ def power_off_vm(id, use_hard_poweroff)
36
+ if use_hard_poweroff
37
+ request(:virtual_guest, "#{id.to_s}/powerOff", :http_method => :GET)
38
+ else
39
+ request(:virtual_guest, "#{id.to_s}/powerOffSoft", :http_method => :GET)
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,42 @@
1
+ #
2
+ # Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+
11
+ class Mock
12
+
13
+ # Starts a BM server
14
+ # @param [Integer] id
15
+ # @return [Excon::Response]
16
+ def power_on_bare_metal_server(id)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ found = self.get_bare_metal_servers.body.map{|server| server['id']}.include?(id)
20
+ if not found
21
+ response.status = 404
22
+ response.body = {
23
+ "error" => "Unable to find object with id of '#{id}'.",
24
+ "code" => "SoftLayer_Exception_ObjectNotFound"
25
+ }
26
+ else
27
+ response.body = true
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ class Real
34
+
35
+ def power_on_bare_metal_server(id)
36
+ request(:hardware_server, "#{id.to_s}/powerOn", :http_method => :GET)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ #
2
+ # Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+
11
+ class Mock
12
+
13
+ # Powers on a VM
14
+ # @param [Integer] id
15
+ # @return [Excon::Response]
16
+ def power_on_vm(id)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ found = self.get_vms.body.map{|server| server['id']}.include?(id)
20
+ if not found
21
+ response.status = 404
22
+ response.body = {
23
+ "error" => "Unable to find object with id of '#{id}'.",
24
+ "code" => "SoftLayer_Exception_ObjectNotFound"
25
+ }
26
+ else
27
+ response.body = true
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ class Real
34
+
35
+ def power_on_vm(id)
36
+ request(:virtual_guest, "#{id.to_s}/powerOn", :http_method => :GET)
37
+ end
38
+
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+
11
+ class Mock
12
+
13
+ # Reboots a BM server
14
+ # @param [Integer] id
15
+ # @return [Excon::Response]
16
+ def reboot_bare_metal_server(id, use_hard_reboot)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ found = self.get_bare_metal_servers.body.map{|server| server['id']}.include?(id)
20
+ if not found
21
+ response.status = 404
22
+ response.body = {
23
+ "error" => "Unable to find object with id of '#{id}'.",
24
+ "code" => "SoftLayer_Exception_ObjectNotFound"
25
+ }
26
+ else
27
+ response.body = true
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ class Real
34
+
35
+ def reboot_bare_metal_server(id, use_hard_reboot)
36
+ if use_hard_reboot
37
+ request(:hardware_server, "#{id.to_s}/rebootHard", :http_method => :GET)
38
+ else
39
+ request(:hardware_server, "#{id.to_s}/rebootSoft", :http_method => :GET)
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,46 @@
1
+ #
2
+ # Author:: Manuel David Franco Barrios (<mafraba@gmail.com>)
3
+ # © Copyright IBM Corporation 2015.
4
+ #
5
+ # LICENSE: MIT (http://opensource.org/licenses/MIT)
6
+ #
7
+ module Fog
8
+ module Compute
9
+ class Softlayer
10
+
11
+ class Mock
12
+
13
+ # Reboots a VM
14
+ # @param [Integer] id
15
+ # @return [Excon::Response]
16
+ def reboot_vm(id, use_hard_reboot)
17
+ response = Excon::Response.new
18
+ response.status = 200
19
+ found = self.get_vms.body.map{|server| server['id']}.include?(id)
20
+ if not found
21
+ response.status = 404
22
+ response.body = {
23
+ "error" => "Unable to find object with id of '#{id}'.",
24
+ "code" => "SoftLayer_Exception_ObjectNotFound"
25
+ }
26
+ else
27
+ response.body = true
28
+ end
29
+ response
30
+ end
31
+ end
32
+
33
+ class Real
34
+
35
+ def reboot_vm(id, use_hard_reboot)
36
+ if use_hard_reboot
37
+ request(:virtual_guest, "#{id.to_s}/rebootHard", :http_method => :GET)
38
+ else
39
+ request(:virtual_guest, "#{id.to_s}/rebootSoft", :http_method => :GET)
40
+ end
41
+ end
42
+
43
+ end
44
+ end
45
+ end
46
+ end
@@ -7,6 +7,6 @@
7
7
 
8
8
  module Fog
9
9
  module Softlayer
10
- VERSION = "0.4.0"
10
+ VERSION = "0.4.1"
11
11
  end
12
12
  end
@@ -64,6 +64,29 @@ Shindo.tests("Fog::Compute[:softlayer] | Server model", ["softlayer"]) do
64
64
  returns(true) { @vm.save }
65
65
  end
66
66
 
67
+ tests("#start") do
68
+ returns(true) { @vm.start }
69
+ returns(true) { @bmc.start }
70
+ end
71
+
72
+ tests("#stop") do
73
+ returns(true) { @vm.stop }
74
+ returns(true) { @bmc.stop }
75
+ end
76
+
77
+ tests("#shutdown") do
78
+ returns(true) { @vm.shutdown }
79
+ end
80
+
81
+ tests("#reboot") do
82
+ returns(true) { @vm.reboot }
83
+ returns(true) { @bmc.reboot }
84
+ returns(true) { @vm.reboot(true) }
85
+ returns(true) { @bmc.reboot(true) }
86
+ returns(true) { @vm.reboot(false) }
87
+ returns(true) { @bmc.reboot(false) }
88
+ end
89
+
67
90
  end
68
91
 
69
92
  tests ("failure") do
@@ -99,6 +122,11 @@ Shindo.tests("Fog::Compute[:softlayer] | Server model", ["softlayer"]) do
99
122
  @vm.save
100
123
  end
101
124
 
125
+ # bare metal servers dont allow shutdown
126
+ tests("#shutdown").raises(Fog::Errors::Error) do
127
+ @bmc.shutdown
128
+ end
129
+
102
130
  tests("#destroy").raises(ArgumentError) do
103
131
  @bmc.destroy
104
132
  end
@@ -33,6 +33,30 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
33
33
  end
34
34
  end
35
35
 
36
+ tests("#power_on_bare_metal_server('#{@server_id})'") do
37
+ response = @sl_connection.power_on_bare_metal_server(@server_id)
38
+ data_matches_schema(true) {response.body}
39
+ data_matches_schema(200) {response.status}
40
+ end
41
+
42
+ tests("#power_off_bare_metal_server('#{@server_id})'") do
43
+ response = @sl_connection.power_off_bare_metal_server(@server_id)
44
+ data_matches_schema(true) {response.body}
45
+ data_matches_schema(200) {response.status}
46
+ end
47
+
48
+ tests("#reboot_bare_metal_server('#{@server_id})', true") do
49
+ response = @sl_connection.reboot_bare_metal_server(@server_id, true)
50
+ data_matches_schema(true) {response.body}
51
+ data_matches_schema(200) {response.status}
52
+ end
53
+
54
+ tests("#reboot_bare_metal_server('#{@server_id})', false") do
55
+ response = @sl_connection.reboot_bare_metal_server(@server_id, false)
56
+ data_matches_schema(true) {response.body}
57
+ data_matches_schema(200) {response.status}
58
+ end
59
+
36
60
  tests("#delete_bare_metal_server('#{@server_id})'") do
37
61
  response = @sl_connection.delete_bare_metal_server(@server_id)
38
62
  data_matches_schema(true) {response.body}
@@ -53,6 +77,30 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
53
77
  @sl_connection.create_bare_metal_server([@bmc])
54
78
  end
55
79
 
80
+ tests("#power_on_bare_metal_server('#{bmc}')") do
81
+ response = @sl_connection.power_on_bare_metal_server(bmc)
82
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
83
+ data_matches_schema(404){ response.status }
84
+ end
85
+
86
+ tests("#power_off_bare_metal_server('#{bmc}')") do
87
+ response = @sl_connection.power_off_bare_metal_server(bmc)
88
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
89
+ data_matches_schema(404){ response.status }
90
+ end
91
+
92
+ tests("#reboot_bare_metal_server('#{bmc}', true)") do
93
+ response = @sl_connection.reboot_bare_metal_server(bmc, true)
94
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
95
+ data_matches_schema(404){ response.status }
96
+ end
97
+
98
+ tests("#reboot_bare_metal_server('#{bmc}', false)") do
99
+ response = @sl_connection.reboot_bare_metal_server(bmc, false)
100
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
101
+ data_matches_schema(404){ response.status }
102
+ end
103
+
56
104
  tests("#delete_bare_metal_server('99999999999999')'") do
57
105
  response = @sl_connection.delete_bare_metal_server(99999999999999)
58
106
  data_matches_schema(String) {response.body}
@@ -50,6 +50,36 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
50
50
  #data_matches_schema(Softlayer::Compute::Formats::VirtualGuest::SERVER) { vm }
51
51
  end
52
52
 
53
+ tests("#power_on_vm(#{@vm_id})") do
54
+ response = @sl_connection.power_on_vm(@vm_id)
55
+ data_matches_schema(true) {response.body}
56
+ data_matches_schema(200) {response.status}
57
+ end
58
+
59
+ tests("#power_off_vm(#{@vm_id}, false)") do
60
+ response = @sl_connection.power_off_vm(@vm_id, false)
61
+ data_matches_schema(true) {response.body}
62
+ data_matches_schema(200) {response.status}
63
+ end
64
+
65
+ tests("#power_off_vm(#{@vm_id}, true)") do
66
+ response = @sl_connection.power_off_vm(@vm_id, true)
67
+ data_matches_schema(true) {response.body}
68
+ data_matches_schema(200) {response.status}
69
+ end
70
+
71
+ tests("#reboot_vm(#{@vm_id}, false)") do
72
+ response = @sl_connection.reboot_vm(@vm_id, false)
73
+ data_matches_schema(true) {response.body}
74
+ data_matches_schema(200) {response.status}
75
+ end
76
+
77
+ tests("#reboot_vm(#{@vm_id}, true)") do
78
+ response = @sl_connection.reboot_vm(@vm_id, true)
79
+ data_matches_schema(true) {response.body}
80
+ data_matches_schema(200) {response.status}
81
+ end
82
+
53
83
  tests("#delete_vm('#{@vm_id})'") do
54
84
  response = @sl_connection.delete_vm(@vm_id)
55
85
  data_matches_schema(true) {response.body}
@@ -80,6 +110,36 @@ Shindo.tests("Fog::Compute[:softlayer] | server requests", ["softlayer"]) do
80
110
  @sl_connection.create_vm(@vms)
81
111
  end
82
112
 
113
+ tests("#power_on_vm('99999999999999')") do
114
+ response = @sl_connection.power_on_vm(99999999999999)
115
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
116
+ data_matches_schema(404) {response.status}
117
+ end
118
+
119
+ tests("#power_off_vm('99999999999999', true)") do
120
+ response = @sl_connection.power_off_vm(99999999999999, true)
121
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
122
+ data_matches_schema(404) {response.status}
123
+ end
124
+
125
+ tests("#power_off_vm('99999999999999', false)") do
126
+ response = @sl_connection.power_off_vm(99999999999999, false)
127
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
128
+ data_matches_schema(404) {response.status}
129
+ end
130
+
131
+ tests("#reboot_vm('99999999999999', true)") do
132
+ response = @sl_connection.reboot_vm(99999999999999, true)
133
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
134
+ data_matches_schema(404) {response.status}
135
+ end
136
+
137
+ tests("#reboot_vm('99999999999999', false)") do
138
+ response = @sl_connection.reboot_vm(99999999999999, false)
139
+ data_matches_schema('SoftLayer_Exception_ObjectNotFound'){ response.body['code'] }
140
+ data_matches_schema(404) {response.status}
141
+ end
142
+
83
143
  tests("#delete_vm('99999999999999')'") do
84
144
  response = @sl_connection.delete_vm(99999999999999)
85
145
  data_matches_schema(String) {response.body}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-softlayer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Eldridge
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-28 00:00:00.000000000 Z
11
+ date: 2015-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -201,9 +201,11 @@ files:
201
201
  - examples/README.md
202
202
  - examples/compute.md
203
203
  - examples/dns.md
204
+ - examples/getting_started.md
204
205
  - examples/global_ip_address.md
205
206
  - examples/key_pairs.md
206
207
  - examples/network.md
208
+ - examples/product.md
207
209
  - examples/storage.md
208
210
  - examples/tags.md
209
211
  - fog-softlayer.gemspec
@@ -272,6 +274,12 @@ files:
272
274
  - lib/fog/softlayer/requests/compute/get_vm.rb
273
275
  - lib/fog/softlayer/requests/compute/get_vm_tags.rb
274
276
  - lib/fog/softlayer/requests/compute/get_vms.rb
277
+ - lib/fog/softlayer/requests/compute/power_off_bare_metal_server.rb
278
+ - lib/fog/softlayer/requests/compute/power_off_vm.rb
279
+ - lib/fog/softlayer/requests/compute/power_on_bare_metal_server.rb
280
+ - lib/fog/softlayer/requests/compute/power_on_vm.rb
281
+ - lib/fog/softlayer/requests/compute/reboot_bare_metal_server.rb
282
+ - lib/fog/softlayer/requests/compute/reboot_vm.rb
275
283
  - lib/fog/softlayer/requests/compute/update_key_pair.rb
276
284
  - lib/fog/softlayer/requests/dns/create_domain.rb
277
285
  - lib/fog/softlayer/requests/dns/create_record.rb