vagrant-junos 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fb4dad728643a6fb389e6f0bd626829c58ca157
4
- data.tar.gz: d9d7fbb07568e587c1741c2a58094228f70ee226
3
+ metadata.gz: f72d17a04c64856719508d00372f21a3c0aab8fa
4
+ data.tar.gz: c94681cd514bcdbacecf4d9ede3f64bd673864fa
5
5
  SHA512:
6
- metadata.gz: 950a39dbe62ba0c2efd7d40e2d9d7a2a288513d5ba9fc9f0f584be449ca225ec505bdb26fbe8aefd8412c93cba38959b20c0578aeb9d35fdbcafb4b1e02efe33
7
- data.tar.gz: b495e7fbdc6d71f60753f1c11c5b8e78e7d18fb75a776b9af59e8e20c224c826f33f8ca0ef1b3746d2262b320ee9f10398142aaed1f22aa68b66eb6a6ff5de2d
6
+ metadata.gz: 9569b8b166cc1873ee64cb6b237f92fd84f671c61de68f11d7db99cb1f1ce9dee7044f0c1ae0ec17ccd0ce9cea82d5f84e7fb4e3134590dcf188d2f9e2a2a785
7
+ data.tar.gz: a7e99c05261a0c9aa12a5ef93c809302722558cac2bc0e53ce8488472a25e90a111e55e23e477434b6e84d6a1a52d2bdd8d2b6843c533537b16ac91f4d293db5
@@ -2,3 +2,5 @@ Style/FileName:
2
2
  Enabled: false
3
3
  Style/LineLength:
4
4
  Enabled: false
5
+ Style/StringLiterals:
6
+ Enabled: false
@@ -1 +1 @@
1
- 2.0.0-p481
1
+ 2.0.0-p576
@@ -2,11 +2,19 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 1.9.3
5
- - 2.1.1
6
- - 2.1.2
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
- - gem install bundler -v '1.5.3'
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
@@ -9,4 +9,11 @@ group :plugins do
9
9
  gem 'vagrant-junos', path: '.'
10
10
  end
11
11
 
12
+ group 'test' do
13
+ gem 'rake'
14
+ gem 'chefspec'
15
+ gem 'foodcritic'
16
+ gem 'rubocop'
17
+ end
18
+
12
19
  gemspec
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # [Vagrant Junos Guest](https://github.com/JNPRAutomate/vagrant-junos)
2
2
 
3
- [![Build Status](https://travis-ci.org/JNPRAutomate/vagrant-junos.svg?branch=master)](https://travis-ci.org/JNPRAutomate/vagrant-junos)[![Gem Version](https://badge.fury.io/rb/vagrant-junos.svg)](http://badge.fury.io/rb/vagrant-junos)[![Dependency Status](https://gemnasium.com/JNPRAutomate/vagrant-junos.svg)](https://gemnasium.com/JNPRAutomate/vagrant-junos)
3
+ [![Build Status](https://travis-ci.org/JNPRAutomate/vagrant-junos.svg?branch=master)](https://travis-ci.org/JNPRAutomate/vagrant-junos)[![Gem Version](https://badge.fury.io/rb/vagrant-junos.svg)](http://badge.fury.io/rb/vagrant-junos)[![Code Climate](https://codeclimate.com/github/JNPRAutomate/vagrant-junos/badges/gpa.svg)](https://codeclimate.com/github/JNPRAutomate/vagrant-junos)[![Dependency Status](https://gemnasium.com/JNPRAutomate/vagrant-junos.svg)](https://gemnasium.com/JNPRAutomate/vagrant-junos)
4
4
 
5
5
 
6
6
 
@@ -1,30 +1,40 @@
1
1
  require 'tempfile'
2
- # require 'vagrant/util/template_renderer'
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
- commands = <<-EOS
13
- configure
14
- set system host-name #{name}
15
- commit and-quit
16
- EOS
17
- Tempfile.open('vagrant') do |temp|
18
- temp.binmode
19
- temp.write(commands)
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
- commands = <<-EOS
15
- configure
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
@@ -1,13 +1,13 @@
1
1
  begin
2
2
  require 'vagrant'
3
3
  rescue LoadError
4
- raise 'The Vagrant Junos plugin must be run within Vagrant'
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 Vagrant Junos plugin is only compatible with Vagrant 1.6+'
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
- # guest_capability('junos', 'configure_networks') do
34
- # require_relative 'cap/configure_networks'
35
- # Cap::ConfigureNetworks
36
- # end
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
- # guest_capability('junos', 'insert_public_key') do
44
- # require_relative 'cap/insert_public_key'
45
- # Cap::InsertPublicKey
46
- # end
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
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  # Junos guest gem + plugin version
3
3
  module GuestJunos
4
- VERSION = '0.0.3'
4
+ VERSION = '0.0.4'
5
5
  end
6
6
  end
@@ -0,0 +1,3 @@
1
+ configure
2
+ set system host-name <%= name %>
3
+ commit and-quit
@@ -0,0 +1,6 @@
1
+ configure
2
+ wildcard range delete interfaces ge-0/0/[1-9]
3
+ <% options.each do |options| -%>
4
+ set interfaces ge-0/0/<%= options[:interface].to_i %> unit 0 family inet address <%= options[:ip] %>/<%= options[:prefix_length] %>
5
+ <% end -%>
6
+ commit and-quit
@@ -0,0 +1,3 @@
1
+ configure
2
+ set system root-password ssh-rsa <%= contents %>
3
+ commit and-quit
@@ -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', '< 1.7.0', '>= 1.5.2'
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.3
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-09-18 00:00:00.000000000 Z
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.5.2
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.5.2
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.1.9
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