nifty-cloud-sdk 1.7 → 1.8.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +41 -0
- data/README.rdoc +1 -1
- data/lib/NIFTY/Cloud/certificates.rb +10 -5
- data/lib/NIFTY/Cloud/instances.rb +30 -11
- data/lib/NIFTY/Cloud/load_balancers.rb +9 -2
- data/lib/NIFTY/Cloud/volumes.rb +39 -6
- data/lib/NIFTY/config.rb +1 -1
- data/lib/NIFTY/version.rb +1 -1
- data/test/test_Cloud.rb +1 -0
- data/test/test_Cloud_availability_zones.rb +1 -0
- data/test/test_Cloud_certificates.rb +17 -3
- data/test/test_Cloud_images.rb +1 -0
- data/test/test_Cloud_instances.rb +35 -9
- data/test/test_Cloud_keypairs.rb +1 -0
- data/test/test_Cloud_load_balancers.rb +38 -4
- data/test/test_Cloud_responses.rb +1 -0
- data/test/test_Cloud_security_groups.rb +1 -0
- data/test/test_Cloud_volumes.rb +84 -2
- data/test/test_helper.rb +1 -0
- metadata +13 -9
data/CHANGELOG
CHANGED
@@ -2,6 +2,47 @@
|
|
2
2
|
ニフティクラウド SDK for Ruby
|
3
3
|
-----------------------------
|
4
4
|
|
5
|
+
2012-11-12 SDK for Ruby Version.1.8.beta1
|
6
|
+
-------------------------------------------------------------------------------
|
7
|
+
* 1.8.beta1リリース
|
8
|
+
- API Version 1.8 に対応
|
9
|
+
|
10
|
+
API Version.1.8 対応
|
11
|
+
|
12
|
+
* lib/NIFTY/Cloud/certificates.rb
|
13
|
+
* test/test_Cloud_certificates.rb
|
14
|
+
- describe_ssl_certificate_attribute, create_ssl_certificate で certAuthority を指定できるようにする (see #5)
|
15
|
+
|
16
|
+
* lib/NIFTY/Cloud/instances.rb
|
17
|
+
* test/test_Cloud_instances.rb
|
18
|
+
- start_instances, reboot_instances で起動時スクリプトを指定できるようにする (see #1)
|
19
|
+
- NIFTY::Cloud::Base#describe_instance_attribute で nextMonthAccountingType を指定できるように修正する (see #7)
|
20
|
+
- IP タイプに "none" を追加する (see #2)
|
21
|
+
- サーバータイプ large24, large32, extra-large16, extra-large24, extra-large32 を追加する (see #3)
|
22
|
+
|
23
|
+
* lib/NIFTY/Cloud/volumes.rb
|
24
|
+
* test/test_Cloud_volumes.rb
|
25
|
+
- create_volume, modify_volume_attribute で accounting_type を設定できるようにする (see #4)
|
26
|
+
|
27
|
+
* lib/NIFTY/Cloud/load_balancers.rb
|
28
|
+
* test/test_Cloud_load_balancers.rb
|
29
|
+
- create_load_balancer, update_load_balancer で accounting_type を設定できるようにする (see #6)
|
30
|
+
|
31
|
+
その他
|
32
|
+
|
33
|
+
* lib/NIFTY/Cloud/instances.rb
|
34
|
+
* test/test_Cloud_instances.rb
|
35
|
+
- run_instances で Windows のイメージ ID が指定された場合のみ :password を必須とみなすようにする (see #13)
|
36
|
+
|
37
|
+
* lib/NIFTY/config.rb
|
38
|
+
- デフォルトの API エンドポイントを https://cp.cloud.nifty.com/api/1.7/ から https://cp.cloud.nifty.com/api/ へ変更する (see #14)
|
39
|
+
|
40
|
+
* test/test_*.rb
|
41
|
+
- テストコードにマジックコメントでスクリプトエンコーディングを指定する (see #16)
|
42
|
+
|
43
|
+
* lib/NIFTY/version.rb, README.rdoc
|
44
|
+
- VERSIONを変更
|
45
|
+
|
5
46
|
|
6
47
|
2011-07-31 SDK for Ruby Version.1.7
|
7
48
|
-------------------------------------------------------------------------------
|
data/README.rdoc
CHANGED
@@ -115,7 +115,7 @@ http://cloud.nifty.com/api/rest/
|
|
115
115
|
|
116
116
|
[ ACCESS_KEY ] 公開キー (default: '<default access key>')
|
117
117
|
[ SECRET_KEY ] 秘密キー (default: '<default secret key>')
|
118
|
-
[ ENDPOINT_URL ] エンドポイント (default: 'https://cp.cloud.nifty.com/api/
|
118
|
+
[ ENDPOINT_URL ] エンドポイント (default: 'https://cp.cloud.nifty.com/api/')
|
119
119
|
[ PROXY_SERVER ] プロキシサーバーURL (default: nil)
|
120
120
|
[ USER_AGENT ] ユーザーエージェント (default: 'NIFTY Cloud API Ruby SDK')
|
121
121
|
[ MAX_RETRY ] 最大リトライ回数 (default: 3)
|
@@ -3,8 +3,9 @@ module NIFTY
|
|
3
3
|
class Base < NIFTY::Base
|
4
4
|
VALIDITY_TERM = ['6', '12', '24']
|
5
5
|
KEY_LENGTH = ['1024', '2048']
|
6
|
-
CERTIFICATE_DESCRIBE_ATTRIBUTE = ['count', 'certState', 'period', 'keyLength', 'uploadState', 'description', 'certInfo']
|
6
|
+
CERTIFICATE_DESCRIBE_ATTRIBUTE = ['count', 'certState', 'period', 'keyLength', 'uploadState', 'description', 'certInfo', 'certAuthority']
|
7
7
|
FILE_TYPE = ['1', '2', '3']
|
8
|
+
CERT_AUTHORITY = ['1', '2']
|
8
9
|
|
9
10
|
# API「CreateSslCertificate」を実行し、SSL 証明書の新規作成または更新を行います。
|
10
11
|
# 申請法人情報が未登録の場合は、エラーが返されます。
|
@@ -15,6 +16,8 @@ module NIFTY
|
|
15
16
|
#
|
16
17
|
# @option options [String] :fqdn_id SSL証明書の識別子(必須)
|
17
18
|
# @option options [String] :fqdn FQDN(必須)
|
19
|
+
# @option options [Integer] :cert_authority 認証局(必須)
|
20
|
+
# 許可値: 1 (cybertrust) | 2 (GeoTrust)
|
18
21
|
# @option options [Integer] :count SSL証明書の数量(必須)
|
19
22
|
# 許可値: 1 - 30
|
20
23
|
# @option options [Integer] :validity_term SSL証明書の有効月数(必須)
|
@@ -34,6 +37,7 @@ module NIFTY
|
|
34
37
|
def create_ssl_certificate( options={} )
|
35
38
|
raise ArgumentError, ":fqdn_id or :fqdn must be provided." if blank?(options[:fqdn_id]) && blank?(options[:fqdn])
|
36
39
|
unless blank?(options[:fqdn])
|
40
|
+
raise ArgumentError, "No :cert_authority provided." if blank?(options[:cert_authority])
|
37
41
|
raise ArgumentError, "No :count provided." if blank?(options[:count])
|
38
42
|
raise ArgumentError, "No :validity_term provided." if blank?(options[:validity_term])
|
39
43
|
raise ArgumentError, "No :key_length provided." if blank?(options[:key_length])
|
@@ -43,12 +47,13 @@ module NIFTY
|
|
43
47
|
raise ArgumentError, "No :location_name provided." if blank?(options[:location_name])
|
44
48
|
end
|
45
49
|
raise ArgumentError, "Invalid :count provided." unless blank?(options[:count]) || ('1'..'30').to_a.include?(options[:count].to_s)
|
50
|
+
raise ArgumentError, "Invalid :cert_authority provided." unless blank?(options[:cert_authority]) || CERT_AUTHORITY.include?(options[:cert_authority].to_s)
|
46
51
|
raise ArgumentError, "Invalid :validity_term provided." unless blank?(options[:validity_term]) ||
|
47
52
|
VALIDITY_TERM.include?(options[:validity_term].to_s)
|
48
53
|
raise ArgumentError, "Invalid :key_length provided." unless blank?(options[:key_length]) || KEY_LENGTH.include?(options[:key_length].to_s)
|
49
54
|
|
50
55
|
params = {'Action' => 'CreateSslCertificate'}
|
51
|
-
params.merge!(opts_to_prms(options, [:fqdn_id, :fqdn, :count, :validity_term, :key_length]))
|
56
|
+
params.merge!(opts_to_prms(options, [:fqdn_id, :fqdn, :cert_authority, :count, :validity_term, :key_length]))
|
52
57
|
params.merge!(opts_to_prms(options, [:organization_name, :organization_unit_name, :country_name,
|
53
58
|
:state_name, :location_name, :email_address], 'CertInfo'))
|
54
59
|
|
@@ -107,9 +112,9 @@ module NIFTY
|
|
107
112
|
#
|
108
113
|
# @option options [String] :fqdn_id SSL証明書の識別子(必須)
|
109
114
|
# @option options [String] :attribute 取得する情報の項目名
|
110
|
-
# 許可値:
|
111
|
-
#
|
112
|
-
# certInfo(SSL証明書の発行申請情報を取得)
|
115
|
+
# 許可値: certAuthority(SSL証明書の認証局を取得) | count(SSL証明書の数量を取得) | certState(SSL証明書の発行ステータスを取得) |
|
116
|
+
# period(SSL証明書の有効期間を取得) | keyLength(SSL証明書の鍵長を取得) | uploadState(SSL証明書の種別を取得) |
|
117
|
+
# description(SSL証明書のメモ情報を取得) | certInfo(SSL証明書の発行申請情報を取得)
|
113
118
|
#
|
114
119
|
# @return [Hash] レスポンスXML解析結果
|
115
120
|
#
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module NIFTY
|
2
2
|
module Cloud
|
3
3
|
class Base < NIFTY::Base
|
4
|
-
INSTANCE_TYPE = ['mini', 'small', 'small2', 'small4', '
|
4
|
+
INSTANCE_TYPE = ['mini', 'small', 'small2', 'small4', 'small8', 'medium', 'medium4', 'medium8', 'medium16',
|
5
|
+
'large', 'large8', 'large16', 'large24', 'large32', 'extra-large16', 'extra-large24', 'extra-large32']
|
5
6
|
ACCOUNTING_TYPE = ['1', '2']
|
6
7
|
BOOLEAN = ['true', 'false']
|
7
|
-
IP_TYPE = ['static', 'dynamic']
|
8
|
+
IP_TYPE = ['static', 'dynamic', 'none']
|
8
9
|
INSTANCES_DESCRIBE_ATTRIBUTE = [
|
9
|
-
'instanceType', 'disableApiTermination', 'blockDeviceMapping', 'accountingType',
|
10
|
+
'instanceType', 'disableApiTermination', 'blockDeviceMapping', 'accountingType', 'nextMonthAccountingType',
|
10
11
|
'loadbalancing', 'copyInfo', 'autoscaling', 'ipType', 'groupId', 'description']
|
11
12
|
INSTANCES_MODIFY_ATTRIBUTE = ['instanceType', 'disableApiTermination', 'instanceName', 'description', 'ipType', 'groupId']
|
12
13
|
INSTANCES_IGNORED_PARAMS = Regexp.union(/MinCount/,
|
@@ -21,6 +22,7 @@ module NIFTY
|
|
21
22
|
/Monitoring\.Enabled/,
|
22
23
|
/SubnetId/,
|
23
24
|
/InstanceInitiatedShutdownBehavior/)
|
25
|
+
WINDOWS_IMAGE_ID = ['12', '16']
|
24
26
|
|
25
27
|
# API「DescribeInstanceAttribute」を実行し、指定したサーバーの詳細情報を取得します。1回のリクエストで、指定したサーバーのどれか1つの詳細情報を取得できます。
|
26
28
|
# サーバーを指定するためには、サーバー名が必要です。削除済みのサーバーを指定した、管理外のサーバーを指定したなど、
|
@@ -28,7 +30,7 @@ module NIFTY
|
|
28
30
|
#
|
29
31
|
# @option options [String] :instance_id サーバー名(必須)
|
30
32
|
# @option options [String] :attribute 取得対象の項目名
|
31
|
-
# 許可値: instanceType | disableApiTermination | blockDeviceMapping | accountingType | loadbalancing | copyInfo | autoscaling | ipType | groupId | description
|
33
|
+
# 許可値: instanceType | disableApiTermination | blockDeviceMapping | accountingType | nextMonthAccountingType | loadbalancing | copyInfo | autoscaling | ipType | groupId | description
|
32
34
|
# @return [Hash] レスポンスXML解析結果
|
33
35
|
#
|
34
36
|
# @example
|
@@ -75,9 +77,9 @@ module NIFTY
|
|
75
77
|
# description(メモ情報を更新) | ipType(IP アドレスの固定化タイプを更新) | groupId(ファイアウォールグループを更新)
|
76
78
|
#
|
77
79
|
# @option options [String] :value 更新値(必須)
|
78
|
-
# 許可値: (:attribute= instanceType) mini | small | small2 | small4 | medium | medium4 | medium8 | large | large8 | large16
|
80
|
+
# 許可値: (:attribute= instanceType) mini | small | small2 | small4 | small8 | medium | medium4 | medium8 | medium16 | large | large8 | large16 | large24 | large32 | extra-large16 | extra-large24 | extra-large32
|
79
81
|
# (:attribute= disableApiTermination) true | false
|
80
|
-
# (:attribute= ipType) static | dynamic
|
82
|
+
# (:attribute= ipType) static | dynamic | none
|
81
83
|
# @return [Hash] レスポンスXML解析結果
|
82
84
|
#
|
83
85
|
# @example
|
@@ -108,6 +110,9 @@ module NIFTY
|
|
108
110
|
# @option options [Array<String>] :instance_id サーバー名(必須)
|
109
111
|
# @option options [Boolean] :force 強制オプション
|
110
112
|
# 許可値: true(強制実行) | false(強制実行しない)
|
113
|
+
# @option options [String] :user_data サーバー起動時スクリプト
|
114
|
+
# @option options [Boolean] :base64_encoded サーバー起動時スクリプトを自動的にBase64 エンコードするかどうか
|
115
|
+
# 許可値: true(base64エンコーディングする) | false(base64エンコーディングしない)
|
111
116
|
# @return [Hash] レスポンスXML解析結果
|
112
117
|
#
|
113
118
|
# @example
|
@@ -117,11 +122,15 @@ module NIFTY
|
|
117
122
|
raise ArgumentError, "No :instance_id provided." if blank?(options[:instance_id])
|
118
123
|
raise ArgumentError, "Invalid :force provided." unless blank?(options[:force]) || BOOLEAN.include?(options[:force].to_s)
|
119
124
|
|
125
|
+
user_data = extract_user_data(options)
|
126
|
+
options[:user_data] = user_data
|
127
|
+
|
120
128
|
params = {
|
121
129
|
'Action' => 'RebootInstances',
|
122
130
|
'Force' => options[:force].to_s
|
123
131
|
}
|
124
132
|
params.merge!(pathlist('InstanceId', options[:instance_id]))
|
133
|
+
params.merge!(opts_to_prms(options, [:user_data]))
|
125
134
|
|
126
135
|
return response_generator(params)
|
127
136
|
end
|
@@ -136,8 +145,11 @@ module NIFTY
|
|
136
145
|
# @option options [String] :image_id OSイメージID名(必須)
|
137
146
|
# @option options [String] :key_name SSHキー名
|
138
147
|
# @option options [Array<String>] :security_group 適用するファイアフォールグループ名
|
148
|
+
# @option options [String] :user_data サーバー起動時スクリプト
|
149
|
+
# @option options [Boolean] :base64_encoded サーバー起動時スクリプトを自動的にBase64 エンコードするかどうか
|
150
|
+
# 許可値: true(base64エンコーディングする) | false(base64エンコーディングしない)
|
139
151
|
# @option options [String] :instance_type サーバータイプ
|
140
|
-
# 許可値: mini | small | small2 | small4 | medium | medium4 | medium8 | large | large8 | large16
|
152
|
+
# 許可値: mini | small | small2 | small4 | small8 | medium | medium4 | medium8 | medium16 | large | large8 | large16 | large24 | large32 | extra-large16 | extra-large24 | extra-large32
|
141
153
|
# @option options [Boolean] :disable_api_termination APIからのサーバー削除の可否
|
142
154
|
# 許可値: true(削除不可) | false(削除可)
|
143
155
|
# @option options [String] :accounting_type 利用料金タイプ
|
@@ -147,7 +159,7 @@ module NIFTY
|
|
147
159
|
# @option options [String] :password 管理者アカウントパスワード
|
148
160
|
# 許可値: 半角英数字
|
149
161
|
# @option options [String] :ip_type IPアドレスタイプ
|
150
|
-
# 許可値: static | dynamic
|
162
|
+
# 許可値: static | dynamic | none
|
151
163
|
# @return [Hash] レスポンスXML解析結果
|
152
164
|
#
|
153
165
|
# @example
|
@@ -162,7 +174,7 @@ module NIFTY
|
|
162
174
|
raise ArgumentError, "Invalid :key_name provided." unless blank?(options[:key_name]) || ALPHANUMERIC =~ options[:key_name].to_s
|
163
175
|
#raise ArgumentError, "No :security_group provided." if blank?(options[:security_group])
|
164
176
|
raise ArgumentError, "Invalid :security_group provided." unless blank?(options[:security_group]) || GROUP_NAME =~ options[:security_group].to_s
|
165
|
-
raise ArgumentError, "No :password provided." if options[:image_id].to_s
|
177
|
+
raise ArgumentError, "No :password provided." if WINDOWS_IMAGE_ID.include?(options[:image_id].to_s) && blank?(options[:password])
|
166
178
|
raise ArgumentError, "Invalid :password provided." unless blank?(options[:password]) || ALPHANUMERIC =~ options[:password].to_s
|
167
179
|
raise ArgumentError, "Invalid :instance_type provided." unless blank?(options[:instance_type]) || INSTANCE_TYPE.include?(options[:instance_type].to_s)
|
168
180
|
raise ArgumentError, "Invalid :disable_api_termination provided." unless blank?(options[:disable_api_termination]) ||
|
@@ -202,8 +214,11 @@ module NIFTY
|
|
202
214
|
#
|
203
215
|
# @option options [Array<String>] :instance_id サーバー名(必須)
|
204
216
|
# @option options [Array<String>] :instance_type サーバータイプ
|
205
|
-
# 許可値: mini | small | small2 | small4 | medium | medium4 | medium8 | large | large8 | large16
|
217
|
+
# 許可値: mini | small | small2 | small4 | small8 | medium | medium4 | medium8 | medium16 | large | large8 | large16 | large24 | large32 | extra-large16 | extra-large24 | extra-large32
|
206
218
|
# @option options [Array<String>] :accounting_type 利用料金タイプ
|
219
|
+
# @option options [String] :user_data サーバー起動時スクリプト
|
220
|
+
# @option options [Boolean] :base64_encoded サーバー起動時スクリプトを自動的にBase64 エンコードするかどうか
|
221
|
+
# 許可値: true(base64エンコーディングする) | false(base64エンコーディングしない)
|
207
222
|
# @return [Hash] レスポンスXML解析結果
|
208
223
|
#
|
209
224
|
# @example
|
@@ -218,10 +233,14 @@ module NIFTY
|
|
218
233
|
raise ArgumentError, "Invalid :accounting_type provided." unless ACCOUNTING_TYPE.include?(p.to_s)
|
219
234
|
end unless blank?(options[:accounting_type])
|
220
235
|
|
236
|
+
user_data = extract_user_data(options)
|
237
|
+
options[:user_data] = user_data
|
238
|
+
|
221
239
|
params = {'Action' => 'StartInstances'}
|
222
240
|
params.merge!(pathlist('InstanceId', options[:instance_id]))
|
223
241
|
params.merge!(pathlist('InstanceType', options[:instance_type]))
|
224
242
|
params.merge!(pathlist('AccountingType', options[:accounting_type]))
|
243
|
+
params.merge!(opts_to_prms(options, [:user_data]))
|
225
244
|
|
226
245
|
return response_generator(params)
|
227
246
|
end
|
@@ -290,7 +309,7 @@ module NIFTY
|
|
290
309
|
# @option options [String] :instance_id コピー元のサーバー名(必須)
|
291
310
|
# @option options [String] :instance_name コピー後のサーバー名(必須)
|
292
311
|
# @option options [String] :instance_type サーバータイプ
|
293
|
-
# 許可値: mini | small | small2 | small4 | medium | medium4 | medium8 | large | large8 | large16
|
312
|
+
# 許可値: mini | small | small2 | small4 | small8 | medium | medium4 | medium8 | medium16 | large | large8 | large16 | large24 | large32 | extra-large16 | extra-large24 | extra-large32
|
294
313
|
# @option options [String] :accounting_type 利用料金タイプ
|
295
314
|
# 許可値: 1(月額課金) | 2(従量課金)
|
296
315
|
# @option options [Array<Hash>] :load_balancers ロードバランサー設定
|
@@ -80,6 +80,8 @@ module NIFTY
|
|
80
80
|
# 許可値: 10 | 20 | 30 | 40 | 100 | 200 (単位: Mbps)
|
81
81
|
# @option options [String] :ip_version グローバルIP アドレスのバージョン
|
82
82
|
# 許可値: v4
|
83
|
+
# @option options [String] :accounting_type 利用料金タイプ
|
84
|
+
# 許可値: 1(月額課金) | 2(従量課金)
|
83
85
|
# @return [Hash] レスポンスXML解析結果
|
84
86
|
#
|
85
87
|
# @example
|
@@ -99,8 +101,9 @@ module NIFTY
|
|
99
101
|
end
|
100
102
|
raise ArgumentError, "Invalid :network_volume provided." unless blank?(options[:network_volume]) || NETWORK_VOLUMES.include?(options[:network_volume].to_s)
|
101
103
|
raise ArgumentError, "Invalid :ip_version provided." unless blank?(options[:ip_version]) || IP_VERSION.include?(options[:ip_version].to_s)
|
104
|
+
raise ArgumentError, "Invalid :accounting_type provided." unless blank?(options[:accounting_type]) || ACCOUNTING_TYPE.include?(options[:accounting_type].to_s)
|
102
105
|
params = {'Action' => 'CreateLoadBalancer'}
|
103
|
-
params.merge!(opts_to_prms(options, [:load_balancer_name, :network_volume, :ip_version]))
|
106
|
+
params.merge!(opts_to_prms(options, [:load_balancer_name, :network_volume, :ip_version, :accounting_type]))
|
104
107
|
params.merge!(pathhashlist('Listeners.member', options[:listeners],
|
105
108
|
{:protocol => 'Protocol',
|
106
109
|
:load_balancer_port => 'LoadBalancerPort',
|
@@ -387,6 +390,8 @@ module NIFTY
|
|
387
390
|
# 許可値: 1(Round-Robin) | 2(Least-Connection)
|
388
391
|
# @option options [String] :network_volume_update 最大ネットワーク流量の更新値
|
389
392
|
# 許可値: 10 | 20 | 30 | 40 | 100 | 200 (単位: Mbps)
|
393
|
+
# @option options [String] :accounting_type_update 利用料金タイプ
|
394
|
+
# 許可値: 1(月額課金) | 2(従量課金)
|
390
395
|
# @return [Hash] レスポンスXML解析結果
|
391
396
|
#
|
392
397
|
# @example
|
@@ -415,6 +420,8 @@ module NIFTY
|
|
415
420
|
BALANCING_TYPE.include?(options[:listener_balancing_type].to_s)
|
416
421
|
raise ArgumentError, "Invalid :network_volume_update provided." unless blank?(options[:network_volume_update]) ||
|
417
422
|
NETWORK_VOLUMES.include?(options[:network_volume_update].to_s)
|
423
|
+
raise ArgumentError, "Invalid :accounting_type_update provided." unless blank?(options[:accounting_type_update]) ||
|
424
|
+
ACCOUNTING_TYPE.include?(options[:accounting_type_update].to_s)
|
418
425
|
|
419
426
|
params = {
|
420
427
|
'Action' => 'UpdateLoadBalancer',
|
@@ -423,7 +430,7 @@ module NIFTY
|
|
423
430
|
'ListenerUpdate.Listener.InstancePort' => options[:listener_instance_port].to_s,
|
424
431
|
'ListenerUpdate.Listener.BalancingType' => options[:listener_balancing_type].to_s
|
425
432
|
}
|
426
|
-
params.merge!(opts_to_prms(options, [:load_balancer_name, :network_volume_update]))
|
433
|
+
params.merge!(opts_to_prms(options, [:load_balancer_name, :network_volume_update, :accounting_type_update]))
|
427
434
|
params.merge!(opts_to_prms(options, [:load_balancer_port, :instance_port], 'ListenerUpdate'))
|
428
435
|
|
429
436
|
return response_generator(params)
|
data/lib/NIFTY/Cloud/volumes.rb
CHANGED
@@ -7,6 +7,7 @@ module NIFTY
|
|
7
7
|
/AvailabilityZone/,
|
8
8
|
/Device/,
|
9
9
|
/Force/)
|
10
|
+
VOLUMES_MODIFY_ATTRIBUTE = ['accountingType']
|
10
11
|
|
11
12
|
# API「AttachVolume」を実行し、指定したディスクをサーバーへ接続します。
|
12
13
|
# ディスクを指定するためには、ディスク名が必要です。接続済み・削除済みのディスクを指定した、管理外のディスクを指定したなど、
|
@@ -39,26 +40,29 @@ module NIFTY
|
|
39
40
|
# 以外のサーバーを指定したなど、無効なサーバーを指定した場合は、エラーが返されます。同様に、ディスクサイズおよびディスク
|
40
41
|
# タイプに規定外の値を指定した、すでに存在するディスク名を指定したなどの場合は、エラーが返されます。
|
41
42
|
#
|
42
|
-
# @option options [String] :size
|
43
|
+
# @option options [String] :size ディスクサイズ(必須)
|
43
44
|
# 許可値: (低速) 1(100) | 2(200) | 3(300) | 4(400) | 5(500) | 10(1000) | 15(1500) | 20(2000)
|
44
45
|
# (高速) 1(100) | 2(200) | 3(300) | 4(400) | 5(500) | 6(600) | 7(700) | 8(800) | 9(900) | 10(1000) (単位: GB)
|
45
|
-
# @option options [String] :volume_id
|
46
|
-
# @option options [String] :disk_type
|
46
|
+
# @option options [String] :volume_id ディスク名
|
47
|
+
# @option options [String] :disk_type ディスクタイプ
|
47
48
|
# 許可値: 1(disk100) | 2(disk40) | 3(disk100A) | 4(disk100B) | 5(disk40A) | 6(disk40B)
|
48
|
-
# @option options [String] :instance_id
|
49
|
+
# @option options [String] :instance_id サーバー名(必須)
|
50
|
+
# @option options [String] :accounting_type 利用料金タイプ
|
51
|
+
# 許可値: 1(月額課金) | 2(従量課金)
|
49
52
|
# @return [Hash] レスポンスXML解析結果
|
50
53
|
#
|
51
54
|
# @example
|
52
|
-
# create_volume(:size => 1, :volume_id => 'vol1', :disk_type => 1, :instance_id => 'server01')
|
55
|
+
# create_volume(:size => 1, :volume_id => 'vol1', :disk_type => 1, :instance_id => 'server01', :accounting_type => 1)
|
53
56
|
#
|
54
57
|
def create_volume( options = {} )
|
55
58
|
raise ArgumentError, "No :size provided." if blank?(options[:size])
|
56
59
|
raise ArgumentError, "No :instance_id provided." if blank?(options[:instance_id])
|
57
60
|
raise ArgumentError, "Invalid :size provided." unless blank?(options[:size]) || VOLUMES_CREATE_SIZE.include?(options[:size].to_s)
|
58
61
|
raise ArgumentError, "Invalid :disk_type provided." unless blank?(options[:disk_type]) || VOLUMES_CREATE_DISK_TYPE.include?(options[:disk_type].to_s)
|
62
|
+
raise ArgumentError, "Invalid :accounting_type provided." unless blank?(options[:accounting_type]) || ACCOUNTING_TYPE.include?(options[:accounting_type].to_s)
|
59
63
|
|
60
64
|
params = {'Action' => 'CreateVolume'}
|
61
|
-
params.merge!(opts_to_prms(options, [:size, :snapshot_id, :availability_zone, :volume_id, :disk_type, :instance_id]))
|
65
|
+
params.merge!(opts_to_prms(options, [:size, :snapshot_id, :availability_zone, :volume_id, :disk_type, :instance_id, :accounting_type]))
|
62
66
|
|
63
67
|
params.reject! {|k, v| VOLUMES_IGNORED_PARAMS =~ k } if @@ignore_amz_params
|
64
68
|
|
@@ -134,6 +138,35 @@ module NIFTY
|
|
134
138
|
|
135
139
|
return response_generator(params)
|
136
140
|
end
|
141
|
+
|
142
|
+
|
143
|
+
# API「ModifyVolumeAttribute」を実行し、指定したディスクの詳細情報を更新します。利用料金タイプの更新は次月から適用されます。
|
144
|
+
#
|
145
|
+
# @option options [String] :instance_id サーバー名(必須)
|
146
|
+
# @option options [String] :attribute 更新対象の項目名(必須)
|
147
|
+
# 許可値: accountingType(利用料金タイプを更新)
|
148
|
+
#
|
149
|
+
# @option options [String] :value 更新値(必須)
|
150
|
+
# 許可値: (:attribute= accountingType) 1(月額課金) | 2(従量課金)
|
151
|
+
# @return [Hash] レスポンスXML解析結果
|
152
|
+
#
|
153
|
+
# @example
|
154
|
+
# modify_volume_attribute(:volume_id => 'vol01', :attribute => 'accountingType', :value => '1')
|
155
|
+
#
|
156
|
+
def modify_volume_attribute( options = {} )
|
157
|
+
raise ArgumentError, "No :volume_id provided." if blank?(options[:volume_id])
|
158
|
+
raise ArgumentError, "No :attribute provided." if blank?(options[:attribute])
|
159
|
+
raise ArgumentError, "Invalid :attribute provided." unless VOLUMES_MODIFY_ATTRIBUTE.include?(options[:attribute].to_s)
|
160
|
+
raise ArgumentError, "No :value provided." if blank?(options[:value])
|
161
|
+
raise ArgumentError, "Invalid :value provided." if options[:attribute] == 'accountingType' && !ACCOUNTING_TYPE.include?(options[:value].to_s)
|
162
|
+
|
163
|
+
params = {'Action' => 'ModifyVolumeAttribute'}
|
164
|
+
params.merge!(opts_to_prms(options, [:volume_id, :attribute, :value]))
|
165
|
+
|
166
|
+
params.reject! {|k, v| VOLUMES_IGNORED_PARAMS =~ k } if @@ignore_amz_params
|
167
|
+
|
168
|
+
return response_generator(params)
|
169
|
+
end
|
137
170
|
end
|
138
171
|
end
|
139
172
|
end
|
data/lib/NIFTY/config.rb
CHANGED
@@ -14,7 +14,7 @@ module NIFTY
|
|
14
14
|
# APIのエンドポイント
|
15
15
|
# @example
|
16
16
|
# 'https://example.com/test/'
|
17
|
-
ENDPOINT_URL = ENV['NIFTY_CLOUD_ENDPOINT_URL'] || 'https://cp.cloud.nifty.com/api/
|
17
|
+
ENDPOINT_URL = ENV['NIFTY_CLOUD_ENDPOINT_URL'] || 'https://cp.cloud.nifty.com/api/'
|
18
18
|
|
19
19
|
# プロキシサーバーのURL(デフォルト: nil)
|
20
20
|
# 形式: //<username>:<password>@<hostname>:<port>
|
data/lib/NIFTY/version.rb
CHANGED
data/test/test_Cloud.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding:utf-8
|
1
2
|
#--
|
2
3
|
# ニフティクラウドSDK for Ruby
|
3
4
|
#
|
@@ -23,15 +24,16 @@ context "certificates" do
|
|
23
24
|
:post_name => 'post', :division_name => 'div'
|
24
25
|
}
|
25
26
|
@basic_create_ssl_cert = {
|
26
|
-
:fqdn => 'ccc.aaa.com', :count => 1, :validity_term => 6, :key_length => 1024, :organization_name => 'org',
|
27
|
+
:fqdn => 'ccc.aaa.com', :cert_authority => 1, :count => 1, :validity_term => 6, :key_length => 1024, :organization_name => 'org',
|
27
28
|
:organization_unit_name => 'orgunit', :state_name => 'TOKYO', :location_name => 'loc'
|
28
29
|
}
|
29
30
|
@basic_upload_ssl_cert = {:certificate => 'cert', :key => 'key'}
|
30
31
|
|
31
32
|
@valid_validity_term = [6, 12, 24, '6', '12', '24']
|
32
33
|
@valid_key_length = [1024, 2048, '1024', '2048']
|
33
|
-
@valid_attribute = %w(count certState period keyLength uploadState description certInfo)
|
34
|
+
@valid_attribute = %w(certAuthority count certState period keyLength uploadState description certInfo)
|
34
35
|
@valid_file_type = [1, 2, 3, '1', '2', '3']
|
36
|
+
@valid_cert_authority = [1, 2, '1', '2']
|
35
37
|
|
36
38
|
@register_corporate_info_for_certificate_response_body = <<-RESPONSE
|
37
39
|
<RegisterCorporateInfoForCertificateResponse xmlns="https://cp.cloud.nifty.com/api/">
|
@@ -311,6 +313,7 @@ context "certificates" do
|
|
311
313
|
@api.stubs(:make_request).with("Action" => "CreateSslCertificate",
|
312
314
|
"FqdnId" => "a",
|
313
315
|
"Fqdn" => "aaa.aaa.aaa",
|
316
|
+
"CertAuthority" => "1",
|
314
317
|
"Count" => "1",
|
315
318
|
"ValidityTerm" => "6",
|
316
319
|
"KeyLength" => "1024",
|
@@ -322,7 +325,7 @@ context "certificates" do
|
|
322
325
|
"CertInfo.EmailAddress" => "a"
|
323
326
|
).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
|
324
327
|
@api.stubs(:exec_request).returns stub(:body => @create_ssl_certificate_response_body, :is_a? => true)
|
325
|
-
response = @api.create_ssl_certificate(:fqdn_id => "a", :fqdn => "aaa.aaa.aaa", :count => 1, :validity_term => 6, :key_length => 1024, :organization_name => "a", :organization_unit_name => "a", :country_name => "a", :state_name => "a", :location_name => "a", :email_address => "a")
|
328
|
+
response = @api.create_ssl_certificate(:fqdn_id => "a", :fqdn => "aaa.aaa.aaa", :cert_authority => 1, :count => 1, :validity_term => 6, :key_length => 1024, :organization_name => "a", :organization_unit_name => "a", :country_name => "a", :state_name => "a", :location_name => "a", :email_address => "a")
|
326
329
|
end
|
327
330
|
|
328
331
|
specify "create_ssl_certificate - :fqdn_id正常" do
|
@@ -336,6 +339,9 @@ context "certificates" do
|
|
336
339
|
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => 15)) }.should.not.raise(NIFTY::ArgumentError)
|
337
340
|
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => 30)) }.should.not.raise(NIFTY::ArgumentError)
|
338
341
|
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => '20')) }.should.not.raise(NIFTY::ArgumentError)
|
342
|
+
@valid_cert_authority.each do |ca|
|
343
|
+
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:cert_authority => ca)) }.should.not.raise(NIFTY::ArgumentError)
|
344
|
+
end
|
339
345
|
@valid_validity_term.each do |term|
|
340
346
|
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:validity_term => term)) }.should.not.raise(NIFTY::ArgumentError)
|
341
347
|
end
|
@@ -364,6 +370,14 @@ context "certificates" do
|
|
364
370
|
lambda { @api.create_ssl_certificate(:fqdn_id => '', :fqdn => '') }.should.raise(NIFTY::ArgumentError)
|
365
371
|
end
|
366
372
|
|
373
|
+
specify "create_ssl_certificate - :cert_authority未指定/不正" do
|
374
|
+
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :cert_authority}) }.should.raise(NIFTY::ArgumentError)
|
375
|
+
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:cert_authority => nil)) }.should.raise(NIFTY::ArgumentError)
|
376
|
+
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:cert_authority => '')) }.should.raise(NIFTY::ArgumentError)
|
377
|
+
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:cert_authority => 'hoge')) }.should.raise(NIFTY::ArgumentError)
|
378
|
+
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:cert_authority => 3)) }.should.raise(NIFTY::ArgumentError)
|
379
|
+
end
|
380
|
+
|
367
381
|
specify "create_ssl_certificate - :count未指定" do
|
368
382
|
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.reject{|k,v| k == :count}) }.should.raise(NIFTY::ArgumentError)
|
369
383
|
lambda { @api.create_ssl_certificate(@basic_create_ssl_cert.merge(:count => nil)) }.should.raise(NIFTY::ArgumentError)
|
data/test/test_Cloud_images.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding:utf-8
|
1
2
|
#--
|
2
3
|
# ニフティクラウドSDK for Ruby
|
3
4
|
#
|
@@ -16,9 +17,11 @@ context "instances" do
|
|
16
17
|
@api = NIFTY::Cloud::Base.new( :access_key_id => "not a key", :secret_access_key => "not a secret",
|
17
18
|
:server => 'cp.cloud.nifty.com', :path => '/api/1.7/', :user_agent => 'NIFTY Cloud API Ruby SDK',
|
18
19
|
:signature_version => '2', :signature_method => 'HmacSHA256')
|
19
|
-
@valid_instance_type = %w(mini small small2 small4 medium medium4 medium8
|
20
|
-
|
20
|
+
@valid_instance_type = %w(mini small small2 small4 small8 medium medium4 medium8 medium16
|
21
|
+
large large8 large16 large24 large32 extra-large16 extra-large24 extra-large32)
|
22
|
+
@valid_ip_type = %w(static dynamic none)
|
21
23
|
@accounting_type = [1, 2, '1', '2']
|
24
|
+
@windows_image_id = [12, 16, '12', '16']
|
22
25
|
|
23
26
|
@basic_run_instances_options = {:security_group => "gr01", :image_id => 2, :key_name => 'foo', :password => 'password'}
|
24
27
|
|
@@ -304,6 +307,7 @@ context "instances" do
|
|
304
307
|
disableApiTermination
|
305
308
|
blockDeviceMapping
|
306
309
|
accountingType
|
310
|
+
nextMonthAccountingType
|
307
311
|
loadbalancing
|
308
312
|
copyInfo
|
309
313
|
autoscaling
|
@@ -623,9 +627,15 @@ context "instances" do
|
|
623
627
|
end
|
624
628
|
|
625
629
|
specify "run_instances - :password未指定/不正" do
|
626
|
-
|
627
|
-
lambda { @api.run_instances(:image_id => 1
|
628
|
-
lambda { @api.run_instances(:image_id => 1, :password =>
|
630
|
+
@api.stubs(:exec_request).returns stub(:body => @run_instances_response_body, :is_a? => true)
|
631
|
+
lambda { @api.run_instances(@basic_run_instances_options.merge(:image_id => 1)) }.should.not.raise(NIFTY::ArgumentError)
|
632
|
+
lambda { @api.run_instances(@basic_run_instances_options.merge(:image_id => 1, :password => nil)) }.should.not.raise(NIFTY::ArgumentError)
|
633
|
+
lambda { @api.run_instances(@basic_run_instances_options.merge(:image_id => 1, :password => '')) }.should.not.raise(NIFTY::ArgumentError)
|
634
|
+
@windows_image_id.each do |image_id|
|
635
|
+
lambda { @api.run_instances(:image_id => image_id) }.should.raise(NIFTY::ArgumentError)
|
636
|
+
lambda { @api.run_instances(:image_id => image_id, :password => nil) }.should.raise(NIFTY::ArgumentError)
|
637
|
+
lambda { @api.run_instances(:image_id => image_id, :password => '') }.should.raise(NIFTY::ArgumentError)
|
638
|
+
end
|
629
639
|
lambda { @api.run_instances(:image_id => 1, :password => 'Pass_word') }.should.raise(NIFTY::ArgumentError)
|
630
640
|
end
|
631
641
|
|
@@ -654,10 +664,11 @@ context "instances" do
|
|
654
664
|
'InstanceType.1' => 'mini',
|
655
665
|
'InstanceType.2' => 'mini',
|
656
666
|
'AccountingType.1' => '1',
|
657
|
-
'AccountingType.2' => '1'
|
667
|
+
'AccountingType.2' => '1',
|
668
|
+
'UserData' => 'data'
|
658
669
|
).returns stub(:body => @start_instances_response_body, :is_a? => true)
|
659
670
|
@api.stubs(:exec_request).returns stub(:body => @start_instances_response_body, :is_a? => true)
|
660
|
-
response = @api.start_instances( :instance_id => %w(server01 server02), :instance_type => %w(mini mini), :accounting_type => %w(1 1) )
|
671
|
+
response = @api.start_instances( :instance_id => %w(server01 server02), :instance_type => %w(mini mini), :accounting_type => %w(1 1), :user_data => 'data')
|
661
672
|
end
|
662
673
|
|
663
674
|
specify "start_instances - :instance_id未指定" do
|
@@ -690,6 +701,13 @@ context "instances" do
|
|
690
701
|
lambda { @api.start_instances(:instance_id => 'i-10a64379', :accounting_type => 'foo') }.should.raise(NIFTY::ArgumentError)
|
691
702
|
end
|
692
703
|
|
704
|
+
specify "start_instances - :user_data正常" do
|
705
|
+
@api.stubs(:exec_request).returns stub(:body => @start_instances_response_body, :is_a? => true)
|
706
|
+
lambda { @api.start_instances(:instance_id => 'i-10a64379', :user_data => 'data') }.should.not.raise(NIFTY::ArgumentError)
|
707
|
+
lambda { @api.start_instances(:instance_id => 'i-10a64379', :user_data => 'data', :base64_encoded => true) }.should.not.raise(NIFTY::ArgumentError)
|
708
|
+
lambda { @api.start_instances(:instance_id => 'i-10a64379', :user_data => 'data', :base64_encoded => false) }.should.not.raise(NIFTY::ArgumentError)
|
709
|
+
end
|
710
|
+
|
693
711
|
|
694
712
|
# stop_instances
|
695
713
|
specify "stop_instances - レスポンスを正しく解析できるか" do
|
@@ -745,10 +763,11 @@ context "instances" do
|
|
745
763
|
@api.stubs(:make_request).with('Action' => 'RebootInstances',
|
746
764
|
'InstanceId.1' => 'server01',
|
747
765
|
'InstanceId.2' => 'server02',
|
748
|
-
'Force' => 'false'
|
766
|
+
'Force' => 'false',
|
767
|
+
'UserData' => 'data'
|
749
768
|
).returns stub(:body => @reboot_instances_response_body, :is_a? => true)
|
750
769
|
@api.stubs(:exec_request).returns stub(:body => @reboot_instances_response_body, :is_a? => true)
|
751
|
-
response = @api.reboot_instances( :instance_id => %w(server01 server02), :force => false )
|
770
|
+
response = @api.reboot_instances( :instance_id => %w(server01 server02), :force => false, :user_data => 'data' )
|
752
771
|
end
|
753
772
|
|
754
773
|
specify "reboot_instances - :force正常" do
|
@@ -759,6 +778,13 @@ context "instances" do
|
|
759
778
|
lambda { @api.reboot_instances(:instance_id => 'i-28a64341', :force => nil) }.should.not.raise(NIFTY::ArgumentError)
|
760
779
|
end
|
761
780
|
|
781
|
+
specify "reboot_instances - :user_data正常" do
|
782
|
+
@api.stubs(:exec_request).returns stub(:body => @reboot_instances_response_body, :is_a? => true)
|
783
|
+
lambda { @api.reboot_instances(:instance_id => 'i-28a64341', :user_data => 'data') }.should.not.raise(NIFTY::ArgumentError)
|
784
|
+
lambda { @api.reboot_instances(:instance_id => 'i-28a64341', :user_data => 'data', :base64_encoded => true) }.should.not.raise(NIFTY::ArgumentError)
|
785
|
+
lambda { @api.reboot_instances(:instance_id => 'i-28a64341', :user_data => 'data', :base64_encoded => false) }.should.not.raise(NIFTY::ArgumentError)
|
786
|
+
end
|
787
|
+
|
762
788
|
specify "reboot_instances - :instance_id未指定" do
|
763
789
|
lambda { @api.reboot_instances }.should.raise(NIFTY::ArgumentError)
|
764
790
|
lambda { @api.reboot_instances(:instance_id => nil) }.should.raise(NIFTY::ArgumentError)
|
data/test/test_Cloud_keypairs.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding:utf-8
|
1
2
|
#--
|
2
3
|
# ニフティクラウドSDK for Ruby
|
3
4
|
#
|
@@ -21,6 +22,7 @@ context "load_balancers" do
|
|
21
22
|
@valid_balancing_type = [1, 2, '1', '2']
|
22
23
|
@valid_network_volume = [10, 20, 30, 40, 100, 200, '10', '20', '30', '40', '100', '200']
|
23
24
|
@valid_ip_version = %w(v4 v6)
|
25
|
+
@accounting_type = %w(1 2)
|
24
26
|
|
25
27
|
@basic_create_lb_params = {
|
26
28
|
:load_balancer_name => 'lb01',
|
@@ -132,6 +134,8 @@ context "load_balancers" do
|
|
132
134
|
<member>ap-japan-1a</member>
|
133
135
|
</AvailabilityZones>
|
134
136
|
<CreatedTime>2010-05-17T11:22:33.456Z</CreatedTime>
|
137
|
+
<AccountingType>1</AccountingType>
|
138
|
+
<NextMonthAccountingType>1</NextMonthAccountingType>
|
135
139
|
</member>
|
136
140
|
</LoadBalancerDescriptions>
|
137
141
|
<LoadBalancerDescriptions>
|
@@ -170,6 +174,8 @@ context "load_balancers" do
|
|
170
174
|
<member>ap-japan-1a</member>
|
171
175
|
</AvailabilityZones>
|
172
176
|
<CreatedTime>2010-05-17T11:22:43.789Z</CreatedTime>
|
177
|
+
<AccountingType>1</AccountingType>
|
178
|
+
<NextMonthAccountingType>1</NextMonthAccountingType>
|
173
179
|
</member>
|
174
180
|
</LoadBalancerDescriptions>
|
175
181
|
</DescribeLoadBalancersResult>
|
@@ -319,10 +325,11 @@ context "load_balancers" do
|
|
319
325
|
"AvailabilityZones.member.1" => "a",
|
320
326
|
"AvailabilityZones.member.2" => "a",
|
321
327
|
"NetworkVolume" => "10",
|
322
|
-
"IpVersion" => "v4"
|
328
|
+
"IpVersion" => "v4",
|
329
|
+
"AccountingType" => "1"
|
323
330
|
).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
324
331
|
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
325
|
-
response = @api.create_load_balancer(:load_balancer_name => "a", :listeners => [{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1},{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1}], :availability_zones => %w(a a), :network_volume => 10, :ip_version => "v4")
|
332
|
+
response = @api.create_load_balancer(:load_balancer_name => "a", :listeners => [{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1},{:protocol => "HTTP", :load_balancer_port => 80, :instance_port => 80, :balancing_type => 1}], :availability_zones => %w(a a), :network_volume => 10, :ip_version => "v4", :accounting_type => "1")
|
326
333
|
end
|
327
334
|
|
328
335
|
specify "create_load_balancer - :listeners - :protocol正常" do
|
@@ -367,6 +374,15 @@ context "load_balancers" do
|
|
367
374
|
end
|
368
375
|
end
|
369
376
|
|
377
|
+
specify "create_load_balancer - :accounting_type正常" do
|
378
|
+
@api.stubs(:exec_request).returns stub(:body => @create_load_balancer_response_body, :is_a? => true)
|
379
|
+
|
380
|
+
@accounting_type.each do |type|
|
381
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:accounting_type => type)) }.should.not.raise(NIFTY::ArgumentError)
|
382
|
+
end
|
383
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:accounting_type => '')) }.should.not.raise(NIFTY::ArgumentError)
|
384
|
+
end
|
385
|
+
|
370
386
|
specify "create_load_balancer - :load_balancer_name未指定" do
|
371
387
|
lambda { @api.create_load_balancer }.should.raise(NIFTY::ArgumentError)
|
372
388
|
lambda { @api.create_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
@@ -404,6 +420,11 @@ context "load_balancers" do
|
|
404
420
|
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:ip_version => 'v5')) }.should.raise(NIFTY::ArgumentError)
|
405
421
|
end
|
406
422
|
|
423
|
+
specify "create_load_balancer - :accounting_type不正" do
|
424
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:accounting_type => 'foo')) }.should.raise(NIFTY::ArgumentError)
|
425
|
+
lambda { @api.create_load_balancer(@basic_create_lb_params.merge(:accounting_type => '3')) }.should.raise(NIFTY::ArgumentError)
|
426
|
+
end
|
427
|
+
|
407
428
|
|
408
429
|
# update_load_balancer
|
409
430
|
specify "update_load_balancer - レスポンスを正しく解析できるか" do
|
@@ -421,10 +442,11 @@ context "load_balancers" do
|
|
421
442
|
"ListenerUpdate.Listener.LoadBalancerPort" => "80",
|
422
443
|
"ListenerUpdate.Listener.InstancePort" => "80",
|
423
444
|
"ListenerUpdate.Listener.BalancingType" => "1",
|
424
|
-
"NetworkVolumeUpdate" => "10"
|
445
|
+
"NetworkVolumeUpdate" => "10",
|
446
|
+
"AccountingTypeUpdate" => "1"
|
425
447
|
).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
426
448
|
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
427
|
-
response = @api.update_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :listener_protocol => "HTTP", :listener_load_balancer_port => 80, :listener_instance_port => 80, :listener_balancing_type => 1, :network_volume_update => 10)
|
449
|
+
response = @api.update_load_balancer(:load_balancer_name => "a", :load_balancer_port => 80, :instance_port => 80, :listener_protocol => "HTTP", :listener_load_balancer_port => 80, :listener_instance_port => 80, :listener_balancing_type => 1, :network_volume_update => 10, :accounting_type_update => 1)
|
428
450
|
end
|
429
451
|
|
430
452
|
specify "update_load_balancer - :load_balancer_port正常" do
|
@@ -476,6 +498,13 @@ context "load_balancers" do
|
|
476
498
|
end
|
477
499
|
end
|
478
500
|
|
501
|
+
specify "update_load_balancer - :accounting_type_update正常" do
|
502
|
+
@api.stubs(:exec_request).returns stub(:body => @update_load_balancer_response_body, :is_a? => true)
|
503
|
+
@accounting_type.each do |type|
|
504
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :accounting_type_update => type) }.should.not.raise(NIFTY::ArgumentError)
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
479
508
|
specify "update_load_balancer - :load_balancer_name未指定" do
|
480
509
|
lambda { @api.update_load_balancer }.should.raise(NIFTY::ArgumentError)
|
481
510
|
lambda { @api.update_load_balancer(:load_balancer_name => nil) }.should.raise(NIFTY::ArgumentError)
|
@@ -523,6 +552,11 @@ context "load_balancers" do
|
|
523
552
|
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :network_volume_update => 'foo') }.should.raise(NIFTY::ArgumentError)
|
524
553
|
end
|
525
554
|
|
555
|
+
specify "update_load_balancer - :accounting_type_update不正" do
|
556
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :accounting_type_update => 3) }.should.raise(NIFTY::ArgumentError)
|
557
|
+
lambda { @api.update_load_balancer(:load_balancer_name => 'lb1', :accounting_type_update => 'foo') }.should.raise(NIFTY::ArgumentError)
|
558
|
+
end
|
559
|
+
|
526
560
|
|
527
561
|
# delete_load_balancer
|
528
562
|
specify "delete_load_balancer - レスポンスを正しく解析できるか" do
|
data/test/test_Cloud_volumes.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding:utf-8
|
1
2
|
#--
|
2
3
|
# ニフティクラウドSDK for Ruby
|
3
4
|
#
|
@@ -25,6 +26,7 @@ context "volumes" do
|
|
25
26
|
1, 2, 3, 4, 5, 6
|
26
27
|
]
|
27
28
|
@basic_create_volume_options = {:size => 1, :instance_id => 'server01'}
|
29
|
+
@accounting_type = ['1', '2']
|
28
30
|
|
29
31
|
@describe_volumes_response_body = <<-RESPONSE
|
30
32
|
<DescribeVolumesResponse xmlns="http://xxxx.nifty.com/xxx/xxx/">
|
@@ -35,6 +37,8 @@ context "volumes" do
|
|
35
37
|
<diskType>Disk40</diskType>
|
36
38
|
<snapshotId/>
|
37
39
|
<availabilityZone>ap-japan-1a</availabilityZone>
|
40
|
+
<accountingType>1</accountingType>
|
41
|
+
<nextMonthAccountingType>1</nextMonthAccountingType>
|
38
42
|
<status>in-use</status>
|
39
43
|
<createTime>2008-05-07T11:51:50.000Z</createTime>
|
40
44
|
<attachmentSet>
|
@@ -59,6 +63,7 @@ context "volumes" do
|
|
59
63
|
<availabilityZone>ap-japan-1a</availabilityZone>
|
60
64
|
<status>creating</status>
|
61
65
|
<createTime>2008-05-07T11:51:50.000Z</createTime>
|
66
|
+
<accountingType>1</accountingType>
|
62
67
|
</CreateVolumeResponse>
|
63
68
|
RESPONSE
|
64
69
|
|
@@ -87,6 +92,13 @@ context "volumes" do
|
|
87
92
|
<attachTime>2008-05-08T11:51:50.000Z</attachTime>
|
88
93
|
</DetachVolumeResponse>
|
89
94
|
RESPONSE
|
95
|
+
|
96
|
+
@modify_volume_attribute_response_body = <<-RESPONSE
|
97
|
+
<ModifyVolumeAttributeResponse xmlns="http://xxxx.nifty.com/xxx/xxx/">
|
98
|
+
<requestId></requestId>
|
99
|
+
<return>true</return>
|
100
|
+
</ModifyVolumeAttributeResponse>
|
101
|
+
RESPONSE
|
90
102
|
end
|
91
103
|
|
92
104
|
# describe_volumes
|
@@ -142,10 +154,11 @@ context "volumes" do
|
|
142
154
|
"AvailabilityZone" => "a",
|
143
155
|
"VolumeId" => "a",
|
144
156
|
"DiskType" => "1",
|
145
|
-
"InstanceId" => "a"
|
157
|
+
"InstanceId" => "a",
|
158
|
+
"AccountingType" => "1"
|
146
159
|
).returns stub(:body => @create_volume_response_body, :is_a? => true)
|
147
160
|
@api.stubs(:exec_request).returns stub(:body => @create_volume_response_body, :is_a? => true)
|
148
|
-
response = @api.create_volume(:instance_id => "a", :size => 1, :snapshot_id => "a", :availability_zone => "a", :volume_id => "a", :disk_type => 1 )
|
161
|
+
response = @api.create_volume(:instance_id => "a", :size => 1, :snapshot_id => "a", :availability_zone => "a", :volume_id => "a", :disk_type => 1, :accounting_type => 1)
|
149
162
|
end
|
150
163
|
|
151
164
|
specify "create_volume - :size, instance_id正常" do
|
@@ -179,6 +192,13 @@ context "volumes" do
|
|
179
192
|
lambda { @api.create_volume(@basic_create_volume_options.merge(:disk_type => type)) }.should.not.raise(NIFTY::ArgumentError)
|
180
193
|
end
|
181
194
|
end
|
195
|
+
|
196
|
+
specify "create_volume - :disk_type正常" do
|
197
|
+
@api.stubs(:exec_request).returns stub(:body => @create_volume_response_body, :is_a? => true)
|
198
|
+
@accounting_type.each do |type|
|
199
|
+
lambda { @api.create_volume(@basic_create_volume_options.merge(:accounting_type => type)) }.should.not.raise(NIFTY::ArgumentError)
|
200
|
+
end
|
201
|
+
end
|
182
202
|
|
183
203
|
specify "create_volume - :size未指定" do
|
184
204
|
lambda { @api.create_volume }.should.raise(NIFTY::ArgumentError)
|
@@ -197,6 +217,11 @@ context "volumes" do
|
|
197
217
|
lambda { @api.create_volume(:size => 1, :key_name => '') }.should.raise(NIFTY::ArgumentError)
|
198
218
|
end
|
199
219
|
|
220
|
+
specify "create_volume - :accounting_type不正" do
|
221
|
+
lambda { @api.create_volume(@basic_create_volume_options.merge(:accounting_type => 'type')) }.should.raise(NIFTY::ArgumentError)
|
222
|
+
lambda { @api.create_volume(@basic_create_volume_options.merge(:accounting_type => 3)) }.should.raise(NIFTY::ArgumentError)
|
223
|
+
end
|
224
|
+
|
200
225
|
|
201
226
|
# delete_volume
|
202
227
|
specify "delete_volume - レスポンスを正しく解析できるか" do
|
@@ -322,4 +347,61 @@ context "volumes" do
|
|
322
347
|
lambda { @api.detach_volume(:volume_id => 'foo', :force => 1) }.should.raise(NIFTY::ArgumentError)
|
323
348
|
end
|
324
349
|
|
350
|
+
# modify_volume_attribute
|
351
|
+
specify "modify_volume_attribute - レスポンスを正しく解析できるか" do
|
352
|
+
@api.stubs(:exec_request).returns stub(:body => @modify_volume_attribute_response_body, :is_a? => true)
|
353
|
+
response = @api.modify_volume_attribute(:volume_id => "vol1", :attribute => 'accountingType', :value => '1')
|
354
|
+
response.return.should.equal "true"
|
355
|
+
end
|
356
|
+
|
357
|
+
specify "modify_volume_attribute - パラメータが正しく作られるか" do
|
358
|
+
@api.stubs(:make_request).with('Action' => 'ModifyVolumeAttribute',
|
359
|
+
'VolumeId' => 'vol01',
|
360
|
+
'Attribute' => 'accountingType',
|
361
|
+
'Value' => '1').returns stub(:body => @modify_volume_attribute_response_body, :is_a? => true)
|
362
|
+
@api.stubs(:exec_request).returns stub(:body => @modify_volume_attribute_response_body, :is_a? => true)
|
363
|
+
response = @api.modify_volume_attribute(:volume_id => "vol01", :attribute => 'accountingType', :value => '1')
|
364
|
+
end
|
365
|
+
|
366
|
+
specify "modify_volume_attribute - :volume_id正常" do
|
367
|
+
@api.stubs(:exec_request).returns stub(:body => @modify_volume_attribute_response_body, :is_a? => true)
|
368
|
+
lambda { @api.modify_volume_attribute(:volume_id => 'foo', :attribute => 'accountingType', :value => '1') }.should.not.raise(NIFTY::ArgumentError)
|
369
|
+
lambda { @api.modify_volume_attribute(:volume_id => 12345, :attribute => 'accountingType', :value => '1') }.should.not.raise(NIFTY::ArgumentError)
|
370
|
+
end
|
371
|
+
|
372
|
+
specify "modify_volume_attribute - :attribute,:value正常" do
|
373
|
+
@api.stubs(:exec_request).returns stub(:body => @modify_volume_attribute_response_body, :is_a? => true)
|
374
|
+
{ 'accountingType' => @accounting_type
|
375
|
+
}.each do |attr, arr|
|
376
|
+
arr.each do |val|
|
377
|
+
lambda { @api.modify_volume_attribute(:volume_id => "vol01", :attribute => attr, :value => val) }.should.not.raise(NIFTY::ArgumentError)
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
specify "modify_volume_attribute - :volume_id未指定" do
|
383
|
+
lambda { @api.modify_volume_attribute }.should.raise(NIFTY::ArgumentError)
|
384
|
+
[ nil, ''].each do |id|
|
385
|
+
lambda { @api.modify_volume_attribute(:volume_id => id) }.should.raise(NIFTY::ArgumentError)
|
386
|
+
end
|
387
|
+
lambda { @api.modify_volume_attribute }.should.raise(NIFTY::ArgumentError)
|
388
|
+
end
|
389
|
+
|
390
|
+
specify "modify_volume_attribute - :attribute未指定/不正" do
|
391
|
+
lambda { @api.modify_volume_attribute(:volume_id => "vol01") }.should.raise(NIFTY::ArgumentError)
|
392
|
+
lambda { @api.modify_volume_attribute(:volume_id => "vol01", :attribute => nil) }.should.raise(NIFTY::ArgumentError)
|
393
|
+
lambda { @api.modify_volume_attribute(:volume_id => "vol01", :attribute => '') }.should.raise(NIFTY::ArgumentError)
|
394
|
+
lambda { @api.modify_volume_attribute(:volume_id => "vol01", :attribute => 'hoge') }.should.raise(NIFTY::ArgumentError)
|
395
|
+
lambda { @api.modify_volume_attribute(:volume_id => "vol01", :attribute => 3) }.should.raise(NIFTY::ArgumentError)
|
396
|
+
end
|
397
|
+
|
398
|
+
specify "modify_volume_attribute - :value未指定/不正" do
|
399
|
+
attribute = %w(accountingType)
|
400
|
+
attribute.each do |attr|
|
401
|
+
lambda { @api.modify_volume_attribute(:volume_id => "i-10a64379", :attribute => attr ) }.should.raise(NIFTY::ArgumentError)
|
402
|
+
lambda { @api.modify_volume_attribute(:volume_id => "i-10a64379", :attribute => attr, :value => nil ) }.should.raise(NIFTY::ArgumentError)
|
403
|
+
lambda { @api.modify_volume_attribute(:volume_id => "i-10a64379", :attribute => attr, :value => 'hoge' ) }.should.raise(NIFTY::ArgumentError)
|
404
|
+
lambda { @api.modify_volume_attribute(:volume_id => "i-10a64379", :attribute => attr, :value => 3 ) }.should.raise(NIFTY::ArgumentError)
|
405
|
+
end
|
406
|
+
end
|
325
407
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nifty-cloud-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 62196225
|
5
|
+
prerelease: 4
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
|
8
|
+
- 8
|
9
|
+
- beta
|
10
|
+
- 1
|
11
|
+
version: 1.8.beta1
|
10
12
|
platform: ruby
|
11
13
|
authors:
|
12
14
|
- NIFTY Corporation
|
@@ -14,7 +16,7 @@ autorequire:
|
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date: 2012-
|
19
|
+
date: 2012-11-12 00:00:00 +09:00
|
18
20
|
default_executable:
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
@@ -248,12 +250,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
248
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
249
251
|
none: false
|
250
252
|
requirements:
|
251
|
-
- - "
|
253
|
+
- - ">"
|
252
254
|
- !ruby/object:Gem::Version
|
253
|
-
hash:
|
255
|
+
hash: 25
|
254
256
|
segments:
|
255
|
-
-
|
256
|
-
|
257
|
+
- 1
|
258
|
+
- 3
|
259
|
+
- 1
|
260
|
+
version: 1.3.1
|
257
261
|
requirements: []
|
258
262
|
|
259
263
|
rubyforge_project:
|