vagrant-esxi 0.0.1

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.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 VMware, Inc.
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.
@@ -0,0 +1,25 @@
1
+ # vagrant-esxi
2
+
3
+ This is a [Vagrant](http://www.vagrantup.com/)
4
+ [plugin](http://docs.vagrantup.com/v2/plugins/index.html)
5
+ that adds VMware ESXi guest support.
6
+
7
+ ## Installation
8
+
9
+ ```
10
+ $ vagrant plugin install vagrant-esxi
11
+ ```
12
+
13
+ ## Example box
14
+
15
+ See the example Packer [template](https://github.com/dougm/packer-esxi) for
16
+ VMware ESXi images.
17
+
18
+ ## Development
19
+
20
+ To build and install the plugin directly from this repo:
21
+
22
+ ```
23
+ $ gem build vagrant-esxi.gemspec
24
+ $ vagrant plugin install vagrant-esxi-0.0.1.gem
25
+ ```
@@ -0,0 +1 @@
1
+ require "vagrant-esxi/plugin"
@@ -0,0 +1,13 @@
1
+ module VagrantPlugins
2
+ module GuestEsxi
3
+ module Cap
4
+ class ChangeHostName
5
+ def self.change_host_name(machine, name)
6
+ if !machine.communicate.test("localcli system hostname get | grep '#{name}'")
7
+ machine.communicate.execute("localcli system hostname set -H '#{name}'")
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,38 @@
1
+ module VagrantPlugins
2
+ module GuestEsxi
3
+ module Cap
4
+ class ConfigureNetworks
5
+ def self.configure_networks(machine, networks)
6
+ networks.each do |network|
7
+ ix = network[:interface]
8
+ switch = "vSwitch#{ix}"
9
+ pg = "VagrantNetwork#{ix}"
10
+ vmnic = "vmnic#{ix}"
11
+ device = "vmk#{ix}"
12
+
13
+ if machine.communicate.test("localcli network ip interface ipv4 get -i #{device}")
14
+ machine.communicate.execute("localcli network ip interface remove -i #{device}")
15
+ end
16
+
17
+ if machine.communicate.test("localcli network vswitch standard list -v #{switch}")
18
+ machine.communicate.execute("localcli network vswitch standard remove -v #{switch}")
19
+ end
20
+
21
+ machine.communicate.execute("localcli network vswitch standard add -v #{switch}")
22
+ machine.communicate.execute("localcli network vswitch standard uplink add -v #{switch} -u #{vmnic}")
23
+ machine.communicate.execute("localcli network vswitch standard portgroup add -v #{switch} -p #{pg}")
24
+ machine.communicate.execute("localcli network ip interface add -i #{device} -p #{pg}")
25
+
26
+ ifconfig = "localcli network ip interface ipv4 set -i #{device}"
27
+
28
+ if network[:type].to_sym == :static
29
+ machine.communicate.execute("#{ifconfig} -t static --ipv4 #{network[:ip]} --netmask #{network[:netmask]}")
30
+ elsif network[:type].to_sym == :dhcp
31
+ machine.communicate.execute("#{ifconfig} -t dhcp")
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module GuestEsxi
3
+ module Cap
4
+ class Halt
5
+ def self.halt(machine)
6
+ begin
7
+ machine.communicate.execute("/bin/halt -d 0")
8
+ rescue IOError
9
+ # Ignore, this probably means connection closed because it
10
+ # shut down.
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ module VagrantPlugins
2
+ module GuestEsxi
3
+ module Cap
4
+ class MountNFSFolder
5
+ extend Vagrant::Util::Retryable
6
+
7
+ def self.mount_nfs_folder(machine, ip, folders)
8
+ folders.each do |name, opts|
9
+ guestpath = opts[:guestpath]
10
+ volume = guestpath.gsub("/", "_")
11
+ machine.communicate.tap do |comm|
12
+ if comm.test("localcli storage nfs list | grep '^#{volume}'")
13
+ comm.execute("localcli storage nfs remove -v #{volume}")
14
+ end
15
+ mount_command = "localcli storage nfs add -H #{ip} -s '#{opts[:hostpath]}' -v '#{volume}'"
16
+ retryable(:on => Vagrant::Errors::LinuxNFSMountFailed, :tries => 5, :sleep => 2) do
17
+ comm.execute(mount_command,
18
+ :error_class => Vagrant::Errors::LinuxNFSMountFailed)
19
+ end
20
+
21
+ # symlink vmfs volume to :guestpath
22
+ if comm.test("test -L '#{guestpath}'")
23
+ comm.execute("rm '#{guestpath}'")
24
+ end
25
+ if comm.test("test -d '#{guestpath}'")
26
+ comm.execute("rmdir '#{guestpath}'")
27
+ end
28
+ dir = File.dirname(guestpath)
29
+ if !comm.test("test -d '#{dir}'")
30
+ comm.execute("mkdir -p '#{dir}'")
31
+ end
32
+
33
+ comm.execute("ln -s '/vmfs/volumes/#{volume}' '#{guestpath}'")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module GuestEsxi
5
+ class Guest < Vagrant.plugin("2", :guest)
6
+ def detect?(machine)
7
+ machine.communicate.test("uname -s | grep VMkernel")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module GuestEsxi
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "ESXi guest."
7
+ description "ESXi guest support."
8
+
9
+ guest("esxi") do
10
+ require File.expand_path("../guest", __FILE__)
11
+ Guest
12
+ end
13
+
14
+ guest_capability("esxi", "change_host_name") do
15
+ require_relative "cap/change_host_name"
16
+ Cap::ChangeHostName
17
+ end
18
+
19
+ guest_capability("esxi", "configure_networks") do
20
+ require_relative "cap/configure_networks"
21
+ Cap::ConfigureNetworks
22
+ end
23
+
24
+ guest_capability("esxi", "mount_nfs_folder") do
25
+ require_relative "cap/mount_nfs_folder"
26
+ Cap::MountNFSFolder
27
+ end
28
+
29
+ guest_capability("esxi", "halt") do
30
+ require_relative "cap/halt"
31
+ Cap::Halt
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module GuestEsxi
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-esxi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Doug MacEachern
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-10-14 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Enables Vagrant to work with VMware ESXi guests
15
+ email:
16
+ - dougm@vmware.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - lib/vagrant-esxi/cap/change_host_name.rb
22
+ - lib/vagrant-esxi/cap/configure_networks.rb
23
+ - lib/vagrant-esxi/cap/halt.rb
24
+ - lib/vagrant-esxi/cap/mount_nfs_folder.rb
25
+ - lib/vagrant-esxi/guest.rb
26
+ - lib/vagrant-esxi/plugin.rb
27
+ - lib/vagrant-esxi/version.rb
28
+ - lib/vagrant-esxi.rb
29
+ - README.md
30
+ - LICENSE
31
+ homepage: https://github.com/dougm/vagrant-esxi
32
+ licenses:
33
+ - MIT
34
+ post_install_message:
35
+ rdoc_options: []
36
+ require_paths:
37
+ - lib
38
+ required_ruby_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 1.8.23
53
+ signing_key:
54
+ specification_version: 3
55
+ summary: Enables Vagrant to work with VMware ESXi guests
56
+ test_files: []
57
+ has_rdoc: