vagrant-lxd 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fef7b1d0ba6f86c3f621e843abe99b6bfcda266f
4
- data.tar.gz: 2de77f085615f775deff08f65a10bdd584182647
2
+ SHA256:
3
+ metadata.gz: 1baeedff522cfbebedcb5502ca770a5acee212b651cd15ee5689de902151e218
4
+ data.tar.gz: a4310d180e7f8b686e474087f715fcf5896f37f51e233a934f9af156a332e633
5
5
  SHA512:
6
- metadata.gz: cc3718c25b56973c47858ad5bc7711a23d0ba1a9ae43b9ab55f42dbf10cd2e67d4730948e92dbcb1e0eddbff595eabc815e4dfd952235766a1d8bb5e69c3dca7
7
- data.tar.gz: c87aa4c96a58bf9162124a6fa910cabeb9ab29c17726ef4403a88a11ec74ff9f11124f49e39ebe13bdcaae38da71427cfcaa31267c3717dc882f5385edc8a9d0
6
+ metadata.gz: c26145438faab6e93dae3e9e838d899478cac316de5d97c9ee844acbebc192d2ff8b8b324ad9099b8a50cb75ac4770f88e60a26b2646020c53fe241a958b2f14
7
+ data.tar.gz: 70768153d8648bf0fc22406e9bb5107f399acac378a9ea5811955a483c11e4e0e9cb575afa8e58a9bb5e3d3844deb4cc6413a6e16001fefa8fe8ec5828be8844
data/.gitignore CHANGED
@@ -1,5 +1,6 @@
1
1
  /.bundle/
2
+ /.tool-versions
2
3
  /.vagrant/
3
- /pkg/
4
4
  /Vagrantfile
5
+ /pkg/
5
6
  /vendor/
@@ -1,4 +1,4 @@
1
- image: "ruby:2.3"
1
+ image: "ruby:2.4"
2
2
 
3
3
  before_script:
4
4
  - apt-get -y update
data/Gemfile CHANGED
@@ -1,12 +1,13 @@
1
1
  source 'https://rubygems.org/'
2
2
 
3
3
  group :development do
4
+ require 'pp' # avoid superclass mismatch error
4
5
  gem 'fakefs'
5
6
  gem 'rake'
6
7
  gem 'rspec'
7
8
  gem 'rspec-its'
8
9
  gem 'rspec-mocks'
9
- gem 'vagrant', :git => 'https://github.com/mitchellh/vagrant.git'
10
+ gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
10
11
  end
11
12
 
12
13
  group :plugins do
@@ -1,60 +1,63 @@
1
1
  GIT
2
2
  remote: https://github.com/mitchellh/vagrant.git
3
- revision: c6b42a04cd1ca9f0936714ee6a44b4c7c001fdeb
3
+ revision: 2063111ab5cfcce0f6b2dbcecd9d24d47b512a96
4
4
  specs:
5
- vagrant (2.2.4.dev)
5
+ vagrant (2.2.10.dev)
6
6
  bcrypt_pbkdf (~> 1.0.0)
7
- childprocess (~> 0.6.0)
7
+ childprocess (~> 4.0.0)
8
8
  ed25519 (~> 1.2.4)
9
9
  erubis (~> 2.7.0)
10
10
  hashicorp-checkpoint (~> 0.1.5)
11
- i18n (~> 1.1.1)
12
- listen (~> 3.1.5)
11
+ i18n (~> 1.8)
12
+ listen (~> 3.1)
13
13
  log4r (~> 1.1.9, < 1.1.11)
14
+ mime (~> 0.4.4)
14
15
  net-scp (~> 1.2.0)
15
- net-sftp (~> 2.1)
16
- net-ssh (~> 5.1.0)
16
+ net-sftp (~> 3.0)
17
+ net-ssh (~> 6.0)
17
18
  rb-kqueue (~> 0.2.0)
18
19
  rest-client (>= 1.6.0, < 3.0)
19
20
  ruby_dep (<= 1.3.1)
20
- rubyzip (~> 1.2.2)
21
- vagrant_cloud (~> 2.0.2)
21
+ rubyzip (~> 2.0)
22
+ vagrant_cloud (~> 2.0.3)
22
23
  wdm (~> 0.1.0)
23
- winrm (~> 2.1)
24
- winrm-elevated (~> 1.1)
25
- winrm-fs (~> 1.0)
24
+ winrm (>= 2.3.4, < 3.0)
25
+ winrm-elevated (>= 1.2.1, < 2.0)
26
+ winrm-fs (>= 1.3.4, < 2.0)
26
27
 
27
28
  PATH
28
29
  remote: .
29
30
  specs:
30
- vagrant-lxd (0.4.1)
31
+ vagrant-lxd (0.5.0)
32
+ activesupport (~> 5.2.3)
33
+ faraday (~> 0.17)
31
34
  hyperkit (~> 1.2.0)
32
35
 
33
36
  GEM
34
37
  remote: https://rubygems.org/
35
38
  specs:
36
- activesupport (5.2.3)
39
+ activesupport (5.2.4.3)
37
40
  concurrent-ruby (~> 1.0, >= 1.0.2)
38
41
  i18n (>= 0.7, < 2)
39
42
  minitest (~> 5.1)
40
43
  tzinfo (~> 1.1)
41
- addressable (2.5.2)
42
- public_suffix (>= 2.0.2, < 4.0)
43
- bcrypt_pbkdf (1.0.0)
44
- builder (3.2.3)
45
- childprocess (0.6.3)
46
- ffi (~> 1.0, >= 1.0.11)
47
- concurrent-ruby (1.1.4)
48
- diff-lcs (1.3)
49
- domain_name (0.5.20180417)
44
+ addressable (2.7.0)
45
+ public_suffix (>= 2.0.2, < 5.0)
46
+ bcrypt_pbkdf (1.0.1)
47
+ builder (3.2.4)
48
+ childprocess (4.0.0)
49
+ concurrent-ruby (1.1.7)
50
+ diff-lcs (1.4.4)
51
+ domain_name (0.5.20190701)
50
52
  unf (>= 0.0.5, < 1.0.0)
51
53
  ed25519 (1.2.4)
54
+ erubi (1.9.0)
52
55
  erubis (2.7.0)
53
- fakefs (0.19.1)
54
- faraday (0.15.4)
56
+ fakefs (1.2.2)
57
+ faraday (0.17.3)
55
58
  multipart-post (>= 1.2, < 3)
56
- ffi (1.10.0)
57
- gssapi (1.2.0)
59
+ ffi (1.13.1)
60
+ gssapi (1.3.0)
58
61
  ffi (>= 1.0.1)
59
62
  gyoku (1.3.1)
60
63
  builder (>= 2.1.2)
@@ -65,34 +68,34 @@ GEM
65
68
  hyperkit (1.2.0)
66
69
  activesupport (>= 4.2.6)
67
70
  sawyer
68
- i18n (1.1.1)
71
+ i18n (1.8.5)
69
72
  concurrent-ruby (~> 1.0)
70
- listen (3.1.5)
71
- rb-fsevent (~> 0.9, >= 0.9.4)
72
- rb-inotify (~> 0.9, >= 0.9.7)
73
- ruby_dep (~> 1.2)
73
+ listen (3.2.1)
74
+ rb-fsevent (~> 0.10, >= 0.10.3)
75
+ rb-inotify (~> 0.9, >= 0.9.10)
74
76
  little-plugger (1.1.4)
75
77
  log4r (1.1.10)
76
- logging (2.2.2)
78
+ logging (2.3.0)
77
79
  little-plugger (~> 1.1)
78
- multi_json (~> 1.10)
79
- mime-types (3.2.2)
80
+ multi_json (~> 1.14)
81
+ mime (0.4.4)
82
+ mime-types (3.3.1)
80
83
  mime-types-data (~> 3.2015)
81
- mime-types-data (3.2018.0812)
82
- minitest (5.11.3)
83
- multi_json (1.13.1)
84
- multipart-post (2.0.0)
84
+ mime-types-data (3.2020.0512)
85
+ minitest (5.14.1)
86
+ multi_json (1.15.0)
87
+ multipart-post (2.1.1)
85
88
  net-scp (1.2.1)
86
89
  net-ssh (>= 2.6.5)
87
- net-sftp (2.1.2)
88
- net-ssh (>= 2.6.5)
89
- net-ssh (5.1.0)
90
+ net-sftp (3.0.0)
91
+ net-ssh (>= 5.0.0, < 7.0.0)
92
+ net-ssh (6.1.0)
90
93
  netrc (0.11.0)
91
94
  nori (2.6.0)
92
- public_suffix (3.0.3)
93
- rake (12.3.2)
94
- rb-fsevent (0.10.3)
95
- rb-inotify (0.10.0)
95
+ public_suffix (4.0.5)
96
+ rake (13.0.1)
97
+ rb-fsevent (0.10.4)
98
+ rb-inotify (0.10.1)
96
99
  ffi (~> 1.0)
97
100
  rb-kqueue (0.2.5)
98
101
  ffi (>= 0.5.0)
@@ -100,53 +103,54 @@ GEM
100
103
  http-cookie (>= 1.0.2, < 2.0)
101
104
  mime-types (>= 1.16, < 4.0)
102
105
  netrc (~> 0.8)
103
- rspec (3.8.0)
104
- rspec-core (~> 3.8.0)
105
- rspec-expectations (~> 3.8.0)
106
- rspec-mocks (~> 3.8.0)
107
- rspec-core (3.8.0)
108
- rspec-support (~> 3.8.0)
109
- rspec-expectations (3.8.2)
106
+ rspec (3.9.0)
107
+ rspec-core (~> 3.9.0)
108
+ rspec-expectations (~> 3.9.0)
109
+ rspec-mocks (~> 3.9.0)
110
+ rspec-core (3.9.2)
111
+ rspec-support (~> 3.9.3)
112
+ rspec-expectations (3.9.2)
110
113
  diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.8.0)
112
- rspec-its (1.2.0)
114
+ rspec-support (~> 3.9.0)
115
+ rspec-its (1.3.0)
113
116
  rspec-core (>= 3.0.0)
114
117
  rspec-expectations (>= 3.0.0)
115
- rspec-mocks (3.8.0)
118
+ rspec-mocks (3.9.1)
116
119
  diff-lcs (>= 1.2.0, < 2.0)
117
- rspec-support (~> 3.8.0)
118
- rspec-support (3.8.0)
120
+ rspec-support (~> 3.9.0)
121
+ rspec-support (3.9.3)
119
122
  ruby_dep (1.3.1)
120
123
  rubyntlm (0.6.2)
121
- rubyzip (1.2.2)
122
- sawyer (0.8.1)
123
- addressable (>= 2.3.5, < 2.6)
124
- faraday (~> 0.8, < 1.0)
124
+ rubyzip (2.3.0)
125
+ sawyer (0.8.2)
126
+ addressable (>= 2.3.5)
127
+ faraday (> 0.8, < 2.0)
125
128
  thread_safe (0.3.6)
126
- tzinfo (1.2.5)
129
+ tzinfo (1.2.7)
127
130
  thread_safe (~> 0.1)
128
131
  unf (0.1.4)
129
132
  unf_ext
130
- unf_ext (0.0.7.5)
131
- vagrant_cloud (2.0.2)
133
+ unf_ext (0.0.7.7)
134
+ vagrant_cloud (2.0.3)
132
135
  rest-client (~> 2.0.2)
133
136
  wdm (0.1.1)
134
- winrm (2.3.1)
137
+ winrm (2.3.4)
135
138
  builder (>= 2.1.2)
136
- erubis (~> 2.7)
139
+ erubi (~> 1.8)
137
140
  gssapi (~> 1.2)
138
141
  gyoku (~> 1.0)
139
142
  httpclient (~> 2.2, >= 2.2.0.2)
140
143
  logging (>= 1.6.1, < 3.0)
141
144
  nori (~> 2.0)
142
145
  rubyntlm (~> 0.6.0, >= 0.6.1)
