vagrant-vboxmanage 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 280d1189e39b23d3de749116bee0608f1e6f6801
4
+ data.tar.gz: a7710f25c1ec28ada03ca58b410e6c6e1342d90f
5
+ SHA512:
6
+ metadata.gz: 76946d07a235e897e57f37da811872644fef57bf89dc015fdc1077e06f19e4174dafc97f6387f5712fd8a9eb974a946c213e14ab8328eea8aa337aa5b1254478
7
+ data.tar.gz: ba409ad56b3fe1189417f68a2929d13119467701178ca6dd02861da3f9929f5dd069829ce1ed324759a0aaf02ce825317467a29c9acefb4dbde340439d3942fc
@@ -0,0 +1,13 @@
1
+ ## [0.0.1](https://github.com/dergachev/vagrant-vbox-snapshot/compare/v0.0.0...v0.0.1) (Sep 23, 2013)
2
+
3
+ BACKWARDS INCOMPATIBILITIES:
4
+
5
+ - none
6
+
7
+ FEATURES:
8
+
9
+ - Initial commit
10
+
11
+ IMPROVEMENTS:
12
+
13
+ - none
@@ -0,0 +1,18 @@
1
+ # Developer notes for vagrant-vboxmanage
2
+
3
+ See docs in https://github.com/dergachev/vagrant-vbox-snapshot/blob/master/DEVNOTES.md
4
+
5
+ ## Resources
6
+
7
+ Testing is a big TODO:
8
+
9
+ * https://github.com/mitchellh/vagrant/blob/master/test/acceptance/ssh_test.rb
10
+
11
+ VBoxManage info:
12
+
13
+ * http://www.virtualbox.org/manual/ch08.html
14
+
15
+ Other Vagrant command examples:
16
+
17
+ * https://github.com/mitchellh/vagrant/blob/master/plugins/providers/virtualbox/driver/version_4_1.rb
18
+ * https://github.com/mitchellh/vagrant/blob/master/plugins/commands/ssh/command.rb
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-snap.gemspec
4
+ gemspec
5
+
6
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
@@ -0,0 +1,58 @@
1
+ vagrant-vboxmanage
2
+ ==================================
3
+ Vagrant plugin that simplifies calling `VBoxManage cmd UUID`
4
+
5
+ ## Usage
6
+
7
+ The following commands are added by this plugin:
8
+
9
+ vagrant vboxmanage [vm-name] [--] <subcommand> [args]
10
+
11
+ Where:
12
+
13
+ * `<subcommand>` is the VBoxManage subcommand, eg `showvminfo`
14
+ * See http://www.virtualbox.org/manual/ch08.html
15
+ * `[vm-name]` is the VM name; must be specified if multiple VMs are defined in Vagrantfile
16
+
17
+ For all commands except those listed in `SPECIAL_COMMANDS.md`, the VM uuid will be inserted
18
+ immediately after the command name. For example:
19
+
20
+ # calls `VBoxManage showvminfo a0b76635-3c88-45ea-b26e-e9f442dc1f6e`
21
+ vagrant vboxmanage showvminfo --details
22
+
23
+ ## Caveats
24
+
25
+ * Only minimally tested.
26
+ * TODO: support for UUID substitution for irregular commands like `guestproperty`.
27
+ * TODO: show VBoxManage-like usage help.
28
+
29
+ ## Installation
30
+
31
+ Ensure you have Vagrant 1.1+ installed, then run:
32
+
33
+ vagrant plugin install vagrant-vboxmanage
34
+
35
+ ## Development
36
+
37
+ To develop on this plugin, do the following:
38
+
39
+ ```
40
+ # get the repo, and then make a feature branch (REPLACE WITH YOUR FORK)
41
+ git clone https://github.com/dergachev/vagrant-vboxmanage.git
42
+ cd vagrant-vboxmanage
43
+ git checkout -b MY-NEW-FEATURE
44
+
45
+ # installs the vagrant gem, which is a dev dependency
46
+ bundle install
47
+
48
+ # hack on the plugin
49
+ vim lib/vagrant-vboxmanage.rb # or any other file
50
+
51
+ # test out your changes, in the context provided by the development vagrant gem, and the local Vagrantfile.
52
+ bundle exec vagrant snapshot ...
53
+
54
+ # commit, push, and do a pull-request
55
+ ```
56
+
57
+ See [DEVNOTES.md](https://github.com/dergachev/vagrant-vboxmanage/blob/master/DEVNOTES.md)
58
+ for the notes I compiled while developing this plugin.
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,170 @@
1
+ list [--long|-l] vms|runningvms|ostypes|hostdvds|hostfloppies|
2
+ bridgedifs|hostonlyifs|dhcpservers|hostinfo|
3
+ hostcpuids|hddbackends|hdds|dvds|floppies|
4
+ usbhost|usbfilters|systemproperties|extpacks|
5
+ groups
6
+
7
+ registervm <filename>
8
+
9
+ createvm --name <name>
10
+ [--groups <group>, ...]
11
+ [--ostype <ostype>]
12
+ [--register]
13
+ [--basefolder <path>]
14
+ [--uuid <uuid>]
15
+
16
+ import <ovf/ova>
17
+ [--dry-run|-n]
18
+ [--options keepallmacs|keepnatmacs]
19
+ [more options]
20
+ (run with -n to have options displayed
21
+ for a particular OVF)
22
+
23
+ export <machines> --output|-o <name>.<ovf/ova>
24
+ [--legacy09|--ovf09|--ovf10|--ovf20]
25
+ [--manifest]
26
+ [--vsys <number of virtual system>]
27
+ [--product <product name>]
28
+ [--producturl <product url>]
29
+ [--vendor <vendor name>]
30
+ [--vendorurl <vendor url>]
31
+ [--version <version info>]
32
+ [--eula <license text>]
33
+ [--eulafile <filename>]
34
+
35
+ closemedium disk|dvd|floppy <uuid>|<filename>
36
+ [--delete]
37
+
38
+ createhd --filename <filename>
39
+ [--size <megabytes>|--sizebyte <bytes>]
40
+ [--diffparent <uuid>|<filename>
41
+ [--format VDI|VMDK|VHD] (default: VDI)
42
+ [--variant Standard,Fixed,Split2G,Stream,ESX]
43
+ clonehd <uuid>|<filename> <uuid>|<outputfile>
44
+ [--format VDI|VMDK|VHD|RAW|<other>]
45
+ [--variant Standard,Fixed,Split2G,Stream,ESX]
46
+ [--existing]
47
+
48
+ convertfromraw <filename> <outputfile>
49
+ [--format VDI|VMDK|VHD]
50
+ [--variant Standard,Fixed,Split2G,Stream,ESX]
51
+ [--uuid <uuid>]
52
+ convertfromraw stdin <outputfile> <bytes>
53
+ [--format VDI|VMDK|VHD]
54
+ [--variant Standard,Fixed,Split2G,Stream,ESX]
55
+ [--uuid <uuid>]
56
+
57
+ getextradata global|<uuid>|<name>
58
+ <key>|enumerate
59
+
60
+ setextradata global|<uuid>|<name>
61
+ <key>
62
+ [<value>] (no value deletes key)
63
+
64
+ setproperty machinefolder default|<folder> |
65
+ vrdeauthlibrary default|<library> |
66
+ websrvauthlibrary default|null|<library> |
67
+ vrdeextpack null|<library> |
68
+ autostartdbpath null|<folder> |
69
+ loghistorycount <value>
70
+
71
+ usbfilter add <index,0-N>
72
+ --target <uuid>|<name>|global
73
+ --name <string>
74
+ --action ignore|hold (global filters only)
75
+ [--active yes|no] (yes)
76
+ [--vendorid <XXXX>] (null)
77
+ [--productid <XXXX>] (null)
78
+ [--revision <IIFF>] (null)
79
+ [--manufacturer <string>] (null)
80
+ [--product <string>] (null)
81
+ [--remote yes|no] (null, VM filters only)
82
+ [--serialnumber <string>] (null)
83
+ [--maskedinterfaces <XXXXXXXX>]
84
+
85
+ usbfilter modify <index,0-N>
86
+ --target <uuid>|<name>|global
87
+ [--name <string>]
88
+ [--action ignore|hold] (global filters only)
89
+ [--active yes|no]
90
+ [--vendorid <XXXX>|""]
91
+ [--productid <XXXX>|""]
92
+ [--revision <IIFF>|""]
93
+ [--manufacturer <string>|""]
94
+ [--product <string>|""]
95
+ [--remote yes|no] (null, VM filters only)
96
+ [--serialnumber <string>|""]
97
+ [--maskedinterfaces <XXXXXXXX>]
98
+
99
+ usbfilter remove <index,0-N>
100
+ --target <uuid>|<name>|global
101
+
102
+ sharedfolder add <vmname>|<uuid>
103
+ --name <name> --hostpath <hostpath>
104
+ [--transient] [--readonly] [--automount]
105
+
106
+ sharedfolder remove <vmname>|<uuid>
107
+ --name <name> [--transient]
108
+
109
+ guestproperty get <vmname>|<uuid>
110
+ <property> [--verbose]
111
+
112
+ guestproperty set <vmname>|<uuid>
113
+ <property> [<value> [--flags <flags>]]
114
+
115
+ guestproperty enumerate <vmname>|<uuid>
116
+ [--patterns <patterns>]
117
+
118
+ guestproperty wait <vmname>|<uuid> <patterns>
119
+ [--timeout <msec>] [--fail-on-timeout]
120
+
121
+ metrics list [*|host|<vmname> [<metric_list>]]
122
+ (comma-separated)
123
+
124
+ metrics setup
125
+ [--period <seconds>] (default: 1)
126
+ [--samples <count>] (default: 1)
127
+ [--list]
128
+ [*|host|<vmname> [<metric_list>]]
129
+
130
+ metrics query [*|host|<vmname> [<metric_list>]]
131
+
132
+ metrics enable
133
+ [--list]
134
+ [*|host|<vmname> [<metric_list>]]
135
+
136
+ metrics disable
137
+ [--list]
138
+ [*|host|<vmname> [<metric_list>]]
139
+
140
+ metrics collect
141
+ [--period <seconds>] (default: 1)
142
+ [--samples <count>] (default: 1)
143
+ [--list]
144
+ [--detach]
145
+ [*|host|<vmname> [<metric_list>]]
146
+
147
+ hostonlyif ipconfig <name>
148
+ [--dhcp |
149
+ --ip<ipv4> [--netmask<ipv4> (def: 255.255.255.0)] |
150
+ --ipv6<ipv6> [--netmasklengthv6<length> (def: 64)]]
151
+ create |
152
+ remove <name>
153
+
154
+ dhcpserver add|modify --netname <network_name> |
155
+ --ifname <hostonly_if_name>
156
+ [--ip <ip_address>
157
+ --netmask <network_mask>
158
+ --lowerip <lower_ip>
159
+ --upperip <upper_ip>]
160
+ [--enable | --disable]
161
+
162
+ dhcpserver remove --netname <network_name> |
163
+ --ifname <hostonly_if_name>
164
+
165
+ extpack install [--replace] <tarball> |
166
+ uninstall [--force] <name> |
167
+ cleanup
168
+
169
+
170
+
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+
5
+ require_relative 'lib/vagrant-vboxmanage.rb'
6
+
7
+ Vagrant.configure("2") do |config|
8
+
9
+ TEST_MULTI_VM = false
10
+ TEST_SHARED_FOLDERS = false
11
+
12
+ if TEST_MULTI_VM
13
+ config.vm.define :web do |web|
14
+ web.vm.box = "precise64"
15
+ end
16
+ config.vm.define :db do |web|
17
+ web.vm.box = "precise64"
18
+ end
19
+ else
20
+ config.vm.box = "precise64"
21
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
22
+ end
23
+
24
+ if TEST_SHARED_FOLDERS
25
+ config.vm.synced_folder "/tmp", "/tmp/host-tmp"
26
+ config.vm.synced_folder "/tmp", "/tmp/host-tmp2"
27
+ end
28
+ end
@@ -0,0 +1,2 @@
1
+ require_relative 'vagrant-vboxmanage/version.rb'
2
+ require_relative 'vagrant-vboxmanage/plugin.rb'
@@ -0,0 +1,82 @@
1
+ module VagrantPlugins
2
+ module VBoxManage
3
+ module Command
4
+ class Root < Vagrant.plugin(2, :command)
5
+
6
+ def execute
7
+ options = {}
8
+
9
+ opts = OptionParser.new do |opts|
10
+ opts.banner = "Usage: vagrant vboxmanage [vm-name] [--] <vboxmanage-cmd> [UUID] [cmd-args]..."
11
+ end
12
+
13
+ if split_index = @argv.index('--')
14
+ # of form `vagrant vboxmanage [vm-name] -- showvminfo ...`
15
+ options[:command] = @argv[split_index + 1]
16
+ options[:extra_args] = @argv.drop(split_index + 2)
17
+ @argv = @argv.take(split_index)
18
+ elsif command_index = @argv.index { |x| vboxmanage_commands_all.include?(x)}
19
+ # of form `vagrant vboxmanage [vm-name] showvminfo...`
20
+ options[:command] = @argv[command_index]
21
+ options[:extra_args] = @argv.drop(command_index + 1)
22
+ @argv = @argv.take(command_index)
23
+ else
24
+ @env.ui.error opts
25
+ @env.ui.error "No valid VBoxManage subcommand detected."
26
+ return 1
27
+ end
28
+
29
+ @logger.debug "Parsing options:" + options.merge({"argv" => @argv}).to_yaml
30
+
31
+ argv = parse_options(opts)
32
+ return if argv.length > 1
33
+
34
+ with_target_vms(argv, single_target: true) do |machine|
35
+ if machine.state.id == :not_created
36
+ machine.env.ui.error("Target machine is not created, unable to run VBoxManage.")
37
+ end
38
+
39
+ if vboxmanage_commands_standard.include?(options[:command])
40
+ @logger.debug("Performing UUID insertion for standard vboxmanage command: #{options[:command]}")
41
+ args = [options[:command], machine.id] + options[:extra_args]
42
+ else
43
+ @logger.debug("Skipping UUID insertion for special vboxmanage command: #{options[:command]}")
44
+ # TODO: handle substitution for commands like `usbfilter add 0 --target <uuid|name>`
45
+ # [VM_UUID] is an optiona literal token `VM_UUID`, which will be replaced by the UUID of the VM referenced by Vagrant
46
+ args = [options[:command]] + options[:extra_args]
47
+ end
48
+
49
+ @logger.debug("Executing: VBoxManage " + args.join(" "))
50
+ machine.provider.driver.execute(*args) do |type, data|
51
+ colors = { :stdout => :green, :stderr => :red }
52
+ machine.env.ui.info(data, :color => colors[type])
53
+ end
54
+ end
55
+ end
56
+
57
+ def vboxmanage_commands_all
58
+ # derived as follows: `VBoxManage | sed '1,/Commands/d' | grep '^ [a-z]' | awk '{ print $1; }' | sort -u`
59
+ return %w{adoptstate bandwidthctl clonehd clonevm closemedium controlvm convertfromraw
60
+ createhd createvm debugvm dhcpserver discardstate export extpack
61
+ getextradata guestcontrol guestproperty hostonlyif import list
62
+ metrics modifyhd modifyvm registervm setextradata setproperty
63
+ sharedfolder showhdinfo showvminfo snapshot startvm storageattach
64
+ storagectl unregistervm usbfilter}
65
+ end
66
+
67
+ # not of form `VBoxManage showvminfo uuid|name ...`
68
+ def vboxmanage_commands_special
69
+ # derived by manual inspection of `VBoxManage`; see SPECIAL_COMMANDS.md
70
+ return %w{list registervm createvm import export closemedium createhd clonehd
71
+ convertfromraw getextradata setextradata setproperty usbfilter
72
+ sharedfolder guestproperty metrics hostonlyif dhcpserver extpack}
73
+ end
74
+
75
+ # of form `VBoxManage showvminfo uuid|name ...`
76
+ def vboxmanage_commands_standard
77
+ return vboxmanage_commands_all - vboxmanage_commands_special
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,20 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The vagrant-vboxmanage plugin must be run within Vagrant."
5
+ end
6
+
7
+ module VagrantPlugins
8
+ module VBoxManage
9
+ class Plugin < Vagrant.plugin("2")
10
+ name "vagrant-vboxmanage"
11
+ description "Simplifies calling the `VBoxManage` command."
12
+
13
+ command "vboxmanage" do
14
+ require_relative 'commands/root.rb'
15
+ Command::Root
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module VBoxManage
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,20 @@
1
+ $:.unshift File.expand_path('../lib', __FILE__)
2
+ require 'vagrant-vboxmanage/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "vagrant-vboxmanage"
6
+ spec.version = VagrantPlugins::VBoxManage::VERSION
7
+ spec.authors = "Alex Dergachev"
8
+ spec.email = "alex@evolvingweb.ca"
9
+ spec.summary = 'Vagrant plugin that simplifies calling the `VBoxManage` command.'
10
+ spec.homepage = 'https://github.com/dergachev/vagrant-vboxmanage'
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_path = 'lib'
17
+
18
+ spec.add_development_dependency "bundler"
19
+ spec.add_development_dependency "rake"
20
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-vboxmanage
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alex Dergachev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-24 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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:
42
+ email: alex@evolvingweb.ca
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - CHANGELOG.md
48
+ - DEVNOTES.md
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - SPECIAL_COMMANDS.md
53
+ - Vagrantfile
54
+ - lib/vagrant-vboxmanage.rb
55
+ - lib/vagrant-vboxmanage/commands/root.rb
56
+ - lib/vagrant-vboxmanage/plugin.rb
57
+ - lib/vagrant-vboxmanage/version.rb
58
+ - vagrant-vboxmanage.gemspec
59
+ homepage: https://github.com/dergachev/vagrant-vboxmanage
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.0.3
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Vagrant plugin that simplifies calling the `VBoxManage` command.
83
+ test_files: []