vagrant-junos 0.0.3 → 0.0.4
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 +4 -4
- data/.rubocop.yml +2 -0
- data/.ruby-version +1 -1
- data/.travis.yml +11 -3
- data/Gemfile +7 -0
- data/README.md +1 -1
- data/lib/vagrant-junos/cap/change_host_name.rb +22 -12
- data/lib/vagrant-junos/cap/configure_networks.rb +52 -0
- data/lib/vagrant-junos/cap/insert_public_key.rb +24 -13
- data/lib/vagrant-junos/plugin.rb +10 -10
- data/lib/vagrant-junos/version.rb +1 -1
- data/templates/guest/junos/hostname.erb +3 -0
- data/templates/guest/junos/network.erb +6 -0
- data/templates/guest/junos/public_key.erb +3 -0
- data/vagrant-junos.gemspec +1 -1
- metadata +11 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f72d17a04c64856719508d00372f21a3c0aab8fa
|
4
|
+
data.tar.gz: c94681cd514bcdbacecf4d9ede3f64bd673864fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9569b8b166cc1873ee64cb6b237f92fd84f671c61de68f11d7db99cb1f1ce9dee7044f0c1ae0ec17ccd0ce9cea82d5f84e7fb4e3134590dcf188d2f9e2a2a785
|
7
|
+
data.tar.gz: a7e99c05261a0c9aa12a5ef93c809302722558cac2bc0e53ce8488472a25e90a111e55e23e477434b6e84d6a1a52d2bdd8d2b6843c533537b16ac91f4d293db5
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0-
|
1
|
+
2.0.0-p576
|
data/.travis.yml
CHANGED
@@ -2,11 +2,19 @@ language: ruby
|
|
2
2
|
|
3
3
|
rvm:
|
4
4
|
- 1.9.3
|
5
|
-
- 2.
|
6
|
-
- 2.1.
|
5
|
+
- 2.0.0
|
6
|
+
- 2.1.3
|
7
|
+
|
8
|
+
env:
|
9
|
+
global:
|
10
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
7
11
|
|
8
12
|
before_install:
|
9
|
-
-
|
13
|
+
- sudo apt-get update -qq
|
14
|
+
- sudo apt-get install -qq -y bsdtar
|
15
|
+
- rvm @global do gem uninstall bundler --all --executables
|
16
|
+
- gem uninstall bundler --all --executables
|
17
|
+
- gem install bundler --version '< 1.7.0'
|
10
18
|
|
11
19
|
script: bundle exec rake build
|
12
20
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# [Vagrant Junos Guest](https://github.com/JNPRAutomate/vagrant-junos)
|
2
2
|
|
3
|
-
[](https://travis-ci.org/JNPRAutomate/vagrant-junos)[](http://badge.fury.io/rb/vagrant-junos)[](https://gemnasium.com/JNPRAutomate/vagrant-junos)
|
3
|
+
[](https://travis-ci.org/JNPRAutomate/vagrant-junos)[](http://badge.fury.io/rb/vagrant-junos)[](https://codeclimate.com/github/JNPRAutomate/vagrant-junos)[](https://gemnasium.com/JNPRAutomate/vagrant-junos)
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -1,30 +1,40 @@
|
|
1
1
|
require 'tempfile'
|
2
|
-
|
2
|
+
require 'vagrant-junos/version'
|
3
|
+
require 'vagrant/util/template_renderer'
|
3
4
|
|
4
5
|
module VagrantPlugins
|
5
6
|
module GuestJunos
|
6
7
|
module Cap
|
7
8
|
# host name change capability - needs to be Junos-aware
|
8
9
|
class ChangeHostName
|
10
|
+
include Vagrant::Util
|
11
|
+
|
9
12
|
def self.change_host_name(machine, name)
|
10
13
|
machine.communicate.tap do |comm|
|
11
14
|
unless comm.test("hostname | grep '^#{name}$'")
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
temp.close
|
21
|
-
comm.upload(temp.path, '/mfs/tmp/set_hostname')
|
22
|
-
end
|
15
|
+
|
16
|
+
# render template, based on Vagrantfile, and upload
|
17
|
+
hostname_module = TemplateRenderer.render('guest/junos/hostname',
|
18
|
+
name: name,
|
19
|
+
template_root: "#{Dir.home}/.vagrant.d/gems/gems/vagrant-junos-#{VagrantPlugins::GuestJunos::VERSION}/templates")
|
20
|
+
upload(machine, hostname_module, '/mfs/tmp/set_hostname')
|
21
|
+
|
22
|
+
# set up us the Junos interfaces
|
23
23
|
comm.execute('cli -f /mfs/tmp/set_hostname')
|
24
24
|
comm.execute('rm /mfs/tmp/set_hostname')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
# Upload a file.
|
30
|
+
def self.upload(machine, content, remote_temp)
|
31
|
+
local_temp = Tempfile.new('vagrant-upload')
|
32
|
+
local_temp.binmode
|
33
|
+
local_temp.write(content)
|
34
|
+
local_temp.close
|
35
|
+
machine.communicate.upload(local_temp.path, "#{remote_temp}")
|
36
|
+
local_temp.delete
|
37
|
+
end
|
28
38
|
end
|
29
39
|
end
|
30
40
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'ipaddr'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'vagrant-junos/version'
|
4
|
+
require 'vagrant/util/template_renderer'
|
5
|
+
|
6
|
+
module VagrantPlugins
|
7
|
+
module GuestJunos
|
8
|
+
module Cap
|
9
|
+
# Configure Junos network interfaces
|
10
|
+
module ConfigureNetworks
|
11
|
+
include Vagrant::Util
|
12
|
+
|
13
|
+
def self.configure_networks(machine, networks)
|
14
|
+
# set the prefix length
|
15
|
+
networks.each do |network|
|
16
|
+
network[:prefix_length] = (network[:netmask] && netmask_to_cidr(network[:netmask]))
|
17
|
+
end
|
18
|
+
|
19
|
+
# render template, based on Vagrantfile, and upload
|
20
|
+
network_module = TemplateRenderer.render('guest/junos/network',
|
21
|
+
options: networks,
|
22
|
+
template_root: "#{Dir.home}/.vagrant.d/gems/gems/vagrant-junos-#{VagrantPlugins::GuestJunos::VERSION}/templates")
|
23
|
+
upload(machine, network_module, '/mfs/tmp/network')
|
24
|
+
deploy(machine)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Upload a file.
|
28
|
+
def self.upload(machine, content, remote_temp)
|
29
|
+
local_temp = Tempfile.new('vagrant-upload')
|
30
|
+
local_temp.binmode
|
31
|
+
local_temp.write(content)
|
32
|
+
local_temp.close
|
33
|
+
machine.communicate.upload(local_temp.path, "#{remote_temp}")
|
34
|
+
local_temp.delete
|
35
|
+
end
|
36
|
+
|
37
|
+
# set up us the Junos interfaces
|
38
|
+
def self.deploy(machine)
|
39
|
+
machine.communicate.tap do |comm|
|
40
|
+
comm.execute('cli -f /mfs/tmp/network')
|
41
|
+
# comm.execute('rm /mfs/tmp/network')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# convert vagrant dotted-decimal notation to cidr
|
46
|
+
def self.netmask_to_cidr(mask)
|
47
|
+
IPAddr.new(mask).to_i.to_s(2).count('1')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -1,30 +1,41 @@
|
|
1
|
-
require 'vagrant/util/shell_quote'
|
2
1
|
require 'tempfile'
|
2
|
+
require 'vagrant-junos/version'
|
3
|
+
require 'vagrant/util/shell_quote'
|
4
|
+
require 'vagrant/util/template_renderer'
|
3
5
|
|
4
6
|
module VagrantPlugins
|
5
7
|
module GuestJunos
|
6
8
|
module Cap
|
7
9
|
# change root's public key
|
8
10
|
class InsertPublicKey
|
11
|
+
include Vagrant::Util
|
12
|
+
|
9
13
|
def self.insert_public_key(machine, contents)
|
10
14
|
contents = Vagrant::Util::Shellquote.escape(contents, "'")
|
11
15
|
contents = contents.gsub("\n", "\\n")
|
12
16
|
|
17
|
+
# render public key junos conf template, based on Vagrantfile, and upload
|
18
|
+
public_key_module = TemplateRenderer.render('guest/junos/public_key',
|
19
|
+
contents,
|
20
|
+
template_root: "#{Dir.home}/.vagrant.d/gems/gems/vagrant-junos-#{VagrantPlugins::GuestJunos::VERSION}/templates")
|
21
|
+
upload(machine, public_key_module, '/mfs/tmp/set_public_Key')
|
22
|
+
|
23
|
+
# set up us root's public key
|
13
24
|
machine.communicate.tap do |comm|
|
14
|
-
|
15
|
-
|
16
|
-
set system root-password ssh-rsa "#{contents}"
|
17
|
-
commit and-quit
|
18
|
-
EOS
|
19
|
-
temp = Tempfile.new('vagrant')
|
20
|
-
temp.binmode
|
21
|
-
temp.write(commands)
|
22
|
-
temp.close
|
23
|
-
comm.upload(temp.path '/mfs/tmp/set_root_key')
|
24
|
-
comm.execute('cli -f /mfs/tmp/set_root_key')
|
25
|
-
comm.execute('rm /mfs/tmp/set_root_key')
|
25
|
+
comm.execute('cli -f /mfs/tmp/set_public_key')
|
26
|
+
comm.execute('rm /mfs/tmp/set_public_key')
|
26
27
|
end
|
27
28
|
end
|
29
|
+
|
30
|
+
# Upload a file.
|
31
|
+
def self.upload(machine, content, remote_temp)
|
32
|
+
local_temp = Tempfile.new('vagrant-upload')
|
33
|
+
local_temp.binmode
|
34
|
+
local_temp.write(content)
|
35
|
+
local_temp.close
|
36
|
+
machine.communicate.upload(local_temp.path, "#{remote_temp}")
|
37
|
+
local_temp.delete
|
38
|
+
end
|
28
39
|
end
|
29
40
|
end
|
30
41
|
end
|
data/lib/vagrant-junos/plugin.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
begin
|
2
2
|
require 'vagrant'
|
3
3
|
rescue LoadError
|
4
|
-
raise 'The
|
4
|
+
raise 'The vagrant-junos plugin must be run within Vagrant'
|
5
5
|
end
|
6
6
|
|
7
7
|
# This is a sanity check to make sure no one is attempting to install
|
8
8
|
# this into an early Vagrant version.
|
9
9
|
if Vagrant::VERSION < '1.6.0'
|
10
|
-
fail 'The
|
10
|
+
fail 'The vagrant-junos plugin is only compatible with Vagrant 1.6+'
|
11
11
|
end
|
12
12
|
|
13
13
|
module VagrantPlugins
|
@@ -30,20 +30,20 @@ module VagrantPlugins
|
|
30
30
|
Cap::ChangeHostName
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
guest_capability('junos', 'configure_networks') do
|
34
|
+
require_relative 'cap/configure_networks'
|
35
|
+
Cap::ConfigureNetworks
|
36
|
+
end
|
37
37
|
|
38
38
|
guest_capability('junos', 'halt') do
|
39
39
|
require_relative 'cap/halt'
|
40
40
|
Cap::Halt
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
43
|
+
guest_capability('junos', 'insert_public_key') do
|
44
|
+
require_relative 'cap/insert_public_key'
|
45
|
+
Cap::InsertPublicKey
|
46
|
+
end
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/vagrant-junos.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6.6'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
spec.add_development_dependency 'rspec-core', '~> 2.14'
|
24
24
|
spec.add_development_dependency 'rspec-expectations', '~> 2.14'
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-junos
|
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
|
- John Deatherage
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.7.0
|
20
|
-
- - '>='
|
17
|
+
- - ~>
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 1.
|
19
|
+
version: 1.6.6
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 1.7.0
|
30
|
-
- - '>='
|
24
|
+
- - ~>
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 1.
|
26
|
+
version: 1.6.6
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rake
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,11 +97,15 @@ files:
|
|
103
97
|
- Rakefile
|
104
98
|
- lib/vagrant-junos.rb
|
105
99
|
- lib/vagrant-junos/cap/change_host_name.rb
|
100
|
+
- lib/vagrant-junos/cap/configure_networks.rb
|
106
101
|
- lib/vagrant-junos/cap/halt.rb
|
107
102
|
- lib/vagrant-junos/cap/insert_public_key.rb
|
108
103
|
- lib/vagrant-junos/guest.rb
|
109
104
|
- lib/vagrant-junos/plugin.rb
|
110
105
|
- lib/vagrant-junos/version.rb
|
106
|
+
- templates/guest/junos/hostname.erb
|
107
|
+
- templates/guest/junos/network.erb
|
108
|
+
- templates/guest/junos/public_key.erb
|
111
109
|
- vagrant-junos.gemspec
|
112
110
|
homepage: https://github.com/JNPRAutomate/vagrant-junos
|
113
111
|
licenses:
|
@@ -129,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
127
|
version: '0'
|
130
128
|
requirements: []
|
131
129
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.0.14
|
133
131
|
signing_key:
|
134
132
|
specification_version: 4
|
135
133
|
summary: A Vagrant plugin for Junos guests, e.g. Firefly Perimeter
|