vagrant-junos 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4fb4dad728643a6fb389e6f0bd626829c58ca157
4
+ data.tar.gz: d9d7fbb07568e587c1741c2a58094228f70ee226
5
+ SHA512:
6
+ metadata.gz: 950a39dbe62ba0c2efd7d40e2d9d7a2a288513d5ba9fc9f0f584be449ca225ec505bdb26fbe8aefd8412c93cba38959b20c0578aeb9d35fdbcafb4b1e02efe33
7
+ data.tar.gz: b495e7fbdc6d71f60753f1c11c5b8e78e7d18fb75a776b9af59e8e20c224c826f33f8ca0ef1b3746d2262b320ee9f10398142aaed1f22aa68b66eb6a6ff5de2d
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
16
+ .swp
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ Style/FileName:
2
+ Enabled: false
3
+ Style/LineLength:
4
+ Enabled: false
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0-p481
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.1.1
6
+ - 2.1.2
7
+
8
+ before_install:
9
+ - gem install bundler -v '1.5.3'
10
+
11
+ script: bundle exec rake build
12
+
13
+ notifications:
14
+ email:
15
+ on_success: never
16
+ on_failure: never
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
5
+ gem 'vagrant-spec', git: 'https://github.com/mitchellh/vagrant-spec.git'
6
+ end
7
+
8
+ group :plugins do
9
+ gem 'vagrant-junos', path: '.'
10
+ end
11
+
12
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Juniper Networks, Inc.
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,67 @@
1
+ # [Vagrant Junos Guest](https://github.com/JNPRAutomate/vagrant-junos)
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)
4
+
5
+
6
+
7
+ This is a [Vagrant](http://www.vagrantup.com) 1.6+ plugin that adds a Junos guest to Vagrant, allowing for OS detection and initial configuration
8
+
9
+ > **NOTE:** This plugin requires Vagrant 1.6.3+,
10
+
11
+ ## Features
12
+
13
+ * Detect [Firefly Perimeter](http://www.juniper.net/us/en/products-services/security/firefly-perimeter/) guest instances automatically, or via [Vagrantfile](https://docs.vagrantup.com/v2/vagrantfile/machine_settings.html). The default boxes on [Juniper's Vagrant Cloud site](https://vagrantcloud.com/Juniper) have `config.vm.guest` explicitly set to Junos.
14
+ * Set the hostname via [Vagrantfile](https://docs.vagrantup.com/v2/vagrantfile/machine_settings.html) - `config.vm.hostname`
15
+ * Change the default SSH key via the [Vagrantfile SSH settings](https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html) - `config.ssh.private_key_path`
16
+ * TBD: network configuration of ge-0/0/0.0 through ge-0/0/9.0
17
+ * TBD: mounting of NFS folders for sharing data, if this is valuable to anyone
18
+ * TBD: a switch to NETCONF-based configuration, if it adds any functionality
19
+
20
+ > **NOTE:** post-bootstrap configuration in Vagrant will be carried out through the [vagrant-netconf](https://github.com/JNPRAutomate/vagrant-netconf) communicator plugin and [vagrant-jprovision](https://github.com/JNPRAutomate/vagrant-jprovision) provisioner plugin. These may or may not be required in the premade boxes in the future.
21
+
22
+ ## Usage
23
+
24
+ Install using standard Vagrant 1.6+ plugin installation methods. The fastest way to get started is to use the standard Vagrant Cloud images:
25
+
26
+ ```
27
+ $ vagrant plugin install vagrant-junos
28
+ ...
29
+ $ vagrant up juniper/ffp-12.1X46-D20.5
30
+ ...
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ >__TODO__: Add docs on Vagrantfile settings
36
+
37
+
38
+ ## Configuration
39
+
40
+ >__TODO__: Add docs on Vagrantfile settings, and Ruby snippets
41
+
42
+ ## Development
43
+
44
+ To work on the `vagrant-junos` plugin, clone this repository out, and use
45
+ [Bundler](http://gembundler.com) to get the dependencies:
46
+
47
+ ```
48
+ $ bundle
49
+ ```
50
+
51
+ Once you have the dependencies, verify the unit tests pass with `rake`:
52
+
53
+ ```
54
+ $ bundle exec rake
55
+ ```
56
+
57
+ If those pass, you're ready to start developing the plugin. You can test
58
+ the plugin without installing it into your Vagrant environment by just
59
+ creating a `Vagrantfile` in the top level of this directory (it is gitignored)
60
+ and add the following line to your `Vagrantfile`
61
+ ```ruby
62
+ Vagrant.require_plugin "vagrant-junos"
63
+ ```
64
+ Use bundler to execute Vagrant:
65
+ ```
66
+ $ bundle exec vagrant up juniper/ffp-12.1X46-D20.5
67
+ ```
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # require 'bundler/gem_tasks' - old way for now
2
+
3
+ require 'rubygems'
4
+ require 'bundler/setup'
5
+ require 'rspec/core/rake_task'
6
+
7
+ # Change to the directory of this file.
8
+ Dir.chdir(File.expand_path('../', __FILE__))
9
+
10
+ # build/install/release
11
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,24 @@
1
+ require 'pathname'
2
+
3
+ require 'vagrant-junos/plugin'
4
+
5
+ # Vagrant's plugin API
6
+ # http://docs.vagrantup.com/v2/plugins/guests.html
7
+ # http://docs.vagrantup.com/v2/plugins/guest-capabilities.html
8
+ module VagrantPlugins
9
+ # A guest plugin for Juniper's Junos network OS.
10
+ # This communicates with the BSD shell of Junos,
11
+ # which matches other Vagrant guest plugin behavior.
12
+ module GuestJunos
13
+ lib_path = Pathname.new(File.expand_path('../vagrant-junos', __FILE__))
14
+ autoload :Action, lib_path.join('action')
15
+ autoload :Errors, lib_path.join('errors')
16
+ end
17
+
18
+ # This returns the path to the source of this plugin.
19
+ #
20
+ # @return [Pathname]
21
+ def self.source_root
22
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ require 'tempfile'
2
+ # require 'vagrant/util/template_renderer'
3
+
4
+ module VagrantPlugins
5
+ module GuestJunos
6
+ module Cap
7
+ # host name change capability - needs to be Junos-aware
8
+ class ChangeHostName
9
+ def self.change_host_name(machine, name)
10
+ machine.communicate.tap do |comm|
11
+ 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
23
+ comm.execute('cli -f /mfs/tmp/set_hostname')
24
+ comm.execute('rm /mfs/tmp/set_hostname')
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ module VagrantPlugins
2
+ module GuestJunos
3
+ module Cap
4
+ # halt because default assumes sudo
5
+ class Halt
6
+ def self.halt(machine)
7
+ begin
8
+ machine.communicate.execute('shutdown -p now')
9
+ rescue IOError
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,31 @@
1
+ require 'vagrant/util/shell_quote'
2
+ require 'tempfile'
3
+
4
+ module VagrantPlugins
5
+ module GuestJunos
6
+ module Cap
7
+ # change root's public key
8
+ class InsertPublicKey
9
+ def self.insert_public_key(machine, contents)
10
+ contents = Vagrant::Util::Shellquote.escape(contents, "'")
11
+ contents = contents.gsub("\n", "\\n")
12
+
13
+ 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')
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,14 @@
1
+
2
+ require 'vagrant'
3
+
4
+ module VagrantPlugins
5
+ module GuestJunos
6
+ # guest plugin for Junos build with root shell login
7
+ class Guest < Vagrant.plugin('2', :guest)
8
+ def detect?(machine)
9
+ # machine.communicate.test("uname -s|grep 'JUNOS'", shell: '/sbin/sh')
10
+ machine.communicate.test("uname -s|grep 'JUNOS'")
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,49 @@
1
+ begin
2
+ require 'vagrant'
3
+ rescue LoadError
4
+ raise 'The Vagrant Junos plugin must be run within Vagrant'
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < '1.6.0'
10
+ fail 'The Vagrant Junos plugin is only compatible with Vagrant 1.6+'
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module GuestJunos
15
+ # plugin to support Junos guests
16
+ class Plugin < Vagrant.plugin('2')
17
+ name 'Junos guest'
18
+ description <<-DESC
19
+ This plugin installs a provider that allows Vagrant to manage
20
+ Junos VMs, such as Firefly Perimeter
21
+ DESC
22
+
23
+ guest('junos') do
24
+ require File.expand_path('../guest', __FILE__)
25
+ Guest
26
+ end
27
+
28
+ guest_capability('junos', 'change_host_name') do
29
+ require_relative 'cap/change_host_name'
30
+ Cap::ChangeHostName
31
+ end
32
+
33
+ # guest_capability('junos', 'configure_networks') do
34
+ # require_relative 'cap/configure_networks'
35
+ # Cap::ConfigureNetworks
36
+ # end
37
+
38
+ guest_capability('junos', 'halt') do
39
+ require_relative 'cap/halt'
40
+ Cap::Halt
41
+ end
42
+
43
+ # guest_capability('junos', 'insert_public_key') do
44
+ # require_relative 'cap/insert_public_key'
45
+ # Cap::InsertPublicKey
46
+ # end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,6 @@
1
+ module VagrantPlugins
2
+ # Junos guest gem + plugin version
3
+ module GuestJunos
4
+ VERSION = '0.0.3'
5
+ end
6
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-junos/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'vagrant-junos'
8
+ spec.version = VagrantPlugins::GuestJunos::VERSION
9
+ spec.authors = ['John Deatherage']
10
+ spec.email = ['jdeatherage@juniper.net']
11
+ spec.summary = 'A Vagrant plugin for Junos guests, e.g. Firefly Perimeter'
12
+ spec.description = 'A Vagrant plugin for Junos guests, e.g. Firefly Perimeter'
13
+ spec.homepage = 'https://github.com/JNPRAutomate/vagrant-junos'
14
+ spec.license = 'Apache-2.0'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '< 1.7.0', '>= 1.5.2'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'rspec-core', '~> 2.14'
24
+ spec.add_development_dependency 'rspec-expectations', '~> 2.14'
25
+ spec.add_development_dependency 'rspec-mocks', '~> 2.14'
26
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-junos
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - John Deatherage
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-18 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.7.0
20
+ - - '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.5.2
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - <
28
+ - !ruby/object:Gem::Version
29
+ version: 1.7.0
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.5.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: rake
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: '10.0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '10.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-core
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.14'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: '2.14'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rspec-expectations
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '2.14'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ version: '2.14'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec-mocks
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: '2.14'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: '2.14'
89
+ description: A Vagrant plugin for Junos guests, e.g. Firefly Perimeter
90
+ email:
91
+ - jdeatherage@juniper.net
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - .gitignore
97
+ - .rubocop.yml
98
+ - .ruby-version
99
+ - .travis.yml
100
+ - Gemfile
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - lib/vagrant-junos.rb
105
+ - lib/vagrant-junos/cap/change_host_name.rb
106
+ - lib/vagrant-junos/cap/halt.rb
107
+ - lib/vagrant-junos/cap/insert_public_key.rb
108
+ - lib/vagrant-junos/guest.rb
109
+ - lib/vagrant-junos/plugin.rb
110
+ - lib/vagrant-junos/version.rb
111
+ - vagrant-junos.gemspec
112
+ homepage: https://github.com/JNPRAutomate/vagrant-junos
113
+ licenses:
114
+ - Apache-2.0
115
+ metadata: {}
116
+ post_install_message:
117
+ rdoc_options: []
118
+ require_paths:
119
+ - lib
120
+ required_ruby_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ requirements: []
131
+ rubyforge_project:
132
+ rubygems_version: 2.1.9
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: A Vagrant plugin for Junos guests, e.g. Firefly Perimeter
136
+ test_files: []