saklient 0.0.1.1 → 0.0.2.2
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 +2 -2
- data/lib/saklient/cloud/models/model.rb +19 -26
- data/lib/saklient/cloud/models/model_appliance.rb +22 -0
- data/lib/saklient/cloud/models/model_archive.rb +2 -0
- data/lib/saklient/cloud/models/model_router.rb +32 -0
- data/lib/saklient/cloud/models/model_swytch.rb +32 -0
- data/lib/saklient/cloud/resources/appliance.rb +417 -1
- data/lib/saklient/cloud/resources/archive.rb +5 -25
- data/lib/saklient/cloud/resources/disk.rb +5 -25
- data/lib/saklient/cloud/resources/ipv4_net.rb +1 -1
- data/lib/saklient/cloud/resources/ipv6_net.rb +1 -1
- data/lib/saklient/cloud/resources/iso_image.rb +3 -2
- data/lib/saklient/cloud/resources/lb_server.rb +304 -0
- data/lib/saklient/cloud/resources/lb_virtual_ip.rb +227 -0
- data/lib/saklient/cloud/resources/load_balancer.rb +250 -0
- data/lib/saklient/cloud/resources/resource.rb +73 -21
- data/lib/saklient/cloud/resources/router.rb +3 -3
- data/lib/saklient/cloud/resources/router_plan.rb +1 -1
- data/lib/saklient/cloud/resources/script.rb +2 -16
- data/lib/saklient/cloud/resources/server.rb +11 -31
- data/lib/saklient/cloud/resources/server_plan.rb +2 -2
- data/lib/saklient/cloud/resources/swytch.rb +1 -1
- data/lib/saklient/cloud/resources/vpc_router.rb +28 -0
- data/lib/saklient/util.rb +10 -0
- data/lib/saklient/version.rb +1 -1
- data/spec/loadbalancer_spec.rb +248 -0
- data/spec/router_spec.rb +1 -1
- metadata +9 -2
@@ -366,6 +366,7 @@ module Saklient
|
|
366
366
|
# @private
|
367
367
|
# @return [Array<String>]
|
368
368
|
def get_tags
|
369
|
+
@n_tags = true
|
369
370
|
return @m_tags
|
370
371
|
end
|
371
372
|
|
@@ -602,14 +603,14 @@ module Saklient
|
|
602
603
|
end
|
603
604
|
@n_icon = false
|
604
605
|
if Saklient::Util::exists_path(r, 'DisplayOrder')
|
605
|
-
@m_display_order = (Saklient::Util::get_by_path(r, 'DisplayOrder')).nil? ? nil : (Saklient::Util::get_by_path(r, 'DisplayOrder').to_s).to_i(10)
|
606
|
+
@m_display_order = (Saklient::Util::get_by_path(r, 'DisplayOrder')).nil? ? nil : (Saklient::Util::get_by_path(r, 'DisplayOrder').to_s).to_s().to_i(10)
|
606
607
|
else
|
607
608
|
@m_display_order = nil
|
608
609
|
@is_incomplete = true
|
609
610
|
end
|
610
611
|
@n_display_order = false
|
611
612
|
if Saklient::Util::exists_path(r, 'SizeMB')
|
612
|
-
@m_size_mib = (Saklient::Util::get_by_path(r, 'SizeMB')).nil? ? nil : (Saklient::Util::get_by_path(r, 'SizeMB').to_s).to_i(10)
|
613
|
+
@m_size_mib = (Saklient::Util::get_by_path(r, 'SizeMB')).nil? ? nil : (Saklient::Util::get_by_path(r, 'SizeMB').to_s).to_s().to_i(10)
|
613
614
|
else
|
614
615
|
@m_size_mib = nil
|
615
616
|
@is_incomplete = true
|
@@ -0,0 +1,304 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require_relative '../../util'
|
4
|
+
|
5
|
+
module Saklient
|
6
|
+
module Cloud
|
7
|
+
module Resources
|
8
|
+
|
9
|
+
# ロードバランサの監視対象サーバ.
|
10
|
+
class LbServer
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
# @private
|
15
|
+
# @return [String]
|
16
|
+
attr_accessor :_ip_address
|
17
|
+
|
18
|
+
public
|
19
|
+
|
20
|
+
# @private
|
21
|
+
# @return [String]
|
22
|
+
def get_ip_address
|
23
|
+
return @_ip_address
|
24
|
+
end
|
25
|
+
|
26
|
+
# @private
|
27
|
+
# @param [String] v
|
28
|
+
# @return [String]
|
29
|
+
def set_ip_address(v)
|
30
|
+
Saklient::Util::validate_type(v, 'String')
|
31
|
+
@_ip_address = v
|
32
|
+
return @_ip_address
|
33
|
+
end
|
34
|
+
|
35
|
+
# IPアドレス
|
36
|
+
#
|
37
|
+
# @return [String]
|
38
|
+
attr_accessor :ip_address
|
39
|
+
|
40
|
+
def ip_address
|
41
|
+
get_ip_address
|
42
|
+
end
|
43
|
+
|
44
|
+
def ip_address=(v)
|
45
|
+
set_ip_address(v)
|
46
|
+
end
|
47
|
+
|
48
|
+
protected
|
49
|
+
|
50
|
+
# @private
|
51
|
+
# @return [Fixnum]
|
52
|
+
attr_accessor :_port
|
53
|
+
|
54
|
+
public
|
55
|
+
|
56
|
+
# @private
|
57
|
+
# @return [Fixnum]
|
58
|
+
def get_port
|
59
|
+
return @_port
|
60
|
+
end
|
61
|
+
|
62
|
+
# @private
|
63
|
+
# @param [Fixnum] v
|
64
|
+
# @return [Fixnum]
|
65
|
+
def set_port(v)
|
66
|
+
Saklient::Util::validate_type(v, 'Fixnum')
|
67
|
+
@_port = v
|
68
|
+
return @_port
|
69
|
+
end
|
70
|
+
|
71
|
+
# ポート番号
|
72
|
+
#
|
73
|
+
# @return [Fixnum]
|
74
|
+
attr_accessor :port
|
75
|
+
|
76
|
+
def port
|
77
|
+
get_port
|
78
|
+
end
|
79
|
+
|
80
|
+
def port=(v)
|
81
|
+
set_port(v)
|
82
|
+
end
|
83
|
+
|
84
|
+
protected
|
85
|
+
|
86
|
+
# @private
|
87
|
+
# @return [String]
|
88
|
+
attr_accessor :_protocol
|
89
|
+
|
90
|
+
public
|
91
|
+
|
92
|
+
# @private
|
93
|
+
# @return [String]
|
94
|
+
def get_protocol
|
95
|
+
return @_protocol
|
96
|
+
end
|
97
|
+
|
98
|
+
# @private
|
99
|
+
# @param [String] v
|
100
|
+
# @return [String]
|
101
|
+
def set_protocol(v)
|
102
|
+
Saklient::Util::validate_type(v, 'String')
|
103
|
+
@_protocol = v
|
104
|
+
return @_protocol
|
105
|
+
end
|
106
|
+
|
107
|
+
# 監視方法
|
108
|
+
#
|
109
|
+
# @return [String]
|
110
|
+
attr_accessor :protocol
|
111
|
+
|
112
|
+
def protocol
|
113
|
+
get_protocol
|
114
|
+
end
|
115
|
+
|
116
|
+
def protocol=(v)
|
117
|
+
set_protocol(v)
|
118
|
+
end
|
119
|
+
|
120
|
+
protected
|
121
|
+
|
122
|
+
# @private
|
123
|
+
# @return [String]
|
124
|
+
attr_accessor :_path_to_check
|
125
|
+
|
126
|
+
public
|
127
|
+
|
128
|
+
# @private
|
129
|
+
# @return [String]
|
130
|
+
def get_path_to_check
|
131
|
+
return @_path_to_check
|
132
|
+
end
|
133
|
+
|
134
|
+
# @private
|
135
|
+
# @param [String] v
|
136
|
+
# @return [String]
|
137
|
+
def set_path_to_check(v)
|
138
|
+
Saklient::Util::validate_type(v, 'String')
|
139
|
+
@_path_to_check = v
|
140
|
+
return @_path_to_check
|
141
|
+
end
|
142
|
+
|
143
|
+
# 監視対象パス
|
144
|
+
#
|
145
|
+
# @return [String]
|
146
|
+
attr_accessor :path_to_check
|
147
|
+
|
148
|
+
def path_to_check
|
149
|
+
get_path_to_check
|
150
|
+
end
|
151
|
+
|
152
|
+
def path_to_check=(v)
|
153
|
+
set_path_to_check(v)
|
154
|
+
end
|
155
|
+
|
156
|
+
protected
|
157
|
+
|
158
|
+
# @private
|
159
|
+
# @return [Fixnum]
|
160
|
+
attr_accessor :_response_expected
|
161
|
+
|
162
|
+
public
|
163
|
+
|
164
|
+
# @private
|
165
|
+
# @return [Fixnum]
|
166
|
+
def get_response_expected
|
167
|
+
return @_response_expected
|
168
|
+
end
|
169
|
+
|
170
|
+
# @private
|
171
|
+
# @param [Fixnum] v
|
172
|
+
# @return [Fixnum]
|
173
|
+
def set_response_expected(v)
|
174
|
+
Saklient::Util::validate_type(v, 'Fixnum')
|
175
|
+
@_response_expected = v
|
176
|
+
return @_response_expected
|
177
|
+
end
|
178
|
+
|
179
|
+
# 監視時に期待されるレスポンスコード
|
180
|
+
#
|
181
|
+
# @return [Fixnum]
|
182
|
+
attr_accessor :response_expected
|
183
|
+
|
184
|
+
def response_expected
|
185
|
+
get_response_expected
|
186
|
+
end
|
187
|
+
|
188
|
+
def response_expected=(v)
|
189
|
+
set_response_expected(v)
|
190
|
+
end
|
191
|
+
|
192
|
+
protected
|
193
|
+
|
194
|
+
# @private
|
195
|
+
# @return [Fixnum]
|
196
|
+
attr_accessor :_active_connections
|
197
|
+
|
198
|
+
public
|
199
|
+
|
200
|
+
# @private
|
201
|
+
# @return [Fixnum]
|
202
|
+
def get_active_connections
|
203
|
+
return @_active_connections
|
204
|
+
end
|
205
|
+
|
206
|
+
# レスポンスコード
|
207
|
+
#
|
208
|
+
# @return [Fixnum]
|
209
|
+
attr_reader :active_connections
|
210
|
+
|
211
|
+
def active_connections
|
212
|
+
get_active_connections
|
213
|
+
end
|
214
|
+
|
215
|
+
protected
|
216
|
+
|
217
|
+
# @private
|
218
|
+
# @return [String]
|
219
|
+
attr_accessor :_status
|
220
|
+
|
221
|
+
public
|
222
|
+
|
223
|
+
# @private
|
224
|
+
# @return [String]
|
225
|
+
def get_status
|
226
|
+
return @_status
|
227
|
+
end
|
228
|
+
|
229
|
+
# レスポンスコード
|
230
|
+
#
|
231
|
+
# @return [String]
|
232
|
+
attr_reader :status
|
233
|
+
|
234
|
+
def status
|
235
|
+
get_status
|
236
|
+
end
|
237
|
+
|
238
|
+
# @private
|
239
|
+
# @param [any] obj
|
240
|
+
def initialize(obj = nil)
|
241
|
+
obj = {} if (obj).nil?
|
242
|
+
health = Saklient::Util::get_by_path_any([obj], [
|
243
|
+
'HealthCheck',
|
244
|
+
'healthCheck',
|
245
|
+
'health_check',
|
246
|
+
'health'
|
247
|
+
])
|
248
|
+
@_ip_address = Saklient::Util::get_by_path_any([obj], [
|
249
|
+
'IPAddress',
|
250
|
+
'ipAddress',
|
251
|
+
'ip_address',
|
252
|
+
'ip'
|
253
|
+
])
|
254
|
+
@_protocol = Saklient::Util::get_by_path_any([health, obj], ['Protocol', 'protocol'])
|
255
|
+
@_path_to_check = Saklient::Util::get_by_path_any([health, obj], [
|
256
|
+
'Path',
|
257
|
+
'path',
|
258
|
+
'pathToCheck',
|
259
|
+
'path_to_check'
|
260
|
+
])
|
261
|
+
port = Saklient::Util::get_by_path_any([obj], ['Port', 'port'])
|
262
|
+
@_port = nil
|
263
|
+
@_port = (port).to_s().to_i(10) if !(port).nil?
|
264
|
+
@_port = nil if @_port == 0
|
265
|
+
responseExpected = Saklient::Util::get_by_path_any([health, obj], [
|
266
|
+
'Status',
|
267
|
+
'status',
|
268
|
+
'responseExpected',
|
269
|
+
'response_expected'
|
270
|
+
])
|
271
|
+
@_response_expected = nil
|
272
|
+
@_response_expected = (responseExpected).to_s().to_i(10) if !(responseExpected).nil?
|
273
|
+
@_response_expected = nil if @_response_expected == 0
|
274
|
+
end
|
275
|
+
|
276
|
+
# @return [any]
|
277
|
+
def to_raw_settings
|
278
|
+
return {
|
279
|
+
IPAddress: @_ip_address,
|
280
|
+
Port: @_port,
|
281
|
+
HealthCheck: {
|
282
|
+
Protocol: @_protocol,
|
283
|
+
Path: @_path_to_check,
|
284
|
+
Status: @_response_expected
|
285
|
+
}
|
286
|
+
}
|
287
|
+
end
|
288
|
+
|
289
|
+
# @param [any] obj
|
290
|
+
# @return [LbServer]
|
291
|
+
def update_status(obj)
|
292
|
+
connStr = obj[:ActiveConn]
|
293
|
+
@_active_connections = 0
|
294
|
+
@_active_connections = (connStr).to_s().to_i(10) if !(connStr).nil?
|
295
|
+
status = obj[:Status]
|
296
|
+
@_status = (status).nil? ? nil : status.downcase()
|
297
|
+
return self
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require_relative '../../util'
|
4
|
+
require_relative 'lb_server'
|
5
|
+
|
6
|
+
module Saklient
|
7
|
+
module Cloud
|
8
|
+
module Resources
|
9
|
+
|
10
|
+
# ロードバランサの仮想IPアドレス.
|
11
|
+
class LbVirtualIp
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
# @private
|
16
|
+
# @return [String]
|
17
|
+
attr_accessor :_virtual_ip_address
|
18
|
+
|
19
|
+
public
|
20
|
+
|
21
|
+
# @private
|
22
|
+
# @return [String]
|
23
|
+
def get_virtual_ip_address
|
24
|
+
return @_virtual_ip_address
|
25
|
+
end
|
26
|
+
|
27
|
+
# @private
|
28
|
+
# @param [String] v
|
29
|
+
# @return [String]
|
30
|
+
def set_virtual_ip_address(v)
|
31
|
+
Saklient::Util::validate_type(v, 'String')
|
32
|
+
@_virtual_ip_address = v
|
33
|
+
return @_virtual_ip_address
|
34
|
+
end
|
35
|
+
|
36
|
+
# VIPアドレス
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
attr_accessor :virtual_ip_address
|
40
|
+
|
41
|
+
def virtual_ip_address
|
42
|
+
get_virtual_ip_address
|
43
|
+
end
|
44
|
+
|
45
|
+
def virtual_ip_address=(v)
|
46
|
+
set_virtual_ip_address(v)
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
# @private
|
52
|
+
# @return [Fixnum]
|
53
|
+
attr_accessor :_port
|
54
|
+
|
55
|
+
public
|
56
|
+
|
57
|
+
# @private
|
58
|
+
# @return [Fixnum]
|
59
|
+
def get_port
|
60
|
+
return @_port
|
61
|
+
end
|
62
|
+
|
63
|
+
# @private
|
64
|
+
# @param [Fixnum] v
|
65
|
+
# @return [Fixnum]
|
66
|
+
def set_port(v)
|
67
|
+
Saklient::Util::validate_type(v, 'Fixnum')
|
68
|
+
@_port = v
|
69
|
+
return @_port
|
70
|
+
end
|
71
|
+
|
72
|
+
# ポート番号
|
73
|
+
#
|
74
|
+
# @return [Fixnum]
|
75
|
+
attr_accessor :port
|
76
|
+
|
77
|
+
def port
|
78
|
+
get_port
|
79
|
+
end
|
80
|
+
|
81
|
+
def port=(v)
|
82
|
+
set_port(v)
|
83
|
+
end
|
84
|
+
|
85
|
+
protected
|
86
|
+
|
87
|
+
# @private
|
88
|
+
# @return [Fixnum]
|
89
|
+
attr_accessor :_delay_loop
|
90
|
+
|
91
|
+
public
|
92
|
+
|
93
|
+
# @private
|
94
|
+
# @return [Fixnum]
|
95
|
+
def get_delay_loop
|
96
|
+
return @_delay_loop
|
97
|
+
end
|
98
|
+
|
99
|
+
# @private
|
100
|
+
# @param [Fixnum] v
|
101
|
+
# @return [Fixnum]
|
102
|
+
def set_delay_loop(v)
|
103
|
+
Saklient::Util::validate_type(v, 'Fixnum')
|
104
|
+
@_delay_loop = v
|
105
|
+
return @_delay_loop
|
106
|
+
end
|
107
|
+
|
108
|
+
# チェック間隔 [秒]
|
109
|
+
#
|
110
|
+
# @return [Fixnum]
|
111
|
+
attr_accessor :delay_loop
|
112
|
+
|
113
|
+
def delay_loop
|
114
|
+
get_delay_loop
|
115
|
+
end
|
116
|
+
|
117
|
+
def delay_loop=(v)
|
118
|
+
set_delay_loop(v)
|
119
|
+
end
|
120
|
+
|
121
|
+
protected
|
122
|
+
|
123
|
+
# @private
|
124
|
+
# @return [Array<LbServer>]
|
125
|
+
attr_accessor :_servers
|
126
|
+
|
127
|
+
public
|
128
|
+
|
129
|
+
# @private
|
130
|
+
# @return [Array<LbServer>]
|
131
|
+
def get_servers
|
132
|
+
return @_servers
|
133
|
+
end
|
134
|
+
|
135
|
+
# 実サーバ
|
136
|
+
#
|
137
|
+
# @return [Array<LbServer>]
|
138
|
+
attr_reader :servers
|
139
|
+
|
140
|
+
def servers
|
141
|
+
get_servers
|
142
|
+
end
|
143
|
+
|
144
|
+
# @private
|
145
|
+
# @param [any] obj
|
146
|
+
def initialize(obj = nil)
|
147
|
+
obj = {} if (obj).nil?
|
148
|
+
vip = Saklient::Util::get_by_path_any([obj], [
|
149
|
+
'VirtualIPAddress',
|
150
|
+
'virtualIpAddress',
|
151
|
+
'virtual_ip_address',
|
152
|
+
'vip'
|
153
|
+
])
|
154
|
+
@_virtual_ip_address = vip
|
155
|
+
port = Saklient::Util::get_by_path_any([obj], ['Port', 'port'])
|
156
|
+
@_port = nil
|
157
|
+
@_port = (port).to_s().to_i(10) if !(port).nil?
|
158
|
+
@_port = nil if @_port == 0
|
159
|
+
delayLoop = Saklient::Util::get_by_path_any([obj], [
|
160
|
+
'DelayLoop',
|
161
|
+
'delayLoop',
|
162
|
+
'delay_loop',
|
163
|
+
'delay'
|
164
|
+
])
|
165
|
+
@_delay_loop = nil
|
166
|
+
@_delay_loop = (delayLoop).to_s().to_i(10) if !(delayLoop).nil?
|
167
|
+
@_delay_loop = nil if @_delay_loop == 0
|
168
|
+
@_servers = []
|
169
|
+
serversDyn = Saklient::Util::get_by_path_any([obj], ['Servers', 'servers'])
|
170
|
+
if !(serversDyn).nil?
|
171
|
+
servers = serversDyn
|
172
|
+
for server in servers
|
173
|
+
@_servers << Saklient::Cloud::Resources::LbServer.new(server)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
# @param [any] settings
|
179
|
+
# @return [LbServer]
|
180
|
+
def add_server(settings = nil)
|
181
|
+
ret = Saklient::Cloud::Resources::LbServer.new(settings)
|
182
|
+
@_servers << ret
|
183
|
+
return ret
|
184
|
+
end
|
185
|
+
|
186
|
+
# @return [any]
|
187
|
+
def to_raw_settings
|
188
|
+
servers = []
|
189
|
+
for server in @_servers
|
190
|
+
servers << server.to_raw_settings
|
191
|
+
end
|
192
|
+
return {
|
193
|
+
VirtualIPAddress: @_virtual_ip_address,
|
194
|
+
Port: @_port,
|
195
|
+
DelayLoop: @_delay_loop,
|
196
|
+
Servers: servers
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
# @param [String] address
|
201
|
+
# @return [LbServer]
|
202
|
+
def get_server_by_address(address)
|
203
|
+
Saklient::Util::validate_type(address, 'String')
|
204
|
+
for srv in @_servers
|
205
|
+
return srv if srv.ip_address == address
|
206
|
+
end
|
207
|
+
return nil
|
208
|
+
end
|
209
|
+
|
210
|
+
# @param [Array] srvs
|
211
|
+
# @return [LbVirtualIp]
|
212
|
+
def update_status(srvs)
|
213
|
+
Saklient::Util::validate_type(srvs, 'Array')
|
214
|
+
for srvDyn in srvs
|
215
|
+
ip = srvDyn[:IPAddress]
|
216
|
+
srv = get_server_by_address(ip)
|
217
|
+
next if (srv).nil?
|
218
|
+
srv.update_status(srvDyn)
|
219
|
+
end
|
220
|
+
return self
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|