saklient 0.0.2.2 → 0.0.2.3

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/saklient/cloud/api.rb +75 -0
  3. data/lib/saklient/cloud/client.rb +1 -1
  4. data/lib/saklient/cloud/facility.rb +45 -0
  5. data/lib/saklient/cloud/models/model.rb +7 -12
  6. data/lib/saklient/cloud/models/model_appliance.rb +17 -2
  7. data/lib/saklient/cloud/models/model_archive.rb +10 -0
  8. data/lib/saklient/cloud/models/model_bridge.rb +148 -0
  9. data/lib/saklient/cloud/models/model_disk.rb +10 -0
  10. data/lib/saklient/cloud/models/model_disk_plan.rb +10 -0
  11. data/lib/saklient/cloud/models/model_icon.rb +10 -0
  12. data/lib/saklient/cloud/models/model_iface.rb +10 -0
  13. data/lib/saklient/cloud/models/model_ipv6_net.rb +10 -0
  14. data/lib/saklient/cloud/models/model_iso_image.rb +10 -0
  15. data/lib/saklient/cloud/models/model_license.rb +148 -0
  16. data/lib/saklient/cloud/models/model_license_info.rb +139 -0
  17. data/lib/saklient/cloud/models/model_region.rb +139 -0
  18. data/lib/saklient/cloud/models/model_router.rb +10 -0
  19. data/lib/saklient/cloud/models/model_router_plan.rb +10 -0
  20. data/lib/saklient/cloud/models/model_script.rb +10 -0
  21. data/lib/saklient/cloud/models/model_server.rb +10 -0
  22. data/lib/saklient/cloud/models/model_server_plan.rb +10 -0
  23. data/lib/saklient/cloud/models/model_swytch.rb +10 -0
  24. data/lib/saklient/cloud/product.rb +25 -0
  25. data/lib/saklient/cloud/resources/appliance.rb +5 -17
  26. data/lib/saklient/cloud/resources/archive.rb +2 -2
  27. data/lib/saklient/cloud/resources/bridge.rb +305 -0
  28. data/lib/saklient/cloud/resources/disk.rb +2 -2
  29. data/lib/saklient/cloud/resources/disk_config.rb +1 -1
  30. data/lib/saklient/cloud/resources/iso_image.rb +2 -2
  31. data/lib/saklient/cloud/resources/lb_server.rb +2 -2
  32. data/lib/saklient/cloud/resources/lb_virtual_ip.rb +1 -1
  33. data/lib/saklient/cloud/resources/license.rb +252 -0
  34. data/lib/saklient/cloud/resources/license_info.rb +180 -0
  35. data/lib/saklient/cloud/resources/load_balancer.rb +1 -1
  36. data/lib/saklient/cloud/resources/region.rb +233 -0
  37. data/lib/saklient/cloud/resources/resource.rb +1 -10
  38. data/lib/saklient/cloud/resources/script.rb +2 -2
  39. data/lib/saklient/cloud/resources/server.rb +2 -2
  40. data/lib/saklient/cloud/resources/swytch.rb +137 -14
  41. data/lib/saklient/version.rb +1 -1
  42. data/spec/archive_spec.rb +1 -0
  43. data/spec/bridge_spec.rb +78 -0
  44. data/spec/exception_spec.rb +1 -1
  45. data/spec/iso_image_spec.rb +1 -1
  46. data/spec/license_spec.rb +73 -0
  47. data/spec/loadbalancer_spec.rb +8 -5
  48. data/spec/server_spec.rb +3 -1
  49. metadata +16 -4
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: UTF-8 -*-
2
2
 
3
3
  module Saklient
4
- VERSION = "0.0.2.2"
4
+ VERSION = "0.0.2.3"
5
5
  end
data/spec/archive_spec.rb CHANGED
@@ -106,6 +106,7 @@ describe 'Archive' do
106
106
  disk.description = description
107
107
  disk.tags = [tag]
108
108
  disk.size_gib = 20
109
+ disk.plan = @api.product.disk.ssd
109
110
  disk.save
110
111
 
111
112
  archive = @api.archive.create
@@ -0,0 +1,78 @@
1
+ $: << File.dirname(__dir__) + '/lib'
2
+ require 'saklient/cloud/api'
3
+ require 'date'
4
+ require 'SecureRandom'
5
+
6
+ describe 'Bridge' do
7
+
8
+
9
+
10
+ before do
11
+
12
+ # load config file
13
+ root = File.dirname(__dir__)
14
+ test_ok_file = root + '/testok'
15
+ expect(File).to exist(test_ok_file)
16
+ config_file = root + '/config.sh'
17
+ expect(File).to exist(config_file)
18
+ @config = {}
19
+ fh = open(config_file)
20
+ fh.each {|line|
21
+ if /^\s*export\s+(\w+)\s*=\s*(.+?)\s*$/.match(line) then
22
+ key = $1
23
+ value = $2
24
+ @config[key.to_sym] = value.gsub(/'([^']*)'|"([^"]*)"|\\(.)|(.)/) {|m|
25
+ $1 || $2 || $3 || $4
26
+ }
27
+ end
28
+ }
29
+ fh.close
30
+ expect(@config[:SACLOUD_TOKEN]).not_to be_empty #'SACLOUD_TOKEN must be defined in config.sh'
31
+ expect(@config[:SACLOUD_SECRET]).not_to be_empty #'SACLOUD_SECRET must be defined in config.sh'
32
+ #expect(@config[:SACLOUD_ZONE]).not_to be_empty #'SACLOUD_ZONE must be defined in config.sh'
33
+
34
+ # authorize
35
+ @api = Saklient::Cloud::API::authorize(@config[:SACLOUD_TOKEN], @config[:SACLOUD_SECRET])
36
+ @api = @api.in_zone(@config[:SACLOUD_ZONE]) if @config[:SACLOUD_ZONE]
37
+ expect(@api).to be_an_instance_of Saklient::Cloud::API
38
+
39
+ end
40
+
41
+
42
+
43
+ it 'should be CRUDed' do
44
+ name = '!ruby_rspec-' + DateTime.now.strftime('%Y%m%d_%H%M%S') + '-' + SecureRandom.uuid[0, 8]
45
+ description = 'This instance was created by saklient.ruby rspec'
46
+
47
+ #
48
+ puts 'リージョンを検索しています...'
49
+ regions = @api.facility.region.with_name_like('石狩').find
50
+ for region in regions do
51
+ expect(region).to be_an_instance_of Saklient::Cloud::Resources::Region
52
+ end
53
+
54
+ puts 'ブリッジを作成しています...'
55
+ bridge = @api.bridge.create
56
+ bridge.name = name
57
+ bridge.description = description
58
+ bridge.region = regions[0]
59
+ bridge.save
60
+
61
+ expect(bridge).to be_an_instance_of Saklient::Cloud::Resources::Bridge
62
+
63
+ #
64
+ puts 'ブリッジを削除しています...'
65
+ bridge.destroy
66
+
67
+ end
68
+
69
+
70
+
71
+ after do
72
+ @config = nil
73
+ @api = nil
74
+ end
75
+
76
+
77
+
78
+ end
@@ -1,5 +1,5 @@
1
1
  $: << File.dirname(__dir__) + '/lib'
2
- require 'saklient/cloud/errors/exception_factory'
2
+ require 'saklient/errors/exception_factory'
3
3
 
4
4
  ExceptionFactory = Saklient::Errors::ExceptionFactory
5
5
  HttpException = Saklient::Errors::HttpException
@@ -104,7 +104,7 @@ describe 'IsoImage' do
104
104
  # search iso images
105
105
  puts 'searching iso images...'
106
106
  isos = @api.iso_image.
107
- with_name_like('CentOS 6.5 64bit').
107
+ with_name_like('CentOS 64bit').
108
108
  with_shared_scope.
109
109
  limit(1).
110
110
  find
