fog-sakuracloud 1.5.2 → 1.6.0

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: e9ea2f60debe6c88f5f1140e7f6a6d99c84506a5
4
- data.tar.gz: a4c7e4cb451357320213c768e1b3f01c45f2dde3
3
+ metadata.gz: 897104786361cfe690b7b1f2578965818d31ad6f
4
+ data.tar.gz: 0541082923de0d63f41810c91082a669e0cf50ac
5
5
  SHA512:
6
- metadata.gz: 1b1b21879d3a6a64c6775413d3aaf64c3ab4a825c0054a17f8bcae1fcace9fceed9e27338f8fcf27ea8524c9efc8f2e31b6f91bec3c0697bdcb9b794da99887a
7
- data.tar.gz: 48030cda02ea34fed30b46e4c67081b41fbd008ea6368fc629973349e9150465646582160b3dc3fe49b704e521ec894d30442a4a33297e681a1d2ce4857f8759
6
+ metadata.gz: 464144e6b2575d09c15de82220f4044780d1c19fac34e546ae297bac95efa0796d5174b0fe9334c1ca14e546701a110f70fd8f837648b173baf5767f15e9ef86
7
+ data.tar.gz: ff5d5db70886fa695d67aa8fa03da6ed2b28ce1fb031e47c3c27fd82ac3993e595e776a2ca95a4a81434c756f36ea8ef6e7345b51a1cb7ffaac12fdc4d4994c0
data/.travis.yml CHANGED
@@ -8,3 +8,5 @@ rvm:
8
8
  - 2.0.0
9
9
  gemfile:
10
10
  - Gemfile
11
+ before_install:
12
+ - gem update bundler
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog of fog-sakuracloud
2
2
 
3
+ ## v1.6.0
4
+
5
+ - Miscs: Wrap request for error messages to be readable. #22
6
+ - Cleanup: replace @attribute[:id] to id #21
7
+
3
8
  ## v1.5.2
4
9
 
5
10
  - Feature: Add filter params Start and End to collect_monitor_router.
@@ -1,5 +1,6 @@
1
1
  require 'fog/core'
2
2
  require 'fog/json'
3
+ require 'fog/sakuracloud/utils/request'
3
4
 
4
5
  module Fog
5
6
  module Compute
@@ -27,6 +27,8 @@ module Fog
27
27
  request :list_zones
28
28
 
29
29
  class Real
30
+ include Fog::SakuraCloud::Utils::Request
31
+
30
32
  def initialize(options = {})
