vagrant-vyos 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +20 -0
- data/.travis.yml +9 -0
- data/Gemfile +10 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +14 -0
- data/lib/vagrant-vyos.rb +18 -0
- data/lib/vagrant-vyos/cap/change_host_name.rb +32 -0
- data/lib/vagrant-vyos/cap/configure_networks.rb +44 -0
- data/lib/vagrant-vyos/cap/halt.rb +16 -0
- data/lib/vagrant-vyos/guest.rb +13 -0
- data/lib/vagrant-vyos/plugin.rb +30 -0
- data/lib/vagrant-vyos/version.rb +5 -0
- data/vagrant-vyos.gemspec +25 -0
- metadata +92 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZWRmN2MwZjNjMzc0YTgzZDViMGYwZDMwOGY0ZmFlZTgxMjI2ZTE3Mg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTYxZGIxMWVlMjQwMGJlYThmZDAwZTNmNDVhZTBmYTkzYzQxZjMzZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NzM0Y2MyZTg3ZWI5YzljNzRkNTc5MDFkNWE4Y2E2MjFhYzc2MjhmZjI2MzVl
|
10
|
+
MjMwMzhlZDUxY2VkMjQ2ODAyZjI5OTU2Y2YxMWE1MzkxMzI5MWIwMWFhMDkx
|
11
|
+
M2UyNDc5NjcwNzE3ZDI4MTVjOTc3MDY1OTU2NTNiZTJkMzk3OTU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTM4MmJlZDUxYWU1NWYwYWI4ZDBhYzk2OTE4ZGQ0YWQwMGM4NmUwMTI4ZjU5
|
14
|
+
ZDFkY2JlMDcwZTBkZjZlNWRmZjA1N2JmOWYwNTg4YjMwNmM4NzFiZjBlNWEz
|
15
|
+
YzQ4YmZjOWVkMTM4YmZjN2JiY2M0ZjZlZDZkOGJhODZhNzhlYTQ=
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
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,34 @@
|
|
1
|
+
# vagrant-vyos
|
2
|
+
[![Build Status](https://travis-ci.org/higebu/vagrant-vyos.png)](https://travis-ci.org/higebu/vagrant-vyos)
|
3
|
+
[![Code Climate](https://codeclimate.com/repos/5302538e69568020f60027b2/badges/c5b01915845941764536/gpa.png)](https://codeclimate.com/repos/5302538e69568020f60027b2/feed)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/vagrant-vyos.png)](http://badge.fury.io/rb/vagrant-vyos)
|
5
|
+
[![Dependency Status](https://gemnasium.com/higebu/vagrant-vyos.png)](https://gemnasium.com/higebu/vagrant-vyos)
|
6
|
+
|
7
|
+
Vagrant-vyos is a [Vagrant](http://www.vagrantup.com) plugin that adds [VyOS](http://vyos.net/wiki/Main_Page) support to Vagrant.
|
8
|
+
|
9
|
+
This plugin fixes following features.
|
10
|
+
|
11
|
+
* `vagrant halt`.
|
12
|
+
* `config.vm.hostname`.
|
13
|
+
* `config.vm.network`.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
```
|
18
|
+
$ vagrant plugin install vagrant-vyos
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
$ vagrant init higebu/vyos-1.1.4
|
25
|
+
$ vagrant up
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contributing
|
29
|
+
|
30
|
+
1. Fork it
|
31
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
32
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
33
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
34
|
+
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
|
data/lib/vagrant-vyos.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
require "vagrant-vyos/plugin"
|
4
|
+
|
5
|
+
module VagrantPlugins
|
6
|
+
module GuestVyOS
|
7
|
+
lib_path = Pathname.new(File.expand_path("../vagrant-vyos", __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,32 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestVyOS
|
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
|
+
source /opt/vyatta/etc/functions/script-template
|
13
|
+
set system host-name #{name}
|
14
|
+
commit
|
15
|
+
save
|
16
|
+
EOS
|
17
|
+
|
18
|
+
temp = Tempfile.new("vagrant")
|
19
|
+
temp.binmode
|
20
|
+
temp.write(commands)
|
21
|
+
temp.close
|
22
|
+
|
23
|
+
comm.upload(temp.path, "/tmp/vagrant-change-hostname")
|
24
|
+
comm.execute("bash /tmp/vagrant-change-hostname")
|
25
|
+
comm.execute("rm -f /tmp/vagrant-change-hostname")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
module VagrantPlugins
|
5
|
+
module GuestVyOS
|
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
|
+
source /opt/vyatta/etc/functions/script-template
|
14
|
+
EOS
|
15
|
+
|
16
|
+
networks.each do |network|
|
17
|
+
commands << "delete interfaces ethernet eth#{network[:interface]}\n"
|
18
|
+
if network[:type].to_sym == :static
|
19
|
+
subnet = IPAddr.new(network[:netmask]).to_i.to_s(2).count("1")
|
20
|
+
commands << "set interfaces ethernet eth#{network[:interface]} address #{network[:ip]}/#{subnet}\n"
|
21
|
+
elsif network[:type].to_sym == :dhcp
|
22
|
+
commands << "set interfaces ethernet eth#{network[:interface]} address dhcp\n"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
commands << <<-EOS
|
27
|
+
commit
|
28
|
+
save
|
29
|
+
EOS
|
30
|
+
|
31
|
+
temp = Tempfile.new("vagrant")
|
32
|
+
temp.binmode
|
33
|
+
temp.write(commands)
|
34
|
+
temp.close
|
35
|
+
|
36
|
+
comm.upload(temp.path, "/tmp/vagrant-configure-network")
|
37
|
+
comm.execute("bash /tmp/vagrant-configure-network")
|
38
|
+
comm.execute("rm -f /tmp/vagrant-configure-network")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module VagrantPlugins
|
2
|
+
module GuestVyOS
|
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 GuestVyOS
|
7
|
+
class Guest < VagrantPlugins::GuestDebian::Guest
|
8
|
+
def detect?(machine)
|
9
|
+
machine.communicate.test("cat /etc/issue | grep -e 'VyOS'")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module GuestVyOS
|
5
|
+
class Plugin < Vagrant.plugin("2")
|
6
|
+
name "VyOS guest"
|
7
|
+
description "VyOS guest support."
|
8
|
+
|
9
|
+
guest("vyos", "debian") do
|
10
|
+
require File.expand_path("../guest", __FILE__)
|
11
|
+
Guest
|
12
|
+
end
|
13
|
+
|
14
|
+
guest_capability("vyos", "halt") do
|
15
|
+
require_relative "cap/halt"
|
16
|
+
Cap::Halt
|
17
|
+
end
|
18
|
+
|
19
|
+
guest_capability("vyos", "configure_networks") do
|
20
|
+
require_relative "cap/configure_networks"
|
21
|
+
Cap::ConfigureNetworks
|
22
|
+
end
|
23
|
+
|
24
|
+
guest_capability("vyos", "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,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/vagrant-vyos/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "vagrant-vyos"
|
6
|
+
spec.version = VagrantPlugins::GuestVyOS::VERSION
|
7
|
+
spec.authors = ["KUSAKABE Yuya"]
|
8
|
+
spec.email = ["yuya.kusakabe@gmail.com"]
|
9
|
+
spec.description = "VyOS Guest Support for Vagrant"
|
10
|
+
spec.summary = "A small gem that adds vyos guest support to vagrant."
|
11
|
+
spec.homepage = "https://github.com/higebu/vagrant-vyos"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($\)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.required_ruby_version = ">= 2.0.0"
|
20
|
+
spec.required_rubygems_version = ">= 1.3.6"
|
21
|
+
spec.rubyforge_project = "vagrant-vyos"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", ">= 1.5.2", "< 1.8.0"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-vyos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KUSAKABE Yuya
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 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.5.2
|
20
|
+
- - <
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.8.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.5.2
|
30
|
+
- - <
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.8.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: VyOS Guest Support for Vagrant
|
48
|
+
email:
|
49
|
+
- yuya.kusakabe@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- .travis.yml
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- lib/vagrant-vyos.rb
|
61
|
+
- lib/vagrant-vyos/cap/change_host_name.rb
|
62
|
+
- lib/vagrant-vyos/cap/configure_networks.rb
|
63
|
+
- lib/vagrant-vyos/cap/halt.rb
|
64
|
+
- lib/vagrant-vyos/guest.rb
|
65
|
+
- lib/vagrant-vyos/plugin.rb
|
66
|
+
- lib/vagrant-vyos/version.rb
|
67
|
+
- vagrant-vyos.gemspec
|
68
|
+
homepage: https://github.com/higebu/vagrant-vyos
|
69
|
+
licenses:
|
70
|
+
- MIT
|
71
|
+
metadata: {}
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 2.0.0
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.3.6
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project: vagrant-vyos
|
88
|
+
rubygems_version: 2.4.6
|
89
|
+
signing_key:
|
90
|
+
specification_version: 4
|
91
|
+
summary: A small gem that adds vyos guest support to vagrant.
|
92
|
+
test_files: []
|