vagrant-guests-openbsd 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-guests-openbsd.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TANABE Ken-ichi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ [![Build Status](https://secure.travis-ci.org/nabeken/vagrant-guests-openbsd.png)](http://travis-ci.org/nabeken/vagrant-guests-openbsd)
2
+
3
+ # vagrant-guests-openbsd
4
+
5
+ Vagrant 1.1 has a build-in OpenBSD plugin but the plugin lacks multiple network and nfs mount support.
6
+
7
+ This plugins allows you to run OpenBSD under vagrant until Vagrant merges this changes.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'vagrant-guests-openbsd', :git => 'git://github.com/nabeken/vagrant-guests-openbsd'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ You should disable build-in OpenBSD plugin.
20
+
21
+ For example, in Mac OS X:
22
+
23
+ $ sudo chmod 0000 /Applications/Vagrant/embedded/gems/gems/vagrant-1.1.2/plugins/guests/openbsd
24
+
25
+ ## Usage
26
+
27
+ Add this line to your Vagrantfile:
28
+
29
+ Vagrant.require_plugin "vagrant-guests-openbsd"
30
+ Vagrant.configure("2") do |config|
31
+ config.vm.guest = :openbsd
32
+
33
+ # If you want hostonly network
34
+ config.vm.network :private_network, ip: "192.168.67.10", netmask: "255.255.255.0"
35
+ # If you want to mount folders with nfs
36
+ config.vm.synced_folder "../", "/vagrant", :nfs => true
37
+
38
+ # other config
39
+ # ...
40
+ end
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new
7
+ task :default => 'spec'
@@ -0,0 +1 @@
1
+ require "vagrant-guests-openbsd/plugin"
@@ -0,0 +1,15 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module GuestOpenBSD
5
+ class Config < Vagrant.plugin("2", :config)
6
+ attr_accessor :halt_timeout
7
+ attr_accessor :halt_check_interval
8
+
9
+ def initialize
10
+ @halt_timeout = 30
11
+ @halt_check_interval = 1
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,58 @@
1
+ require 'vagrant'
2
+ require 'log4r'
3
+
4
+ module VagrantPlugins
5
+ module GuestOpenBSD
6
+ class Guest < Vagrant.plugin("2", :guest)
7
+ class OpenBSDError < Vagrant::Errors::VagrantError
8
+ error_namespace("vagrant.guest.openbsd")
9
+ end
10
+
11
+ def initialize(*args)
12
+ super
13
+ @logger = Log4r::Logger.new("vagrant::guest::openbsd")
14
+ end
15
+
16
+ def halt
17
+ vm.communicate.sudo("shutdown -hp now")
18
+ end
19
+
20
+ def mount_shared_folder(name, guestpath, options)
21
+ @logger.info("OpenBSD does not have shared folder support. Use nfs option instead.")
22
+ end
23
+
24
+ def mount_nfs(ip, folders)
25
+ folders.each do |name, opts|
26
+ vm.communicate.sudo("mkdir -p #{opts[:guestpath]}")
27
+ vm.communicate.sudo("mount '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'")
28
+ end
29
+ end
30
+
31
+ def configure_networks(networks)
32
+ # remove any hostname.em expect hostname.em0
33
+ vm.communicate.sudo("[ -f /etc/hostname.em0 ] && mv /etc/hostname.em0 /tmp")
34
+ vm.communicate.sudo("rm /etc/hostname.em* || :")
35
+ vm.communicate.sudo("[ -f /tmp/hostname.em0 ] && mv /tmp/hostname.em0 /etc")
36
+
37
+ networks.each do |network|
38
+ case network[:type]
39
+ when :static
40
+ vm.communicate.sudo("su -m root -c 'echo inet #{network[:ip]} #{network[:netmask]}" +
41
+ " > /etc/hostname.em#{network[:interface]}'")
42
+ vm.communicate.sudo("sh /etc/netstart em#{network[:interface]}")
43
+ when :dhcp
44
+ vm.communicate.sudo("su -m root -c 'echo dhcp > /etc/hostname.em#{network[:interface]}'")
45
+ vm.communicate.sudo("sh /etc/netstart em#{network[:interface]}")
46
+ end
47
+ end
48
+ end
49
+
50
+ def change_host_name(name)
51
+ if !vm.communicate.test("[ `hostname -f` = #{name} ] || [ `hostname -s` = #{name} ]")
52
+ vm.communicate.sudo("su -m root -c 'echo #{name} > /etc/myname'")
53
+ vm.communicate.sudo("hostname #{name}")
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,20 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module GuestOpenBSD
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "OpenBSD guest"
7
+ description "OpenBSD guest support."
8
+
9
+ config("openbsd") do
10
+ require_relative "config"
11
+ Config
12
+ end
13
+
14
+ guest("openbsd") do
15
+ require_relative "guest"
16
+ Guest
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,71 @@
1
+ require 'vagrant-guests-openbsd/guest'
2
+
3
+ describe VagrantPlugins::GuestOpenBSD::Guest do
4
+ let(:communicate) {
5
+ double("communicate")
6
+ }
7
+ let(:vm) {
8
+ v = double("vm")
9
+ v.stub(:communicate).and_return(communicate)
10
+ v
11
+ }
12
+ let(:guest) {
13
+ described_class.new(vm)
14
+ }
15
+
16
+ it "should halt guest using 'shutdown -hp now'" do
17
+ communicate.should_receive(:sudo).with("shutdown -hp now")
18
+ guest.halt
19
+ end
20
+
21
+ it "should mount nfs folders" do
22
+ ip = "192.168.1.1"
23
+ folders = {
24
+ 'folder1' => {:guestpath => '/guest1', :hostpath => '/host1'},
25
+ 'folder2' => {:guestpath => '/guest2', :hostpath => '/host2'}
26
+ }
27
+ folders.each do |name, opts|
28
+ communicate.should_receive(:sudo).with("mkdir -p #{opts[:guestpath]}")
29
+ communicate.should_receive(:sudo).with("mount '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'")
30
+ end
31
+ guest.mount_nfs(ip, folders)
32
+ end
33
+
34
+ it "should configure networks using hostname.in(5)" do
35
+ networks = [
36
+ {:type => :static, :ip => '192.168.10.10', :netmask => '255.255.255.0', :interface => 1},
37
+ {:type => :dhcp, :interface => 2},
38
+ {:type => :static, :ip => '10.168.10.10', :netmask => '255.255.0.0', :interface => 3},
39
+ ]
40
+ communicate.should_receive(:sudo).with("[ -f /etc/hostname.em0 ] && mv /etc/hostname.em0 /tmp")
41
+ communicate.should_receive(:sudo).with("rm /etc/hostname.em* || :")
42
+ communicate.should_receive(:sudo).with("[ -f /tmp/hostname.em0 ] && mv /tmp/hostname.em0 /etc")
43
+
44
+ communicate.should_receive(:sudo).with(
45
+ "su -m root -c 'echo inet #{networks[0][:ip]} #{networks[0][:netmask]} > /etc/hostname.em#{networks[0][:interface]}'")
46
+ communicate.should_receive(:sudo).with("sh /etc/netstart em#{networks[0][:interface]}")
47
+ communicate.should_receive(:sudo).with(
48
+ "su -m root -c 'echo dhcp > /etc/hostname.em#{networks[1][:interface]}'")
49
+ communicate.should_receive(:sudo).with("sh /etc/netstart em#{networks[1][:interface]}")
50
+ communicate.should_receive(:sudo).with(
51
+ "su -m root -c 'echo inet #{networks[2][:ip]} #{networks[2][:netmask]} > /etc/hostname.em#{networks[2][:interface]}'")
52
+ communicate.should_receive(:sudo).with("sh /etc/netstart em#{networks[2][:interface]}")
53
+
54
+ guest.configure_networks(networks)
55
+ end
56
+
57
+ it "should change hostname when hostname is differ from current" do
58
+ hostname = 'vagrant-openbsd'
59
+ communicate.stub(:test).and_return(false)
60
+ communicate.should_receive(:sudo).with("su -m root -c 'echo #{hostname} > /etc/myname'")
61
+ communicate.should_receive(:sudo).with("hostname #{hostname}")
62
+ guest.change_host_name(hostname)
63
+ end
64
+
65
+ it "should not change hostname when hostname equals current" do
66
+ hostname = 'vagrant-openbsd'
67
+ communicate.stub(:test).and_return(true)
68
+ communicate.should_not_receive(:sudo)
69
+ guest.change_host_name(hostname)
70
+ end
71
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "vagrant-guests-openbsd"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["TANABE Ken-ichi"]
9
+ spec.email = ["nabeken@tknetworks.org"]
10
+ spec.description = %q{Vagrant Guests Plugin for OpenBSD}
11
+ spec.summary = %q{This plugins allows you to run OpenBSD under vagrant}
12
+ spec.homepage = "https://github.com/nabeken/vagrant-guests-openbsd"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec-core"
23
+ spec.add_development_dependency "rspec-expectations"
24
+ spec.add_development_dependency "rspec-mocks"
25
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-guests-openbsd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - TANABE Ken-ichi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec-core
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rspec-expectations
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec-mocks
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Vagrant Guests Plugin for OpenBSD
95
+ email:
96
+ - nabeken@tknetworks.org
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .rspec
103
+ - .travis.yml
104
+ - Gemfile
105
+ - LICENSE.txt
106
+ - README.md
107
+ - Rakefile
108
+ - lib/vagrant-guests-openbsd.rb
109
+ - lib/vagrant-guests-openbsd/config.rb
110
+ - lib/vagrant-guests-openbsd/guest.rb
111
+ - lib/vagrant-guests-openbsd/plugin.rb
112
+ - spec/guest_spec.rb
113
+ - vagrant-guests-openbsd.gemspec
114
+ homepage: https://github.com/nabeken/vagrant-guests-openbsd
115
+ licenses:
116
+ - MIT
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ segments:
128
+ - 0
129
+ hash: 2395952838110609467
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ segments:
137
+ - 0
138
+ hash: 2395952838110609467
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 1.8.23
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: This plugins allows you to run OpenBSD under vagrant
145
+ test_files:
146
+ - spec/guest_spec.rb