vagrant-sakura 0.0.3 → 0.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ed22d90e7ac0a847a3df3114dfb4d3c72f09ed03
4
- data.tar.gz: c515ec435d3c2bfec4d73e6c2fb2a9fa49d5405b
3
+ metadata.gz: 91ae77db719a831bfc178948c26fbe82e7df357a
4
+ data.tar.gz: b354a3f5f56a44a814ac3465bdef5b566c08c1f4
5
5
  SHA512:
6
- metadata.gz: d06e0b32afab6b86ae38cbe7a4d85284968a7d03c565de5778eabb7e10d5352446fabf6496905c05032a87caac374a7ab90ea37f2e9033bd4a12e0758cc9fa5f
7
- data.tar.gz: 7ea023edc7e7aa70a994e2c9cccd55dfe3855ec40b687b424b2abf0899d904955ec90f37de2167f74a9c84239dd222abb1a9ab3ae33161d99abe3d8aaa85d57f
6
+ metadata.gz: 5dbc6a375afe6b557a9a20ae23ce293f8888b08c0c2e76523283feee697a8c39708ec728e6e456891de9f0ad29f4d46dfc6f4265a5b8776931530bec85e84687
7
+ data.tar.gz: 2cc0c550aa9ecf306f90d2f680924b727cb31b5a6f253e138756bf493f052177f414a3180c64639d5a620dd9b842695e05e5030c624854505293dfc5b3325f1b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 0.0.5 (2014/04/19)
2
+
3
+ - Fix Vagrant 1.5 compatibility.
4
+ - Update default disk archive.
5
+
6
+ # 0.0.4 (2013/11/06)
7
+
8
+ - Support `disk_id` configuration to reuse Disk resource.
9
+
1
10
  # 0.0.3 (2013/10/22)
2
11
 
3
12
  - Support `provision` command.
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gemspec
4
-
5
3
  group :development do
