vagrant-lxd 0.1.0

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.
@@ -0,0 +1,52 @@
1
+ #
2
+ # Copyright (c) 2017 Catalyst.net Ltd
3
+ #
4
+ # This file is part of vagrant-lxd.
5
+ #
6
+ # vagrant-lxd is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at
9
+ # your option) any later version.
10
+ #
11
+ # vagrant-lxd is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with vagrant-lxd. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'vagrant-lxd/version'
21
+
22
+ module VagrantLXD
23
+ class Plugin < Vagrant.plugin('2')
24
+ name Version::NAME
25
+ description Version::DESCRIPTION
26
+
27
+ provider(:lxd, box_format: 'lxc', priority: 1) do
28
+ require_relative 'provider'
29
+ Provider
30
+ end
31
+
32
+ synced_folder(:lxd) do
33
+ require_relative 'synced_folder'
34
+ SyncedFolder
35
+ end
36
+
37
+ config(:lxd, :provider) do
38
+ require_relative 'config'
39
+ Config
40
+ end
41
+
42
+ command(:lxd) do
43
+ require_relative 'command'
44
+ Command
45
+ end
46
+
47
+ provider_capability(:lxd, 'snapshot_list') do
48
+ require_relative 'capability'
49
+ Capability
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,49 @@
1
+ #
2
+ # Copyright (c) 2017 Catalyst.net Ltd
3
+ #
4
+ # This file is part of vagrant-lxd.
5
+ #
6
+ # vagrant-lxd is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at
9
+ # your option) any later version.
10
+ #
11
+ # vagrant-lxd is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with vagrant-lxd. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'vagrant-lxd/action'
21
+
22
+ module VagrantLXD
23
+ class Provider < Vagrant.plugin('2', :provider)
24
+ def initialize(machine)
25
+ @machine = machine
26
+ end
27
+
28
+ def action(name)
29
+ Action.send(name) if Action.respond_to?(name)
30
+ end
31
+
32
+ def state
33
+ env = @machine.action('state', lock: false)
34
+ state = env[:machine_state]
35
+ short = state.to_s.gsub('_', ' ')
36
+ long = I18n.t("vagrant.commands.status.#{state}")
37
+ Vagrant::MachineState.new(state, short, long)
38
+ end
39
+
40
+ def ssh_info
41
+ env = @machine.action('info', lock: false)
42
+ env[:machine_info]
43
+ end
44
+
45
+ def to_s
46
+ 'LXD'
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,76 @@
1
+ #
2
+ # Copyright (c) 2017 Catalyst.net Ltd
3
+ #
4
+ # This file is part of vagrant-lxd.
5
+ #
6
+ # vagrant-lxd is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at
9
+ # your option) any later version.
10
+ #
11
+ # vagrant-lxd is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with vagrant-lxd. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ require 'vagrant-lxd/driver'
21
+
22
+ module VagrantLXD
23
+ class SyncedFolder < Vagrant.plugin('2', :synced_folder)
24
+
25
+ def usable?(machine, raise_error = false)
26
+ return false unless machine.provider_name == :lxd
27
+
28
+ @driver ||= Driver.new(machine)
29
+
30
+ if @driver.synced_folders_usable?
31
+ true
32
+ elsif not raise_error
33
+ false
34
+ else
35
+ fail Vagrant::Errors::SyncedFolderUnusable, type: 'lxd'
36
+ end
37
+ end
38
+
39
+ # TODO Figure out the proper way to mount folders before
40
+ # provisioning without using `#prepare` (which is deprecated).
41
+ def prepare(machine, folders, opts)
42
+ enable(machine, folders, opts)
43
+ end
44
+
45
+ def enable(machine, folders, opts)
46
+ usable?(machine, true)
47
+
48
+ # Skip any folders that are already attached.
49
+ # TODO This could be made less chatty by fetching the whole list
50
+ # of devices up front and comparing the incoming folders to that.
51
+ folders = folders.reject do |name, folder|
52
+ @driver.mounted?(name, folder)
53
+ end
54
+
55
+ if folders.any?
56
+ machine.ui.info 'Mounting shared folders...'
57
+ folders.reject { |_, f| f[:disabled] }.each do |name, folder|
58
+ machine.ui.detail "#{folder[:guestpath]} => #{folder[:hostpath]}"
59
+ @driver.mount(name, folder)
60
+ end
61
+ end
62
+ end
63
+
64
+ def disable(machine, folders, opts)
65
+ usable?(machine, true)
66
+
67
+ if folders.any?
68
+ machine.ui.info 'Unmounting shared folders...'
69
+ folders.reject { |_, f| f[:disabled] }.each do |name, folder|
70
+ machine.ui.detail "#{folder[:guestpath]} => #{folder[:hostpath]}"
71
+ @driver.unmount(name, folder)
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,26 @@
1
+ #
2
+ # Copyright (c) 2017 Catalyst.net Ltd
3
+ #
4
+ # This file is part of vagrant-lxd.
5
+ #
6
+ # vagrant-lxd is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at
9
+ # your option) any later version.
10
+ #
11
+ # vagrant-lxd is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with vagrant-lxd. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ module VagrantLXD
21
+ module Version
22
+ NAME = 'vagrant-lxd'
23
+ VERSION = '0.1.0'
24
+ DESCRIPTION = 'Vagrant LXD provider'
25
+ end
26
+ end
@@ -0,0 +1,110 @@
1
+ ---
2
+ en:
3
+ vagrant:
4
+ commands:
5
+ status:
6
+ frozen: |-
7
+ The VM is frozen. To start it, you can run `vagrant up`, or you can
8
+ instead run `vagrant destroy` to delete it and discard all saved state.
9
+ stopped: |-
10
+ The VM is stopped. To start it, you can run `vagrant up`, or you can
11
+ instead run `vagrant destroy` to delete it and discard all saved state.
12
+ actions:
13
+ vm:
14
+ snapshot:
15
+ restored: |-
16
+ The machine has been restored to snapshot '%{name}'!
17
+ errors:
18
+ lxd_connection_failure: |-
19
+ The provider was unable to contact the LXD daemon at %{api_endpoint}.
20
+
21
+ It's possible that LXD isn't installed, or that it isn't configured to
22
+ accept HTTPS connections from your machine. You can check whether HTTPS
23
+ access is enabled with the following command:
24
+
25
+ $ lxc config show core.https_address
26
+
27
+ If the result is empty or an error is shown, you will need to correct
28
+ the way LXD is configured before Vagrant can use it. This can be done
29
+ with the following command:
30
+
31
+ $ lxc config set core.https_address %{https_address}
32
+
33
+ You can find more documentation about configuring LXD at:
34
+
35
+ https://linuxcontainers.org/lxd/getting-started-cli/#initial-configuration
36
+
37
+ lxd_authentication_failure: |-
38
+ The provider could not authenticate to the LXD daemon at %{api_endpoint}.
39
+
40
+ You may need configure LXD to allow requests from this machine. The
41
+ easiest way to do this is to add your LXC client certificate to LXD's
42
+ list of trusted certificates. This can typically be done with the
43
+ following command:
44
+
45
+ $ lxc config trust add %{client_cert}
46
+
47
+ You can find more information about configuring LXD at:
48
+
49
+ https://linuxcontainers.org/lxd/getting-started-cli/#initial-configuration
50
+
51
+ lxd_operation_timeout: |-
52
+ The container failed to respond within %{time_limit} seconds. Try
53
+ running the following command to see whether an error occurs:
54
+
55
+ $ lxc %{operation} %{machine_id}
56
+
57
+ If that command runs successfully, there may be a bug in the LXD
58
+ provider. If this is the case, please submit an issue at:
59
+
60
+ https://gitlab.com/catalyst-it/vagrant-lxd/issues
61
+
62
+ lxd_network_address_acquisition_timeout: |-
63
+ The container failed to acquire an IPv4 address within %{time_limit}
64
+ seconds. It's possible that the LXD network bridge has not been configured.
65
+ Try running the following command to see whether a bridge exists and has
66
+ an inet address:
67
+
68
+ $ ip address show %{lxd_bridge}
69
+
70
+ If that command runs successfully and the bridge appears to be correctly
71
+ configured, there may be a bug in the LXD provider. If this is the case,
72
+ please submit an issue at:
73
+
74
+ https://gitlab.com/catalyst-it/vagrant-lxd/issues
75
+
76
+ lxd_container_creation_failure: |-
77
+ The provider was unable to create a container for the '%{machine_name}' VM.
78
+
79
+ %{reason}.
80
+
81
+ The LXD logs may contain more information about the cause of this failure.
82
+
83
+ lxd_image_creation_failure: |-
84
+ The provider was unable to create an LXD image for the '%{machine_name}' VM.
85
+
86
+ The underlying error message was:
87
+
88
+ %{error_message}
89
+
90
+ This may be a bug in the LXD provider. If you think this is the case,
91
+ please submit an issue at:
92
+
93
+ https://gitlab.com/catalyst-it/vagrant-lxd/issues
94
+
95
+ lxd_duplicate_attachment_failure: |-
96
+ A machine can only be associated with one container at a time.
97
+
98
+ To attach '%{machine_name}' to '%{container}', you must first
99
+ detach it from its current container using `vagrant lxd detach`.
100
+
101
+ lxd_container_not_found: |-
102
+ The requested container '%{container}' doesn't exist.
103
+
104
+ You can list available containers with the `lxc list` command.
105
+ lxd_container_already_exists: |-
106
+ A container with the name '%{container}' already exists.
107
+
108
+ You will either need to delete this container and try again, or attach
109
+ the VM to it with `vagrant lxd attach %{machine_name} %{container}`.
110
+
@@ -0,0 +1,39 @@
1
+ #
2
+ # Copyright (c) 2017 Catalyst.net Ltd
3
+ #
4
+ # This file is part of vagrant-lxd.
5
+ #
6
+ # vagrant-lxd is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or (at
9
+ # your option) any later version.
10
+ #
11
+ # vagrant-lxd is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with vagrant-lxd. If not, see <http://www.gnu.org/licenses/>.
18
+ #
19
+
20
+ $: << File.expand_path('../lib', __FILE__)
21
+
22
+ require 'vagrant-lxd/version'
23
+
24
+ Gem::Specification.new do |spec|
25
+ spec.name = VagrantLXD::Version::NAME
26
+ spec.version = VagrantLXD::Version::VERSION
27
+ spec.summary = VagrantLXD::Version::DESCRIPTION
28
+ spec.description = 'A Vagrant plugin that allows management of containers using LXD.'
29
+ spec.authors = ['Evan Hanson']
30
+ spec.email = ['evanh@catalyst.net.nz']
31
+ spec.license = 'GPLv3'
32
+ spec.homepage = 'https://gitlab.com/catalyst-it/vagrant-lxd'
33
+ spec.require_paths = ['lib']
34
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
35
+ f.match(%r{^(test|spec|features)/})
36
+ end
37
+
38
+ spec.add_runtime_dependency 'hyperkit', '~> 1.1.0'
39
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-lxd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Evan Hanson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hyperkit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.0
27
+ description: A Vagrant plugin that allows management of containers using LXD.
28
+ email:
29
+ - evanh@catalyst.net.nz
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - LICENSE.md
38
+ - README.md
39
+ - Rakefile
40
+ - lib/vagrant-lxd.rb
41
+ - lib/vagrant-lxd/action.rb
42
+ - lib/vagrant-lxd/capability.rb
43
+ - lib/vagrant-lxd/command.rb
44
+ - lib/vagrant-lxd/config.rb
45
+ - lib/vagrant-lxd/driver.rb
46
+ - lib/vagrant-lxd/plugin.rb
47
+ - lib/vagrant-lxd/provider.rb
48
+ - lib/vagrant-lxd/synced_folder.rb
49
+ - lib/vagrant-lxd/version.rb
50
+ - templates/locales/en.yml
51
+ - vagrant-lxd.gemspec
52
+ homepage: https://gitlab.com/catalyst-it/vagrant-lxd
53
+ licenses:
54
+ - GPLv3
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.6.12
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Vagrant LXD provider
76
+ test_files: []