fog-sakuracloud 1.1.1 → 1.2.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: 4e8ecce349b459ae043fccf7ea8dc8b2c8fa3506
4
- data.tar.gz: d9e7e949951398b3d728890f4d9e2314455cf0d0
3
+ metadata.gz: 2c091507bd4319e29aaec68ccec48639442edba9
4
+ data.tar.gz: ef1f332eeed7a16ceb330d8eb9510b87d5ece2bb
5
5
  SHA512:
6
- metadata.gz: 155277ba5e70df4e104729a176faa23551db0e30738d91b1a78f901cf1ce7e9f9a01ec411258f9f647bfbdb44693bd95b49a9ef2e26b0be97796f133c50eab75
7
- data.tar.gz: 404a55f1caa65bad24c81a9d048afc8003e287d3779626e231d2fb7016139a575f658fd5fe6e11c414534f037afba8a28d9809b8304548376552ac7a1d86f5d5
6
+ metadata.gz: 8edf9a260ef6f5990ade711a07478f3761e6cde29e9cde6a0353777f87627e9e74b994a2960c5de981ff40aaf7d22a9b7538cd30da030f15003dc2d3603ddf35
7
+ data.tar.gz: 10dcd3507057780c9959c70e5b4b250f510e3cbad3ce1f684bb7b4c17ae50fb0a1231ab3d3ec59c16c023e88679f2e8a398aaf0757369ce29e66a081dfc4f420
@@ -1,5 +1,9 @@
1
1
  # Changelog of fog-sakuracloud
2
2
 
3
+ ## v1.2.0
4
+
5
+ - Feature: Manage Interface.
6
+
3
7
  ## v1.1.1
4
8
 
5
9
  - Bugfix: Delete Server
@@ -25,6 +25,7 @@ module Fog
25
25
  request :list_plans
26
26
  request :list_ssh_keys
27
27
  request :list_zones
28
+ request :regist_interface_to_server
28
29
 
29
30
  class Real
30
31
  def initialize(options = {})
@@ -17,6 +17,12 @@ module Fog
17
17
  nil
18
18
  end
19
19
 
20
+ def regist_interface_to_server(id)
21
+ sv = get(id)
22
+ sv.regist_interface
23
+ sv
24
+ end
25
+
20
26
  def create(options = {})
21
27
  user = options[:user] || 'root'
22
28
  Fog::Logger.warning("Create Server")
@@ -0,0 +1,27 @@
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module Network
5
+ class SakuraCloud
6
+ class Interface < Fog::Model
7
+ identity :id, :aliases => 'ID'
8
+ attribute :macaddress, :aliases => 'MACAddress'
9
+ attribute :ipaddress, :aliases => 'IPAddress'
10
+ attribute :user_ipaddress, :aliases => 'UserIPAddress'
11
+ attribute :switch, :aliases => 'Switch'
12
+ attribute :server, :aliases => 'Server'
13
+
14
+ def delete
15
+ service.delete_interface(identity)
16
+ true
17
+ end
18
+ alias_method :destroy, :delete
19
+
20
+ def connect_to_switch(switch_id)
21
+ service.connect_interface_to_switch(identity, switch_id)
22
+ true
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,37 @@
1
+ require 'fog/core/collection'
2
+ require 'fog/sakuracloud/models/network/interface'
3
+
4
+ module Fog
5
+ module Network
6
+ class SakuraCloud
7
+ class Interfaces < Fog::Collection
8
+ model Fog::Network::SakuraCloud::Interface
9
+
10
+ def all
11
+ load service.list_interfaces.body['Interfaces']
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 regist_onto_server(server_id)
21
+ id = service.regist_interface_to_server(server_id)
22
+ get(id)
23
+ end
24
+
25
+ def connect_to_switch(id, switch_id)
26
+ id = service.connect_interface_to_switch(id, switch_id)
27
+ get(id)
28
+ end
29
+
30
+ def delete(id)
31
+ service.delete_interface(id)
32
+ true
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -11,6 +11,8 @@ module Fog
11
11
  collection :routers
12
12
  model :switch
13
13
  collection :switches
14
+ model :interface
15
+ collection :interfaces
14
16
 
15
17
  request_path 'fog/sakuracloud/requests/network'
16
18
  request :list_routers
@@ -19,6 +21,10 @@ module Fog
19
21
  request :list_switches
20
22
  request :create_switch
21
23
  request :delete_switch
24
+ request :list_interfaces
25
+ request :regist_interface_to_server
26
+ request :connect_interface_to_switch
27
+ request :delete_interface
22
28
 
23
29
  class Real
