vagrant-screenshot 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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +33 -0
- data/Rakefile +1 -0
- data/lib/vagrant-screenshot.rb +4 -0
- data/lib/vagrant-screenshot/errors.rb +14 -0
- data/lib/vagrant-screenshot/screenshot_command.rb +80 -0
- data/vagrant-screenshot.gemspec +23 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Vagrant plugin to take screenshots of VMs
|
|
2
|
+
=========================================
|
|
3
|
+
|
|
4
|
+
This plugin is useful to debug your VM while booting
|
|
5
|
+
|
|
6
|
+
Instalation
|
|
7
|
+
-----------
|
|
8
|
+
|
|
9
|
+
$ gem install vagrant-screenshot
|
|
10
|
+
|
|
11
|
+
Add to your Vagrantfile
|
|
12
|
+
|
|
13
|
+
require 'vagrant-screenshot'
|
|
14
|
+
|
|
15
|
+
Usage
|
|
16
|
+
-----
|
|
17
|
+
|
|
18
|
+
$ vagrant screenshot
|
|
19
|
+
$ vagrant screenshot my-vm-name
|
|
20
|
+
|
|
21
|
+
For more information use
|
|
22
|
+
|
|
23
|
+
$ vagrant screenshot --help
|
|
24
|
+
|
|
25
|
+
There is a ``--open``(or ``-o``) option to open the generated images, but
|
|
26
|
+
it's only available on OS X for now.
|
|
27
|
+
|
|
28
|
+
Contributing
|
|
29
|
+
------------
|
|
30
|
+
|
|
31
|
+
1. Create an issue (if it doesn't exist yet)
|
|
32
|
+
2. Fork [this repository](https://github.com/igorsobreira/vagrant-screenshot), make your changes
|
|
33
|
+
3. Send a pull request
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
module Vagrant
|
|
2
|
+
|
|
3
|
+
module Command
|
|
4
|
+
class ScreenshotCommand < Base
|
|
5
|
+
|
|
6
|
+
VBOX_MANAGE = 'VBoxManage'
|
|
7
|
+
|
|
8
|
+
def execute
|
|
9
|
+
options = {}
|
|
10
|
+
filenames = []
|
|
11
|
+
|
|
12
|
+
raise Errors::VBoxManageCommandNotFound if vbox_manage_command.empty?
|
|
13
|
+
|
|
14
|
+
opts = build_screenshot_options options
|
|
15
|
+
argv = parse_options(opts)
|
|
16
|
+
return if !argv
|
|
17
|
+
|
|
18
|
+
vm_name = argv[0]
|
|
19
|
+
with_target_vms(vm_name) do |vm|
|
|
20
|
+
if vm.state != :running
|
|
21
|
+
notify "Skiping #{vm.name}. VM not running"
|
|
22
|
+
else
|
|
23
|
+
notify "Taking screenshot for #{vm.name}"
|
|
24
|
+
filename = create_output_filename vm.name
|
|
25
|
+
take_screenshot vm.uuid, filename
|
|
26
|
+
filenames << filename
|
|
27
|
+
open_generated_files(filenames) if options[:open]
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
protected
|
|
34
|
+
|
|
35
|
+
def vbox_manage_command
|
|
36
|
+
%x[which VBoxManage].chomp
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def open_command
|
|
40
|
+
# Currently just Mac's 'open' command is supported, if it's
|
|
41
|
+
# not found the -o option is not provided
|
|
42
|
+
%x[which open].chomp
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def build_screenshot_options(options)
|
|
46
|
+
opts = OptionParser.new do |opts|
|
|
47
|
+
opts.banner = "Take screenshot from all active VMs.\n\n"
|
|
48
|
+
opts.banner += "Usage: vagrant screenshot [vm-name1, vm-name2, ...]\n\n"
|
|
49
|
+
|
|
50
|
+
if !open_command.empty?
|
|
51
|
+
opts.on("-o", "--open", "Opens the generated images") do |c|
|
|
52
|
+
options[:open] = true
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
opts
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def create_output_filename(vm_name)
|
|
61
|
+
"screenshot-#{vm_name}.png"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def take_screenshot(vm_uuid, filename)
|
|
65
|
+
%x[#{VBOX_MANAGE} controlvm #{vm_uuid} screenshotpng #{filename}]
|
|
66
|
+
notify "Screenshot saved on #{filename}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def open_generated_files(filenames)
|
|
70
|
+
%x[open #{filenames.join(' ')}]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def notify(msg)
|
|
74
|
+
puts msg
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "vagrant-screenshot"
|
|
6
|
+
s.version = "0.1"
|
|
7
|
+
s.authors = ["Igor Sobreira"]
|
|
8
|
+
s.email = ["igor@igorsobreira.com"]
|
|
9
|
+
s.homepage = "https://github.com/igorsobreira/vagrant-screenshot"
|
|
10
|
+
s.summary = %q{Vagrant plugin to take screenshots of VMs}
|
|
11
|
+
s.description = %q{Vagrant plugin to take screenshots of VMs}
|
|
12
|
+
|
|
13
|
+
s.rubyforge_project = "vagrant-screenshot"
|
|
14
|
+
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
# specify any dependencies here; for example:
|
|
21
|
+
# s.add_development_dependency "rspec"
|
|
22
|
+
# s.add_runtime_dependency "rest-client"
|
|
23
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: vagrant-screenshot
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.1'
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Igor Sobreira
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-03-13 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Vagrant plugin to take screenshots of VMs
|
|
15
|
+
email:
|
|
16
|
+
- igor@igorsobreira.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- .gitignore
|
|
22
|
+
- Gemfile
|
|
23
|
+
- README.md
|
|
24
|
+
- Rakefile
|
|
25
|
+
- lib/vagrant-screenshot.rb
|
|
26
|
+
- lib/vagrant-screenshot/errors.rb
|
|
27
|
+
- lib/vagrant-screenshot/screenshot_command.rb
|
|
28
|
+
- vagrant-screenshot.gemspec
|
|
29
|
+
homepage: https://github.com/igorsobreira/vagrant-screenshot
|
|
30
|
+
licenses: []
|
|
31
|
+
post_install_message:
|
|
32
|
+
rdoc_options: []
|
|
33
|
+
require_paths:
|
|
34
|
+
- lib
|
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
|
+
none: false
|
|
37
|
+
requirements:
|
|
38
|
+
- - ! '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ! '>='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
requirements: []
|
|
48
|
+
rubyforge_project: vagrant-screenshot
|
|
49
|
+
rubygems_version: 1.8.11
|
|
50
|
+
signing_key:
|
|
51
|
+
specification_version: 3
|
|
52
|
+
summary: Vagrant plugin to take screenshots of VMs
|
|
53
|
+
test_files: []
|