vagrant-vyatta 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 KUSAKABE Yuya
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,31 @@
1
+ # vagrant-vyatta
2
+
3
+ Vagrant-vyatta is a [Vagrant](http://www.vagrantup.com) plugin that adds a [Vyatta](http://www.vyatta.org/) support to Vagrant.
4
+
5
+ This plugin fixes following features.
6
+
7
+ * `vagrant halt`.
8
+ * `config.vm.hostname`.
9
+ * `config.vm.network`.
10
+
11
+ ## Installation
12
+
13
+ ```
14
+ $ vagrant plugin install vagrant-vyatta
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```
20
+ $ vagrant box add vyatta http://higebu.com/box/vyatta-livecd_VC6.5R1_amd64_virtualbox.box
21
+ $ vagrant init vyatta
22
+ $ vagrant up
23
+ ```
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+
4
+ # Immediately sync all stdout so that tools like buildbot can
5
+ # immediately load in the output.
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
9
+ # Change to the directory of this file.
10
+ Dir.chdir(File.expand_path("../", __FILE__))
11
+
12
+ # This installs the tasks that help with gem creation and
13
+ # publishing.
14
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,35 @@
1
+ require 'tempfile'
2
+
3
+ module VagrantPlugins
4
+ module GuestVyatta
5
+ module Cap
6
+ class ChangeHostName
7
+ def self.change_host_name(machine, name)
8
+ machine.communicate.tap do |comm|
9
+ if !comm.test("sudo hostname | grep '^#{name}$'")
10
+
11
+ commands = <<-EOS
12
+ WRAPPER=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper
13
+ . /etc/bash_completion
14
+ $WRAPPER begin
15
+ $WRAPPER set system host-name #{name}
16
+ $WRAPPER commit
17
+ $WRAPPER save
18
+ $WRAPPER end
19
+ EOS
20
+
21
+ temp = Tempfile.new("vagrant")
22
+ temp.binmode
23
+ temp.write(commands)
24
+ temp.close
25
+
26
+ comm.upload(temp.path, "/tmp/vagrant-change-hostname")
27
+ comm.sudo("sudo bash /tmp/vagrant-change-hostname")
28
+ comm.sudo("sudo rm /tmp/vagrant-change-hostname")
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,47 @@
1
+ require 'ipaddr'
2
+ require 'tempfile'
3
+
4
+ module VagrantPlugins
5
+ module GuestVyatta
6
+ module Cap
7
+ class ConfigureNetworks
8
+
9
+ def self.configure_networks(machine, networks)
10
+ machine.communicate.tap do |comm|
11
+
12
+ commands = <<-EOS
13
+ WRAPPER=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper
14
+ . /etc/bash_completion
15
+ $WRAPPER begin
16
+ EOS
17
+
18
+ networks.each do |network|
19
+ commands << "$WRAPPER delete interfaces ethernet eth#{network[:interface]}\n"
20
+ if network[:type].to_sym == :static
21
+ subnet = IPAddr.new(network[:netmask]).to_i.to_s(2).count("1")
22
+ commands << "$WRAPPER set interfaces ethernet eth#{network[:interface]} address #{network[:ip]}/#{subnet}\n"
23
+ elsif network[:type].to_sym == :dhcp
24
+ commands << "$WRAPPER set interfaces ethernet eth#{network[:interface]} address dhcp\n"
25
+ end
26
+ end
27
+
28
+ commands << <<-EOS
29
+ $WRAPPER commit
30
+ $WRAPPER save
31
+ $WRAPPER end
32
+ EOS
33
+
34
+ temp = Tempfile.new("vagrant")
35
+ temp.binmode
36
+ temp.write(commands)
37
+ temp.close
38
+
39
+ comm.upload(temp.path, "/tmp/vagrant-configure-network")
40
+ comm.sudo("sudo bash /tmp/vagrant-configure-network")
41
+ comm.sudo("sudo rm /tmp/vagrant-configure-network")
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module GuestVyatta
3
+ module Cap
4
+ class Halt
5
+ def self.halt(machine)
6
+ begin
7
+ machine.communicate.sudo("sudo shutdown -h now")
8
+ rescue IOError
9
+ # Do nothing, because it probably means the machine shut down
10
+ # and SSH connection was lost.
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ require "vagrant"
2
+
3
+ require Vagrant.source_root.join("plugins/guests/debian/guest")
4
+
5
+ module VagrantPlugins
6
+ module GuestVyatta
7
+ class Guest < VagrantPlugins::GuestDebian::Guest
8
+ def detect?(machine)
9
+ machine.communicate.test("cat /etc/issue | grep 'Vyatta'")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,30 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module GuestVyatta
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "Vyatta guest"
7
+ description "Vyatta guest support."
8
+
9
+ guest("vyatta", "debian") do
10
+ require File.expand_path("../guest", __FILE__)
11
+ Guest
12
+ end
13
+
14
+ guest_capability("vyatta", "halt") do
15
+ require_relative "cap/halt"
16
+ Cap::Halt
17
+ end
18
+
19
+ guest_capability("vyatta", "configure_networks") do
20
+ require_relative "cap/configure_networks"
21
+ Cap::ConfigureNetworks
22
+ end
23
+
24
+ guest_capability("vyatta", "change_host_name") do
25
+ require_relative "cap/change_host_name"
26
+ Cap::ChangeHostName
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module GuestVyatta
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,18 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-vyatta/plugin"
4
+
5
+ module VagrantPlugins
6
+ module GuestVyatta
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-vyatta", __FILE__))
8
+ autoload :Action, lib_path.join("action")
9
+ autoload :Errors, lib_path.join("errors")
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ $:.unshift File.expand_path("../lib", __FILE__)
3
+ require 'vagrant-vyatta/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "vagrant-vyatta"
7
+ s.version = VagrantPlugins::GuestVyatta::VERSION
8
+ s.authors = ["KUSAKABE Yuya"]
9
+ s.email = ["yuya.kusakabe@gmail.com"]
10
+ s.description = "Enables Vagrant to manage Vyatta"
11
+ s.summary = "Enables Vagrant to manage Vyatta"
12
+ s.homepage = "https://github.com/higebu/vagrant-vyatta"
13
+ s.license = "MIT"
14
+
15
+ s.required_rubygems_version = ">= 1.8.23"
16
+ s.rubyforge_project = "vagrant-vyatta"
17
+
18
+ s.add_development_dependency "bundler", "~> 1.3"
19
+ s.add_development_dependency "rake"
20
+
21
+ # The following block of code determines the files that should be included
22
+ # in the gem. It does this by reading all the files in the directory where
23
+ # this gemspec is, and parsing out the ignored files from the gitignore.
24
+ # Note that the entire gitignore(5) syntax is not supported, specifically
25
+ # the "!" syntax, but it should mostly work correctly.
26
+ root_path = File.dirname(__FILE__)
27
+ all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
28
+ all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
29
+ gitignore_path = File.join(root_path, ".gitignore")
30
+ gitignore = File.readlines(gitignore_path)
31
+ gitignore.map! { |line| line.chomp.strip }
32
+ gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
33
+
34
+ unignored_files = all_files.reject do |file|
35
+ # Ignore any directories, the gemspec only cares about files
36
+ next true if File.directory?(file)
37
+
38
+ # Ignore any paths that match anything in the gitignore. We do
39
+ # two tests here:
40
+ #
41
+ # - First, test to see if the entire path matches the gitignore.
42
+ # - Second, match if the basename does, this makes it so that things
43
+ # like '.DS_Store' will match sub-directories too (same behavior
44
+ # as git).
45
+ #
46
+ gitignore.any? do |ignore|
47
+ File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
48
+ File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
49
+ end
50
+ end
51
+
52
+ s.files = unignored_files
53
+ s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
54
+ s.require_path = 'lib'
55
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-vyatta
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - KUSAKABE Yuya
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-23 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
+ description: Enables Vagrant to manage Vyatta
47
+ email:
48
+ - yuya.kusakabe@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - Gemfile
54
+ - Rakefile
55
+ - README.md
56
+ - lib/vagrant-vyatta/version.rb
57
+ - lib/vagrant-vyatta/plugin.rb
58
+ - lib/vagrant-vyatta/guest.rb
59
+ - lib/vagrant-vyatta/cap/change_host_name.rb
60
+ - lib/vagrant-vyatta/cap/configure_networks.rb
61
+ - lib/vagrant-vyatta/cap/halt.rb
62
+ - lib/vagrant-vyatta.rb
63
+ - LICENSE
64
+ - vagrant-vyatta.gemspec
65
+ - .gitignore
66
+ homepage: https://github.com/higebu/vagrant-vyatta
67
+ licenses:
68
+ - MIT
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ segments:
80
+ - 0
81
+ hash: 4242460176597138424
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 1.8.23
88
+ requirements: []
89
+ rubyforge_project: vagrant-vyatta
90
+ rubygems_version: 1.8.23
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Enables Vagrant to manage Vyatta
94
+ test_files: []