saklient 0.0.2.4 → 0.0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/saklient/cloud/client.rb +1 -1
- data/lib/saklient/cloud/resources/iface.rb +19 -0
- data/lib/saklient/cloud/resources/swytch.rb +2 -1
- data/lib/saklient/version.rb +1 -1
- data/spec/swytch_spec.rb +99 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 950d3224ffc0b0dcd5b574e28ac96bde7fc96943
|
4
|
+
data.tar.gz: d5b980c1ea8b7c78868ccb8b04963b5d2cc1db57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 535fa1ff83ba2cf15754fda12ea80a58f4189b8dc1d05e0891e9f24088976d4b5eec99ce5fbfdb6ad4423c0141bb39761df3f233e1b1aa6fd1d3934f57a03bdc
|
7
|
+
data.tar.gz: 4b3a4ef1a50ffe6c8173336d8f7537c978bbff1441014914e58df9d5e5e4f9fb8adb1ed1df209e0ea1e9a99bd2c79bc72b46e34e675dab5d1b6db7fe7d510d7e
|
@@ -73,7 +73,7 @@ module Saklient
|
|
73
73
|
|
74
74
|
extra_headers = {
|
75
75
|
'Content-Type' => 'application/x-www-form-urlencoded',
|
76
|
-
'User-Agent' => 'saklient.ruby ver-0.0.2.
|
76
|
+
'User-Agent' => 'saklient.ruby ver-0.0.2.5 rev-a581b28f8ddd2cd75cb32f710d33d3d650bba044',
|
77
77
|
'X-Requested-With' => 'XMLHttpRequest',
|
78
78
|
'X-Sakura-HTTP-Method' => method,
|
79
79
|
'X-Sakura-Error-Level' => 'warning',
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative '../../errors/saklient_exception'
|
4
4
|
require_relative '../client'
|
5
5
|
require_relative 'resource'
|
6
|
+
require_relative 'swytch'
|
6
7
|
|
7
8
|
module Saklient
|
8
9
|
module Cloud
|
@@ -95,6 +96,16 @@ module Saklient
|
|
95
96
|
api_deserialize(obj, wrapped)
|
96
97
|
end
|
97
98
|
|
99
|
+
# スイッチに接続します.
|
100
|
+
#
|
101
|
+
# @param [Swytch] swytch 接続先のスイッチ.
|
102
|
+
# @return [Iface] this
|
103
|
+
def connect_to_swytch(swytch)
|
104
|
+
Saklient::Util::validate_type(swytch, 'Saklient::Cloud::Resources::Swytch')
|
105
|
+
@_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/to/switch/' + Saklient::Util::url_encode(swytch._id))
|
106
|
+
return reload
|
107
|
+
end
|
108
|
+
|
98
109
|
# 共有セグメントに接続します.
|
99
110
|
#
|
100
111
|
# @return [Iface] this
|
@@ -103,6 +114,14 @@ module Saklient
|
|
103
114
|
return reload
|
104
115
|
end
|
105
116
|
|
117
|
+
# スイッチから切断します.
|
118
|
+
#
|
119
|
+
# @return [Iface] this
|
120
|
+
def disconnect_from_swytch
|
121
|
+
@_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/to/switch')
|
122
|
+
return reload
|
123
|
+
end
|
124
|
+
|
106
125
|
protected
|
107
126
|
|
108
127
|
# @return [bool]
|
@@ -175,7 +175,7 @@ module Saklient
|
|
175
175
|
|
176
176
|
# このルータ+スイッチの帯域プランを変更します.
|
177
177
|
#
|
178
|
-
# @param [Fixnum] bandWidthMbps
|
178
|
+
# @param [Fixnum] bandWidthMbps 帯域幅(api.product.router.find() から取得できる {RouterPlan} の bandWidthMbps を指定).
|
179
179
|
# @return [Swytch] this
|
180
180
|
def change_plan(bandWidthMbps)
|
181
181
|
Saklient::Util::validate_type(bandWidthMbps, 'Fixnum')
|
@@ -186,6 +186,7 @@ module Saklient
|
|
186
186
|
|
187
187
|
# このルータ+スイッチをブリッジに接続します.
|
188
188
|
#
|
189
|
+
# @param swytch 接続先のブリッジ.
|
189
190
|
# @param [Bridge] bridge
|
190
191
|
# @return [Swytch] this
|
191
192
|
def connect_to_bridge(bridge)
|
data/lib/saklient/version.rb
CHANGED
data/spec/swytch_spec.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
$: << File.dirname(__dir__) + '/lib'
|
2
|
+
require 'saklient/cloud/api'
|
3
|
+
require 'date'
|
4
|
+
require 'SecureRandom'
|
5
|
+
require 'ipaddr'
|
6
|
+
|
7
|
+
describe 'Swytch' do
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
before do
|
12
|
+
|
13
|
+
# load config file
|
14
|
+
root = File.dirname(__dir__)
|
15
|
+
test_ok_file = root + '/testok'
|
16
|
+
expect(File).to exist(test_ok_file)
|
17
|
+
config_file = root + '/config.sh'
|
18
|
+
expect(File).to exist(config_file)
|
19
|
+
@config = {}
|
20
|
+
fh = open(config_file)
|
21
|
+
fh.each {|line|
|
22
|
+
if /^\s*export\s+(\w+)\s*=\s*(.+?)\s*$/.match(line) then
|
23
|
+
key = $1
|
24
|
+
value = $2
|
25
|
+
@config[key.to_sym] = value.gsub(/'([^']*)'|"([^"]*)"|\\(.)|(.)/) {|m|
|
26
|
+
$1 || $2 || $3 || $4
|
27
|
+
}
|
28
|
+
end
|
29
|
+
}
|
30
|
+
fh.close
|
31
|
+
expect(@config[:SACLOUD_TOKEN]).not_to be_empty #'SACLOUD_TOKEN must be defined in config.sh'
|
32
|
+
expect(@config[:SACLOUD_SECRET]).not_to be_empty #'SACLOUD_SECRET must be defined in config.sh'
|
33
|
+
#expect(@config[:SACLOUD_ZONE]).not_to be_empty #'SACLOUD_ZONE must be defined in config.sh'
|
34
|
+
|
35
|
+
# authorize
|
36
|
+
@api = Saklient::Cloud::API::authorize(@config[:SACLOUD_TOKEN], @config[:SACLOUD_SECRET])
|
37
|
+
@api = @api.in_zone(@config[:SACLOUD_ZONE]) if @config[:SACLOUD_ZONE]
|
38
|
+
expect(@api).to be_an_instance_of Saklient::Cloud::API
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
it 'should be CRUDed' do
|
45
|
+
name = '!ruby_rspec-' + DateTime.now.strftime('%Y%m%d_%H%M%S') + '-' + SecureRandom.uuid[0, 8]
|
46
|
+
description = 'This instance was created by saklient.ruby rspec'
|
47
|
+
|
48
|
+
#
|
49
|
+
puts 'ルータ+スイッチを作成しています...'
|
50
|
+
swytch = @api.swytch.create
|
51
|
+
swytch.name = name
|
52
|
+
swytch.description = description
|
53
|
+
swytch.save
|
54
|
+
expect(swytch).to be_an_instance_of Saklient::Cloud::Resources::Swytch
|
55
|
+
|
56
|
+
#
|
57
|
+
puts 'サーバを作成しています...'
|
58
|
+
server = @api.server.create
|
59
|
+
expect(server).to be_an_instance_of Saklient::Cloud::Resources::Server
|
60
|
+
server.name = name
|
61
|
+
server.description = description
|
62
|
+
server.plan = @api.product.server.get_by_spec(1, 1)
|
63
|
+
server.save
|
64
|
+
expect(server.id.to_i).to be > 0
|
65
|
+
|
66
|
+
#
|
67
|
+
puts 'インタフェースを増設しています...'
|
68
|
+
iface = server.add_iface()
|
69
|
+
expect(iface).to be_an_instance_of Saklient::Cloud::Resources::Iface
|
70
|
+
expect(iface.id.to_i).to be > 0
|
71
|
+
|
72
|
+
#
|
73
|
+
puts 'インタフェースをスイッチに接続しています...'
|
74
|
+
iface.connect_to_swytch(swytch)
|
75
|
+
|
76
|
+
#
|
77
|
+
puts 'インタフェースをスイッチから切断しています...'
|
78
|
+
iface.disconnect_from_swytch
|
79
|
+
|
80
|
+
#
|
81
|
+
puts 'サーバを削除しています...'
|
82
|
+
server.destroy
|
83
|
+
|
84
|
+
#
|
85
|
+
puts 'スイッチを削除しています...'
|
86
|
+
swytch.destroy
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
after do
|
93
|
+
@config = nil
|
94
|
+
@api = nil
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: saklient
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.2.
|
4
|
+
version: 0.0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- townewgokgok
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -261,6 +261,7 @@ files:
|
|
261
261
|
- spec/loadbalancer_spec.rb
|
262
262
|
- spec/router_spec.rb
|
263
263
|
- spec/server_spec.rb
|
264
|
+
- spec/swytch_spec.rb
|
264
265
|
- spec/util_spec.rb
|
265
266
|
- test-sshkey.txt
|
266
267
|
homepage: http://sakura-internet.github.io/saklient.doc/
|
@@ -297,5 +298,5 @@ test_files:
|
|
297
298
|
- spec/loadbalancer_spec.rb
|
298
299
|
- spec/router_spec.rb
|
299
300
|
- spec/server_spec.rb
|
301
|
+
- spec/swytch_spec.rb
|
300
302
|
- spec/util_spec.rb
|
301
|
-
has_rdoc:
|