fog-sakuracloud 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/lib/fog/sakuracloud.rb +6 -1
- data/lib/fog/sakuracloud/models/compute/servers.rb +1 -0
- data/lib/fog/sakuracloud/models/script/note.rb +39 -0
- data/lib/fog/sakuracloud/models/script/notes.rb +27 -0
- data/lib/fog/sakuracloud/models/volume/disk.rb +8 -0
- data/lib/fog/sakuracloud/requests/script/create_note.rb +52 -0
- data/lib/fog/sakuracloud/requests/script/delete_note.rb +45 -0
- data/lib/fog/sakuracloud/requests/script/list_notes.rb +39 -0
- data/lib/fog/sakuracloud/requests/script/modify_note.rb +53 -0
- data/lib/fog/sakuracloud/requests/volume/configure_disk.rb +1 -2
- data/lib/fog/sakuracloud/requests/volume/register_note_to_disk.rb +35 -0
- data/lib/fog/sakuracloud/script.rb +76 -0
- data/lib/fog/sakuracloud/version.rb +1 -1
- data/lib/fog/sakuracloud/volume.rb +1 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a76f70a4a79d0560762658616131d59e11a8dd2
|
4
|
+
data.tar.gz: f85a8f58dc6ef37c10ea7115be964b677f64a44e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8a5575a01d508477e6a460aa85af7bee10175b0feba5f8a37605ccea86ef1bc09cf1e3fcd2433351b8204ab3097f81f0487791770c8f0a383823868b1bfb59a
|
7
|
+
data.tar.gz: 96a97d8528df9158fb97811b7515d6617efa5bb11eaa3382d9976772821a059eea41712ea7249cce512ee402c367c9d992e38e3e43381afefd6b0d16e84c7e27
|
data/CHANGELOG.md
CHANGED
data/lib/fog/sakuracloud.rb
CHANGED
@@ -21,8 +21,13 @@ module Fog
|
|
21
21
|
SAKURACLOUD_API_ZONE = "is1b" unless defined? SAKURACLOUD_API_ZONE
|
22
22
|
SAKURACLOUD_API_ENDPOINT = "/cloud/zone/#{SAKURACLOUD_API_ZONE}/api/cloud/#{SAKURACLOUD_API_VERSION}/"
|
23
23
|
|
24
|
+
# Miscs
|
25
|
+
## Startup Script
|
26
|
+
autoload :Script, File.expand_path('../sakuracloud/script', __FILE__)
|
27
|
+
|
24
28
|
service(:compute, 'Compute')
|
25
|
-
service(:volume,
|
29
|
+
service(:volume, 'Volume')
|
26
30
|
service(:network, 'Network')
|
31
|
+
service(:script, 'Script')
|
27
32
|
end
|
28
33
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module SakuraCloud
|
5
|
+
class Script
|
6
|
+
class Note < Fog::Model
|
7
|
+
identity :id, :aliases => 'ID'
|
8
|
+
attribute :name, :aliases => 'Name'
|
9
|
+
attribute :note_class, :aliases => 'Class'
|
10
|
+
attribute :scope, :aliases => 'Scope'
|
11
|
+
attribute :content, :aliases => 'Content'
|
12
|
+
attribute :description, :aliases => 'Description'
|
13
|
+
attribute :remark, :aliases => 'Remark'
|
14
|
+
attribute :availability, :aliases => 'Availability'
|
15
|
+
attribute :icon, :aliases => 'Icon'
|
16
|
+
|
17
|
+
|
18
|
+
def delete
|
19
|
+
service.delete_note(identity)
|
20
|
+
true
|
21
|
+
end
|
22
|
+
alias_method :destroy, :delete
|
23
|
+
|
24
|
+
def save
|
25
|
+
requires :name, :content
|
26
|
+
if identity
|
27
|
+
Fog::Logger.warning("Update Note #{identity}")
|
28
|
+
data = service.modify_note(@attributes).body["Note"]
|
29
|
+
else
|
30
|
+
Fog::Logger.warning("Create New Note")
|
31
|
+
data = service.create_note(@attributes).body["Note"]
|
32
|
+
end
|
33
|
+
merge_attributes(data)
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
require 'fog/sakuracloud/models/script/note'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module SakuraCloud
|
6
|
+
class Script
|
7
|
+
class Notes < Fog::Collection
|
8
|
+
model Fog::SakuraCloud::Script::Note
|
9
|
+
|
10
|
+
def all
|
11
|
+
load service.list_notes.body['Notes']
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(id)
|
15
|
+
all.find { |f| f.id == id }
|
16
|
+
rescue Fog::Errors::NotFound
|
17
|
+
nil
|
18
|
+
end
|
19
|
+
|
20
|
+
def delete(id)
|
21
|
+
service.delete_note(id)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -42,6 +42,14 @@ module Fog
|
|
42
42
|
service.associate_ip_to_disk(@attributes[:id], subnet )
|
43
43
|
true
|
44
44
|
end
|
45
|
+
|
46
|
+
def register_script(notes)
|
47
|
+
note_ids = []
|
48
|
+
note_ids << notes
|
49
|
+
requires :id
|
50
|
+
service.register_note_to_disk(@attributes[:id], note_ids.flatten )
|
51
|
+
true
|
52
|
+
end
|
45
53
|
end
|
46
54
|
end
|
47
55
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module SakuraCloud
|
5
|
+
class Script
|
6
|
+
class Real
|
7
|
+
def create_note(options)
|
8
|
+
body = {
|
9
|
+
"Note" => {
|
10
|
+
"Name" => options[:name],
|
11
|
+
"Content" => options[:content]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
request(
|
16
|
+
:headers => {
|
17
|
+
'Authorization' => "Basic #{@auth_encord}"
|
18
|
+
},
|
19
|
+
:expects => 201,
|
20
|
+
:method => 'POST',
|
21
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note",
|
22
|
+
:body => Fog::JSON.encode(body)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end # Real
|
26
|
+
|
27
|
+
class Mock
|
28
|
+
def create_note(options)
|
29
|
+
response = Excon::Response.new
|
30
|
+
response.status = 201
|
31
|
+
response.body = {
|
32
|
+
"Note"=>
|
33
|
+
{"ID"=>"112700759852",
|
34
|
+
"Name"=>"foobar",
|
35
|
+
"Class"=>"shell",
|
36
|
+
"Scope"=>"user",
|
37
|
+
"Content"=>"#!/bin/bash",
|
38
|
+
"Description"=>"",
|
39
|
+
"Remark"=>nil,
|
40
|
+
"Availability"=>"available",
|
41
|
+
"CreatedAt"=>"2015-09-05T20:32:12+09:00",
|
42
|
+
"ModifiedAt"=>"2015-09-05T20:32:12+09:00",
|
43
|
+
"Icon"=>nil,
|
44
|
+
"Tags"=>[]},
|
45
|
+
"Success"=>true,
|
46
|
+
"is_ok"=>true}
|
47
|
+
response
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module SakuraCloud
|
5
|
+
class Script
|
6
|
+
class Real
|
7
|
+
def delete_note( id )
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:expects => [200],
|
13
|
+
:method => 'DELETE',
|
14
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note/#{id}"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end # Real
|
18
|
+
|
19
|
+
class Mock
|
20
|
+
def delete_note( id )
|
21
|
+
response = Excon::Response.new
|
22
|
+
response.status = 200
|
23
|
+
response.body = {
|
24
|
+
"Note"=>
|
25
|
+
{"ID"=>"112700759822",
|
26
|
+
"Name"=>"hogehoge2",
|
27
|
+
"Class"=>"shell",
|
28
|
+
"Scope"=>"user",
|
29
|
+
"Content"=>"",
|
30
|
+
"Description"=>"",
|
31
|
+
"Remark"=>nil,
|
32
|
+
"Availability"=>"available",
|
33
|
+
"CreatedAt"=>"2015-09-05T20:04:24+09:00",
|
34
|
+
"ModifiedAt"=>"2015-09-05T20:04:24+09:00",
|
35
|
+
"Icon"=>nil,
|
36
|
+
"Tags"=>[]},
|
37
|
+
"Success"=>true,
|
38
|
+
"is_ok"=>true
|
39
|
+
}
|
40
|
+
response
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module SakuraCloud
|
5
|
+
class Script
|
6
|
+
class Real
|
7
|
+
def list_notes(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_notes(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"Internet"=>[
|
24
|
+
{"Index"=>0,
|
25
|
+
"ID"=>"112600707538",
|
26
|
+
"Switch"=>{
|
27
|
+
"ID"=>"112600707539",
|
28
|
+
"Name"=>"router2"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
],
|
32
|
+
"is_ok"=>true
|
33
|
+
}
|
34
|
+
response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module SakuraCloud
|
5
|
+
class Script
|
6
|
+
class Real
|
7
|
+
def modify_note( options )
|
8
|
+
body = {
|
9
|
+
"Note" => {
|
10
|
+
"Name" => options[:name],
|
11
|
+
"Content" => options[:content]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
request(
|
16
|
+
:headers => {
|
17
|
+
'Authorization' => "Basic #{@auth_encord}"
|
18
|
+
},
|
19
|
+
:expects => [200],
|
20
|
+
:method => 'PUT',
|
21
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/note/#{options[:id]}",
|
22
|
+
:body => Fog::JSON.encode(body)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end # Real
|
26
|
+
|
27
|
+
class Mock
|
28
|
+
def modify_note( options )
|
29
|
+
response = Excon::Response.new
|
30
|
+
response.status = 200
|
31
|
+
response.body = {
|
32
|
+
"Note"=>
|
33
|
+
{"ID"=>"112700759822",
|
34
|
+
"Name"=>"hogehoge2",
|
35
|
+
"Class"=>"shell",
|
36
|
+
"Scope"=>"user",
|
37
|
+
"Content"=>"",
|
38
|
+
"Description"=>"",
|
39
|
+
"Remark"=>nil,
|
40
|
+
"Availability"=>"available",
|
41
|
+
"CreatedAt"=>"2015-09-05T20:04:24+09:00",
|
42
|
+
"ModifiedAt"=>"2015-09-05T20:04:24+09:00",
|
43
|
+
"Icon"=>nil,
|
44
|
+
"Tags"=>[]},
|
45
|
+
"Success"=>true,
|
46
|
+
"is_ok"=>true
|
47
|
+
}
|
48
|
+
response
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def register_note_to_disk( disk_id, notes )
|
8
|
+
body = {
|
9
|
+
"Notes" => notes.map {|note| { "ID" => note }}
|
10
|
+
}
|
11
|
+
|
12
|
+
request(
|
13
|
+
:headers => {
|
14
|
+
'Authorization' => "Basic #{@auth_encord}"
|
15
|
+
},
|
16
|
+
:expects => [200],
|
17
|
+
:method => 'PUT',
|
18
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/disk/#{disk_id.to_s}/config",
|
19
|
+
:body => Fog::JSON.encode(body)
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end # Real
|
23
|
+
|
24
|
+
class Mock
|
25
|
+
def register_note_to_disk( disk_id, notes )
|
26
|
+
response = Excon::Response.new
|
27
|
+
response.status = 200
|
28
|
+
response.body = {
|
29
|
+
}
|
30
|
+
response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Fog
|
2
|
+
module SakuraCloud
|
3
|
+
class Script < Fog::Service
|
4
|
+
requires :sakuracloud_api_token
|
5
|
+
requires :sakuracloud_api_token_secret
|
6
|
+
|
7
|
+
recognizes :sakuracloud_api_url
|
8
|
+
|
9
|
+
model_path 'fog/sakuracloud/models/script'
|
10
|
+
model :note
|
11
|
+
collection :notes
|
12
|
+
|
13
|
+
request_path 'fog/sakuracloud/requests/script'
|
14
|
+
request :list_notes
|
15
|
+
request :create_note
|
16
|
+
request :modify_note
|
17
|
+
request :delete_note
|
18
|
+
|
19
|
+
class Real
|
20
|
+
def initialize(options = {})
|
21
|
+
@auth_encord = Base64.strict_encode64([
|
22
|
+
options[:sakuracloud_api_token],
|
23
|
+
options[:sakuracloud_api_token_secret]
|
24
|
+
].join(':'))
|
25
|
+
Fog.credentials[:sakuracloud_api_token] = options[:sakuracloud_api_token]
|
26
|
+
Fog.credentials[:sakuracloud_api_token_secret] = options[:sakuracloud_api_token_secret]
|
27
|
+
|
28
|
+
@sakuracloud_api_url = options[:sakuracloud_api_url] || 'https://secure.sakura.ad.jp'
|
29
|
+
|
30
|
+
@connection = Fog::Core::Connection.new(@sakuracloud_api_url)
|
31
|
+
end
|
32
|
+
|
33
|
+
def request(params)
|
34
|
+
response = parse @connection.request(params)
|
35
|
+
response
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
def parse(response)
|
40
|
+
return response if response.body.empty?
|
41
|
+
response.body = Fog::JSON.decode(response.body)
|
42
|
+
response
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Mock
|
47
|
+
def self.data
|
48
|
+
@data ||= Hash.new do |hash, key|
|
49
|
+
hash[key] = {
|
50
|
+
:notes => []
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.reset
|
56
|
+
@data = nil
|
57
|
+
end
|
58
|
+
|
59
|
+
def initialize(options={})
|
60
|
+
@sakuracloud_api_token = options[:sakuracloud_api_token]
|
61
|
+
@sakuracloud_api_token_secret = options[:sakuracloud_api_token_secret]
|
62
|
+
end
|
63
|
+
|
64
|
+
def data
|
65
|
+
self.class.data[@sakuracloud_api_token]
|
66
|
+
self.class.data[@sakuracloud_api_token_secret]
|
67
|
+
end
|
68
|
+
|
69
|
+
def reset_data
|
70
|
+
self.class.data.delete(@sakuracloud_api_token)
|
71
|
+
self.class.data.delete(@sakuracloud_api_token_secret)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
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.0
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2015-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -225,6 +225,8 @@ files:
|
|
225
225
|
- lib/fog/sakuracloud/models/network/routers.rb
|
226
226
|
- lib/fog/sakuracloud/models/network/switch.rb
|
227
227
|
- lib/fog/sakuracloud/models/network/switches.rb
|
228
|
+
- lib/fog/sakuracloud/models/script/note.rb
|
229
|
+
- lib/fog/sakuracloud/models/script/notes.rb
|
228
230
|
- lib/fog/sakuracloud/models/volume/archive.rb
|
229
231
|
- lib/fog/sakuracloud/models/volume/archives.rb
|
230
232
|
- lib/fog/sakuracloud/models/volume/disk.rb
|
@@ -246,6 +248,10 @@ files:
|
|
246
248
|
- lib/fog/sakuracloud/requests/network/delete_switch.rb
|
247
249
|
- lib/fog/sakuracloud/requests/network/list_routers.rb
|
248
250
|
- lib/fog/sakuracloud/requests/network/list_switches.rb
|
251
|
+
- lib/fog/sakuracloud/requests/script/create_note.rb
|
252
|
+
- lib/fog/sakuracloud/requests/script/delete_note.rb
|
253
|
+
- lib/fog/sakuracloud/requests/script/list_notes.rb
|
254
|
+
- lib/fog/sakuracloud/requests/script/modify_note.rb
|
249
255
|
- lib/fog/sakuracloud/requests/volume/associate_ip_to_disk.rb
|
250
256
|
- lib/fog/sakuracloud/requests/volume/attach_disk.rb
|
251
257
|
- lib/fog/sakuracloud/requests/volume/configure_disk.rb
|
@@ -254,6 +260,8 @@ files:
|
|
254
260
|
- lib/fog/sakuracloud/requests/volume/list_archives.rb
|
255
261
|
- lib/fog/sakuracloud/requests/volume/list_disks.rb
|
256
262
|
- lib/fog/sakuracloud/requests/volume/list_plans.rb
|
263
|
+
- lib/fog/sakuracloud/requests/volume/register_note_to_disk.rb
|
264
|
+
- lib/fog/sakuracloud/script.rb
|
257
265
|
- lib/fog/sakuracloud/version.rb
|
258
266
|
- lib/fog/sakuracloud/volume.rb
|
259
267
|
- tests/helper.rb
|
@@ -286,7 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
286
294
|
version: '0'
|
287
295
|
requirements: []
|
288
296
|
rubyforge_project:
|
289
|
-
rubygems_version: 2.4.
|
297
|
+
rubygems_version: 2.4.8
|
290
298
|
signing_key:
|
291
299
|
specification_version: 4
|
292
300
|
summary: Module for the 'fog' gem to support Sakura no Cloud
|