vagrant-niftycloud 0.1.6 → 0.2.0

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.
data/CHANGELOG.md CHANGED
@@ -1,19 +1,23 @@
1
- # 0.1.6 (July 29, 2013)
1
+ ## 0.2.0 (July 30, 2013)
2
+
3
+ * エンドポイント切り替え、リージョン・ゾーンの設定を正式サポート
4
+
5
+ ### 0.1.6 (July 29, 2013)
2
6
 
3
7
  * vagrant up直後にCtrl+Cで中断した場合に、vagrant statusでステータスが取得できない問題を修正
4
8
 
5
- # 0.1.5 (July 27, 2013)
9
+ ### 0.1.5 (July 27, 2013)
6
10
 
7
11
  * gemspecファイルのライセンス表示を追加
8
12
 
9
- # 0.1.4 (July 25, 2013)
13
+ ### 0.1.4 (July 25, 2013)
10
14
 
11
15
  * Vagrantfileでinstance_idを指定せずにvagrant upした場合に、instance_id決定ロジックが can't convert nil into String を吐くケースがある問題を修正
12
16
  * rsyncでのローカルファイル転送時に.gitディレクトリをexcludeするよう修正
13
17
 
14
- # 0.1.3 (July 24, 2013)
18
+ ### 0.1.3 (July 24, 2013)
15
19
 
16
20
  * access_key_id、secret_access_keyがVagrantfileで指定されていない場合に取得する環境変数名が間違っていた
17
21
 
18
- # 0.1.0 (July 22, 2013)
22
+ ## 0.1.0 (July 22, 2013)
19
23
  * Initial release.