@@ -0,0 +1,73 @@
1
+ $: << File.dirname(__dir__) + '/lib'
2
+ require 'saklient/cloud/api'
3
+ require 'date'
4
+ require 'SecureRandom'
5
+
6
+ describe 'License' do
7
+
8
+
9
+
10
+ before do
11
+
12
+ # load config file
13
+ root = File.dirname(__dir__)
14
+ test_ok_file = root + '/testok'
15
+ expect(File).to exist(test_ok_file)
16
+ config_file = root + '/config.sh'
17
+ expect(File).to exist(config_file)
18
+ @config = {}
19
+ fh = open(config_file)
20
+ fh.each {|line|
21
+ if /^\s*export\s+(\w+)\s*=\s*(.+?)\s*$/.match(line) then
22
+ key = $1
23
+ value = $2
24
+ @config[key.to_sym] = value.gsub(/'([^']*)'|"([^"]*)"|\\(.)|(.)/) {|m|
25
+ $1 || $2 || $3 || $4
26
+ }
27
+ end
28
+ }
29
+ fh.close
30
+ expect(@config[:SACLOUD_TOKEN]).not_to be_empty #'SACLOUD_TOKEN must be defined in config.sh'
31
+ expect(@config[:SACLOUD_SECRET]).not_to be_empty #'SACLOUD_SECRET must be defined in config.sh'
32
+ #expect(@config[:SACLOUD_ZONE]).not_to be_empty #'SACLOUD_ZONE must be defined in config.sh'
33
+
34
+ # authorize
35
+ @api = Saklient::Cloud::API::authorize(@config[:SACLOUD_TOKEN], @config[:SACLOUD_SECRET])
36
+ @api = @api.in_zone(@config[:SACLOUD_ZONE]) if @config[:SACLOUD_ZONE]
37
+ expect(@api).to be_an_instance_of Saklient::Cloud::API
38
+
39
+ end
40
+
41
+
42
+
43
+ it 'should be CRUDed' do
44
+ name = '!ruby_rspec-' + DateTime.now.strftime('%Y%m%d_%H%M%S') + '-' + SecureRandom.uuid[0, 8]
45
+
46
+ #
47
+ puts 'ライセンス種別情報を検索しています...'
48
+ infos = @api.product.license.with_name_like('Office').find
49
+ for info in infos do
50
+ expect(info).to be_an_instance_of Saklient::Cloud::Resources::LicenseInfo
51
+ end
52
+
53
+ puts 'ライセンスを作成しています...'
54
+ license = @api.license.create
55
+ license.name = name
56
+ license.info = infos[0]
57
+ license.save
58
+
59
+ puts 'ライセンスを削除しています...'
60
+ license.destroy
61
+
62
+ end
63
+
64
+
65
+
66
+ after do
67
+ @config = nil
68
+ @api = nil
69
+ end
70
+
71
+
72
+
73
+ end
@@ -8,7 +8,8 @@ describe 'LoadBalancer' do
8
8
 
9
9
 
10
10
 
11
- TESTS_CONFIG_READYMADE_LB_ID = '112600809060'
11
+ TESTS_CONFIG_READYMADE_LB_ID = nil #'112600809060'
12
+ TESTS_CONFIG_READYMADE_SWYTCH_ID = '112500447075' #'112600553094'
12
13
 
13
14
  before do
14
15
 
@@ -55,9 +56,9 @@ describe 'LoadBalancer' do
55
56
 
56
57
  # search a switch
57
58
  puts 'searching a swytch...'
58
- swytches = @api.swytch.with_tag('lb-attached').limit(1).find()
59
- expect(swytches.length).to be > 0
60
- swytch = swytches[0]
59
+ swytch = @api.swytch.get_by_id(TESTS_CONFIG_READYMADE_SWYTCH_ID)
60
+ # expect(swytches.length).to be > 0
61
+ # swytch = swytches[0]
61
62
  expect(swytch).to be_an_instance_of Saklient::Cloud::Resources::Swytch
62
63
  expect(swytch.ipv4_nets.length).to be > 0
63
64
  net = swytch.ipv4_nets[0]
@@ -66,7 +67,9 @@ describe 'LoadBalancer' do
66
67
  # create a loadbalancer
67
68
  puts 'creating a LB...'
68
69
  vrid = 123
69
- lb = @api.appliance.create_load_balancer(swytch, vrid, ['133.242.255.244', '133.242.255.245'], true)
70
+ real_ip1 = IPAddr.new(IPAddr.new(net.default_route).to_i + 3, Socket::AF_INET).to_s
71
+ real_ip2 = IPAddr.new(IPAddr.new(net.default_route).to_i + 4, Socket::AF_INET).to_s
72
+ lb = @api.appliance.create_load_balancer(swytch, vrid, [real_ip1, real_ip2], true)
70
73
 
71
74
  ok = false
72
75
  begin
data/spec/server_spec.rb CHANGED
@@ -78,9 +78,11 @@ describe 'Server' do
78
78
 
79
79
  # search archives
80
80
  puts 'searching archives...'
81
- archives = @api.archive.with_name_like('CentOS 6.5 64bit').with_size_gib(20).with_shared_scope.limit(1).find
81
+ archives = @api.archive.with_name_like('CentOS 64bit').with_size_gib(20).with_shared_scope.limit(1).find
82
+ expect(archives.length).to be > 0
82
83
  # printf "found %d archive(s)\n", archives.length
83
84
  archive = archives[0]
85
+ expect(archive.id.to_i).to be > 0
84
86
  # p archive.dump
85
87
 
86
88
  # search scripts
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.2
4
+ version: 0.0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - townewgokgok
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-14 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -166,15 +166,20 @@ files:
166
166
  - lib/saklient/cloud/errors/unsupported_res_class_exception.rb
167
167
  - lib/saklient/cloud/errors/user_not_specified_exception.rb
168
168
  - lib/saklient/cloud/errors/vnc_proxy_request_failure_exception.rb
169
+ - lib/saklient/cloud/facility.rb
169
170
  - lib/saklient/cloud/models/model.rb
170
171
  - lib/saklient/cloud/models/model_appliance.rb
171
172
  - lib/saklient/cloud/models/model_archive.rb
173
+ - lib/saklient/cloud/models/model_bridge.rb
172
174
  - lib/saklient/cloud/models/model_disk.rb
173
175
  - lib/saklient/cloud/models/model_disk_plan.rb
174
176
  - lib/saklient/cloud/models/model_icon.rb
175
177
  - lib/saklient/cloud/models/model_iface.rb
176
178
  - lib/saklient/cloud/models/model_ipv6_net.rb
177
179
  - lib/saklient/cloud/models/model_iso_image.rb
180
+ - lib/saklient/cloud/models/model_license.rb
181
+ - lib/saklient/cloud/models/model_license_info.rb
182
+ - lib/saklient/cloud/models/model_region.rb
178
183
  - lib/saklient/cloud/models/model_router.rb
179
184
  - lib/saklient/cloud/models/model_router_plan.rb
180
185
  - lib/saklient/cloud/models/model_script.rb
@@ -185,6 +190,7 @@ files:
185
190
  - lib/saklient/cloud/product.rb
186
191
  - lib/saklient/cloud/resources/appliance.rb
187
192
  - lib/saklient/cloud/resources/archive.rb
193
+ - lib/saklient/cloud/resources/bridge.rb
188
194
  - lib/saklient/cloud/resources/disk.rb
189
195
  - lib/saklient/cloud/resources/disk_config.rb
190
196
  - lib/saklient/cloud/resources/disk_plan.rb
@@ -196,7 +202,10 @@ files:
196
202
  - lib/saklient/cloud/resources/iso_image.rb
197
203
  - lib/saklient/cloud/resources/lb_server.rb
198
204
  - lib/saklient/cloud/resources/lb_virtual_ip.rb
205
+ - lib/saklient/cloud/resources/license.rb
206
+ - lib/saklient/cloud/resources/license_info.rb
199
207
  - lib/saklient/cloud/resources/load_balancer.rb
208
+ - lib/saklient/cloud/resources/region.rb
200
209
  - lib/saklient/cloud/resources/resource.rb
201
210
  - lib/saklient/cloud/resources/router.rb
202
211
  - lib/saklient/cloud/resources/router_plan.rb
@@ -244,9 +253,11 @@ files:
244
253
  - lib/saklient/version.rb
245
254
  - saklient.gemspec
246
255
  - spec/archive_spec.rb
256
+ - spec/bridge_spec.rb
247
257
  - spec/enum_spec.rb
248
258
  - spec/exception_spec.rb
249
259
  - spec/iso_image_spec.rb
260
+ - spec/license_spec.rb
250
261
  - spec/loadbalancer_spec.rb
251
262
  - spec/router_spec.rb
252
263
  - spec/server_spec.rb
@@ -272,17 +283,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
272
283
  version: '0'
273
284
  requirements: []
274
285
  rubyforge_project:
275
- rubygems_version: 2.0.14
286
+ rubygems_version: 2.4.3
276
287
  signing_key:
277
288
  specification_version: 4
278
289
  summary: SAKURA Internet API Client Library for Ruby
279
290
  test_files:
280
291
  - spec/archive_spec.rb
292
+ - spec/bridge_spec.rb
281
293
  - spec/enum_spec.rb
282
294
  - spec/exception_spec.rb
283
295
  - spec/iso_image_spec.rb
296
+ - spec/license_spec.rb
284
297
  - spec/loadbalancer_spec.rb
285
298
  - spec/router_spec.rb
286
299
  - spec/server_spec.rb
287
300
  - spec/util_spec.rb
288
- has_rdoc: