vagrant-package-vmware 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a836fe7fbdd7501699ec395b34578db5f6452634
4
+ data.tar.gz: 75beb1ffe2991df1ee82fd47a498a888753dc951
5
+ SHA512:
6
+ metadata.gz: 266a62ec80e00bd83fd62e6d7205f6362341b5b3a5e778a1b93777b727c3a5edb82efd21fd13edabe85459799a2d14824adae98219a1dd25c88a78d0a9cc012d
7
+ data.tar.gz: 8ecf1a07218e8de3783318a8dcfa7436158c9d5604a066b036dad2df34f8aed569ea54b75364e8e815bc5e49cd925739dfb367743d924fee44ad2472c5869b3d
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /vendor/
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :plugins do
4
+ gemspec
5
+ end
6
+
7
+ group :development do
8
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
9
+ end
@@ -0,0 +1,112 @@
1
+ GIT
2
+ remote: https://github.com/mitchellh/vagrant.git
3
+ revision: 04fdab961e258b6b05c10a26ab1f073bf0894439
4
+ specs:
5
+ vagrant (2.0.3.dev)
6
+ childprocess (~> 0.6.0)
7
+ erubis (~> 2.7.0)
8
+ hashicorp-checkpoint (~> 0.1.5)
9
+ i18n (>= 0.6.0, <= 0.8.0)
10
+ listen (~> 3.1.5)
11
+ log4r (~> 1.1.9, < 1.1.11)
12
+ net-scp (~> 1.2.0)
13
+ net-sftp (~> 2.1)
14
+ net-ssh (~> 4.2.0)
15
+ rb-kqueue (~> 0.2.0)
16
+ rest-client (>= 1.6.0, < 3.0)
17
+ ruby_dep (<= 1.3.1)
18
+ wdm (~> 0.1.0)
19
+ winrm (~> 2.1)
20
+ winrm-elevated (~> 1.1)
21
+ winrm-fs (~> 1.0)
22
+
23
+ PATH
24
+ remote: .
25
+ specs:
26
+ vagrant-package-vmware (0.1.0)
27
+
28
+ GEM
29
+ remote: https://rubygems.org/
30
+ specs:
31
+ builder (3.2.3)
32
+ childprocess (0.6.3)
33
+ ffi (~> 1.0, >= 1.0.11)
34
+ domain_name (0.5.20170404)
35
+ unf (>= 0.0.5, < 1.0.0)
36
+ erubis (2.7.0)
37
+ ffi (1.9.23)
38
+ gssapi (1.2.0)
39
+ ffi (>= 1.0.1)
40
+ gyoku (1.3.1)
41
+ builder (>= 2.1.2)
42
+ hashicorp-checkpoint (0.1.5)
43
+ http-cookie (1.0.3)
44
+ domain_name (~> 0.5)
45
+ httpclient (2.8.3)
46
+ i18n (0.8.0)
47
+ listen (3.1.5)
48
+ rb-fsevent (~> 0.9, >= 0.9.4)
49
+ rb-inotify (~> 0.9, >= 0.9.7)
50
+ ruby_dep (~> 1.2)
51
+ little-plugger (1.1.4)
52
+ log4r (1.1.10)
53
+ logging (2.2.2)
54
+ little-plugger (~> 1.1)
55
+ multi_json (~> 1.10)
56
+ mime-types (3.1)
57
+ mime-types-data (~> 3.2015)
58
+ mime-types-data (3.2016.0521)
59
+ multi_json (1.13.1)
60
+ net-scp (1.2.1)
61
+ net-ssh (>= 2.6.5)
62
+ net-sftp (2.1.2)
63
+ net-ssh (>= 2.6.5)
64
+ net-ssh (4.2.0)
65
+ netrc (0.11.0)
66
+ nori (2.6.0)
67
+ rake (10.5.0)
68
+ rb-fsevent (0.10.2)
69
+ rb-inotify (0.9.10)
70
+ ffi (>= 0.5.0, < 2)
71
+ rb-kqueue (0.2.5)
72
+ ffi (>= 0.5.0)
73
+ rest-client (2.0.2)
74
+ http-cookie (>= 1.0.2, < 2.0)
75
+ mime-types (>= 1.16, < 4.0)
76
+ netrc (~> 0.8)
77
+ ruby_dep (1.3.1)
78
+ rubyntlm (0.6.2)
79
+ rubyzip (1.2.1)
80
+ unf (0.1.4)
81
+ unf_ext
82
+ unf_ext (0.0.7.5)
83
+ wdm (0.1.1)
84
+ winrm (2.2.3)
85
+ builder (>= 2.1.2)
86
+ erubis (~> 2.7)
87
+ gssapi (~> 1.2)
88
+ gyoku (~> 1.0)
89
+ httpclient (~> 2.2, >= 2.2.0.2)
90
+ logging (>= 1.6.1, < 3.0)
91
+ nori (~> 2.0)
92
+ rubyntlm (~> 0.6.0, >= 0.6.1)
93
+ winrm-elevated (1.1.0)
94
+ winrm (~> 2.0)
95
+ winrm-fs (~> 1.0)
96
+ winrm-fs (1.2.0)
97
+ erubis (~> 2.7)
98
+ logging (>= 1.6.1, < 3.0)
99
+ rubyzip (~> 1.1)
100
+ winrm (~> 2.0)
101
+
102
+ PLATFORMS
103
+ ruby
104
+
105
+ DEPENDENCIES
106
+ bundler (~> 1.16)
107
+ rake (~> 10.0)
108
+ vagrant!
109
+ vagrant-package-vmware!
110
+
111
+ BUNDLED WITH
112
+ 1.16.1
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2018 David Kramer.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # vagrant-package-vmware
2
+
3
+ `vagrant-package-vmware` is a [Vagrant](http://vagrantup.com) plugin for packaging a running VMware vagrant environment into a box.
4
+
5
+ ## Installation
6
+
7
+ Use `vagrant plugin` to install the gem in your Vagrant environment:
8
+
9
+ ```bash
10
+ $ vagrant plugin install vagrant-package-vmware
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ $ vagrant package-vmware -h
17
+
18
+ Usage: vagrant package-vmware [options] [name|id]
19
+
20
+ Options:
21
+
22
+ --output NAME Name of the file to output
23
+ --include FILE,FILE.. Comma separated additional files to package with the box
24
+ --vagrantfile FILE Vagrantfile to package with the box
25
+ -h, --help Print this help
26
+ ```
27
+
28
+ ## Example
29
+
30
+ ```bash
31
+ $ vagrant package-vmware 7d54359 --output new.box
32
+
33
+ Cloning machine...
34
+ Compressing package to: /Users/vagrant/new.box
35
+ ```
36
+
37
+ ## Development
38
+
39
+ The vagrant-vmware-fusion plugin really doesn't like being loaded from a vendor'ed vagrant, so you can't use the usual technique of `bundle exec vagrant ...` to test this plugin. The following commands build and install the checked-out gem:
40
+
41
+ ```bash
42
+ $ bundle exec rake build
43
+ $ vagrant plugin uninstall vagrant-package-vmware
44
+ $ vagrant plugin install pkg/vagrant-package-vmware-*.gem
45
+ $ vagrant package-vmware -h
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bacongravy/vagrant-package-vmware.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "vagrant/package/vmware"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ begin
2
+ require 'vagrant'
3
+ rescue LoadError
4
+ raise 'The vagrant-package-vmware plugin must be run within Vagrant.'
5
+ end
6
+
7
+ require 'vagrant-package-vmware/plugin'
@@ -0,0 +1,33 @@
1
+ require 'vagrant/action/builder'
2
+ require 'vagrant/action'
3
+ require 'vagrant/action/general/package_setup_files'
4
+ require 'vagrant/action/general/package_setup_folders'
5
+
6
+ module VagrantPlugins
7
+ module PackageVMware
8
+ module Action
9
+
10
+ include Vagrant::Action::Builtin
11
+ include Vagrant::Action::General
12
+
13
+ def self.action_package_vmware
14
+ require_relative 'action/halt_machine'
15
+ require_relative 'action/package_machine'
16
+ require_relative 'action/package_metadata'
17
+ require_relative 'action/package_vagrantfile'
18
+
19
+ Vagrant::Action::Builder.new.tap do |b|
20
+ b.use HaltMachine
21
+ b.use SyncedFolderCleanup
22
+ b.use PackageSetupFolders
23
+ b.use PackageSetupFiles
24
+ b.use Package
25
+ b.use PackageVagrantfile
26
+ b.use PackageMetadata
27
+ b.use PackageMachine
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ module VagrantPlugins
2
+ module PackageVMware
3
+ module Action
4
+ class HaltMachine
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ env[:machine].action(:halt)
12
+ @app.call(env)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ require 'vagrant/util/subprocess'
2
+
3
+ module VagrantPlugins
4
+ module PackageVMware
5
+ module Action
6
+ class PackageMachine
7
+
8
+ def initialize(app, env)
9
+ @app = app
10
+ end
11
+
12
+ def call(env)
13
+ require_relative '../errors'
14
+
15
+ package_machine = env[:machine]
16
+ package_output = env['package.output']
17
+ package_directory = env['package.directory']
18
+
19
+ output_name = File.basename(package_output, '.box')
20
+ input_vmx = package_machine.provider.driver.vmx_path.to_s
21
+ output_vmx = "#{package_directory}/#{output_name}.vmx"
22
+
23
+ env[:ui].info "Cloning machine..."
24
+ result = Vagrant::Util::Subprocess.execute("vmrun", "clone", input_vmx, output_vmx, "full", "-cloneName=#{output_name}")
25
+
26
+ raise Errors::CloneFailed, result: result if result.exit_code != 0
27
+
28
+ @app.call(env)
29
+ end
30
+
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,27 @@
1
+ module VagrantPlugins
2
+ module PackageVMware
3
+ module Action
4
+ class PackageMetadata
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ @env = env
12
+ create_metadata
13
+ @app.call(env)
14
+ end
15
+
16
+ def create_metadata
17
+ File.open(File.join(@env['package.directory'], "metadata.json"), "w") do |f|
18
+ f.write(JSON.generate({
19
+ provider: @env[:machine].provider_name
20
+ }))
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ module VagrantPlugins
2
+ module PackageVMware
3
+ module Action
4
+ class PackageVagrantfile
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ end
9
+
10
+ def call(env)
11
+ @env = env
12
+ create_vagrantfile
13
+ @app.call(env)
14
+ end
15
+
16
+ def create_vagrantfile
17
+ File.open(File.join(@env['package.directory'], "Vagrantfile"), "w") do |f|
18
+ f.write(<<EOF
19
+ include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
20
+ load include_vagrantfile if File.exist?(include_vagrantfile)
21
+ EOF
22
+ )
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,65 @@
1
+ module VagrantPlugins
2
+ module PackageVMware
3
+ class Command < Vagrant.plugin(2, :command)
4
+ def self.synopsis
5
+ "packages a running VMware vagrant environment into a box"
6
+ end
7
+
8
+ def execute
9
+ options = {}
10
+ options[:tty] = true
11
+
12
+ opts = OptionParser.new do |o|
13
+ o.banner = "Usage: vagrant package-vmware [options] [name]"
14
+ o.separator ""
15
+ o.separator "Options:"
16
+ o.separator ""
17
+
18
+ o.on("--output NAME", "Name of the file to output") do |output|
19
+ options[:output] = output
20
+ end
21
+
22
+ o.on("--include FILE,FILE..", Array, "Comma separated additional files to package with the box") do |i|
23
+ options[:include] = i
24
+ end
25
+
26
+ o.on("--vagrantfile FILE", "Vagrantfile to package with the box") do |v|
27
+ options[:vagrantfile] = v
28
+ end
29
+ end
30
+
31
+ # Parse the options
32
+ argv = parse_options(opts)
33
+ return if !argv
34
+
35
+ @logger.debug("package options: #{options.inspect}")
36
+
37
+ package_target(argv[0], options)
38
+
39
+ # Success, exit status 0
40
+ 0
41
+ end
42
+
43
+ def package_target(name, options)
44
+ with_target_vms(name, single_target: true) do |vm|
45
+ @logger.debug("Packaging VM: #{vm.name}")
46
+ package_vm(vm, options)
47
+ end
48
+ end
49
+
50
+ def package_vm(vm, options)
51
+ require_relative 'action'
52
+
53
+ opts = options.inject({}) do |acc, data|
54
+ k,v = data
55
+ acc["package.#{k}"] = v
56
+ acc
57
+ end
58
+ opts[:machine] = vm
59
+
60
+ @env.action_runner.run(VagrantPlugins::PackageVMware::Action.action_package_vmware, opts)
61
+ end
62
+
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,13 @@
1
+ require 'vagrant/errors'
2
+
3
+ module VagrantPlugins
4
+ module PackageVMware
5
+ module Errors
6
+ class CloneFailed < Vagrant::Errors::VagrantError
7
+ def error_message
8
+ "Clone failed: #{(@extra_data[:result].stdout + @extra_data[:result].stderr).chomp}"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,16 @@
1
+ module VagrantPlugins
2
+ module PackageVMware
3
+ class Plugin < Vagrant.plugin("2")
4
+ name "package-vmware command"
5
+ description <<-DESC
6
+ The `package-vmware` command will take a previously existing Vagrant
7
+ environment and package it into a box file.
8
+ DESC
9
+
10
+ command("package-vmware") do
11
+ require_relative 'command'
12
+ Command
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module PackageVMware
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "vagrant-package-vmware/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-package-vmware"
8
+ spec.version = VagrantPlugins::PackageVMware::VERSION
9
+ spec.authors = ["David Kramer"]
10
+ spec.email = ["bacongravy@icloud.com"]
11
+
12
+ spec.summary = %q{Enables Vagrant to package a running VMware environment into a box}
13
+ spec.homepage = "https://github.com/bacongravy/vagrant-package-vmware"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.16"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-package-vmware
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - David Kramer
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-03-04 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description:
42
+ email:
43
+ - bacongravy@icloud.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile.lock
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - lib/vagrant-package-vmware.rb
57
+ - lib/vagrant-package-vmware/action.rb
58
+ - lib/vagrant-package-vmware/action/halt_machine.rb
59
+ - lib/vagrant-package-vmware/action/package_machine.rb
60
+ - lib/vagrant-package-vmware/action/package_metadata.rb
61
+ - lib/vagrant-package-vmware/action/package_vagrantfile.rb
62
+ - lib/vagrant-package-vmware/command.rb
63
+ - lib/vagrant-package-vmware/errors.rb
64
+ - lib/vagrant-package-vmware/plugin.rb
65
+ - lib/vagrant-package-vmware/version.rb
66
+ - vagrant-package-vmware.gemspec
67
+ homepage: https://github.com/bacongravy/vagrant-package-vmware
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.5.2
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Enables Vagrant to package a running VMware environment into a box
91
+ test_files: []