31
33
  @auth_encode = Base64.strict_encode64([
32
34
  options[:sakuracloud_api_token],
@@ -41,18 +43,6 @@ module Fog
41
43
 
42
44
  @connection = Fog::Core::Connection.new(@sakuracloud_api_url)
43
45
  end
44
-
45
- def request(params)
46
- response = parse @connection.request(params)
47
- response
48
- end
49
-
50
- private
51
- def parse(response)
52
- return response if response.body.empty?
53
- response.body = Fog::JSON.decode(response.body)
54
- response
55
- end
56
46
  end
57
47
 
58
48
  class Mock
@@ -17,6 +17,8 @@ module Fog
17
17
  request :modify_zone
18
18
 
19
19
  class Real
20
+ include Fog::SakuraCloud::Utils::Request
21
+
20
22
  def initialize(options = {})
21
23
  @auth_encode = Base64.strict_encode64([
22
24
  options[:sakuracloud_api_token],
@@ -31,18 +33,6 @@ module Fog
31
33
 
32
34
  @connection = Fog::Core::Connection.new(@sakuracloud_api_url)
33
35
  end
34
-
35
- def request(params)
36
- response = parse @connection.request(params)
37
- response
38
- end
39
-
40
- private
41
- def parse(response)
42
- return response if response.body.empty?
43
- response.body = Fog::JSON.decode(response.body)
44
- response
45
- end
46
36
  end
47
37
 
48
38
  class Mock
@@ -20,17 +20,17 @@ module Fog
20
20
 
21
21
  def boot
22
22
  requires :id
23
- service.boot_server(@attributes[:id])
23
+ service.boot_server(id)
24
24
  end
25
25
 
26
26
  def stop(force = false)
27
27
  requires :id
28
- service.stop_server(@attributes[:id], force)
28
+ service.stop_server(id, force)
29
29
  end
30
30
 
31
31
  def delete(force = false, disks = [])
32
32
  requires :id
33
- service.delete_server(@attributes[:id], force, disks)
33
+ service.delete_server(id, force, disks)
34
34
  true
35
35
  end
36
36
  alias_method :destroy, :delete
@@ -32,13 +32,13 @@ module Fog
32
32
 
33
33
  def configure(sshkey_id)
34
34
  requires :id
35
- service.configure_disk(@attributes[:id], sshkey_id )
35
+ service.configure_disk(id, sshkey_id )
36
36
  true
37
37
  end
38
38
 
39
39
  def carve_hostname_on_disk(hostname)
40
40
  requires :id
41
- service.carve_hostname_on_disk(@attributes[:id], hostname )
41
+ service.carve_hostname_on_disk(id, hostname )
42
42
  true
43
43
  end
44
44
 
@@ -54,7 +54,7 @@ module Fog
54
54
  :defaultroute => defaultroute
55
55
  }
56
56
  requires :id
57
- service.associate_ip_to_disk(@attributes[:id], subnet )
57
+ service.associate_ip_to_disk(id, subnet )
58
58
  true
59
59
  end
60
60
 
@@ -62,7 +62,7 @@ module Fog
62
62
  note_ids = []
63
63
  note_ids << notes
64
64
  requires :id
65
- service.register_note_to_disk(@attributes[:id], note_ids.flatten )
65
+ service.register_note_to_disk(id, note_ids.flatten )
66
66
  true
67
67
  end
68
68
  end
@@ -28,6 +28,8 @@ module Fog
28
28
  request :delete_interface
29
29
 
30
30
  class Real
31
+ include Fog::SakuraCloud::Utils::Request
32
+
31
33
  def initialize(options = {})
32
34
  @auth_encode = Base64.strict_encode64([
33
35
  options[:sakuracloud_api_token],
@@ -42,18 +44,6 @@ module Fog
42
44
 
43
45
  @connection = Fog::Core::Connection.new(@sakuracloud_api_url)
44
46
  end
45
-
46
- def request(params)
47
- response = parse @connection.request(params)
48
- response
49
- end
50
-
51
- private
52
- def parse(response)
53
- return response if response.body.empty?
54
- response.body = Fog::JSON.decode(response.body)
55
- response
56
- end
57
47
  end
58
48
 
59
49
  class Mock
@@ -17,6 +17,8 @@ module Fog
17
17
  request :delete_note
18
18
 
19
19
  class Real
20
+ include Fog::SakuraCloud::Utils::Request
21
+
20
22
  def initialize(options = {})
21
23
  @auth_encode = Base64.strict_encode64([
22
24
  options[:sakuracloud_api_token],
@@ -31,18 +33,6 @@ module Fog
31
33
 
32
34
  @connection = Fog::Core::Connection.new(@sakuracloud_api_url)
33
35
  end
34
-
35
- def request(params)
36
- response = parse @connection.request(params)
37
- response
38
- end
39
-
40
- private
41
- def parse(response)
42
- return response if response.body.empty?
43
- response.body = Fog::JSON.decode(response.body)
44
- response
45
- end
46
36
  end
47
37
 
48
38
  class Mock
@@ -0,0 +1,25 @@
1
+ module Fog
2
+ module SakuraCloud
3
+ module Utils
4
+ module Request
5
+ def request(params)
6
+ response = parse @connection.request(params)
7
+
8
+ response
9
+ ## SakuraCloud API returns Japanese message.
10
+ # This wrapper decodes and show message to be human readble.
11
+ rescue Excon::Errors::HTTPStatusError => e
12
+ Fog::Logger.warning ::JSON.parse(e.response.body)['error_msg']
13
+ raise e
14
+ end
15
+
16
+ private
17
+ def parse(response)
18
+ return response if response.body.empty?
19
+ response.body = Fog::JSON.decode(response.body)
20
+ response
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Sakuracloud
3
- VERSION = "1.5.2"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
@@ -27,6 +27,8 @@ module Fog
27
27
  request :carve_hostname_on_disk
28
28
 
29
29
  class Real
30
+ include Fog::SakuraCloud::Utils::Request
31
+
30
32
  def initialize(options = {})
31
33
  @auth_encode = Base64.strict_encode64([
32
34
  options[:sakuracloud_api_token],
@@ -41,18 +43,6 @@ module Fog
41
43
 
42
44
  @connection = Fog::Core::Connection.new(@sakuracloud_api_url)
43
45
  end
44
-
45
- def request(params)
46
- response = parse @connection.request(params)
47
- response
48
- end
49
-
50
- private
51
- def parse(response)
52
- return response if response.body.empty?
53
- response.body = Fog::JSON.decode(response.body)
54
- response
55
- end
56
46
  end
57
47
 
58
48
  class Mock
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-sakuracloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawanoboly
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-18 00:00:00.000000000 Z
11
+ date: 2015-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -277,6 +277,7 @@ files:
277
277
  - lib/fog/sakuracloud/requests/volume/list_plans.rb
278
278
  - lib/fog/sakuracloud/requests/volume/register_note_to_disk.rb
279
279
  - lib/fog/sakuracloud/script.rb
280
+ - lib/fog/sakuracloud/utils/request.rb
280
281
  - lib/fog/sakuracloud/version.rb
281
282
  - lib/fog/sakuracloud/volume.rb
282
283
  - tests/helper.rb