vagrant-commit 0.6 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3490e577682290c018ad28e96c72e9a11cd5008a5a8a1a61315cc6eb3de4e33f
4
- data.tar.gz: 171f2b1e8d17c6160c6cb8f2d57313d1b8dedc55a7b4cee5e9992b8731fe5124
3
+ metadata.gz: 29d259393ffcb220f7b9585d40ab8314279b9758fe6d4b1ab23299ac7c64fae0
4
+ data.tar.gz: 9fd10897890403f3fed69e0557c62deccdb1b63cd4e083cbf9fbdb22428b87ae
5
5
  SHA512:
6
- metadata.gz: b15e4644c83585d77690c9ff1a946c2e57e06ef3ab526002325b3a42bb50e7a52675102280c18a317251e1e714c7fccd10333fc41202a78933a14a0761ed15f4
7
- data.tar.gz: 1d75c04e006e0147a11140e009e3a7596f7fe5ff9db6e4e978e8f8ee541ef2a6d1f8fbd14da808f00f97f2ec54d1462ffec57ab4f9781d3192f61dcbfb351b4e
6
+ metadata.gz: 5c94189424a37a506c6434156378442230fc25b1d5ec3b9639c53c12d0c1d1cee449e46c7c0e030edfc06bc62eb3d42ba8174f7487fa1db7a18a845a1ed1bd88
7
+ data.tar.gz: ca8714dab547af8ac59c6dc8f70a224aaf1c2f79fb366f4d5b94129ef62b2dc2f4b6f951f9ccca0d1c117bef9d471c7898d4654a843b9494259fc4ded68e59cf
@@ -1,5 +1,6 @@
1
1
 
2
2
  require_relative 'action'
3
+ # require 'pry'
3
4
 
4
5
  module Vagrant
5
6
  module Commit
@@ -83,4 +84,69 @@ module Vagrant
83
84
  end
84
85
  end
85
86
  end
87
+
88
+ module CopyBox
89
+ class Command < Vagrant.plugin('2', :command)
90
+
91
+ def metadata_json
92
+ <<-EOF
93
+ {
94
+ "provider": "libvirt",
95
+ "format": "qcow2",
96
+ "virtual_size": 32
97
+ }
98
+ EOF
99
+ end
100
+
101
+ def Vagrantfile
102
+ <<-EOF
103
+ Vagrant.configure("2") do |config|
104
+ config.vm.provider :libvirt do |libvirt|
105
+ libvirt.driver = "kvm"
106
+ libvirt.host = ""
107
+ libvirt.connect_via_ssh = false
108
+ libvirt.storage_pool_name = "default"
109
+ end
110
+ end
111
+
112
+ user_vagrantfile = File.expand_path('../_include/Vagrantfile', __FILE__)
113
+ load user_vagrantfile if File.exists?(user_vagrantfile)
114
+ EOF
115
+ end
116
+
117
+ def execute
118
+ opts = OptionParser.new do |o|
119
+ o.banner = "Usage: vagrant copybox <source> <target>"
120
+ end
121
+
122
+ # Parse the options
123
+ argv = parse_options(opts)
124
+ src_boxname, target_boxname = argv
125
+ if !src_boxname || !target_boxname
126
+ raise Vagrant::Errors::CLIInvalidUsage,
127
+ help: opts.help.chomp
128
+ end
129
+ collection = Vagrant::BoxCollection.new(@env.boxes_path)
130
+ box = collection.find(src_boxname, :libvirt, "> 0")
131
+ provider = box.metadata["provider"]
132
+
133
+ # create necessary files in the boxes path
134
+ root_dir = @env.boxes_path
135
+ version = "0"
136
+ new_box_dir = root_dir.join(target_boxname).join(version).join(provider.to_s)
137
+ new_box_dir.mkpath
138
+ new_box_dir.join("metadata.json").open("w") do |f|
139
+ f.write(metadata_json())
140
+ end
141
+ new_box_dir.join("Vagrantfile").open("w") do |f|
142
+ f.write(Vagrantfile())
143
+ end
144
+ src_path = box.directory.join("box.img")
145
+ target_path = new_box_dir.join("box.img")
146
+ FileUtils.cp(src_path, target_path)
147
+ end
148
+ end
149
+ end
150
+
151
+
86
152
  end
@@ -18,7 +18,12 @@ module Vagrant
18
18
  require_relative 'command'
19
19
  Vagrant::ShowInfo::Command
20
20
  end
21
-
21
+
22
+
23
+ command(:copybox) do
24
+ require_relative 'command'
25
+ Vagrant::CopyBox::Command
26
+ end
22
27
  end
23
28
  end
24
29
 
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Commit
3
- VERSION = "0.6"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-commit
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitalii Abetkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-04 00:00:00.000000000 Z
11
+ date: 2019-06-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Vagrant plugin that does qemu-img commit
14
14
  email: