vagrant-smartos-guest 0.0.1.pre.1

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: ae6b489bc2acfeaffc3aaa15ed83957d7be2e816
4
+ data.tar.gz: 6acc4e6487dc2d1e3b63e734fcdb1e4b77dd87df
5
+ SHA512:
6
+ metadata.gz: a91738cc7e676ab5c8000053e6e2f9124efe51ba32b28024d95be7ded349a3d72eca9bc5a229303ae2bb0e26c31be401add8f51092a31bd2eb44fea9d096edbb
7
+ data.tar.gz: f3e2866b278a7db8e8b4ac5db3a9ae8cd3f28f0e0336f21c53dcbd5b7ab7bb0de3dd6eceea0aea60c321c9e47a35409c424bcc2beb045ee4686522de4c24fe03
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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-smartos-guest.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Eric Saxby
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,55 @@
1
+ vagrant-smartos-guest
2
+ =====================
3
+
4
+ Adds Vagrant guest detection and guest capabilities for SmartOS.
5
+
6
+ ## Installation
7
+
8
+ If using a development install of Vagrant, add the following to your
9
+ Gemfile:
10
+
11
+ ```ruby
12
+ group :development do
13
+ gem 'vagrant'
14
+ end
15
+
16
+ group :plugins do
17
+ gem 'vagrant-smartos-guest'
18
+ end
19
+ ```
20
+
21
+ Otherwise install the plugin into your omnibus installation of Vagrant:
22
+
23
+ ```bash
24
+ vagrant plugin install vagrant-smartos-guest
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ This plugin allows Vagrant to recognize when a guest box is a SmartOS
30
+ global zone or local zone.
31
+
32
+ When connecting to a SmartOS global zone in VirtualBox without guest
33
+ additions, very likely the default mountpoint will need to be disabled.
34
+
35
+ To disable the default mountpoint, add this to your Vagrantfile inside
36
+ your config block:
37
+
38
+ ```ruby
39
+ config.vm.synced_folder ".", "/vagrant", disabled: true
40
+ ```
41
+
42
+ When using a synced folder of type `rsync` in a global zone, you will
43
+ almost certainly want to sync the folder into a persistent location.
44
+
45
+ ```ruby
46
+ config.vm.synced_folder ".", "/vagrant", disabled: true
47
+ config.vm.synced_folder ".", "/zones/vagrant", type: 'rsync'
48
+ ```
49
+
50
+ When sharing a folder via NFS, you can override the default mountpoint:
51
+
52
+ ```ruby
53
+ config.vm.synced_folder ".", "/vagrant", type: "nfs"
54
+ ```
55
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Cap
4
+ class ChangeHostName
5
+ def self.change_host_name(machine, name)
6
+ su_cmd = machine.config.smartos.suexec_cmd
7
+
8
+ # Only do this if the hostname is not already set
9
+ if !machine.communicate.test("hostname | grep '#{name}'")
10
+ machine.communicate.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"")
11
+ machine.communicate.execute("#{su_cmd} hostname #{name}")
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Cap
4
+ class ConfigureNetworks
5
+ def self.configure_networks(machine, networks)
6
+ su_cmd = machine.config.smartos.suexec_cmd
7
+
8
+ networks.each do |network|
9
+ device = "#{machine.config.smartos.device}#{network[:interface]}"
10
+ ifconfig_cmd = "#{su_cmd} /sbin/ifconfig #{device}"
11
+
12
+ machine.communicate.execute("#{ifconfig_cmd} plumb")
13
+
14
+ if network[:type].to_sym == :static
15
+ machine.communicate.execute("#{ifconfig_cmd} inet #{network[:ip]} netmask #{network[:netmask]}")
16
+ machine.communicate.execute("#{ifconfig_cmd} up")
17
+ machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"")
18
+ elsif network[:type].to_sym == :dhcp
19
+ machine.communicate.execute("#{ifconfig_cmd} dhcp start")
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
@@ -0,0 +1,22 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Cap
4
+ class Halt
5
+ def self.halt(machine)
6
+ # There should be an exception raised if the line
7
+ #
8
+ # vagrant::::profiles=Primary Administrator
9
+ #
10
+ # does not exist in /etc/user_attr. TODO
11
+ begin
12
+ machine.communicate.execute(
13
+ "#{machine.config.smartos.suexec_cmd} /usr/sbin/shutdown -y -i5 -g0")
14
+ rescue IOError
15
+ # Ignore, this probably means connection closed because it
16
+ # shut down.
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Cap
4
+ class MountNFS
5
+ def self.mount_nfs_folder(machine, ip, folders)
6
+ sudo = machine.config.smartos.suexec_cmd
7
+
8
+ folders.each do |name, opts|
9
+ machine.communicate.tap do |comm|
10
+ comm.execute("#{sudo} mkdir -p #{opts[:guestpath]}", {:shell => "sh"})
11
+ comm.execute("#{sudo} /usr/sbin/mount -F nfs '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'", {:shell => "sh"})
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,25 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Cap
4
+ class RSync
5
+ def self.rsync_installed(machine)
6
+ machine.communicate.test("which rsync")
7
+ end
8
+
9
+ def self.rsync_install(machine, folder_opts)
10
+ username = machine.ssh_info[:username]
11
+ sudo = machine.config.smartos.suexec_cmd
12
+
13
+ machine.communicate.tap do |comm|
14
+ comm.execute("#{sudo} mkdir -p '#{folder_opts[:guestpath]}'")
15
+ comm.execute("#{sudo} chown -R #{username} '#{folder_opts[:guestpath]}'")
16
+ end
17
+ end
18
+
19
+ def self.rsync_pre(machine, folder_opts)
20
+ rsync_install(machine, folder_opts)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ require 'vagrant'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ class Config < Vagrant.plugin("2", :config)
6
+ attr_accessor :halt_timeout
7
+ attr_accessor :halt_check_interval
8
+ # This sets the command to use to execute items as a superuser. sudo is default
9
+ attr_accessor :suexec_cmd
10
+ attr_accessor :device
11
+
12
+ def initialize
13
+ @halt_timeout = 30
14
+ @halt_check_interval = 1
15
+ @suexec_cmd = 'pfexec'
16
+ @device = "e1000g"
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ require 'vagrant'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ class Guest < Vagrant.plugin("2", :guest)
6
+ def detect?(machine)
7
+ machine.communicate.test("cat /etc/release | grep -i SmartOS")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,55 @@
1
+ require 'vagrant'
2
+
3
+ module Vagrant
4
+ module Smartos
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "SmartOS guest."
7
+ description "SmartOS guest support."
8
+
9
+ config("smartos") do
10
+ require File.expand_path("../config", __FILE__)
11
+ Config
12
+ end
13
+
14
+ guest("smartos") do
15
+ require File.expand_path("../guest", __FILE__)
16
+ Guest
17
+ end
18
+
19
+ guest_capability("smartos", "change_host_name") do
20
+ require_relative "cap/change_host_name"
21
+ Cap::ChangeHostName
22
+ end
23
+
24
+ guest_capability("smartos", "configure_networks") do
25
+ require_relative "cap/configure_networks"
26
+ Cap::ConfigureNetworks
27
+ end
28
+
29
+ guest_capability("smartos", "halt") do
30
+ require_relative "cap/halt"
31
+ Cap::Halt
32
+ end
33
+
34
+ guest_capability("smartos", "mount_nfs_folder") do
35
+ require_relative "cap/mount_nfs"
36
+ Cap::MountNFS
37
+ end
38
+
39
+ guest_capability("smartos", "rsync_installed") do
40
+ require_relative "cap/rsync"
41
+ Cap::RSync
42
+ end
43
+
44
+ guest_capability("smartos", "rsync_install") do
45
+ require_relative "cap/rsync"
46
+ Cap::RSync
47
+ end
48
+
49
+ guest_capability("smartos", "rsync_pre") do
50
+ require_relative "cap/rsync"
51
+ Cap::RSync
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ module Vagrant
2
+ module Smartos
3
+ module Guest
4
+ VERSION = "0.0.1.pre.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'vagrant/smartos/guest/version'
2
+ require 'vagrant/smartos/guest/plugin'
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant/smartos/guest/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-smartos-guest"
8
+ spec.version = Vagrant::Smartos::Guest::VERSION
9
+ spec.authors = ["Eric Saxby"]
10
+ spec.email = ["sax@livinginthepast.org"]
11
+ spec.summary = %q{Allow Vagrant to detect SmartOS guests and guest capabilities}
12
+ spec.description = %q{Allow Vagrant to detect SmartOS guests and guest capabilities}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
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.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-smartos-guest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.1
5
+ platform: ruby
6
+ authors:
7
+ - Eric Saxby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-13 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'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Allow Vagrant to detect SmartOS guests and guest capabilities
42
+ email:
43
+ - sax@livinginthepast.org
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/vagrant/smartos/guest.rb
54
+ - lib/vagrant/smartos/guest/cap/change_host_name.rb
55
+ - lib/vagrant/smartos/guest/cap/configure_networks.rb
56
+ - lib/vagrant/smartos/guest/cap/halt.rb
57
+ - lib/vagrant/smartos/guest/cap/mount_nfs.rb
58
+ - lib/vagrant/smartos/guest/cap/rsync.rb
59
+ - lib/vagrant/smartos/guest/config.rb
60
+ - lib/vagrant/smartos/guest/guest.rb
61
+ - lib/vagrant/smartos/guest/plugin.rb
62
+ - lib/vagrant/smartos/guest/version.rb
63
+ - vagrant-smartos-guest.gemspec
64
+ homepage: ''
65
+ licenses:
66
+ - MIT
67
+ metadata: {}
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">"
80
+ - !ruby/object:Gem::Version
81
+ version: 1.3.1
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.2.0
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Allow Vagrant to detect SmartOS guests and guest capabilities
88
+ test_files: []