vagrant-zones 0.1.93 → 0.1.94

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: e07b281bab5dd258c7b640b659c330061d87458a795247b941c05dbc6e194b84
4
- data.tar.gz: d48d93a6e9089267a6e93ddf45419fb2d8729fce1e806421e514ec0d9a81b3f2
3
+ metadata.gz: 778869048e63a224ab469bebda92cd1c236c14defc620300a72033c50ccb7f6c
4
+ data.tar.gz: 4eff63c5b2b5b92624bccc019e3a1cc8dd3d937ba67ed40603658f187f7475ac
5
5
  SHA512:
6
- metadata.gz: '0685b5eab45e2cd3ec84f3bcca2fb6f1ca141967b832d2162b1853d91cfcd533ea98bb66fc6f01c0a17fd20ae0768baef5821d2b5fb80fefa44899d3ea264c0c'
7
- data.tar.gz: 25bcb6927db98c2e4771883796758908f56fa9a243f592dbc2af68fca2ac45084589945a974df289fa8bdbf5a1c71804b6498d60a8f71e9984cefed9d5c3f3b0
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
- brand = @machine.provider_config.brand
33
- kernel = @machine.provider_config.kernel
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
- tmp_dir = "#{Dir.pwd}/_tmp_package"
40
- Dir.mkdir(tmp_dir)
41
- datasetpath = "#{@machine.provider_config.boot['array']}/#{@machine.provider_config.boot['dataset']}/#{name}"
42
- t = Time.new
43
- datetime = %(#{t.year}-#{t.month}-#{t.day}-#{t.hour}:#{t.min}:#{t.sec})
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
- if env['package.include']
53
- extra = '_include'
54
- env['package.include'].each do |f|
55
- env[:ui].info("Including user file: #{f}")
56
- FileUtils.cp(f, tmp_dir)
57
- end
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
- ## Include Vagrant file
61
- if env['package.vagrantfile']
62
- extra = '_include'
63
- Dir.mkdir(@tmp_include) unless File.directory?(@tmp_include)
64
- env[:ui].info('Including user Vagrantfile')
65
- FileUtils.cp(env['package.vagrantfile'], "#{@tmp_include}/Vagrantfile")
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 the Metadata and Vagrantfile
69
- Dir.chdir(tmp_dir)
70
- File.write('./metadata.json', metadata_content(brand, kernel, vcc, boxshortname))
71
- File.write('./Vagrantfile', vagrantfile_content(brand, kernel, datasetpath))
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, extra)
75
- FileUtils.mv("#{tmp_dir}/#{boxname}", "../#{boxname}")
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} --nameofnewbox'")
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
- puts "#{@pfexec} zfs send -r #{datasetpath}/boot@vagrant_box#{datetime} > #{destination}" if result.zero? && config.debug
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, extra)
124
+ def assemble_box(boxname, tmp_dir)
120
125
  is_linux = `bash -c '[[ "$(uname -a)" =~ "Linux" ]]'`
121
- `tar -cvzf #{boxname} ./metadata.json ./Vagrantfile ./box.zss #{extra}` if is_linux
122
- `tar -cvzEf #{boxname} ./metadata.json ./Vagrantfile ./box.zss #{extra}` unless is_linux
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
@@ -17,7 +17,7 @@ module VagrantPlugins
17
17
  @additional_disks = UNSET_VALUE
18
18
  @autoboot = true
19
19
  @post_provision_boot = false
20
- @kernel = UNSET_VALUE
20
+ @kernel = nil
21
21
  @boxshortname = UNSET_VALUE
22
22
  @cdroms = nil
23
23
  @shared_dir = nil
@@ -2,7 +2,7 @@
2
2
 
3
3
  module VagrantPlugins
4
4
  module ProviderZone
5
- VERSION = '0.1.93'
5
+ VERSION = '0.1.94'
6
6
  NAME = 'vagrant-zones'
7
7
  end
8
8
  end
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.93
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-07 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n