24
30
  def initialize(options = {})
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+
3
+ module Fog
4
+ module Network
5
+ class SakuraCloud
6
+ class Real
7
+ def connect_interface_to_switch( id, switch_id )
8
+ response = request(
9
+ :headers => {
10
+ 'Authorization' => "Basic #{@auth_encord}"
11
+ },
12
+ :expects => [200],
13
+ :method => 'PUT',
14
+ :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/interface/#{id}/to/switch/#{switch_id}"
15
+ )
16
+ response.body['Interface']['ID']
17
+ end
18
+ end # Real
19
+
20
+ class Mock
21
+ def regist_interface_to_server( id, switch_id )
22
+ response = Excon::Response.new
23
+ response.status = 20
24
+ response.body = {
25
+ }
26
+ response
27
+ end
28
+ end
29
+ end # SakuraCloud
30
+ end # Network0
31
+ end # Fog
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ module Fog
4
+ module Network
5
+ class SakuraCloud
6
+ class Real
7
+ def delete_interface( id )
8
+ request(
9
+ :headers => {
10
+ 'Authorization' => "Basic #{@auth_encord}"
11
+ },
12
+ :expects => [200],
13
+ :method => 'DELETE',
14
+ :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/interface/#{id}"
15
+ )
16
+ end
17
+ end # Real
18
+
19
+ class Mock
20
+ def delete_interface( 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 # Network
30
+ end # Fog
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+
3
+ module Fog
4
+ module Network
5
+ class SakuraCloud
6
+ class Real
7
+ def list_interfaces(options = {})
8
+ filter = {
9
+ "Include" => [
10
+ "ID",
11
+ "MACAddress",
12
+ "IPAddress",
13
+ "UserIPAddress",
14
+ "Switch.ID",
15
+ "Server.ID"]
16
+ }
17
+ request(
18
+ :headers => {
19
+ 'Authorization' => "Basic #{@auth_encord}"
20
+ },
21
+ :method => 'GET',
22
+ :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/interface",
23
+ :query => URI.encode(Fog::JSON.encode(filter))
24
+ )
25
+ end
26
+ end
27
+
28
+ class Mock
29
+ def list_interfaces(options = {})
30
+ response = Excon::Response.new
31
+ response.status = 200
32
+ response.body = {
33
+ }
34
+ response
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,40 @@
1
+ # coding: utf-8
2
+
3
+ module Fog
4
+ module Network
5
+ class SakuraCloud
6
+ class Real
7
+ def regist_interface_to_server( server_id )
8
+ body = {
9
+ "Interface" => {
10
+ "Server" => {
11
+ "ID" => server_id
12
+ }
13
+ }
14
+ }
15
+
16
+ response = request(
17
+ :headers => {
18
+ 'Authorization' => "Basic #{@auth_encord}"
19
+ },
20
+ :expects => [201],
21
+ :method => 'POST',
22
+ :path => "#{Fog::SakuraCloud::SAKURACLOUD_API_ENDPOINT}/interface",
23
+ :body => Fog::JSON.encode(body)
24
+ )
25
+ response.body['Interface']['ID']
26
+ end
27
+ end # Real
28
+
29
+ class Mock
30
+ def regist_interface_to_server( id )
31
+ response = Excon::Response.new
32
+ response.status = 201
33
+ response.body = {
34
+ }
35
+ response
36
+ end
37
+ end
38
+ end # SakuraCloud
39
+ end # Network
40
+ end # Fog
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Sakuracloud
3
- VERSION = "1.1.1"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  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.1.1
4
+ version: 1.2.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-09 00:00:00.000000000 Z
11
+ date: 2015-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-core
@@ -221,6 +221,8 @@ files:
221
221
  - lib/fog/sakuracloud/models/compute/ssh_keys.rb
222
222
  - lib/fog/sakuracloud/models/compute/zone.rb
223
223
  - lib/fog/sakuracloud/models/compute/zones.rb
224
+ - lib/fog/sakuracloud/models/network/interface.rb
225
+ - lib/fog/sakuracloud/models/network/interfaces.rb
224
226
  - lib/fog/sakuracloud/models/network/router.rb
225
227
  - lib/fog/sakuracloud/models/network/routers.rb
226
228
  - lib/fog/sakuracloud/models/network/switch.rb
@@ -242,12 +244,16 @@ files:
242
244
  - lib/fog/sakuracloud/requests/compute/list_ssh_keys.rb
243
245
  - lib/fog/sakuracloud/requests/compute/list_zones.rb
244
246
  - lib/fog/sakuracloud/requests/compute/stop_server.rb
247
+ - lib/fog/sakuracloud/requests/network/connect_interface_to_switch.rb
245
248
  - lib/fog/sakuracloud/requests/network/create_router.rb
246
249
  - lib/fog/sakuracloud/requests/network/create_switch.rb
250
+ - lib/fog/sakuracloud/requests/network/delete_interface.rb
247
251
  - lib/fog/sakuracloud/requests/network/delete_router.rb
248
252
  - lib/fog/sakuracloud/requests/network/delete_switch.rb
253
+ - lib/fog/sakuracloud/requests/network/list_interfaces.rb
249
254
  - lib/fog/sakuracloud/requests/network/list_routers.rb
250
255
  - lib/fog/sakuracloud/requests/network/list_switches.rb
256
+ - lib/fog/sakuracloud/requests/network/regist_interface_to_server.rb
251
257
  - lib/fog/sakuracloud/requests/script/create_note.rb
252
258
  - lib/fog/sakuracloud/requests/script/delete_note.rb
253
259
  - lib/fog/sakuracloud/requests/script/list_notes.rb