vagrant-lxd 0.5.6 → 0.6.0.pre
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 +4 -4
- data/Gemfile.lock +8 -8
- data/README.md +38 -4
- data/lib/vagrant-lxd/config.rb +11 -1
- data/lib/vagrant-lxd/driver.rb +28 -1
- data/lib/vagrant-lxd/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c196e74a9041fa5c9b44c3cd7778f72132bf91a29d346b3e0fbbfe274cff72d
|
4
|
+
data.tar.gz: 06ea3d638d67f537708380a0e25913651525520d8c5a293d95152b78caf0c97f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: debc110656b0c942d485e80b0221c5a8938bc3743ff9fde2bbd7108dcd57e3dbe7203947b8590a2e2c36ffe40e69c9eecc3c4ab4dcffe7f244802f5ebec9cc32
|
7
|
+
data.tar.gz: 83334cdbb74697c2875f59c023681bdbb1c1c1f4820a74e856ce6045bbb36c96ea28789a1f8fc9776e5fe8627a665702bd193e38049a5257f7d469838498eeb4
|
data/Gemfile.lock
CHANGED
@@ -27,7 +27,7 @@ GIT
|
|
27
27
|
PATH
|
28
28
|
remote: .
|
29
29
|
specs:
|
30
|
-
vagrant-lxd (0.
|
30
|
+
vagrant-lxd (0.6.0.pre)
|
31
31
|
activesupport (~> 5.2.3)
|
32
32
|
faraday (~> 0.17)
|
33
33
|
hyperkit (~> 1.3.0)
|
@@ -35,7 +35,7 @@ PATH
|
|
35
35
|
GEM
|
36
36
|
remote: https://rubygems.org/
|
37
37
|
specs:
|
38
|
-
activesupport (5.2.
|
38
|
+
activesupport (5.2.8)
|
39
39
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
40
40
|
i18n (>= 0.7, < 2)
|
41
41
|
minitest (~> 5.1)
|
@@ -51,7 +51,7 @@ GEM
|
|
51
51
|
erubi (1.10.0)
|
52
52
|
excon (0.87.0)
|
53
53
|
fakefs (1.4.0)
|
54
|
-
faraday (0.17.
|
54
|
+
faraday (0.17.5)
|
55
55
|
multipart-post (>= 1.2, < 3)
|
56
56
|
ffi (1.15.4)
|
57
57
|
gssapi (1.3.1)
|
@@ -76,16 +76,16 @@ GEM
|
|
76
76
|
mime-types (3.3.1)
|
77
77
|
mime-types-data (~> 3.2015)
|
78
78
|
mime-types-data (3.2021.0901)
|
79
|
-
minitest (5.
|
79
|
+
minitest (5.15.0)
|
80
80
|
multi_json (1.15.0)
|
81
|
-
multipart-post (2.
|
81
|
+
multipart-post (2.2.3)
|
82
82
|
net-scp (1.2.1)
|
83
83
|
net-ssh (>= 2.6.5)
|
84
84
|
net-sftp (3.0.0)
|
85
85
|
net-ssh (>= 5.0.0, < 7.0.0)
|
86
86
|
net-ssh (6.1.0)
|
87
87
|
nori (2.6.0)
|
88
|
-
public_suffix (4.0.
|
88
|
+
public_suffix (4.0.7)
|
89
89
|
rake (13.0.6)
|
90
90
|
rb-fsevent (0.11.0)
|
91
91
|
rb-inotify (0.10.1)
|
@@ -111,9 +111,9 @@ GEM
|
|
111
111
|
rspec-support (3.10.2)
|
112
112
|
rubyntlm (0.6.3)
|
113
113
|
rubyzip (2.3.2)
|
114
|
-
sawyer (0.
|
114
|
+
sawyer (0.9.2)
|
115
115
|
addressable (>= 2.3.5)
|
116
|
-
faraday (
|
116
|
+
faraday (>= 0.17.3, < 3)
|
117
117
|
thread_safe (0.3.6)
|
118
118
|
tzinfo (1.2.9)
|
119
119
|
thread_safe (~> 0.1)
|
data/README.md
CHANGED
@@ -85,6 +85,7 @@ Vagrant.configure('2') do |config|
|
|
85
85
|
lxd.privileged = nil
|
86
86
|
lxd.ephemeral = false
|
87
87
|
lxd.profiles = ['default']
|
88
|
+
lxd.project = 'default'
|
88
89
|
lxd.environment = {}
|
89
90
|
lxd.config = {}
|
90
91
|
end
|
@@ -148,7 +149,7 @@ is passed through to LXD. The hash values should all be strings:
|
|
148
149
|
recursive: 'false',
|
149
150
|
}
|
150
151
|
|
151
|
-
[disk]: https://
|
152
|
+
[disk]: https://linuxcontainers.org/lxd/docs/master/instances/#type-disk
|
152
153
|
|
153
154
|
### Shared LXD Containers
|
154
155
|
|
@@ -203,7 +204,7 @@ Note that enabling these options will invalidate any user and group ID
|
|
203
204
|
mappings you may have configured for synced folders, since privileged
|
204
205
|
containers use the same UID and GID space as the host machine.
|
205
206
|
|
206
|
-
[containers]: https://
|
207
|
+
[containers]: https://linuxcontainers.org/lxd/docs/master/instances/
|
207
208
|
|
208
209
|
### Adding Devices
|
209
210
|
|
@@ -234,7 +235,7 @@ to run graphical applications transparently from within the guest:
|
|
234
235
|
Note that disk devices should be configured as [synced
|
235
236
|
folders](#synced-folders) rather than ad-hoc devices.
|
236
237
|
|
237
|
-
[device-config]: https://
|
238
|
+
[device-config]: https://linuxcontainers.org/lxd/docs/master/instances/#devices-configuration
|
238
239
|
|
239
240
|
### Container Configuration
|
240
241
|
|
@@ -252,7 +253,40 @@ Not all instance settings make sense in the Vagrant context, and some will or
|
|
252
253
|
won't work based on your LXD host's configuration, so making sure the config is
|
253
254
|
valid is up to you.
|
254
255
|
|
255
|
-
[instance-config]: https://
|
256
|
+
[instance-config]: https://linuxcontainers.org/lxd/docs/master/instances/#key-value-configuration
|
257
|
+
|
258
|
+
### LXD Projects
|
259
|
+
|
260
|
+
Since version 3.8, LXD has supported [projects] as a way to segment an LXD
|
261
|
+
server. Each project has its own set of containers, profiles, images, and so
|
262
|
+
on.
|
263
|
+
|
264
|
+
This plugin allows the project for a container to be set on a per-machine
|
265
|
+
basis. If `project` is unset, the container will be created in the "default"
|
266
|
+
project. Different machines in the same Vagrantfile can use different projects:
|
267
|
+
|
268
|
+
config.vm.define 'default' do |box|
|
269
|
+
box.vm.provider 'lxd' do |lxd|
|
270
|
+
lxd.project = 'default'
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
config.vm.define 'custom-project-machine' do |box|
|
275
|
+
box.vm.provider 'lxd' do |lxd|
|
276
|
+
lxd.project = 'example'
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
Configuring LXD projects is out of scope for this README, but note that each
|
281
|
+
project must include a network device and root disk for this plugin to work
|
282
|
+
correctly. The following commands should get you started with a new project:
|
283
|
+
|
284
|
+
lxc project create example
|
285
|
+
lxc project switch example
|
286
|
+
lxc profile device add default eth0 nic name=eth0 parent=lxdbr0 nictype=bridged
|
287
|
+
lxc profile device add default root disk path=/ pool=default
|
288
|
+
|
289
|
+
[projects]: https://linuxcontainers.org/lxd/docs/master/projects/
|
256
290
|
|
257
291
|
## Hacking
|
258
292
|
|
data/lib/vagrant-lxd/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2017-
|
2
|
+
# Copyright (c) 2017-2022 Catalyst.net Ltd
|
3
3
|
#
|
4
4
|
# This file is part of vagrant-lxd.
|
5
5
|
#
|
@@ -32,6 +32,7 @@ module VagrantLXD
|
|
32
32
|
attr_accessor :nesting
|
33
33
|
attr_accessor :privileged
|
34
34
|
attr_accessor :profiles
|
35
|
+
attr_accessor :project
|
35
36
|
attr_accessor :vagrant_uid
|
36
37
|
attr_accessor :vagrant_gid
|
37
38
|
attr_accessor :client_certificate
|
@@ -47,6 +48,7 @@ module VagrantLXD
|
|
47
48
|
@privileged = UNSET_VALUE
|
48
49
|
@ephemeral = UNSET_VALUE
|
49
50
|
@profiles = UNSET_VALUE
|
51
|
+
@project = UNSET_VALUE
|
50
52
|
@api_endpoint = UNSET_VALUE
|
51
53
|
@vagrant_uid = UNSET_VALUE
|
52
54
|
@vagrant_gid = UNSET_VALUE
|
@@ -121,6 +123,10 @@ module VagrantLXD
|
|
121
123
|
errors << "Invalid `profiles' (value must be an array of strings): #{profiles.inspect}"
|
122
124
|
end
|
123
125
|
|
126
|
+
unless project.is_a? String
|
127
|
+
errors << "Invalid `project' (value must be a string): #{project.inspect}"
|
128
|
+
end
|
129
|
+
|
124
130
|
unless vagrant_uid.is_a? Integer and vagrant_uid >= 0
|
125
131
|
errors << "Invalid `vagrant_uid' (value must be a non-negative integer): #{vagrant_uid.inspect}"
|
126
132
|
end
|
@@ -189,6 +195,10 @@ module VagrantLXD
|
|
189
195
|
@profiles = ['default']
|
190
196
|
end
|
191
197
|
|
198
|
+
if project == UNSET_VALUE
|
199
|
+
@project = 'default'
|
200
|
+
end
|
201
|
+
|
192
202
|
if timeout == UNSET_VALUE
|
193
203
|
@timeout = 10
|
194
204
|
end
|
data/lib/vagrant-lxd/driver.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c) 2017-
|
2
|
+
# Copyright (c) 2017-2022 Catalyst.net Ltd
|
3
3
|
#
|
4
4
|
# This file is part of vagrant-lxd.
|
5
5
|
#
|
@@ -103,6 +103,23 @@ module VagrantLXD
|
|
103
103
|
error_key 'snapshot_not_found'
|
104
104
|
end
|
105
105
|
|
106
|
+
# Custom middleware that adds a `project` query parameter to all
|
107
|
+
# outgoing requests, in order to select the active LXD project.
|
108
|
+
class ProjectMiddleware < Faraday::Middleware
|
109
|
+
def call(env)
|
110
|
+
url = URI(env.url.to_s)
|
111
|
+
url.query = "#{url.query}&project=#{project}"
|
112
|
+
url.query.delete_prefix!('&')
|
113
|
+
@app.call(env.merge(url: url))
|
114
|
+
end
|
115
|
+
|
116
|
+
def ProjectMiddleware.create(project)
|
117
|
+
Class.new(self) do
|
118
|
+
define_method(:project) { project }
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
106
123
|
class Hyperkit::BadRequest
|
107
124
|
def reason
|
108
125
|
return unless data.is_a? Hash
|
@@ -130,6 +147,7 @@ module VagrantLXD
|
|
130
147
|
attr_reader :nesting
|
131
148
|
attr_reader :privileged
|
132
149
|
attr_reader :profiles
|
150
|
+
attr_reader :project
|
133
151
|
attr_reader :client_certificate
|
134
152
|
attr_reader :client_key
|
135
153
|
attr_reader :vagrant_uid
|
@@ -146,6 +164,7 @@ module VagrantLXD
|
|
146
164
|
@privileged = machine.provider_config.privileged
|
147
165
|
@ephemeral = machine.provider_config.ephemeral
|
148
166
|
@profiles = machine.provider_config.profiles
|
167
|
+
@project = machine.provider_config.project
|
149
168
|
@name = machine.provider_config.name
|
150
169
|
@client_certificate = machine.provider_config.client_certificate
|
151
170
|
@client_key = machine.provider_config.client_key
|
@@ -406,11 +425,19 @@ module VagrantLXD
|
|
406
425
|
api_endpoint: api_endpoint.to_s,
|
407
426
|
client_cert: cert.certificate,
|
408
427
|
client_key: cert.key,
|
428
|
+
middleware: middleware,
|
409
429
|
verify_ssl: false,
|
410
430
|
user_agent: USER_AGENT,
|
411
431
|
)
|
412
432
|
end
|
413
433
|
|
434
|
+
def middleware
|
435
|
+
project_middleware = ProjectMiddleware.create(project)
|
436
|
+
Hyperkit::Default.middleware.dup.tap do |builder|
|
437
|
+
builder.insert_after(Hyperkit::Middleware::FollowRedirects, project_middleware)
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
414
441
|
def machine_id
|
415
442
|
@machine.id
|
416
443
|
end
|
data/lib/vagrant-lxd/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-lxd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evan Hanson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -95,9 +95,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- - "
|
98
|
+
- - ">"
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
100
|
+
version: 1.3.1
|
101
101
|
requirements: []
|
102
102
|
rubygems_version: 3.0.3
|
103
103
|
signing_key:
|