vagrant-sakura 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32a5e6b2569917292788ba089660bda6e4784a84
4
- data.tar.gz: d659d26e867df31f8cc26f98a30a6cb25312876e
3
+ metadata.gz: 945fc69723e0d563c7daeb0ae6a40271166dbcf6
4
+ data.tar.gz: c7ce8eaf073dc58e7408507907bc1c695a8005ae
5
5
  SHA512:
6
- metadata.gz: 6996f6f9b63da9f1f461ac1670dc7aa4c9600b420a777f4db3db3d594848e38e2f47b63656735b98d484d8708ead0048b7875e84e835dfaef601c4f89d627eeb
7
- data.tar.gz: b08907c41a673d625f3f7152dc6b17ee50e4e924c62953bccda7bbe298e46bae7c1afd8d155963a7a3c962c510fb8799d3ed8b0d3c7113accca541677b1c90c8
6
+ metadata.gz: f75e242e6e681c00957bef08bfbc9d0843d07fd0dc99e8492f8c2adce5bd287a414634078afcd1e5555810ec682167933954929ee06585ea4df0b5b09e75032d
7
+ data.tar.gz: 870c6fb96b0cc5ae989ebbe6ae73c18c4fa50fb87de7d159341235edbcbe852274339f62f8d8ac0a359194d819f0d7bc82c6abe53742c00250bea7dac16e82a0
data/CHANGELOG.md CHANGED
@@ -1,32 +1,53 @@
1
- # 0.0.8 (2016/05/12)
1
+ # CHANGELOG
2
+
3
+ ## 0.0.9 (2018/07/13)
4
+
5
+ ### General
6
+
7
+ - Git repo moved from tsahara/vagrant-sakura to sacloud/vagrant-sakura (#12)
8
+
9
+ ### Core
10
+
11
+ - Update default settings (#9, #16)
12
+ - Add tags and description parameter (#11)
13
+ - Supports `SAKURACLOUD_*` environment variables (#18)
14
+
15
+ ### Misc.
16
+
17
+ - Update docs (#8)
18
+ - Add detail error message (#10)
19
+ - Set User-Agent header (#13)
20
+
21
+ ## 0.0.8 (2016/05/12)
22
+
2
23
  - Update default disk archive.
3
24
 
4
- # 0.0.7 (2015/02/19)
25
+ ## 0.0.7 (2015/02/19)
5
26
 
6
27
  - Update CA certificate for secure.sakura.ad.jp.
7
28
 
8
- # 0.0.6 (2014/07/14)
29
+ ## 0.0.6 (2014/07/14)
9
30
 
10
31
  - Add `public_key_path` and `use_insecure_key` configuration parameters.
11
32
 
12
- # 0.0.5 (2014/04/19)
33
+ ## 0.0.5 (2014/04/19)
13
34
 
14
35
  - Fix Vagrant 1.5 compatibility.
15
36
  - Update default disk archive.
16
37
 
17
- # 0.0.4 (2013/11/06)
38
+ ## 0.0.4 (2013/11/06)
18
39
 
19
40
  - Support `disk_id` configuration to reuse Disk resource.
20
41
 
21
- # 0.0.3 (2013/10/22)
42
+ ## 0.0.3 (2013/10/22)
22
43
 
23
44
  - Support `provision` command.
24
45
 
25
- # 0.0.2 (2013/10/08)
46
+ ## 0.0.2 (2013/10/08)
26
47
 
27
48
  - Add `vagrant sakura-list-id` command.
28
49
  - Support `zone_id` configuration.
29
50
 
30
- # 0.0.1 (2013/10/07)
51
+ ## 0.0.1 (2013/10/07)
31
52
 
32
53
  - Initial release.
data/Gemfile CHANGED
@@ -1,7 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v1.8.1'
4
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v2.1.2'
5
+ gem "test-unit", "~> 3.2.3"
5
6
  end
6
7
 
7
8
  group :plugins do
data/README.md CHANGED
@@ -2,10 +2,13 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/vagrant-sakura.png)](http://badge.fury.io/rb/vagrant-sakura)
4
4
 
5
+
5
6
  この gem は [Vagrant](http://www.vagrantup.com) に
6
7
  [さくらのクラウド](http://cloud.sakura.ad.jp)上のサーバを操作する
7
8
  機能を追加する provider です。
8
9
 
10
+ > __*このリポジトリは[tsahara/vagrant-sakura](https://github.com/tsahara/vagrant-sakura)から移行されました。*__
11
+
9
12
  ## 機能 / 制限
10
13
 
11
14
  * さくらのクラウド上にサーバを作成できます。
@@ -39,7 +42,7 @@ $ vagrant up --provider=sakura
39
42
  まずはじめに、ダミーの box を好きな名前で追加してください:
40
43
 
41
44
  ```sh
42
- $ vagrant box add dummy https://github.com/tsahara/vagrant-sakura/raw/master/dummy.box
45
+ $ vagrant box add dummy https://github.com/sacloud/vagrant-sakura/raw/master/dummy.box
43
46
  ...
44
47
  ```
45
48
 
@@ -61,13 +64,15 @@ Vagrant.configure("2") do |config|
61
64
  end
62
65
  ```
63
66
 
64
- そして ``vagrant up --provider=sakrua`` を実行してください。
67
+ そして ``vagrant up --provider=sakura`` を実行してください。
65
68
 
66
69
  サーバのディスクソースを ``sakura.disk_source_archive`` で指定しなかった
67
- 場合のデフォルトは ``112800438454`` で
68
- Ubuntu Server 14.04.4 LTS 64bit
70
+ 場合のデフォルトは ``113000423772`` で
71
+ Ubuntu Server 16.04.4 LTS 64bit(石狩第2ゾーン)
69
72
  です。
70
73
 
74
+ > ※注: アーカイブのIDはゾーンごとに異なります
75
+
71
76
  このディスクソースのログインアカウントは ``root`` ではないため、
72
77
  ``config.ssh.username`` で指定してやる必要があります。
73
78
 
@@ -123,8 +128,10 @@ $ vagrant sakura-list-id
123
128
  - ``disk_source_archive`` - サーバで利用するディスクのベースとするアーカイブ
124
129
  - ``server_name`` - サーバ名
125
130
  - ``server_plan`` - 作成するサーバのプラン ID
131
+ - ``tags`` - 作成するサーバ/ディスクのタグ(リスト)
132
+ - ``description`` - 作成するサーバ/ディスクの説明
126
133
  - ``sshkey_id`` - サーバへのログインに利用する SSH 公開鍵のリソース ID
127
- - ``zone_id`` - ゾーン ID (石狩第1=`is1a`, 石狩第2=`is1b`、東京第1=`tk1a`)
134
+ - ``zone_id`` - ゾーン ID (石狩第1=`is1a`, 石狩第2=`is1b`、東京第1=`tk1a`、デフォルトは`is1b`)
128
135
 
129
136
  ## ネットワーク
130
137
  ``vagrant-sakura`` は ``config.vm.network`` を利用したネットワークの構築を
@@ -24,12 +24,16 @@ module VagrantPlugins
24
24
  sshkey_id = env[:machine].provider_config.sshkey_id
25
25
  public_key_path = env[:machine].provider_config.public_key_path
26
26
  use_insecure_key = env[:machine].provider_config.use_insecure_key
27
+ tags = env[:machine].provider_config.tags
28
+ description = env[:machine].provider_config.description
27
29
 
28
30
  env[:ui].info(I18n.t("vagrant_sakura.creating_instance"))
29
31
  env[:ui].info(" -- Server Name: #{server_name}")
30
32
  env[:ui].info(" -- Server Plan: #{server_plan}")
31
33
  env[:ui].info(" -- Disk Plan: #{disk_plan}")
32
34
  env[:ui].info(" -- Disk Source Archive: #{disk_source_archive}")
35
+ env[:ui].info(" -- Tags: #{tags}") unless tags.empty?
36
+ env[:ui].info(" -- Description: \"#{description}\"") unless description.empty?
33
37
 
34
38
  api = env[:sakura_api]
35
39
 
@@ -44,7 +48,9 @@ module VagrantPlugins
44
48
  "Connection" => "virtio",
45
49
  "SourceArchive" => {
46
50
  "ID" => disk_source_archive
47
- }
51
+ },
52
+ "Tags" => tags,
53
+ "Description" => description
48
54
  }
49
55
  }
50
56
  response = api.post("/disk", data)
@@ -76,7 +82,9 @@ module VagrantPlugins
76
82
  "ServerPlan" => { "ID" => server_plan },
77
83
  "ConnectedSwitches" => [
78
84
  { "Scope" => "shared", "BandWidthMbps" => 100 }
79
- ]
85
+ ],
86
+ "Tags" => tags,
87
+ "Description" => description
80
88
  }
81
89
  }
82
90
  response = api.post("/server", data)
@@ -56,6 +56,16 @@ module VagrantPlugins
56
56
  # The ID of the zone.
57
57
  attr_accessor :zone_id
58
58
 
59
+ # The tags of the server and disk.
60
+ #
61
+ # @return [Array<String>]
62
+ attr_accessor :tags
63
+
64
+ # The description of the server and disk.
65
+ #
66
+ # @return [String]
67
+ attr_accessor :description
68
+
59
69
  def initialize
60
70
  @access_token = UNSET_VALUE
61
71
  @access_token_secret = UNSET_VALUE
@@ -68,15 +78,19 @@ module VagrantPlugins
68
78
  @sshkey_id = UNSET_VALUE
69
79
  @use_insecure_key = UNSET_VALUE
70
80
  @zone_id = UNSET_VALUE
81
+ @tags = UNSET_VALUE
82
+ @description = UNSET_VALUE
71
83
  end
72
84
 
73
85
  def finalize!
74
86
  if @access_token == UNSET_VALUE
75
87
  @access_token = ENV['SAKURA_ACCESS_TOKEN']
88
+ @access_token = ENV['SAKURACLOUD_ACCESS_TOKEN'] if @access_token.nil?
76
89
  end
77
90
 
78
91
  if @access_token_secret == UNSET_VALUE
79
92
  @access_token_secret = ENV['SAKURA_ACCESS_TOKEN_SECRET']
93
+ @access_token_secret = ENV['SAKURACLOUD_ACCESS_TOKEN_SECRET'] if @access_token_secret.nil?
80
94
  end
81
95
 
82
96
  if @disk_id == UNSET_VALUE
@@ -88,7 +102,7 @@ module VagrantPlugins
88
102
  end
89
103
 
90
104
  if @disk_source_archive == UNSET_VALUE
91
- @disk_source_archive = 112800438454
105
+ @disk_source_archive = 113000423772 # Ubuntu Server 16.04.4 LTS 64bit on is1b
92
106
  end
93
107
 
94
108
  @public_key_path = nil if @public_key_path == UNSET_VALUE
@@ -106,8 +120,16 @@ module VagrantPlugins
106
120
  @use_insecure_key = false if @use_insecure_key == UNSET_VALUE
107
121
 
108
122
  if @zone_id == UNSET_VALUE
109
- @zone_id = "is1a" # the first zone
123
+ @zone_id = ENV['SAKURACLOUD_ZONE']
124
+ @zone_id = "is1b" if @zone_id.nil?
110
125
  end
126
+
127
+ @tags = [] if @tags == UNSET_VALUE
128
+ @tags = [@tags] unless @tags.is_a?(Array)
129
+ @tags.map!(&:to_s)
130
+
131
+ @description = "" if @description == UNSET_VALUE
132
+ @description = @description.to_s
111
133
  end
112
134
 
113
135
  def validate(machine)
@@ -49,11 +49,13 @@ module VagrantPlugins
49
49
 
50
50
  def do_request(request)
51
51
  request.basic_auth @access_token, @access_token_secret
52
+ request['User-Agent'] = "vagrant-sakura/v#{VagrantPlugins::Sakura::VERSION}"
52
53
  response = @https.request(request)
53
54
  @logger.debug("#{request.method} #{request.path} #{request.body} "+
54
55
  "=> #{response.code} : #{response.body}")
55
56
 
56
- emsg = "#{response.code} (#{request.method} #{request.path})"
57
+ emsg_detail = JSON.pretty_generate JSON.parse(response.body)
58
+ emsg = "#{response.code} (#{request.method} #{request.path})\n#{emsg_detail}"
57
59
  case response.code
58
60
  when /2../
59
61
  # Success
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Sakura
3
- VERSION = "0.0.8"
3
+ VERSION = "0.0.9"
4
4
  end
5
5
  end
@@ -0,0 +1,104 @@
1
+ require 'test/unit'
2
+ require "vagrant-sakura/config"
3
+
4
+ module VagrantPlugins
5
+ module Sakura
6
+ class TestConfig < Test::Unit::TestCase
7
+
8
+ def setup
9
+ %w("SAKURACLOUD_ACCESS_TOKEN" "SAKURACLOUD_ACCESS_TOKEN_SECRET" "SAKURACLOUD_ZONE").map do |k|
10
+ ENV.delete(k)
11
+ end
12
+ end
13
+
14
+ def test_apikeys
15
+ cases = {
16
+ "config only" => {
17
+ "config" => {
18
+ "access_token" => "foo",
19
+ "access_token_secret" => "bar"
20
+ },
21
+ "env" => {},
22
+ "expects" => {
23
+ "token" => "foo",
24
+ "secret" => "bar",
25
+ "zone" => "is1b"
26
+ }
27
+ },
28
+ "env(SAKURA_*) only" => {
29
+ "config" => {},
30
+ "env" => {
31
+ "SAKURA_ACCESS_TOKEN" => "foo",
32
+ "SAKURA_ACCESS_TOKEN_SECRET" => "bar",
33
+ },
34
+ "expects" => {
35
+ "token" => "foo",
36
+ "secret" => "bar",
37
+ "zone" => "is1b"
38
+ }
39
+ },
40
+ "env(SAKURACLOUD_*) only" => {
41
+ "config" => {},
42
+ "env" => {
43
+ "SAKURACLOUD_ACCESS_TOKEN" => "foo",
44
+ "SAKURACLOUD_ACCESS_TOKEN_SECRET" => "bar",
45
+ "SAKURACLOUD_ZONE" => "tk1a",
46
+ },
47
+ "expects" => {
48
+ "token" => "foo",
49
+ "secret" => "bar",
50
+ "zone" => "tk1a"
51
+ }
52
+ },
53
+ "env order" => {
54
+ "config" => {},
55
+ "env" => {
56
+ "SAKURA_ACCESS_TOKEN" => "foo",
57
+ "SAKURA_ACCESS_TOKEN_SECRET" => "bar",
58
+ "SAKURACLOUD_ACCESS_TOKEN" => "not_use",
59
+ "SAKURACLOUD_ACCESS_TOKEN_SECRET" => "not_use",
60
+ "SAKURACLOUD_ZONE" => "tk1a",
61
+ },
62
+ "expects" => {
63
+ "token" => "foo",
64
+ "secret" => "bar",
65
+ "zone" => "tk1a"
66
+ }
67
+ },
68
+ "conf and env order" => {
69
+ "config" => {
70
+ "access_token" => "foo",
71
+ "access_token_secret" => "bar",
72
+ "zone_id" => "tk1a"
73
+ },
74
+ "env" => {
75
+ "SAKURA_ACCESS_TOKEN" => "not_use",
76
+ "SAKURA_ACCESS_TOKEN_SECRET" => "not_use",
77
+ "SAKURACLOUD_ACCESS_TOKEN" => "not_use",
78
+ "SAKURACLOUD_ACCESS_TOKEN_SECRET" => "not_use",
79
+ "SAKURACLOUD_ZONE" => "not_use",
80
+ },
81
+ "expects" => {
82
+ "token" => "foo",
83
+ "secret" => "bar",
84
+ "zone" => "tk1a"
85
+ }
86
+ }
87
+ }
88
+
89
+ cases.map {|name, c|
90
+ puts "Case: #{name}"
91
+ conf = Config.new
92
+ conf.set_options c["config"]
93
+
94
+ ENV.update c["env"]
95
+
96
+ conf.finalize!
97
+ assert_equal c["expects"]["token"], conf.access_token
98
+ assert_equal c["expects"]["secret"], conf.access_token_secret
99
+ assert_equal c["expects"]["zone"], conf.zone_id
100
+ }
101
+ end
102
+ end
103
+ end
104
+ end
@@ -6,11 +6,11 @@ require 'vagrant-sakura/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "vagrant-sakura"
8
8
  spec.version = VagrantPlugins::Sakura::VERSION
9
- spec.authors = ["Tomoyuki Sahara"]
10
- spec.email = ["sahara@caddr.net"]
9
+ spec.authors = ["Tomoyuki Sahara", "Kazumichi Yamamoto"]
10
+ spec.email = ["yamamoto.febc@gmail.com"]
11
11
  spec.description = %q{Enables Vagrant to manage machines in Sakura Cloud.}
12
12
  spec.summary = %q{Enables Vagrant to manage machines in Sakura Cloud.}
13
- spec.homepage = "https://github.com/tsahara/vagrant-sakura"
13
+ spec.homepage = "https://github.com/sacloud/vagrant-sakura"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,18 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-sakura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoyuki Sahara
8
+ - Kazumichi Yamamoto
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-05-12 00:00:00.000000000 Z
12
+ date: 2018-07-13 00:00:00.000000000 Z
12
13
  dependencies: []
13
14
  description: Enables Vagrant to manage machines in Sakura Cloud.
14
15
  email:
15
- - sahara@caddr.net
16
+ - yamamoto.febc@gmail.com
16
17
  executables: []
17
18
  extensions: []
18
19
  extra_rdoc_files: []
@@ -53,8 +54,9 @@ files:
53
54
  - lib/vagrant-sakura/provider.rb
54
55
  - lib/vagrant-sakura/version.rb
55
56
  - locales/en.yml
57
+ - test/test_config.rb
56
58
  - vagrant-sakura.gemspec
57
- homepage: https://github.com/tsahara/vagrant-sakura
59
+ homepage: https://github.com/sacloud/vagrant-sakura
58
60
  licenses:
59
61
  - MIT
60
62
  metadata: {}
@@ -74,8 +76,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
76
  version: '0'
75
77
  requirements: []
76
78
  rubyforge_project:
77
- rubygems_version: 2.4.5
79
+ rubygems_version: 2.5.2
78
80
  signing_key:
79
81
  specification_version: 4
80
82
  summary: Enables Vagrant to manage machines in Sakura Cloud.
81
- test_files: []
83
+ test_files:
84
+ - test/test_config.rb