143
- winrm-elevated (1.1.1)
146
+ winrm-elevated (1.2.1)
147
+ erubi (~> 1.8)
144
148
  winrm (~> 2.0)
145
149
  winrm-fs (~> 1.0)
146
- winrm-fs (1.3.2)
147
- erubis (~> 2.7)
150
+ winrm-fs (1.3.4)
151
+ erubi (~> 1.8)
148
152
  logging (>= 1.6.1, < 3.0)
149
- rubyzip (~> 1.1)
153
+ rubyzip (~> 2.0)
150
154
  winrm (~> 2.0)
151
155
 
152
156
  PLATFORMS
@@ -162,4 +166,4 @@ DEPENDENCIES
162
166
  vagrant-lxd!
163
167
 
164
168
  BUNDLED WITH
165
- 2.0.1
169
+ 2.1.4
data/README.md CHANGED
@@ -13,7 +13,8 @@ The following features are currently supported:
13
13
  - VM management (create, suspend, destroy, etc.)
14
14
  - IPv4 networking
15
15
  - Synced folders
16
- - Snapshots
16
+ - Snapshots (via `vagrant snapshot`)
17
+ - Box Packaging (via `vagrant package`)
17
18
 
18
19
  The following features are not expected to work yet:
19
20
 
@@ -147,7 +148,7 @@ is passed through to LXD. The hash values should all be strings:
147
148
  recursive: 'false',
148
149
  }
149
150
 
150
- [disk]: https://lxd.readthedocs.io/en/latest/containers/#type-disk
151
+ [disk]: https://lxd.readthedocs.io/en/latest/instances/#type-disk
151
152
 
152
153
  ### Shared LXD Containers
153
154
 