data/README.md CHANGED
@@ -5,10 +5,6 @@
5
5
  [![Build Status](https://travis-ci.org/sakama/vagrant-niftycloud.png)](https://travis-ci.org/sakama/vagrant-niftycloud)
6
6
  [![Code Climate](https://codeclimate.com/github/sakama/vagrant-niftycloud.png)](https://codeclimate.com/github/sakama/vagrant-niftycloud)
7
7
 
8
- `開発中!8月頭を目処に処理をブラッシュアップします`
9
-
10
- `リージョン・ゾーン周り以外のロジックはほぼ問題ないと思います`
11
-
12
8
  [Vagrant](http://www.vagrantup.com) 1.2以降のバージョンのproviderとして[ニフティクラウド](http://cloud.nifty.com/) を使えるようにするためのプラグインです。
13
9
 
14
10
  Vagrantでニフティクラウド上のサーバインスタンスの制御や、[Chef](http://www.opscode.com/chef/)や[Puppet](https://puppetlabs.com/) 等を使ったサーバのprovisioningが可能となります。
@@ -206,7 +202,8 @@ Vagrant.configure("2") do |config|
206
202
  config.vm.provider :niftycloud do |niftycloud, override|
207
203
  niftycloud.access_key_id = "foo"
208
204
  niftycloud.secret_access_key = "bar"
209
- niftycloud.zone = "east-12"
205
+ niftycloud.zone = "east-12" # ここでどのゾーンで立ち上げるか決定
206
+
210
207
  niftycloud.key_name = "vagrantkey"
211
208
  niftycloud.firewall = "test"
212
209
  niftycloud.password = "password"
@@ -214,12 +211,12 @@ Vagrant.configure("2") do |config|
214
211
  override.ssh.private_key_path = "/path/to/private_key.pem"
215
212
 
216
213
  # シンプルな書き方
217
- niftycloud.zone_config "east-12", :image_id => 26
214
+ niftycloud.zone_config "east-13", :instance_type => "small"
218
215
 
219
216
  # より多くの設定を上書きしたい場合
220
217
  niftycloud.zone_config "east-13" do |zone|
221
218
  zone.image_id = 21
222
- zone.instance_type = small
219
+ zone.instance_type = "small"
223
220
  zone.key_name = "vagrantkey2"
224
221
  end
225
222
  end
@@ -230,6 +227,19 @@ zone_configブロックでリージョン/ゾーン特有の設定を指定し
230
227
 
231
228
  指定していない設定項目についてはトップレベルの設定値を継承します。
232
229
 
230
+ ### ニフティクラウドのリージョン切り替え
231
+ ニフティクラウドのリージョン切り替えについてはVagrantfile中だけでは設定できません。
232
+
233
+ 環境変数`NIFTY_CLOUD_ENDPOINT_URL`に[適切なリクエスト先エンドポイント](http://cloud.nifty.com/api/endpoint.htm)を指定してやる必要があります。
234
+
235
+ 以下のコマンドを実行するか、.bashrcや.zshrc等に追記するなどして下さい。
236
+
237
+ ```
238
+ # 東日本リージョンでAPI最新版を使用
239
+ export NIFTY_CLOUD_ENDPOINT_URL='https://east-1.cp.cloud.nifty.com/api/'
240
+ # 西日本リージョンでAPI最新版を使用
241
+ export NIFTY_CLOUD_ENDPOINT_URL='https://west-1.cp.cloud.nifty.com/api/'
242
+ ```
233
243
 
234
244
  ## VagrantのNetwork機能への対応
235
245
 
@@ -7,8 +7,9 @@ Vagrant.configure("2") do |config|
7
7
  config.vm.provider :niftycloud do |niftycloud, override|
8
8
  niftycloud.access_key_id = ENV["NIFTY_CLOUD_ACCESS_KEY"] || "foo"
9
9
  niftycloud.secret_access_key = ENV["NIFTY_CLOUD_SECRET_KEY"] || "bar"
10
- niftycloud.image_id = "26"
11
10
  niftycloud.zone= "east-12"
11
+
12
+ niftycloud.image_id = "26"
12
13
  niftycloud.instance_type= "mini"
13
14
  niftycloud.key_name = "sshkeypairname"
14
15
  niftycloud.firewall = "vagrantservers"
@@ -28,21 +28,13 @@ module VagrantPlugins
28
28
  def start(env)
29
29
  env[:ui].info(I18n.t("vagrant_niftycloud.resuming"))
30
30
 
31
- # 起動直後等、resume処理できないステータスの場合一旦待つ
32
- server = get(env[:machine])
33
- while server.instanceState.name == 'pending'
34
- sleep 5
35
- server = get(env[:machine])
36
- env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
37
- end
31
+ # 起動直後等、start処理できないステータスの場合一旦待つ
32
+ wait_while_status_is(env, 'pending')
38
33
 
34
+ server = get(env[:machine])
39
35
  if server.instanceState.name != 'running'
40
36
  @connection.start_instances(:instance_id => env[:machine].id)
41
- while server.instanceState.name != 'running'
42
- sleep 5
43
- server = get(env[:machine])
44
- env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
45
- end
37
+ wait_while_status_is(env, 'not_running')
46
38
  end
47
39
  end
48
40
 
@@ -51,20 +43,12 @@ module VagrantPlugins
51
43
  env[:ui].info(I18n.t("vagrant_niftycloud.suspending"))
52
44
 
53
45
  # 起動直後等、stop処理できないステータスの場合一旦待つ
54
- server = get(env[:machine])
55
- while server.instanceState.name == 'pending'
56
- sleep 5
57
- server = get(env[:machine])
58
- env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
59
- end
46
+ wait_while_status_is(env, 'pending')
60
47
 
48
+ server = get(env[:machine])
61
49
  if server.instanceState.name != 'stopped'
62
50
  @connection.stop_instances(:instance_id => env[:machine].id, :force => false)
63
- while server.instanceState.name != 'stopped'
64
- sleep 5
65
- server = get(env[:machine])
66
- env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
67
- end
51
+ wait_while_status_is(env, 'not_stopped')
68
52
  end
69
53
  end
70
54
 
@@ -73,12 +57,7 @@ module VagrantPlugins
73
57
  env[:ui].info(I18n.t("vagrant_niftycloud.terminating"))
74
58
 
75
59
  # 起動直後等、terminate処理できないステータスの場合一旦待つ
76
- server = get(env[:machine])
77
- while server.instanceState.name == 'pending'
78
- sleep 5
79
- server = get(env[:machine])
80
- env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
81
- end
60
+ wait_while_status_is(env, 'pending')
82
61
 
83
62
  attribute = @connection.describe_instance_attribute(:instance_id => env[:machine].id, :attribute => 'disableApiTermination')
84
63
  if attribute.disableApiTermination.value == 'false'
@@ -90,7 +69,25 @@ module VagrantPlugins
90
69
  server = get(env[:machine])
91
70
  if server.instanceState.name == 'stopped'
92
71
  response = @connection.terminate_instances(:instance_id => env[:machine].id)
93
- return response
72
+ end
73
+ end
74
+
75
+ # あるstatusである間、status確認を定期的に実行しつつ待機する
76
+ def wait_while_status_is(env, status)
77
+ server = get(env[:machine])
78
+ if status =~ /^not_/
79
+ status.sub!("not_", "")
80
+ while server.instanceState.name != status
81
+ env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
82
+ sleep 5
83
+ server = get(env[:machine])
84
+ end
85
+ else
86
+ while server.instanceState.name == status
87
+ env[:ui].info(I18n.t("vagrant_niftycloud.processing"))
88
+ sleep 5
89
+ server = get(env[:machine])
90
+ end
94
91
  end
95
92
  end
96
93
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module NiftyCloud
3
- VERSION = "0.1.6"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-niftycloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-29 00:00:00.000000000 Z
12
+ date: 2013-07-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: -2659219092827590807
151
+ hash: -3269219555380113176
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  none: false
154
154
  requirements: