vagrant-zones 0.1.93 → 0.1.94
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/lib/vagrant-zones/action/package.rb +70 -62
- data/lib/vagrant-zones/config.rb +1 -1
- data/lib/vagrant-zones/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 778869048e63a224ab469bebda92cd1c236c14defc620300a72033c50ccb7f6c
|
4
|
+
data.tar.gz: 4eff63c5b2b5b92624bccc019e3a1cc8dd3d937ba67ed40603658f187f7475ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f7627181d958f935cfef5b30a8169c410481b463323694ec5c73dbf8ce3735bd1bc32798ee011a6e405c79d9d1658b3cf6f1336c9e7a5d6e3e737a601ef33a6
|
7
|
+
data.tar.gz: 7ada33a5baa5222d69bb773876dac9ca1256dba2d00ff0f92329f78b6675d210b870d229971e3a9de383604d4bcf465c904b0c1d53033e9ddadfb7f5b42ec0eb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [0.1.94](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.93...v0.1.94) (2024-01-09)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* linting changes ([6e0ca30](https://github.com/STARTcloud/vagrant-zones/commit/6e0ca305cb708cf3e9b8856c81f232b30d1fbd34))
|
9
|
+
* linting changes ([5efd5ae](https://github.com/STARTcloud/vagrant-zones/commit/5efd5ae4df118f0236541dc2f801221732864602))
|
10
|
+
* linting changes ([b74c980](https://github.com/STARTcloud/vagrant-zones/commit/b74c9808d1867d5fa05f0193419f777da39fa5de))
|
11
|
+
* linting changes ([eeaf8eb](https://github.com/STARTcloud/vagrant-zones/commit/eeaf8eb5da9162123b7fa2be99790deac6121a28))
|
12
|
+
* linting changes ([d2e23b4](https://github.com/STARTcloud/vagrant-zones/commit/d2e23b43c20a8037a50a49ca738d8e66a3fedc61))
|
13
|
+
* linting changes ([ce961e3](https://github.com/STARTcloud/vagrant-zones/commit/ce961e3c6d96aa24f8140beb6e4f92e4974feb5b))
|
14
|
+
* linting changes ([7735b66](https://github.com/STARTcloud/vagrant-zones/commit/7735b66944efcfe62cb86a19f58f42aa7933a994))
|
15
|
+
* linting changes ([117af25](https://github.com/STARTcloud/vagrant-zones/commit/117af25973eef16eda3f3d7ec3f83ab7e2ed0f4b))
|
16
|
+
* linting changes ([50a32ec](https://github.com/STARTcloud/vagrant-zones/commit/50a32ecd3fa3704d67068c7f50803d639a205c1b))
|
17
|
+
* linting changes ([6ae3aa1](https://github.com/STARTcloud/vagrant-zones/commit/6ae3aa10a7bca6cc057091bb0af77a634cb2083d))
|
18
|
+
* linting changes ([b936a8b](https://github.com/STARTcloud/vagrant-zones/commit/b936a8b218ac4046a44b1242d98852eaab382847))
|
19
|
+
* linting changes ([5c30988](https://github.com/STARTcloud/vagrant-zones/commit/5c30988965bf396fd8744464ea16ca6260f8a406))
|
20
|
+
* linting changes ([f96e885](https://github.com/STARTcloud/vagrant-zones/commit/f96e8854a5eea2c499de3ea9b93c4e9f4349be3a))
|
21
|
+
* linting changes ([b0cc1c3](https://github.com/STARTcloud/vagrant-zones/commit/b0cc1c3577d50940badf28e60c6bbfc155ff5ffc))
|
22
|
+
* linting changes ([547d81d](https://github.com/STARTcloud/vagrant-zones/commit/547d81d564c9a241fba856748a223faf65ce7f4a))
|
23
|
+
* linting changes ([bc66f9b](https://github.com/STARTcloud/vagrant-zones/commit/bc66f9bffc7e2d4f0ff475a942c0514c4916c487))
|
24
|
+
* linting changes ([a0b7295](https://github.com/STARTcloud/vagrant-zones/commit/a0b7295ca60ecfb6ee85cb178d1d70cb217a3fb3))
|
25
|
+
* linting changes ([895fb1f](https://github.com/STARTcloud/vagrant-zones/commit/895fb1f214888128b2512df3e827b6f5fdef90c2))
|
26
|
+
* linting changes ([13893a7](https://github.com/STARTcloud/vagrant-zones/commit/13893a70d389eca1a583bd150dae35d85fd7e7db))
|
27
|
+
* linting changes ([ed04b7f](https://github.com/STARTcloud/vagrant-zones/commit/ed04b7f94c3f433eaca4ff60ff678755edebb4ef))
|
28
|
+
* packaging process ([59bbb0d](https://github.com/STARTcloud/vagrant-zones/commit/59bbb0d5a2b0fcb0f851113718eb2196725c6708))
|
29
|
+
|
3
30
|
## [0.1.93](https://github.com/STARTcloud/vagrant-zones/compare/v0.1.92...v0.1.93) (2024-01-07)
|
4
31
|
|
5
32
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
require 'pathname'
|
3
5
|
require 'log4r'
|
6
|
+
require 'json'
|
4
7
|
module VagrantPlugins
|
5
8
|
module ProviderZone
|
6
9
|
module Action
|
@@ -25,58 +28,79 @@ module VagrantPlugins
|
|
25
28
|
end
|
26
29
|
|
27
30
|
def call(env)
|
28
|
-
@machine = env[:machine]
|
29
|
-
@driver = @machine.provider.driver
|
30
|
-
name = @machine.name
|
31
31
|
boxname = env['package.output']
|
32
|
-
|
33
|
-
|
34
|
-
vcc = @machine.provider_config.vagrant_cloud_creator
|
35
|
-
boxshortname = @machine.provider_config.boxshortname
|
32
|
+
mpc = env[:machine].provider_config
|
33
|
+
files = {}
|
36
34
|
raise "#{boxname}: Already exists" if File.exist?(boxname)
|
37
35
|
|
38
36
|
## Create Snapshot
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
snapshot_create(datasetpath, datetime, env[:ui], @machine.provider_config)
|
45
|
-
snapshot_send(datasetpath, "#{tmp_dir}/box.zss", datetime, env[:ui], @machine.provider_config)
|
46
|
-
## snapshot_delete(datasetpath, env[:ui], datetime)
|
47
|
-
|
48
|
-
# Package VM
|
49
|
-
extra = ''
|
37
|
+
FileUtils.mkdir_p("#{Dir.pwd}/_tmp_package")
|
38
|
+
datasetpath = "#{mpc.boot['array']}/#{mpc.boot['dataset']}/#{env[:machine].name}"
|
39
|
+
datetime = Time.new.strftime('%Y-%m-%d-%H:%M:%S')
|
40
|
+
snapshot_create(datasetpath, datetime, env[:ui], mpc)
|
41
|
+
snapshot_send(datasetpath, "#{Dir.pwd}/_tmp_package/box.zss", datetime, env[:ui], mpc)
|
50
42
|
|
51
43
|
## Include User Extra Files
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
44
|
+
env['package.include'].each do |file|
|
45
|
+
source = Pathname.new(file)
|
46
|
+
dest = if source.relative?
|
47
|
+
source
|
48
|
+
else
|
49
|
+
source.basename
|
50
|
+
end
|
51
|
+
files[file] = dest
|
52
|
+
end
|
53
|
+
|
54
|
+
# Verify the mapping
|
55
|
+
files.each_key do |from|
|
56
|
+
raise Vagrant::Errors::PackageIncludeMissing, file: from unless File.exist?(from)
|
58
57
|
end
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
59
|
+
files.each do |from, dest|
|
60
|
+
include_directory = Pathname.new("#{Dir.pwd}/_tmp_package/")
|
61
|
+
to = include_directory.join(dest)
|
62
|
+
FileUtils.mkdir_p(to.parent)
|
63
|
+
if File.directory?(from)
|
64
|
+
FileUtils.cp_r(Dir.glob(from), to.parent, preserve: true)
|
65
|
+
else
|
66
|
+
FileUtils.cp(from, to, preserve: true)
|
67
|
+
end
|
66
68
|
end
|
67
69
|
|
68
|
-
## Create
|
69
|
-
|
70
|
-
|
71
|
-
|
70
|
+
## Create a Vagrantfile or load from Users Defined File
|
71
|
+
vagrantfile_content = <<~'CODE'
|
72
|
+
require 'yaml'
|
73
|
+
require_relative 'Hosts'
|
74
|
+
settings = YAML::load(File.read("#{File.dirname(__FILE__)}/Hosts.yml"))
|
75
|
+
Vagrant.configure("2") do |config|
|
76
|
+
Hosts.configure(config, settings)
|
77
|
+
end
|
78
|
+
CODE
|
79
|
+
File.write("#{Dir.pwd}/_tmp_package/Vagrantfile", vagrantfile_content)
|
80
|
+
files[env['package.vagrantfile']] = '_Vagrantfile' if env['package.vagrantfile']
|
81
|
+
|
82
|
+
info_content_hash = {
|
83
|
+
'boxname' => boxname,
|
84
|
+
'Author' => mpc.vagrant_cloud_creator,
|
85
|
+
'Vagrant-Zones' => 'This box was built with Vagrant-Zones: https://github.com/STARTcloud/vagrant-zones'
|
86
|
+
}
|
87
|
+
File.write("#{Dir.pwd}/_tmp_package/info.json", info_content_hash.to_json)
|
88
|
+
|
89
|
+
metadata_content_hash = {
|
90
|
+
'provider' => 'zone',
|
91
|
+
'architecture' => 'amd64',
|
92
|
+
'brand' => mpc.brand,
|
93
|
+
'format' => 'zss',
|
94
|
+
'url' => "https://app.vagrantup.com/#{mpc.vagrant_cloud_creator}/boxes/#{mpc.boxshortname}"
|
95
|
+
}
|
96
|
+
metadata_content_hash['kernel'] = mpc.kernel if !mpc.kernel.nil? && mpc.kernel != false
|
97
|
+
File.write("#{Dir.pwd}/_tmp_package/metadata.json", metadata_content_hash.to_json)
|
72
98
|
|
73
99
|
## Create the Box file
|
74
|
-
assemble_box(boxname,
|
75
|
-
FileUtils.
|
76
|
-
Dir.chdir('../')
|
77
|
-
FileUtils.rm_rf(tmp_dir)
|
100
|
+
assemble_box(boxname, "#{Dir.pwd}/_tmp_package")
|
101
|
+
FileUtils.rm_rf("#{Dir.pwd}/_tmp_package")
|
78
102
|
|
79
|
-
env[:ui].info("Box created, You can now add the box: 'vagrant box add #{boxname} --
|
103
|
+
env[:ui].info("Box created, You can now add the box: 'vagrant box add #{boxname} --name newbox'")
|
80
104
|
@app.call(env)
|
81
105
|
end
|
82
106
|
|
@@ -94,32 +118,16 @@ module VagrantPlugins
|
|
94
118
|
def snapshot_send(datasetpath, destination, datetime, uii, config)
|
95
119
|
uii.info('Sending Snapshot to ZFS Send Stream image.')
|
96
120
|
result = execute(true, "#{@pfexec} zfs send #{datasetpath}/boot@vagrant_box#{datetime} > #{destination}")
|
97
|
-
|
98
|
-
end
|
99
|
-
|
100
|
-
def metadata_content(_brand, _kernel, vcc, boxshortname)
|
101
|
-
<<-ZONEBOX
|
102
|
-
{ "provider": "zone", "architecture": "amd64", "url": "https://app.vagrantup.com/#{vcc}/boxes/#{boxshortname}" }
|
103
|
-
ZONEBOX
|
104
|
-
end
|
105
|
-
|
106
|
-
def vagrantfile_content(brand, _kernel, datasetpath)
|
107
|
-
<<-ZONEBOX
|
108
|
-
Vagrant.configure('2') do |config|
|
109
|
-
config.vm.provider :zone do |zone|
|
110
|
-
zone.brand = "#{brand}"
|
111
|
-
zone.datasetpath = "#{datasetpath}"
|
112
|
-
end
|
113
|
-
end
|
114
|
-
user_vagrantfile = File.expand_path('../_include/Vagrantfile', __FILE__)
|
115
|
-
load user_vagrantfile if File.exists?(user_vagrantfile)
|
116
|
-
ZONEBOX
|
121
|
+
uii.info("#{@pfexec} zfs send -r #{datasetpath}/boot@vagrant_box#{datetime} > #{destination}") if result.zero? && config.debug
|
117
122
|
end
|
118
123
|
|
119
|
-
def assemble_box(boxname,
|
124
|
+
def assemble_box(boxname, tmp_dir)
|
120
125
|
is_linux = `bash -c '[[ "$(uname -a)" =~ "Linux" ]]'`
|
121
|
-
|
122
|
-
|
126
|
+
Dir.chdir(tmp_dir) do
|
127
|
+
files = Dir.glob(File.join('.', '*'))
|
128
|
+
tar_command = is_linux ? 'tar -cvzf' : 'tar -cvzEf'
|
129
|
+
`#{tar_command} ../#{boxname} #{files.join(' ')}`
|
130
|
+
end
|
123
131
|
end
|
124
132
|
end
|
125
133
|
end
|
data/lib/vagrant-zones/config.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-zones
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.94
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Gilbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|