fog-sakuracloud 1.3.3 → 1.4.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: bc87e35240b373e929ee71398d01f06ad7823e9c
4
- data.tar.gz: 636eace3ef92c43bf63f8bd5c087333e2416f1e4
3
+ metadata.gz: 0f179bb5fe911c507374a15fd4244bcc3a3a8cb5
4
+ data.tar.gz: ee254916549f9391ef89bf8e87cdd0c40381dba4
5
5
  SHA512:
6
- metadata.gz: f0b3d8c49c7fa7dc74fe291c8272672a8ac655979743cd94388f7603f110c0c03fb2b059d672fc6658938b21775d8e8cdb9a656f31781c990cab6ed5c652982b
7
- data.tar.gz: 37e9719543fa6a7f990c7d4fff6ef330b0ec899d995659a9fbb68ebfd35bcd0c79525b41eb96e2ddcbcb5ea4e7e9b76c68bd4141bc2c585e5b06f6ba4a21aa82
6
+ metadata.gz: 9c4d0e4e4bab316d496b91939dea5f1e54032ef83f3aac68262063633d9fa84f0fad382bb7d5c43a7d476644a5a90ca74df0af65034b0729ae1cadb28943a4ef
7
+ data.tar.gz: 3ce680b80b8855ecf9d192f88978bebcd36e4c545f1f18c910b487f68ab2f8a14eb8bc54ba3a1baab123fa743f2d0b6b085717520e1d57226a7ad175a10a6138
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog of fog-sakuracloud
2
2
 
3
+ ## v1.4.0
4
+
5
+ - Feature: #17 Support Standard Disk Plan for Disk creation HT: @noralife
6
+ - Feature: #18 Add attach feature to Disk Model HT: @noralife
7
+
3
8
  ## v1.3.3
4
9
 
5
10
  - Typo: Fix typo ( auth_encord -> auth_encode ) #16 HT: @mazgi
@@ -44,10 +44,12 @@ module Fog
44
44
  Fog::Logger.warning("Create Volume")
45
45
  sakuracloud_api_token = options[:sakuracloud_api_token] || Fog.credentials[:sakuracloud_api_token]
46
46
  sakuracloud_api_token_secret = options[:sakuracloud_api_token_secret] || Fog.credentials[:sakuracloud_api_token_secret]
47
+ size_mb = options[:volume][:size_mb].to_i || 20480
47
48
  volume = Fog::Volume::SakuraCloud.new(:sakuracloud_api_token => sakuracloud_api_token, :sakuracloud_api_token_secret => sakuracloud_api_token_secret)
48
49
  disk = volume.disks.create :name => Fog::UUID.uuid,
49
50
  :plan => options[:volume][:diskplan].to_i,
50
- :source_archive => options[:volume][:sourcearchive].to_s
51
+ :source_archive => options[:volume][:sourcearchive].to_s,
52
+ :size_mb => size_mb
51
53
  Fog::Logger.warning("Waiting disk until available")
52
54
  disk.wait_for { availability == 'available' }
53
55
  volume.attach_disk(disk.id, server.id)
@@ -20,8 +20,12 @@ module Fog
20
20
  alias_method :destroy, :delete
21
21
 
22
22
  def save
23
- requires :name, :plan, :source_archive
24
- data = service.create_disk(@attributes[:name], @attributes[:plan], @attributes[:source_archive]).body["Disk"]
23
+ requires :name, :plan
24
+ options = {
25
+ :source_archive => source_archive,
26
+ :size_mb => size_mb
27
+ }
28
+ data = service.create_disk(name, plan, options).body["Disk"]
25
29
  merge_attributes(data)
26
30
  true
27
31
  end
@@ -38,6 +42,11 @@ module Fog
38
42
  true
39
43
  end
40
44
 
45
+ def attach(server_id)
46
+ service.attach_disk(id, server_id)
47
+ true
48
+ end
49
+
41
50
  def associate_ip(ipaddress, networkmasklen, defaultroute)
42
51
  subnet ={
43
52
  :ipaddress => ipaddress,
@@ -4,24 +4,22 @@ module Fog
4
4
  module Volume
5
5
  class SakuraCloud
6
6
  class Real
7
- def create_disk( name, plan, sourcearchive )
8
- body = {
9
- "Disk" => {
10
- "Name" => name,
11
- "SourceArchive" => {
12
- "ID" => sourcearchive.to_s
13
- },
14
- "Plan" => {
15
- "ID" => plan.to_i
16
- }
17
- }
18
- }
7
+ def create_disk( name, plan, options = {} )
8
+ body = { "Disk" => { "Name" => name, "Plan" => { "ID" => plan.to_i } } }
9
+
10
+ if !options[:source_archive].nil?
11
+ body["Disk"]["SourceArchive"] = { "ID"=>options[:source_archive].to_s }
12
+ end
13
+
14
+ if !options[:size_mb].nil?
15
+ body["Disk"]["SizeMB"] = options[:size_mb].to_i
16
+ end
19
17
 
20
18
  request(
21
19
  :headers => {
22
20
  'Authorization' => "Basic #{@auth_encode}"
23
21
  },
24
- :expects => [202],
22
+ :expects => [201, 202],
25
23
  :method => 'POST',
26
24
  :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/disk",
27
25
  :body => Fog::JSON.encode(body)
@@ -30,7 +28,7 @@ module Fog
30
28
  end # Real
31
29
 
32
30
  class Mock
33
- def create_disk( name, plan, sourcearchive )
31
+ def create_disk( name, plan, options = {} )
34
32
  response = Excon::Response.new
35
33
  response.status = 202
36
34
  response.body = {
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Sakuracloud
3
- VERSION = "1.3.3"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -33,7 +33,7 @@ end
33
33
  Shindo.tests('Fog::Volume[:sakuracloud] | create_disks request', ['sakuracloud', 'volume']) do
34
34
  tests('success') do
35
35
  tests('#create_disks') do
36
- disks = sakuracloud_volume_service.create_disk('foobar', 4, 112500463685)
36
+ disks = sakuracloud_volume_service.create_disk('foobar', 4, {:sourcearchive => 112500463685})
37
37
  test 'returns a Hash' do
38
38
  disks.body.is_a? Hash
39
39
  end
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.3.3
4
+ version: 1.4.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-09-29 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core