fog-sakuracloud 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +65 -0
- data/.gitmodules +3 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +113 -0
- data/fog-sakuracloud.gemspec +41 -0
- data/gemfiles/Gemfile.1.8.7 +6 -0
- data/lib/fog/sakuracloud.rb +16 -0
- data/lib/fog/sakuracloud/compute.rb +65 -0
- data/lib/fog/sakuracloud/models/compute/plan.rb +15 -0
- data/lib/fog/sakuracloud/models/compute/plans.rb +22 -0
- data/lib/fog/sakuracloud/models/compute/server.rb +40 -0
- data/lib/fog/sakuracloud/models/compute/servers.rb +63 -0
- data/lib/fog/sakuracloud/models/compute/ssh_key.rb +13 -0
- data/lib/fog/sakuracloud/models/compute/ssh_keys.rb +22 -0
- data/lib/fog/sakuracloud/models/compute/zone.rb +13 -0
- data/lib/fog/sakuracloud/models/compute/zones.rb +22 -0
- data/lib/fog/sakuracloud/models/volume/archive.rb +14 -0
- data/lib/fog/sakuracloud/models/volume/archives.rb +22 -0
- data/lib/fog/sakuracloud/models/volume/disk.rb +37 -0
- data/lib/fog/sakuracloud/models/volume/disks.rb +27 -0
- data/lib/fog/sakuracloud/models/volume/plan.rb +12 -0
- data/lib/fog/sakuracloud/models/volume/plans.rb +22 -0
- data/lib/fog/sakuracloud/requests/compute/boot_server.rb +31 -0
- data/lib/fog/sakuracloud/requests/compute/create_server.rb +41 -0
- data/lib/fog/sakuracloud/requests/compute/delete_server.rb +33 -0
- data/lib/fog/sakuracloud/requests/compute/list_plans.rb +46 -0
- data/lib/fog/sakuracloud/requests/compute/list_servers.rb +44 -0
- data/lib/fog/sakuracloud/requests/compute/list_ssh_keys.rb +40 -0
- data/lib/fog/sakuracloud/requests/compute/list_zones.rb +40 -0
- data/lib/fog/sakuracloud/requests/compute/stop_server.rb +37 -0
- data/lib/fog/sakuracloud/requests/volume/attach_disk.rb +30 -0
- data/lib/fog/sakuracloud/requests/volume/configure_disk.rb +35 -0
- data/lib/fog/sakuracloud/requests/volume/create_disk.rb +43 -0
- data/lib/fog/sakuracloud/requests/volume/delete_disk.rb +30 -0
- data/lib/fog/sakuracloud/requests/volume/list_archives.rb +46 -0
- data/lib/fog/sakuracloud/requests/volume/list_disks.rb +50 -0
- data/lib/fog/sakuracloud/requests/volume/list_plans.rb +40 -0
- data/lib/fog/sakuracloud/version.rb +5 -0
- data/lib/fog/sakuracloud/volume.rb +88 -0
- data/tests/helper.rb +8 -0
- data/tests/sakuracloud/helper.rb +7 -0
- data/tests/sakuracloud/requests/compute/plans_tests.rb +32 -0
- data/tests/sakuracloud/requests/compute/servers_tests.rb +46 -0
- data/tests/sakuracloud/requests/compute/ssh_keys_tests.rb +30 -0
- data/tests/sakuracloud/requests/compute/zones_tests.rb +30 -0
- data/tests/sakuracloud/requests/volume/archives_tests.rb +31 -0
- data/tests/sakuracloud/requests/volume/disks_tests.rb +47 -0
- data/tests/sakuracloud/requests/volume/plans_tests.rb +30 -0
- metadata +326 -0
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def list_servers(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/server"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_servers(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"Servers" =>
|
24
|
+
[
|
25
|
+
{"Index" => 0,
|
26
|
+
"ID"=>112600055376,
|
27
|
+
"Name"=>"foober1",
|
28
|
+
"ServerPlan"=> {},
|
29
|
+
"Instance"=> {},
|
30
|
+
"Disks"=> []},
|
31
|
+
{"Index" => 1,
|
32
|
+
"ID"=>112600055377,
|
33
|
+
"Name"=>"foober2",
|
34
|
+
"ServerPlan"=> {},
|
35
|
+
"Instance"=> {},
|
36
|
+
"Disks"=> []}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
response
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def list_ssh_keys(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/sshkey"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_ssh_keys(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"SSHKeys"=>
|
24
|
+
[
|
25
|
+
{"Index"=>0,
|
26
|
+
"ID"=>"888888888888",
|
27
|
+
"Name"=>"foobar1",
|
28
|
+
"PublicKey"=>"ssh-rsa dummy"},
|
29
|
+
{"Index"=>1,
|
30
|
+
"ID"=>"999999999999",
|
31
|
+
"Name"=>"foobar2",
|
32
|
+
"PublicKey"=>"ssh-rsa dummy"}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def list_zones(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/zone"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_zones(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"Zones" =>
|
24
|
+
[
|
25
|
+
{"Index"=>0,
|
26
|
+
"ID"=>31001,
|
27
|
+
"Name"=>"is1a",
|
28
|
+
"Description"=>"石狩第1ゾーン"},
|
29
|
+
{"Index"=>1,
|
30
|
+
"ID"=>31002,
|
31
|
+
"Name"=>"is1b",
|
32
|
+
"Description"=>"石狩第2ゾーン"}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def stop_server( id, force = false )
|
8
|
+
if force
|
9
|
+
body = { "Force" => true }
|
10
|
+
else
|
11
|
+
body = {}
|
12
|
+
end
|
13
|
+
request(
|
14
|
+
:headers => {
|
15
|
+
'Authorization' => "Basic #{@auth_encord}"
|
16
|
+
},
|
17
|
+
:expects => [200,202],
|
18
|
+
:method => 'DELETE',
|
19
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/server/#{id}/power",
|
20
|
+
:body => Fog::JSON.encode(body)
|
21
|
+
)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
end # Real
|
25
|
+
|
26
|
+
class Mock
|
27
|
+
def stop_server( id, force = false )
|
28
|
+
response = Excon::Response.new
|
29
|
+
response.status = 202
|
30
|
+
response.body = {
|
31
|
+
}
|
32
|
+
response
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end # SakuraCloud
|
36
|
+
end # Volume
|
37
|
+
end # Fog
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def attach_disk( disk_id, server_id )
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:expects => [200],
|
13
|
+
:method => 'PUT',
|
14
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/disk/#{disk_id.to_s}/to/server/#{server_id.to_s}"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end # Real
|
18
|
+
|
19
|
+
class Mock
|
20
|
+
def attach_disk( disk_id, server_id )
|
21
|
+
response = Excon::Response.new
|
22
|
+
response.status = 200
|
23
|
+
response.body = {
|
24
|
+
}
|
25
|
+
response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end # SakuraCloud
|
29
|
+
end # Volume
|
30
|
+
end # Fog
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def configure_disk( disk_id, sshkey_id )
|
8
|
+
body = {
|
9
|
+
"SSHKey" => {"ID" => sshkey_id.to_s }
|
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 configure_disk( disk_id, sshkey_id )
|
26
|
+
response = Excon::Response.new
|
27
|
+
response.status = 200
|
28
|
+
response.body = {
|
29
|
+
}
|
30
|
+
response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end # SakuraCloud
|
34
|
+
end # Volume
|
35
|
+
end # Fog
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
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
|
+
}
|
19
|
+
|
20
|
+
request(
|
21
|
+
:headers => {
|
22
|
+
'Authorization' => "Basic #{@auth_encord}"
|
23
|
+
},
|
24
|
+
:expects => [202],
|
25
|
+
:method => 'POST',
|
26
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/disk",
|
27
|
+
:body => Fog::JSON.encode(body)
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end # Real
|
31
|
+
|
32
|
+
class Mock
|
33
|
+
def create_disk( name, plan, sourcearchive )
|
34
|
+
response = Excon::Response.new
|
35
|
+
response.status = 202
|
36
|
+
response.body = {
|
37
|
+
}
|
38
|
+
response
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end # SakuraCloud
|
42
|
+
end # Volume
|
43
|
+
end # Fog
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def delete_disk( id )
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:expects => [200],
|
13
|
+
:method => 'DELETE',
|
14
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/disk/#{id}"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end # Real
|
18
|
+
|
19
|
+
class Mock
|
20
|
+
def delete_disk( id )
|
21
|
+
response = Excon::Response.new
|
22
|
+
response.status = 200
|
23
|
+
response.body = {
|
24
|
+
}
|
25
|
+
response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end # SakuraCloud
|
29
|
+
end # Volume
|
30
|
+
end # Fog
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def list_archives(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/archive"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_archives(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"Archives" =>
|
24
|
+
[
|
25
|
+
{"Index"=>0,
|
26
|
+
"ID"=>112500514887,
|
27
|
+
"Name"=>"CentOS 5.10 64bit (基本セット)",
|
28
|
+
"Availability"=>"available",
|
29
|
+
"SizeMB"=>20480,
|
30
|
+
"Plan"=>{"ID"=>2, "StorageClass"=>"iscsi1204", "Name"=>"標準プラン"}
|
31
|
+
},
|
32
|
+
{"Index"=>1,
|
33
|
+
"ID"=>112500571575,
|
34
|
+
"Name"=>"CentOS 6.5 64bit (基本セット)",
|
35
|
+
"Availability"=>"available",
|
36
|
+
"SizeMB"=>102400,
|
37
|
+
"Plan"=>{"ID"=>2, "StorageClass"=>"iscsi1204", "Name"=>"標準プラン"}
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
response
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def list_disks(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/disk"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_disks(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"Disks" =>
|
24
|
+
[
|
25
|
+
{"Index" => 0,
|
26
|
+
"ID" =>112600053890,
|
27
|
+
"Name" =>"foober1",
|
28
|
+
"Connection" => "virtio",
|
29
|
+
"Availability"=>"available",
|
30
|
+
"SizeMB"=>20480,
|
31
|
+
"Plan"=> {},
|
32
|
+
"SourceDisk" => nil,
|
33
|
+
"SourceArchive" => {}},
|
34
|
+
{"Index" => 1,
|
35
|
+
"ID" =>112600053891,
|
36
|
+
"Name" =>"foober2",
|
37
|
+
"Connection" => "virtio",
|
38
|
+
"Availability"=>"available",
|
39
|
+
"SizeMB"=>20480,
|
40
|
+
"Plan"=> {},
|
41
|
+
"SourceDisk" => nil,
|
42
|
+
"SourceArchive" => {}}
|
43
|
+
]
|
44
|
+
}
|
45
|
+
response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Volume
|
5
|
+
class SakuraCloud
|
6
|
+
class Real
|
7
|
+
def list_plans(options = {})
|
8
|
+
request(
|
9
|
+
:headers => {
|
10
|
+
'Authorization' => "Basic #{@auth_encord}"
|
11
|
+
},
|
12
|
+
:method => 'GET',
|
13
|
+
:path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/product/disk"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def list_plans(options = {})
|
20
|
+
response = Excon::Response.new
|
21
|
+
response.status = 200
|
22
|
+
response.body = {
|
23
|
+
"DiskPlans" =>
|
24
|
+
[
|
25
|
+
{"Index"=>0,
|
26
|
+
"ID"=>4,
|
27
|
+
"Name"=>"SSDプラン",
|
28
|
+
"Availability"=>"available"},
|
29
|
+
{"Index"=>1,
|
30
|
+
"ID"=>2,
|
31
|
+
"Name"=>"標準プラン",
|
32
|
+
"Availability"=>"available"}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
response
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|