6
- gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
4
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v1.5.3'
5
+ end
6
+
7
+ group :plugins do
8
+ gem "vagrant-sakura", path: "."
7
9
  end
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Vagrant Sakura Provider
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/vagrant-sakura.png)](http://badge.fury.io/rb/vagrant-sakura)
4
+
3
5
  この gem は [Vagrant](http://www.vagrantup.com) に
4
6
  [さくらのクラウド](http://cloud.sakura.ad.jp)上のサーバを操作する
5
7
  機能を追加する provider です。
@@ -9,7 +11,10 @@
9
11
  * さくらのクラウド上にサーバを作成できます。
10
12
  * サーバに SSH ログインできます。
11
13
  * サーバを停止/再開(オフ/オン)できます。
12
- * provision は動きません。
14
+ * Chef をはじめとする provisioner が動きます。
15
+
16
+ なお Chef を利用する場合は `vagrant-omnibus` プラグインを使ってサーバ上に
17
+ Chef をインストールしてください。
13
18
 
14
19
  ## インストール
15
20
 
@@ -26,6 +26,9 @@ module VagrantPlugins
26
26
  end
27
27
 
28
28
  disks = response["Server"]["Disks"].map { |disk| disk["ID"] }
29
+ disks.delete_if { |diskid|
30
+ diskid == env[:machine].provider_config.disk_id.to_s
31
+ }
29
32
  data = { "WithDisk" => disks }
30
33
  response = api.delete("/server/#{serverid}", data)
31
34
  # error check
@@ -13,12 +13,13 @@ module VagrantPlugins
13
13
  puts ""
14
14
 
15
15
  puts "---- Archives ----"
16
- puts "%-14s %s" % ["ID", "Name"]
16
+ puts "%-14s %5s %s" % ["ID", "Size", "Name"]
17
17
  r = api.get("/archive")
18
18
  r["Archives"].sort { |a, b|
19
19
  a["DisplayOrder"] <=> b["DisplayOrder"]
20
20
  }.each { |archive|
21
- puts "%-14u %s" % [archive["ID"], archive["Name"]]
21
+ gb = archive["SizeMB"] / 1024
22
+ puts "%-14u %3uGB %s" % [archive["ID"], gb, archive["Name"]]
22
23
  }
23
24
  puts ""
24
25
 
@@ -30,39 +30,43 @@ module VagrantPlugins
30
30
  env[:ui].info(" -- Disk Source Archive: #{disk_source_archive}")
31
31
 
32
32
  api = env[:sakura_api]
33
- data = {
34
- "Disk" => {
35
- "Name" => server_name,
36
- "Plan" => { "ID" => disk_plan },
37
- "Connection" => "virtio",
38
- "SourceArchive" => {
39
- "ID" => disk_source_archive
40
- }
33
+
34
+ if env[:machine].provider_config.disk_id
35
+ diskid = env[:machine].provider_config.disk_id
36
+
37
+ else
38
+ data = {
39
+ "Disk" => {
40
+ "Name" => server_name,
41
+ "Plan" => { "ID" => disk_plan },
42
+ "Connection" => "virtio",
43
+ "SourceArchive" => {
44
+ "ID" => disk_source_archive
45
+ }
46
+ }
41
47
  }
42
- }
43
- response = api.post("/disk", data)
44
- unless response["Disk"]["ID"]
45
- raise 'no Disk ID returned'
46
- end
47
- diskid = response["Disk"]["ID"]
48
- # Disk Created
49
-
50
- while true
51
- response = api.get("/disk/#{diskid}")
52
- case response["Disk"]["Availability"]
53
- when "available"
54
- break
55
- when "migrating"
56
- migrated = response["Disk"]["MigratedMB"]
57
- size = response["Disk"]["SizeMB"]
58
- env[:ui].info("Disk #{diskid} is migrating (#{migrated}/#{size})")
59
- else
60
- status = presponse["Disk"]["Availability"]
61
- env[:ui].info("Disk #{diskid} is #{status}")
48
+ response = api.post("/disk", data)
49
+ unless response["Disk"]["ID"]
50
+ raise 'no Disk ID returned'
51
+ end
52
+ diskid = response["Disk"]["ID"]
53
+
54
+ while true
55
+ response = api.get("/disk/#{diskid}")
56
+ case response["Disk"]["Availability"]
57
+ when "available"
58
+ break
59
+ when "migrating"
60
+ migrated = response["Disk"]["MigratedMB"]
61
+ size = response["Disk"]["SizeMB"]
62
+ env[:ui].info("Disk #{diskid} is migrating (#{migrated}/#{size})")
63
+ else
64
+ status = presponse["Disk"]["Availability"]
65
+ env[:ui].info("Disk #{diskid} is #{status}")
66
+ end
67
+ sleep 3
62
68
  end
63
- sleep 3
64
69
  end
65
- # Wait for Disk is available
66
70
 
67
71
  data = {
68
72
  "Server" => {
@@ -80,8 +84,13 @@ module VagrantPlugins
80
84
  env[:machine].id = serverid = response["Server"]["ID"]
81
85
  # Server Created
82
86
 
83
- response = api.put("/disk/#{diskid}/to/server/#{serverid}")
84
- # Disk mounted to Server
87
+ begin
88
+ response = api.put("/disk/#{diskid}/to/server/#{serverid}")
89
+ # Disk mounted to Server
90
+ rescue VagrantPlugins::Sakura::Driver::NotFoundError
91
+ terminate(env)
92
+ raise
93
+ end
85
94
 
86
95
  data = {
87
96
  "UserSubnet" => {}
@@ -68,10 +68,14 @@ module VagrantPlugins
68
68
  "chown #{ssh_info[:username]} '#{guestpath}'")
69
69
 
70
70
  # Rsync over to the guest path using the SSH info
71
+ ssharg = "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no"
72
+ ssharg += Array(ssh_info[:private_key_path]).map { |path|
73
+ " -i '#{path}'"
74
+ }.join
71
75
  command = [
72
76
  "rsync", "--verbose", "--archive", "-z",
73
77
  "--exclude", ".vagrant/", "--exclude", "Vagrantfile",
74
- "-e", "ssh -p #{ssh_info[:port]} -o StrictHostKeyChecking=no -i '#{ssh_info[:private_key_path]}'",
78
+ "-e", ssharg,
75
79
  hostpath,
76
80
  "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
77
81
 
@@ -131,7 +131,7 @@ module VagrantPlugins
131
131
 
132
132
  def self.action_up
133
133
  Vagrant::Action::Builder.new.tap do |b|
134
- b.use HandleBoxUrl
134
+ b.use HandleBox
135
135
  b.use ConfigValidate
136
136
  b.use ConnectSakura
137
137
  b.use Call, ReadState do |env, b2|
@@ -1,6 +1,10 @@
1
1
  module VagrantPlugins
2
2
  module Sakura
3
3
  class Command < Vagrant.plugin(2, :command)
4
+ def self.synopsis
5
+ "query Sakura for available archives and server plans"
6
+ end
7
+
4
8
  def execute
5
9
  with_target_vms(nil, { :provider => "sakura" }) do |vm|
6
10
  vm.action(:list_id)
@@ -13,6 +13,11 @@ module VagrantPlugins
13
13
  # @return [String]
14
14
  attr_accessor :access_token_secret
15
15
 
16
+ # The ID of the disk to be connected to the server.
17
+ #
18
+ # @return [Fixnum]
19
+ attr_accessor :disk_id
20
+
16
21
  # The plan ID of the disk to be connected to the server.
17
22
  #
18
23
  # @return [Fixnum]
@@ -44,6 +49,7 @@ module VagrantPlugins
44
49
  def initialize
45
50
  @access_token = UNSET_VALUE
46
51
  @access_token_secret = UNSET_VALUE
52
+ @disk_id = UNSET_VALUE
47
53
  @disk_plan = UNSET_VALUE
48
54
  @disk_source_archive = UNSET_VALUE
49
55
  @server_name = UNSET_VALUE
@@ -61,12 +67,16 @@ module VagrantPlugins
61
67
  @access_token_secret = ENV['SAKURA_ACCESS_TOKEN_SECRET']
62
68
  end
63
69
 
70
+ if @disk_id == UNSET_VALUE
71
+ @disk_id = nil # create a new disk
72
+ end
73
+
64
74
  if @disk_plan == UNSET_VALUE
65
75
  @disk_plan = 4 # SSD
66
76
  end
67
77
 
68
78
  if @disk_source_archive == UNSET_VALUE
69
- @disk_source_archive = 112500182464 # Ubuntu 12.04
79
+ @disk_source_archive = 112500459149 # Ubuntu Server 12.04.3 LTS 64bit
70
80
  end
71
81
 
72
82
  if @server_name == UNSET_VALUE
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Sakura
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -17,7 +17,4 @@ Gem::Specification.new do |spec|
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
20
  end
metadata CHANGED
@@ -1,43 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-sakura
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoyuki Sahara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-22 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.3'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.3'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
39
- - !ruby/object:Gem::Version
40
- version: '0'
11
+ date: 2014-04-19 00:00:00.000000000 Z
12
+ dependencies: []
41
13
  description: Enables Vagrant to manage machines in Sakura Cloud.
42
14
  email:
43
15
  - sahara@surt.net
@@ -45,7 +17,7 @@ executables: []
45
17
  extensions: []
46
18
  extra_rdoc_files: []
47
19
  files:
48
- - .gitignore
20
+ - ".gitignore"
49
21
  - CHANGELOG.md
50
22
  - Gemfile
51
23
  - LICENSE-vagrant-aws.txt
@@ -92,17 +64,17 @@ require_paths:
92
64
  - lib
93
65
  required_ruby_version: !ruby/object:Gem::Requirement
94
66
  requirements:
95
- - - '>='
67
+ - - ">="
96
68
  - !ruby/object:Gem::Version
97
69
  version: '0'
98
70
  required_rubygems_version: !ruby/object:Gem::Requirement
99
71
  requirements:
100
- - - '>='
72
+ - - ">="
101
73
  - !ruby/object:Gem::Version
102
74
  version: '0'
103
75
  requirements: []
104
76
  rubyforge_project:
105
- rubygems_version: 2.0.3
77
+ rubygems_version: 2.2.2
106
78
  signing_key:
107
79
  specification_version: 4
108
80
  summary: Enables Vagrant to manage machines in Sakura Cloud.