vagrant-commit 0.5.6

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2cfbdc8188c8f8be3dc65e813f565193c073c27ff37af19094c8937c4a53ffb7
4
+ data.tar.gz: 4ec0f10bfba013fc1364bdd0b27b49f5dc1f6fe7d86fc04f0869fac702c6bef8
5
+ SHA512:
6
+ metadata.gz: e1a1a5dfd137c5f7476c7ff21a56ab5a19e52bdb19d2e3f51ada3effb44a30e3b3b523f1c4b5a4925a790137097bede8bdcab67eff40660fdfcc4ba053a7efe0
7
+ data.tar.gz: bee875f21c3f79dd8817eabfda1b41456192530d5b48b19b7ab52b3b7204ab7227b73402dabbbaf338149bfdfed3c74a7dcdb30d6619adba6388a0a232efd5a6
data/.gitignore ADDED
@@ -0,0 +1,20 @@
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
18
+ /development/.vagrant
19
+ .DS_Store
20
+ .idea/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-commit.gemspec
4
+ gemspec
5
+
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ Current way to install (execute in current directory):
2
+
3
+ ```
4
+ /usr/bin/ruby /usr/bin/gem build ./vagrant-commit.gemspec
5
+ vagrant plugin install ./vagrant-commit-0.5.6.gem
6
+ ```
7
+
8
+ Usage:
9
+
10
+ ```
11
+ vagrant commit [hostname]
12
+ ```
@@ -0,0 +1,26 @@
1
+ module Vagrant
2
+ module Commit
3
+ module Action
4
+ class CommitVolumes
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ end
9
+
10
+
11
+ def call(env)
12
+ server = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
13
+
14
+ server.volumes.each do |vol|
15
+ machine_name = env[:machine].name.to_s
16
+ env[:ui].info("#{machine_name}: commiting #{vol.path}")
17
+ `sudo -E qemu-img commit #{vol.path}`
18
+ end
19
+
20
+ @app.call env
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,31 @@
1
+ module Vagrant
2
+ module Commit
3
+ module Action
4
+ class FullDestroyVolumes
5
+
6
+ def initialize(app, env)
7
+ @app = app
8
+ end
9
+
10
+
11
+ def call(env)
12
+ server = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
13
+ files = []
14
+ server.volumes.each do |vol|
15
+ backing = `sudo -E qemu-img info #{vol.path} --force | grep 'backing file:' | cut -d ':' -f2`.chomp
16
+ files << backing
17
+ end
18
+ `vagrant destroy -f`
19
+ files.each do |backing|
20
+ `sudo -E rm -rf #{backing}`
21
+ end
22
+
23
+
24
+ @app.call env
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,26 @@
1
+ require_relative 'action/commit_volumes'
2
+ require_relative 'action/full_destroy'
3
+
4
+
5
+ module Vagrant
6
+ module Commit
7
+ module Action
8
+ class << self
9
+ # Call = Vagrant::Action::Builtin::Call
10
+
11
+ def action_commit_volumes
12
+ Vagrant::Action::Builder.new.tap do |b|
13
+ b.use CommitVolumes
14
+ end
15
+ end
16
+
17
+ def action_full_destroy
18
+ Vagrant::Action::Builder.new.tap do |b|
19
+ b.use FullDestroyVolumes
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,60 @@
1
+
2
+ require_relative 'action'
3
+
4
+ module Vagrant
5
+ module Commit
6
+ class Command < Vagrant.plugin('2', :command)
7
+
8
+ def self.synopsis
9
+ "(plugin) qemu-img commit the volumes"
10
+ end
11
+
12
+ def execute
13
+ opts = OptionParser.new do |o|
14
+ o.banner = "Usage: vagrant commit [name|id]"
15
+ end
16
+
17
+ # Parse the options
18
+ argv = parse_options(opts)
19
+
20
+ with_target_vms(argv) do |machine|
21
+ machine_name = machine.name.to_s
22
+ if machine.state.id != :shutoff
23
+ @env.ui.info("Halting #{machine_name}")
24
+ end
25
+ machine.action(:halt)
26
+ @env.action_runner.run(Vagrant::Commit::Action.action_commit_volumes, {
27
+ :machine => machine,
28
+ })
29
+
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ module FullDestroy
36
+ class Command < Vagrant.plugin('2', :command)
37
+
38
+ def self.synopsis
39
+ "(plugin): Fully destroy the box (if commit was used)"
40
+ end
41
+
42
+ def execute
43
+ opts = OptionParser.new do |o|
44
+ o.banner = "Usage: vagrant fulldestroy [name|id]"
45
+ end
46
+
47
+ # Parse the options
48
+ argv = parse_options(opts)
49
+
50
+ with_target_vms(argv) do |machine|
51
+ machine.action(:halt)
52
+ @env.action_runner.run(Vagrant::Commit::Action.action_full_destroy, {
53
+ :machine => machine,
54
+ })
55
+
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,20 @@
1
+ module Vagrant
2
+ module Commit
3
+ class Plugin < Vagrant.plugin('2')
4
+ name 'vagrant commit'
5
+ description 'Forwards notify-send from guest to host machine'
6
+
7
+ command(:commit) do
8
+ require_relative 'command'
9
+ Vagrant::Commit::Command
10
+ end
11
+
12
+ command(:fulldestroy) do
13
+ require_relative 'command'
14
+ Vagrant::FullDestroy::Command
15
+ end
16
+
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Commit
3
+ VERSION = "0.5.6"
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ require 'vagrant'
2
+ require 'socket'
3
+ require 'erb'
4
+ require 'ostruct'
5
+
6
+ if File.exists?(File.join(File.expand_path('../../', __FILE__), '.git'))
7
+ $:.unshift(File.expand_path('../../lib', __FILE__))
8
+ end
9
+
10
+ require 'vagrant-commit/plugin'
11
+ require "vagrant-commit/version"
12
+
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-commit/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "vagrant-commit"
8
+ gem.version = Vagrant::Commit::VERSION
9
+ gem.authors = ["Vitalii Abetkin"]
10
+ gem.email = ["v.abetkin@gmail.com"]
11
+ gem.description = 'A Vagrant plugin that does qemu-img commit'
12
+ gem.summary = gem.description
13
+ gem.homepage = "https://github.com/fgrehm/vagrant-commit"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,54 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-commit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.6
5
+ platform: ruby
6
+ authors:
7
+ - Vitalii Abetkin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-06-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Vagrant plugin that does qemu-img commit
14
+ email:
15
+ - v.abetkin@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - ".rspec"
22
+ - Gemfile
23
+ - README.md
24
+ - lib/vagrant-commit.rb
25
+ - lib/vagrant-commit/action.rb
26
+ - lib/vagrant-commit/action/commit_volumes.rb
27
+ - lib/vagrant-commit/action/full_destroy.rb
28
+ - lib/vagrant-commit/command.rb
29
+ - lib/vagrant-commit/plugin.rb
30
+ - lib/vagrant-commit/version.rb
31
+ - vagrant-commit.gemspec
32
+ homepage: https://github.com/fgrehm/vagrant-commit
33
+ licenses: []
34
+ metadata: {}
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubygems_version: 3.0.3
51
+ signing_key:
52
+ specification_version: 4
53
+ summary: A Vagrant plugin that does qemu-img commit
54
+ test_files: []