vgrnt 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +15 -0
- data/lib/vgrnt/base.rb +14 -7
- data/lib/vgrnt/util/vagrantfile.rb +33 -26
- data/lib/vgrnt/version.rb +1 -1
- data/spec/acceptance/util_spec.rb +1 -1
- data/spec/unit/fixtures/util_vagrantfile/Vagrantfile-misc1 +45 -0
- data/spec/unit/fixtures/util_vagrantfile/Vagrantfile-multi +13 -0
- data/spec/unit/fixtures/util_vagrantfile/Vagrantfile-plugins +9 -0
- data/spec/unit/fixtures/util_vagrantfile/Vagrantfile-simple +7 -0
- data/spec/unit/util_spec.rb +48 -7
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec9d0aba10f8e4965ff0be10e8734933faa88c0
|
4
|
+
data.tar.gz: a3434a03c3abe317c00a78cda479be664aa9e3cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e73e399f049fbf2c68312e1b7ea5c55e9d22ae6dd21cc7f5cea59aba198d943493019014fe642ff4bfce9e9e6d14bff30d81bc9d6d8c70d90a24ee367ba88db
|
7
|
+
data.tar.gz: 6527718cba50263df9bafcf60aa40fed17f74eae4ea2c6d428b7383b2ceb4906503cb2f3e4eb045439de3623c03281676da206ed8a039ad3868a9d759044eaaf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.0.4](https://github.com/dergachev/vagrant/compare/v0.0.3...v0.0.4) (Dec 3, 2013)
|
2
|
+
|
3
|
+
BUGFIX:
|
4
|
+
|
5
|
+
- Fix `vgrnt ssh` hanging due to improper shellout technique.
|
6
|
+
|
7
|
+
FEATURES:
|
8
|
+
|
9
|
+
- Added support for `vgrnt status`
|
10
|
+
|
11
|
+
IMPROVEMENTS:
|
12
|
+
|
13
|
+
- Refactored codebase a bit
|
14
|
+
- Implemented acceptance tests (unit tests still non-existant)
|
15
|
+
|
1
16
|
## [0.0.3](https://github.com/dergachev/vagrant/compare/v0.0.2...v0.0.3) (Nov 12, 2013)
|
2
17
|
|
3
18
|
FEATURES:
|
data/lib/vgrnt/base.rb
CHANGED
@@ -24,7 +24,7 @@ module Vgrnt
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
# Undoes the automatic removal of -- in Thor::Options.peek. Otherwise "vgrnt ssh precise -- ls /"
|
27
|
+
# Undoes the automatic removal of -- in Thor::Options.peek. Otherwise "vgrnt ssh precise -- ls /"
|
28
28
|
# is parsed as "precise ls /". TODO: is there a less hacky way to handle this?
|
29
29
|
class ::Thor::Options
|
30
30
|
def peek
|
@@ -60,10 +60,10 @@ module Vgrnt
|
|
60
60
|
if machine && machine[:state] == 'running'
|
61
61
|
# found by running "VAGRANT_LOG=debug vagrant ssh"
|
62
62
|
default_ssh_args = [
|
63
|
-
"vagrant@#{ssh_info[:ssh_ip]}",
|
64
|
-
"-p", ssh_info[:ssh_port],
|
65
|
-
"-o", "DSAAuthentication=yes", "-o", "LogLevel=FATAL", "-o", "StrictHostKeyChecking=no",
|
66
|
-
"-o", "UserKnownHostsFile=/dev/null", "-o", "IdentitiesOnly=yes",
|
63
|
+
"vagrant@#{ssh_info[:ssh_ip]}",
|
64
|
+
"-p", ssh_info[:ssh_port],
|
65
|
+
"-o", "DSAAuthentication=yes", "-o", "LogLevel=FATAL", "-o", "StrictHostKeyChecking=no",
|
66
|
+
"-o", "UserKnownHostsFile=/dev/null", "-o", "IdentitiesOnly=yes",
|
67
67
|
"-i", "~/.vagrant.d/insecure_private_key"
|
68
68
|
]
|
69
69
|
|
@@ -74,7 +74,14 @@ module Vgrnt
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
# Using IO.popen is important:
|
78
|
+
# - POpen3 ignores STDIN. Backticks buffer stdout. Kernel::exec breaks rspec.
|
79
|
+
# - getc instead of gets fixes the 1 line lag.
|
80
|
+
IO.popen(ssh_command) do |io|
|
81
|
+
while c = io.getc do
|
82
|
+
putc c
|
83
|
+
end
|
84
|
+
end
|
78
85
|
end
|
79
86
|
|
80
87
|
desc "ssh-config [vm-name]", "Store output of 'vagrant ssh-config' to .vgrnt-sshconfig"
|
@@ -151,7 +158,7 @@ module Vgrnt
|
|
151
158
|
# TODO: handle substitution for commands like `usbfilter add 0 --target <uuid|name>`
|
152
159
|
|
153
160
|
@logger.debug "Non-standard vboxmanage command detected (#{vboxmanage_subcommand}). Substituting 'VM_ID' for VM id."
|
154
|
-
|
161
|
+
|
155
162
|
# [VM_ID] is an optional literal token which will be replaced by the UUID of the VM referenced by Vagrant
|
156
163
|
args.map! { |a| a == 'VM_UUID' ? machine[:id] : a }
|
157
164
|
command = (["VBoxManage", vboxmanage_subcommand] + args).join(" ")
|
@@ -1,37 +1,44 @@
|
|
1
|
-
# TODO: test me
|
2
|
-
|
3
|
-
$vagrant_config_vms = []
|
4
|
-
|
5
|
-
module Vagrant
|
6
|
-
def self.configure(*args, &block)
|
7
|
-
yield Vgrnt::Util::Vagrantfile::Proxy.new
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
1
|
module Vgrnt
|
12
2
|
module Util
|
13
3
|
module Vagrantfile
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
|
5
|
+
def self.defined_vms(path = nil)
|
6
|
+
Vagrant._eval_vagrantfile(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
module Vagrant
|
10
|
+
def self._remove_named_arguments(source)
|
11
|
+
source = source.gsub(/([\s\(,])[a-zA-Z0-9_]+: ?/, '\1')
|
12
|
+
return source
|
18
13
|
end
|
19
14
|
|
20
|
-
|
21
|
-
|
15
|
+
# eval Vagrantfile inside of Vgrnt::Util::Vagrantfile namespace
|
16
|
+
def self._eval_vagrantfile(path = nil)
|
17
|
+
# NOT THREAD SAFE (not sure how to do this given static methods)
|
18
|
+
@@vagrant_config_vms = []
|
19
|
+
|
20
|
+
vgrntfile_source = File.read(path || './Vagrantfile')
|
21
|
+
if RUBY_VERSION.to_f <= 1.8
|
22
|
+
vgrntfile_source = Vagrant::_remove_named_arguments(vgrntfile_source)
|
23
|
+
end
|
24
|
+
module_eval(vgrntfile_source)
|
25
|
+
|
26
|
+
@@vagrant_config_vms << :default if @@vagrant_config_vms.empty?
|
27
|
+
return @@vagrant_config_vms
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.configure(*args, &block)
|
31
|
+
yield self
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.define(*args)
|
35
|
+
@@vagrant_config_vms << args.first
|
22
36
|
end
|
23
|
-
end
|
24
37
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
$vagrant_config_vms = []
|
29
|
-
load('./Vagrantfile')
|
30
|
-
# puts $vagrant_config_vms.inspect
|
31
|
-
if $vagrant_config_vms.empty?
|
32
|
-
$vagrant_config_vms << :default
|
38
|
+
# stub out anything else
|
39
|
+
def self.method_missing(*args)
|
40
|
+
return self
|
33
41
|
end
|
34
|
-
return $vagrant_config_vms
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
data/lib/vgrnt/version.rb
CHANGED
@@ -34,7 +34,7 @@ describe Vgrnt::Util::VirtualBox do
|
|
34
34
|
expect(Vgrnt::Util::VirtualBox::showvminfo('vgrnt-test')).to include 'UUID'
|
35
35
|
end
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
describe "::runningMachines" do
|
39
39
|
it 'ensure .vgrnt directory exists' do
|
40
40
|
expect(in_vagrant_env { File.exists? '.vagrant' }).to be_true
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
# from https://github.com/tknerr/vagrant-managed-servers/blob/fa60145d9fca221092e81346e95624d49080e304/Vagrantfile
|
5
|
+
|
6
|
+
# require plugin for testing via bundler
|
7
|
+
Vagrant.require_plugin "vagrant-managed-servers"
|
8
|
+
Vagrant.require_plugin "vagrant-omnibus"
|
9
|
+
|
10
|
+
Vagrant.configure("2") do |config|
|
11
|
+
|
12
|
+
config.omnibus.chef_version = "11.4.4"
|
13
|
+
|
14
|
+
#
|
15
|
+
# fake a managed server by bringing up a virtualbox vm
|
16
|
+
#
|
17
|
+
config.vm.define :fake_managed_server do |fms_config|
|
18
|
+
fms_config.vm.box = "opscode_ubuntu-13.04_provisionerless"
|
19
|
+
fms_config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box"
|
20
|
+
|
21
|
+
fms_config.vm.network :private_network, ip: "33.33.77.35"
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# configure managed provider to connect to `fake_managed_server`
|
26
|
+
#
|
27
|
+
config.vm.define :my_server do |ms_config|
|
28
|
+
|
29
|
+
ms_config.vm.box = "dummy"
|
30
|
+
ms_config.vm.box_url = "https://github.com/tknerr/vagrant-managed-servers/raw/master/dummy.box"
|
31
|
+
|
32
|
+
ms_config.vm.provider :managed do |managed_config, override|
|
33
|
+
managed_config.server = "33.33.77.35"
|
34
|
+
override.ssh.username = "vagrant"
|
35
|
+
override.ssh.private_key_path = "#{ENV['HOME']}/.vagrant.d/insecure_private_key"
|
36
|
+
end
|
37
|
+
|
38
|
+
ms_config.vm.provision :chef_solo do |chef|
|
39
|
+
chef.cookbooks_path = [ './cookbooks' ]
|
40
|
+
chef.add_recipe "apt"
|
41
|
+
chef.add_recipe "apache2"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure('2') do |config|
|
5
|
+
config.vm.box = "precise64"
|
6
|
+
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
|
7
|
+
|
8
|
+
config.vm.define :vm1 do |config|
|
9
|
+
end
|
10
|
+
|
11
|
+
config.vm.define :vm2 do |config|
|
12
|
+
end
|
13
|
+
end
|
data/spec/unit/util_spec.rb
CHANGED
@@ -1,13 +1,54 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
# RSpec.configure do |c|
|
4
|
-
# c.include Helpers
|
5
|
-
# end
|
1
|
+
require "spec_helper"
|
6
2
|
|
7
3
|
describe Vgrnt::Util::VirtualBox do
|
8
4
|
describe "::showvminfo_command" do
|
9
|
-
it
|
10
|
-
expect(Vgrnt::Util::VirtualBox::showvminfo_command(
|
5
|
+
it "should generate VBoxManage command" do
|
6
|
+
expect(Vgrnt::Util::VirtualBox::showvminfo_command("test")).to eq "VBoxManage showvminfo test --machinereadable"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe Vgrnt::Util::Vagrantfile do
|
12
|
+
|
13
|
+
subject { described_class.defined_vms("spec/unit/fixtures/util_vagrantfile/" + vagrantfile) }
|
14
|
+
|
15
|
+
describe "::defined_vms" do
|
16
|
+
context "parsing Vagrantfile-simple" do
|
17
|
+
let(:vagrantfile) { "Vagrantfile-simple" }
|
18
|
+
it { should eq [:default] }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "parsing Vagrantfile-multi" do
|
22
|
+
let(:vagrantfile) { "Vagrantfile-multi" }
|
23
|
+
it { should eq [:vm1, :vm2] }
|
24
|
+
end
|
25
|
+
|
26
|
+
context "parsing Vagrantfile-plugins" do
|
27
|
+
let(:vagrantfile) { "Vagrantfile-plugins" }
|
28
|
+
it { should eq [:default] }
|
29
|
+
end
|
30
|
+
|
31
|
+
context "parsing Vagrantfile-misc1" do
|
32
|
+
let(:vagrantfile) { "Vagrantfile-misc1" }
|
33
|
+
it { should eq [:fake_managed_server, :my_server] }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "Vagrant::_remove_named_arguments" do
|
38
|
+
def process(input)
|
39
|
+
Vgrnt::Util::Vagrantfile::Vagrant._remove_named_arguments(input)
|
40
|
+
end
|
41
|
+
it "works with simple named arguments" do
|
42
|
+
expect(process 'meth 1, scope: "meh", arg2: "meh"').to eq 'meth 1, "meh", "meh"'
|
43
|
+
end
|
44
|
+
it "works with space-free named arguments" do
|
45
|
+
expect(process 'meth 1, scope:"meh", arg2:"meh"').to eq 'meth 1, "meh", "meh"'
|
46
|
+
end
|
47
|
+
it "leaves symbols alone" do
|
48
|
+
expect(process 'meth :bob, 1, sum(:three)').to eq 'meth :bob, 1, sum(:three)'
|
11
49
|
end
|
12
50
|
end
|
13
51
|
end
|
52
|
+
|
53
|
+
# describe Vgrnt::Util::Vagrantfile do
|
54
|
+
# end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vgrnt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Dergachev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -95,6 +95,10 @@ files:
|
|
95
95
|
- spec/acceptance/support/acceptance_helper.rb
|
96
96
|
- spec/acceptance/util_spec.rb
|
97
97
|
- spec/spec_helper.rb
|
98
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-misc1
|
99
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-multi
|
100
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-plugins
|
101
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-simple
|
98
102
|
- spec/unit/util_spec.rb
|
99
103
|
- vgrnt.gemspec
|
100
104
|
homepage: https://github.com/dergachev/vgrnt
|
@@ -129,4 +133,8 @@ test_files:
|
|
129
133
|
- spec/acceptance/support/acceptance_helper.rb
|
130
134
|
- spec/acceptance/util_spec.rb
|
131
135
|
- spec/spec_helper.rb
|
136
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-misc1
|
137
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-multi
|
138
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-plugins
|
139
|
+
- spec/unit/fixtures/util_vagrantfile/Vagrantfile-simple
|
132
140
|
- spec/unit/util_spec.rb
|