@@ -233,7 +234,7 @@ to run graphical applications transparently from within the guest:
233
234
  Note that disk devices should be configured as [synced
234
235
  folders](#synced-folders) rather than ad-hoc devices.
235
236
 
236
- [device-config]: https://lxd.readthedocs.io/en/latest/containers/#device-configuration
237
+ [device-config]: https://lxd.readthedocs.io/en/latest/instances/#devices-configuration
237
238
 
238
239
  ## Hacking
239
240
 
@@ -124,6 +124,20 @@ module VagrantLXD
124
124
  end
125
125
  end
126
126
 
127
+ class Package
128
+ def initialize(app, env)
129
+ @app = app
130
+ @env = env
131
+ end
132
+
133
+ def call(env)
134
+ env['package.directory'] = env[:machine_package]
135
+ @app.call(env)
136
+ ensure
137
+ FileUtils.rm_rf(env[:machine_package])
138
+ end
139
+ end
140
+
127
141
  #
128
142
  # Action definitions.
129
143
  #
@@ -335,6 +349,24 @@ module VagrantLXD
335
349
  builder { |b| b.use SSHRun }
336
350
  end
337
351
 
352
+ def package
353
+ builder do |b|
354
+ b.use Call, state do |env, c|
355
+ case env[:machine_state]
356
+ when Vagrant::MachineState::NOT_CREATED_ID
357
+ next
358
+ when :frozen, :running
359
+ c.use halt
360
+ end
361
+
362
+ c.use Message, :info, 'Packaging machine...'
363
+ c.use LXD.action(:package)
364
+ c.use Package
365
+ c.use Vagrant::Action::General::Package
366
+ end
367
+ end
368
+ end
369
+
338
370
  private
339
371
 
340
372
  def builder
@@ -29,14 +29,33 @@ module VagrantLXD
29
29
  def Capability.synced_folders(env)
30
30
  logger = Log4r::Logger.new('vagrant::lxd::capability')
31
31
  logger.debug "Checking synced folders support for effective UID/GID #{Process.uid}/#{Process.gid}..."
32
- result = %w(uid gid).all? do |type|
32
+ %w(uid gid).all? do |type|
33
33
  begin
34
- File.readlines("/etc/sub#{type}").grep(/^root:#{Process.send(type)}:[1-9]/).any?
34
+ id = Process.send(type)
35
+ id_map = File.readlines("/etc/sub#{type}")
36
+ id_in_sub_id?(id, id_map)
35
37
  rescue StandardError => e
36
38
  logger.warn "Cannot read subordinate permissions file: #{e.message}"
37
39
  false
38
40
  end
39
41
  end
40
42
  end
43
+
44
+ # Determines whether the given numerical `id` is included in the
45
+ # subordinate map `id_map`, which should be an array of lines from
46
+ # the file /etc/subuid or /etc/subgid.
47
+ #
48
+ # Invalid lines, and any lines for a user or group other than root,
49
+ # are ignored. See subuid(5) and subgid(5) for details about these
50
+ # files, and the expected format of their entries.
51
+ def Capability.id_in_sub_id?(id, id_map)
52
+ id_map.any? do |line|
53
+ if line.match(/^(root|0):(\d+):(\d+)/)
54
+ range_min = $2.to_i
55
+ range_max = range_min + $3.to_i
56
+ id.between?(range_min, range_max)
57
+ end
58
+ end
59
+ end
41
60
  end
42
61
  end
@@ -20,10 +20,12 @@
20
20
  require 'active_support/core_ext/object/deep_dup'
21
21
  require 'active_support/core_ext/hash/except'
22
22
  require 'hyperkit'
23
+ require 'json'
24
+ require 'monitor'
23
25
  require 'securerandom'
24
26
  require 'tempfile'
25
27
  require 'timeout'
26
- require 'monitor'
28
+ require 'yaml'
27
29
  require 'vagrant/machine_state'
28
30
  require 'vagrant-lxd/driver/certificate'
29
31
 
@@ -69,6 +71,10 @@ module VagrantLXD
69
71
  error_key 'lxd_image_creation_failure'
70
72
  end
71
73
 
74
+ class ImageExportFailure < Vagrant::Errors::VagrantError
75
+ error_key 'lxd_image_export_failure'
76
+ end
77
+
72
78
  class ContainerNotFound < Vagrant::Errors::VagrantError
73
79
  error_key 'lxd_container_not_found'
74
80
  end
@@ -122,6 +128,36 @@ module VagrantLXD
122
128
  end
123
129
  end
124
130
 
131
+ # XXX This monkey patch has the fix from https://github.com/jeffshantz/hyperkit/pull/15
132
+ # TODO Remove this once there is a new release of the hyperkit gem.
133
+ module Hyperkit::Connection
134
+ def sawyer_options
135
+ opts = {
136
+ :links_parser => Sawyer::LinkParsers::Simple.new,
137
+ }
138
+ conn_opts = {}
139
+ conn_opts[:builder] = @middleware if @middleware
140
+ conn_opts[:proxy] = @proxy if @proxy
141
+
142
+ conn_opts[:ssl] = {
143
+ verify: verify_ssl
144
+ }
145
+
146
+ if client_cert && File.exist?(client_cert)
147
+ conn_opts[:ssl][:client_cert] = OpenSSL::X509::Certificate.new(File.read(client_cert))
148
+ end
149
+
150
+ # XXX https://github.com/jeffshantz/hyperkit/pull/15/files
151
+ if client_key && File.exist?(client_key)
152
+ conn_opts[:ssl][:client_key] = OpenSSL::PKey.read(File.read(client_key))
153
+ end
154
+
155
+ opts[:faraday] = Faraday.new(conn_opts)
156
+
157
+ opts
158
+ end
159
+ end
160
+
125
161
  NOT_CREATED = Vagrant::MachineState::NOT_CREATED_ID
126
162
 
127
163
  attr_reader :api_endpoint
@@ -167,8 +203,8 @@ module VagrantLXD
167
203
  raw_idmap = container[:config][:'raw.idmap']
168
204
  begin
169
205
  raw_idmap and
170
- raw_idmap =~ /^uid #{Process.uid} #{vagrant_uid}$/ and
171
- raw_idmap =~ /^gid #{Process.gid} #{vagrant_gid}$/
206
+ id_in_map?(Process.uid, 'uid', raw_idmap) and
207
+ id_in_map?(Process.gid, 'gid', raw_idmap)
172
208
  end
173
209
  rescue Vagrant::Errors::ProviderNotUsable
174
210
  false
@@ -341,6 +377,14 @@ module VagrantLXD
341
377
  end
342
378
  end
343
379
 
380
+ def package
381
+ if in_state? :stopped
382
+ create_package_directory
383
+ else
384
+ @logger.debug "Skipped packaging (#{machine_id} is not stopped)"
385
+ end
386
+ end
387
+
344
388
  def configure
345
389
  container = lxd.container(machine_id)
346
390
  container[:config] = container[:config].to_hash.merge(config)
@@ -389,7 +433,7 @@ module VagrantLXD
389
433
  end
390
434
  end
391
435
 
392
- private
436
+ private
393
437
 
394
438
  #
395
439
  # The remaining methods are just conveniences, not part of the API
@@ -536,11 +580,27 @@ module VagrantLXD
536
580
  config
537
581
  end
538
582
 
583
+ # Determines whether the numerical `id` of the specified `type` is
584
+ # included in the given idmap. These values should follow the format
585
+ # of the "raw.idmap" property specified here:
586
+ #
587
+ # https://lxd.readthedocs.io/en/latest/userns-idmap/#custom-idmaps
588
+ #
589
+ def id_in_map?(id, type, map)
590
+ range_types = ['both', type]
591
+ map.each_line.any? do |line|
592
+ range_type, range_values = line.split
593
+ range = range_values.split('-')
594
+ begin
595
+ range_types.include?(range_type) and
596
+ id.between?(range.first.to_i, range.last.to_i)
597
+ end
598
+ end
599
+ end
600
+
539
601
  def locate_or_generate_client_certificate
540
602
  vagrant_path = @machine.env.data_dir / 'lxd'
541
- default_path = Certificate.default_path / 'lxc'
542
-
543
- search_paths = [vagrant_path, default_path]
603
+ search_paths = [vagrant_path] + Certificate.default_paths
544
604
 
545
605
  Certificate.locate(search_paths) or
546
606
  Certificate.generate(vagrant_path)
@@ -555,6 +615,7 @@ module VagrantLXD
555
615
  lxc_dir = @machine.box.directory
556
616
  lxc_rootfs = lxc_dir / 'rootfs.tar.gz'
557
617
  lxc_fingerprint = Digest::SHA256.file(lxc_rootfs).hexdigest
618
+ lxc_metadata = JSON.load(File.read(lxc_dir / 'metadata.json'))
558
619
 
559
620
  lxd_dir = @machine.box.directory / '..' / 'lxd'
560
621
  lxd_rootfs = lxd_dir / 'rootfs.tar.gz'
@@ -569,6 +630,10 @@ module VagrantLXD
569
630
  SafeChdir.safe_chdir(tmpdir) do
570
631
  FileUtils.cp(lxc_rootfs, tmpdir)
571
632
 
633
+ File.open('metadata.json', 'w') do |metadata|
634
+ metadata.puts JSON.pretty_generate(lxc_metadata.merge('provider' => 'lxd'))
635
+ end
636
+
572
637
  File.open('metadata.yaml', 'w') do |metadata|
573
638
  metadata.puts 'architecture: ' << `uname -m`.strip
574
639
  metadata.puts 'creation_date: ' << Time.now.strftime('%s')
@@ -582,6 +647,7 @@ module VagrantLXD
582
647
  FileUtils.mkdir_p(lxd_dir)
583
648
  FileUtils.mv('rootfs.tar.gz', lxd_dir)
584
649
  FileUtils.mv('metadata.yaml', lxd_dir)
650
+ FileUtils.mv('metadata.json', lxd_dir)
585
651
  end
586
652
  end
587
653
 
@@ -594,6 +660,42 @@ module VagrantLXD
594
660
  FileUtils.rm_rf(tmpdir)
595
661
  end
596
662
 
663
+ # TODO s.a.
664
+ def create_package_directory
665
+ package_directory = Dir.mktmpdir
666
+
667
+ image = begin
668
+ lxd.create_image_from_container(machine_id, IMAGE_PROPERTIES)
669
+ rescue Hyperkit::BadRequest => e
670
+ if e.reason =~ /The image already exists: (\h{64})/
671
+ {
672
+ metadata: { fingerprint: $1 }
673
+ }
674
+ else
675
+ fail ImageExportFailure, machine_name: @machine.name, reason: e.reason
676
+ end
677
+ end
678
+
679
+ lxd.export_image(image[:metadata][:fingerprint], package_directory, filename: 'rootfs.tar.gz')
680
+
681
+ File.open(File.join(package_directory, 'metadata.json'), 'w') do |metadata|
682
+ metadata.puts JSON.pretty_generate({
683
+ 'provider' => 'lxc',
684
+ 'version' => '1.0.0',
685
+ 'built-on' => Time.now.strftime("%a %m %d %H:%M:%S %z %Y"),
686
+ })
687
+ end
688
+ rescue Exception => e
689
+ @machine.ui.error 'Failed to export container image'
690
+ @logger.error 'Error preparing container image: ' << e.message << "\n" << e.backtrace.join("\n")
691
+ fail ImageExportFailure, machine_name: @machine.name, reason: e.message
692
+ else
693
+ package_directory
694
+ ensure
695
+ # If the image was created just for this package, remove it.
696
+ lxd.delete_image(image[:metadata][:fingerprint]) rescue nil if image.is_a? Sawyer::Resource
697
+ end
698
+
597
699
  def error(klass)
598
700
  klass.new(
599
701
  provider: Version::NAME,
@@ -33,8 +33,11 @@ module VagrantLXD
33
33
 
34
34
  @logger = Log4r::Logger.new('vagrant::lxd::driver::certificate')
35
35
 
36
- def Certificate.default_path
37
- Pathname.new('~/.config').expand_path
36
+ def Certificate.default_paths
37
+ [
38
+ Pathname.new('~/.config/lxc').expand_path,
39
+ Pathname.new('~/snap/lxd/current/.config/lxc').expand_path,
40
+ ]
38
41
  end
39
42
 
40
43
  def Certificate.issuer_name
@@ -20,7 +20,7 @@
20
20
  module VagrantLXD
21
21
  module Version
22
22
  NAME = 'vagrant-lxd'
23
- VERSION = '0.4.1'
23
+ VERSION = '0.5.0'
24
24
  DESCRIPTION = 'Vagrant LXD provider'
25
25
  end
26
26
  end
@@ -134,6 +134,13 @@ en:
134
134
 
135
135
  https://gitlab.com/catalyst-it/vagrant-lxd/issues
136
136
 
137
+ lxd_image_export_failure: |-
138
+ The provider was unable to export a container image for '%{machine_name}'.
139
+
140
+ The underlying error message was: %{reason}
141
+
142
+ The LXD logs may contain more information about the cause of this failure.
143
+
137
144
  lxd_duplicate_attachment_failure: |-
138
145
  A machine can only be associated with one container at a time.
139
146
 
@@ -35,5 +35,10 @@ Gem::Specification.new do |spec|
35
35
  f.match(%r{^(test|spec|features)/})
36
36
  end
37
37
 
38
+ spec.add_runtime_dependency 'activesupport', '~> 5.2.3'
38
39
  spec.add_runtime_dependency 'hyperkit', '~> 1.2.0'
40
+
41
+ # NOTE fixed to preserve ruby 1.x compatibility, versions after 1.0
42
+ # use the safe navigation operator and thus need ruby 2.3 or newer
43
+ spec.add_runtime_dependency 'faraday', '~> 0.17'
39
44
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-lxd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Hanson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-24 00:00:00.000000000 Z
11
+ date: 2020-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.3
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: hyperkit
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +38,20 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: 1.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.17'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.17'
27
55
  description: A Vagrant plugin that allows management of containers using LXD.
28
56
  email:
29
57
  - evanh@catalyst.net.nz
@@ -71,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
99
  - !ruby/object:Gem::Version
72
100
  version: '0'
73
101
  requirements: []
74
- rubyforge_project:
75
- rubygems_version: 2.6.12
102
+ rubygems_version: 3.0.3
76
103
  signing_key:
77
104
  specification_version: 4
78
105
  summary: Vagrant LXD provider