vagrant-lxd 0.3.2 → 0.3.3
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/.gitlab-ci.yml +1 -1
 - data/Gemfile.lock +3 -3
 - data/README.md +14 -1
 - data/lib/vagrant-lxd/action.rb +2 -2
 - data/lib/vagrant-lxd/driver.rb +15 -1
 - data/lib/vagrant-lxd/synced_folder.rb +39 -1
 - data/lib/vagrant-lxd/version.rb +1 -1
 - data/templates/locales/en.yml +14 -0
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 304c1f8ee64a31435d51d95726660fd666f3febd
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 46cc574e2ad04aa6604e929c8046e10accabc81c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e6a49fa60209a54a54ce4de1714281bfc760ad75a80898a34d300e935b35fca7d51397f473229ffc2f037403601a7ccf8dfb583fe88aa8c6d9e32e0bbbd46b4b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: ef6b64e67ecbbe673819096205b28bcba675c9162137efd550803810b8d54228fc1ccd49616cdabab705ee89092a2d0b26e91f343a0f3fc875471afe2ee71245
         
     | 
    
        data/.gitlab-ci.yml
    CHANGED
    
    
    
        data/Gemfile.lock
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            GIT
         
     | 
| 
       2 
2 
     | 
    
         
             
              remote: https://github.com/mitchellh/vagrant.git
         
     | 
| 
       3 
     | 
    
         
            -
              revision:  
     | 
| 
      
 3 
     | 
    
         
            +
              revision: c6b42a04cd1ca9f0936714ee6a44b4c7c001fdeb
         
     | 
| 
       4 
4 
     | 
    
         
             
              specs:
         
     | 
| 
       5 
5 
     | 
    
         
             
                vagrant (2.2.4.dev)
         
     | 
| 
       6 
6 
     | 
    
         
             
                  bcrypt_pbkdf (~> 1.0.0)
         
     | 
| 
         @@ -27,7 +27,7 @@ GIT 
     | 
|
| 
       27 
27 
     | 
    
         
             
            PATH
         
     | 
| 
       28 
28 
     | 
    
         
             
              remote: .
         
     | 
| 
       29 
29 
     | 
    
         
             
              specs:
         
     | 
| 
       30 
     | 
    
         
            -
                vagrant-lxd (0.3. 
     | 
| 
      
 30 
     | 
    
         
            +
                vagrant-lxd (0.3.3)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  hyperkit (~> 1.2.0)
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
            GEM
         
     | 
| 
         @@ -50,7 +50,7 @@ GEM 
     | 
|
| 
       50 
50 
     | 
    
         
             
                  unf (>= 0.0.5, < 1.0.0)
         
     | 
| 
       51 
51 
     | 
    
         
             
                ed25519 (1.2.4)
         
     | 
| 
       52 
52 
     | 
    
         
             
                erubis (2.7.0)
         
     | 
| 
       53 
     | 
    
         
            -
                fakefs (0. 
     | 
| 
      
 53 
     | 
    
         
            +
                fakefs (0.19.1)
         
     | 
| 
       54 
54 
     | 
    
         
             
                faraday (0.15.4)
         
     | 
| 
       55 
55 
     | 
    
         
             
                  multipart-post (>= 1.2, < 3)
         
     | 
| 
       56 
56 
     | 
    
         
             
                ffi (1.10.0)
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -90,7 +90,7 @@ Vagrant.configure('2') do |config| 
     | 
|
| 
       90 
90 
     | 
    
         
             
            end
         
     | 
| 
       91 
91 
     | 
    
         
             
            ```
         
     | 
| 
       92 
92 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
            ###  
     | 
| 
      
 93 
     | 
    
         
            +
            ### Synced Folders
         
     | 
| 
       94 
94 
     | 
    
         | 
| 
       95 
95 
     | 
    
         
             
            In order to use shared folders, you must first add your user ID to the
         
     | 
| 
       96 
96 
     | 
    
         
             
            host machine's subuid(5) and subgid(5) files:
         
     | 
| 
         @@ -115,6 +115,19 @@ the default with the `vagrant_uid` and `vagrant_gid` settings. 
     | 
|
| 
       115 
115 
     | 
    
         
             
                  lxd.vagrand_gid = 1000 # defaults to vagrant_uid
         
     | 
| 
       116 
116 
     | 
    
         
             
                end
         
     | 
| 
       117 
117 
     | 
    
         | 
| 
      
 118 
     | 
    
         
            +
            #### Disk Device Configuration
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            Synced folders are mounted as [disk devices][disk] within the guest. You
         
     | 
| 
      
 121 
     | 
    
         
            +
            can configure them by adding settings to folder's `config` hash, which
         
     | 
| 
      
 122 
     | 
    
         
            +
            is passed through to LXD. The hash values should all be strings:
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
                config.vm.synced_folder '/foo', '/bar', config: {
         
     | 
| 
      
 125 
     | 
    
         
            +
                  readonly: 'true',
         
     | 
| 
      
 126 
     | 
    
         
            +
                  recursive: 'false',
         
     | 
| 
      
 127 
     | 
    
         
            +
                }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            [disk]: https://lxd.readthedocs.io/en/latest/containers/#type-disk
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
       118 
131 
     | 
    
         
             
            ### Shared LXD Containers
         
     | 
| 
       119 
132 
     | 
    
         | 
| 
       120 
133 
     | 
    
         
             
            It's possible to share a single LXD container between multiple Vagrant
         
     | 
    
        data/lib/vagrant-lxd/action.rb
    CHANGED
    
    | 
         @@ -140,9 +140,9 @@ module VagrantLXD 
     | 
|
| 
       140 
140 
     | 
    
         
             
                          c.use CheckForSyncedFolderSupport
         
     | 
| 
       141 
141 
     | 
    
         
             
                          c.use LXD.action(:create)
         
     | 
| 
       142 
142 
     | 
    
         
             
                          c.use Provision
         
     | 
| 
       143 
     | 
    
         
            -
                          c.use LXD.action(:resume)
         
     | 
| 
       144 
143 
     | 
    
         
             
                          c.use SetHostname
         
     | 
| 
       145 
144 
     | 
    
         
             
                          c.use SyncedFolders
         
     | 
| 
      
 145 
     | 
    
         
            +
                          c.use LXD.action(:resume)
         
     | 
| 
       146 
146 
     | 
    
         
             
                          c.use WaitForCommunicator
         
     | 
| 
       147 
147 
     | 
    
         
             
                        when :running
         
     | 
| 
       148 
148 
     | 
    
         
             
                          c.use Message, :info, 'Machine is already running.'
         
     | 
| 
         @@ -224,9 +224,9 @@ module VagrantLXD 
     | 
|
| 
       224 
224 
     | 
    
         
             
                          c.use CheckForSyncedFolderSupport
         
     | 
| 
       225 
225 
     | 
    
         
             
                          c.use LXD.action(:configure)
         
     | 
| 
       226 
226 
     | 
    
         
             
                          c.use Provision
         
     | 
| 
       227 
     | 
    
         
            -
                          c.use LXD.action(:resume)
         
     | 
| 
       228 
227 
     | 
    
         
             
                          c.use SetHostname
         
     | 
| 
       229 
228 
     | 
    
         
             
                          c.use SyncedFolders
         
     | 
| 
      
 229 
     | 
    
         
            +
                          c.use LXD.action(:resume)
         
     | 
| 
       230 
230 
     | 
    
         
             
                          c.use WaitForCommunicator
         
     | 
| 
       231 
231 
     | 
    
         
             
                        else
         
     | 
| 
       232 
232 
     | 
    
         
             
                          c.use Message, :error, "Machine cannot be resumed while #{env[:machine_state]}."
         
     | 
    
        data/lib/vagrant-lxd/driver.rb
    CHANGED
    
    | 
         @@ -80,6 +80,14 @@ module VagrantLXD 
     | 
|
| 
       80 
80 
     | 
    
         
             
                  error_key 'lxd_duplicate_attachment_failure'
         
     | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         | 
| 
      
 83 
     | 
    
         
            +
                class DiskMountFailure < Vagrant::Errors::VagrantError
         
     | 
| 
      
 84 
     | 
    
         
            +
                  error_key 'lxd_disk_mount_failure'
         
     | 
| 
      
 85 
     | 
    
         
            +
                end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                class DiskUnmountFailure < Vagrant::Errors::VagrantError
         
     | 
| 
      
 88 
     | 
    
         
            +
                  error_key 'lxd_disk_unmount_failure'
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
       83 
91 
     | 
    
         
             
                class SnapshotNotFound < Vagrant::Errors::VagrantError
         
     | 
| 
       84 
92 
     | 
    
         
             
                  error_key 'snapshot_not_found'
         
     | 
| 
       85 
93 
     | 
    
         
             
                end
         
     | 
| 
         @@ -150,9 +158,12 @@ module VagrantLXD 
     | 
|
| 
       150 
158 
     | 
    
         
             
                def mount(name, options)
         
     | 
| 
       151 
159 
     | 
    
         
             
                  container = @lxd.container(machine_id)
         
     | 
| 
       152 
160 
     | 
    
         
             
                  devices = container[:devices].to_hash
         
     | 
| 
       153 
     | 
    
         
            -
                  devices[name] = { type: 'disk', path: options[:guestpath], source: options[:hostpath] }
         
     | 
| 
      
 161 
     | 
    
         
            +
                  devices[name] = { type: 'disk', path: options[:guestpath], source: options[:hostpath] }.merge(options[:config])
         
     | 
| 
       154 
162 
     | 
    
         
             
                  container[:devices] = devices
         
     | 
| 
       155 
163 
     | 
    
         
             
                  @lxd.update_container(machine_id, container)
         
     | 
| 
      
 164 
     | 
    
         
            +
                rescue Hyperkit::BadRequest => e
         
     | 
| 
      
 165 
     | 
    
         
            +
                  @machine.ui.error 'Failed to mount synced folder'
         
     | 
| 
      
 166 
     | 
    
         
            +
                  fail DiskMountFailure, machine_name: @machine.name, guestpath: options[:guestpath], reason: e.reason
         
     | 
| 
       156 
167 
     | 
    
         
             
                end
         
     | 
| 
       157 
168 
     | 
    
         | 
| 
       158 
169 
     | 
    
         
             
                def mounted?(name, options)
         
     | 
| 
         @@ -173,6 +184,9 @@ module VagrantLXD 
     | 
|
| 
       173 
184 
     | 
    
         
             
                  devices.delete(name.to_sym)
         
     | 
| 
       174 
185 
     | 
    
         
             
                  container[:devices] = devices
         
     | 
| 
       175 
186 
     | 
    
         
             
                  @lxd.update_container(machine_id, container)
         
     | 
| 
      
 187 
     | 
    
         
            +
                rescue Hyperkit::BadRequest => e
         
     | 
| 
      
 188 
     | 
    
         
            +
                  @machine.ui.error 'Failed to unmount synced folder'
         
     | 
| 
      
 189 
     | 
    
         
            +
                  fail DiskUnmountFailure, machine_name: @machine.name, guestpath: options[:guestpath], reason: e.reason
         
     | 
| 
       176 
190 
     | 
    
         
             
                end
         
     | 
| 
       177 
191 
     | 
    
         | 
| 
       178 
192 
     | 
    
         
             
                def attach(container)
         
     | 
| 
         @@ -38,6 +38,8 @@ module VagrantLXD 
     | 
|
| 
       38 
38 
     | 
    
         | 
| 
       39 
39 
     | 
    
         
             
                # TODO Figure out the proper way to mount folders before
         
     | 
| 
       40 
40 
     | 
    
         
             
                # provisioning without using `#prepare` (which is deprecated).
         
     | 
| 
      
 41 
     | 
    
         
            +
                # TODO Umount existing devices if they go missing from the
         
     | 
| 
      
 42 
     | 
    
         
            +
                # Vagrantfile (either via deletion or setting disabled: true).
         
     | 
| 
       41 
43 
     | 
    
         
             
                def prepare(machine, folders, opts)
         
     | 
| 
       42 
44 
     | 
    
         
             
                  enable(machine, folders, opts)
         
     | 
| 
       43 
45 
     | 
    
         
             
                end
         
     | 
| 
         @@ -52,10 +54,22 @@ module VagrantLXD 
     | 
|
| 
       52 
54 
     | 
    
         
             
                    @driver.mounted?(name, folder)
         
     | 
| 
       53 
55 
     | 
    
         
             
                  end
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
      
 57 
     | 
    
         
            +
                  # Sanity check folder configs and bail if something's wrong.
         
     | 
| 
      
 58 
     | 
    
         
            +
                  folders.each do |name, folder|
         
     | 
| 
      
 59 
     | 
    
         
            +
                    validate_folder(folder)
         
     | 
| 
      
 60 
     | 
    
         
            +
                  end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                  # Ensure all folders have a config hash.
         
     | 
| 
      
 63 
     | 
    
         
            +
                  folders.each do |name, folder|
         
     | 
| 
      
 64 
     | 
    
         
            +
                    folder[:config] ||= {}
         
     | 
| 
      
 65 
     | 
    
         
            +
                    folder[:config] = Hash[folder[:config].map { |k, v| [k.to_sym, v.to_s] }]
         
     | 
| 
      
 66 
     | 
    
         
            +
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
       55 
68 
     | 
    
         
             
                  if folders.any?
         
     | 
| 
       56 
69 
     | 
    
         
             
                    machine.ui.info 'Mounting shared folders...'
         
     | 
| 
       57 
70 
     | 
    
         
             
                    folders.reject { |_, f| f[:disabled] }.each do |name, folder|
         
     | 
| 
       58 
     | 
    
         
            -
                       
     | 
| 
      
 71 
     | 
    
         
            +
                      details = config_summary(folder[:config])
         
     | 
| 
      
 72 
     | 
    
         
            +
                      machine.ui.detail "#{folder[:guestpath]} => #{folder[:hostpath]} #{details}".strip
         
     | 
| 
       59 
73 
     | 
    
         
             
                      @driver.mount(name, folder)
         
     | 
| 
       60 
74 
     | 
    
         
             
                    end
         
     | 
| 
       61 
75 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -72,5 +86,29 @@ module VagrantLXD 
     | 
|
| 
       72 
86 
     | 
    
         
             
                    end
         
     | 
| 
       73 
87 
     | 
    
         
             
                  end
         
     | 
| 
       74 
88 
     | 
    
         
             
                end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              protected
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                def validate_folder(folder)
         
     | 
| 
      
 93 
     | 
    
         
            +
                  config = folder.fetch(:config) { Hash.new }
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                  unless config.is_a? Hash
         
     | 
| 
      
 96 
     | 
    
         
            +
                    fail Vagrant::Errors::ConfigInvalid, errors: "Invalid synced_folder `config' (value must be a hash)"
         
     | 
| 
      
 97 
     | 
    
         
            +
                  end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                  unless config.keys.all? { |x| x.is_a? String or x.is_a? Symbol }
         
     | 
| 
      
 100 
     | 
    
         
            +
                    fail Vagrant::Errors::ConfigInvalid, errors: "Invalid synced_folder `config' (hash keys must be strings)"
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                  unless config.values.all? { |x| x.is_a? String or x == true or x == false }
         
     | 
| 
      
 104 
     | 
    
         
            +
                    fail Vagrant::Errors::ConfigInvalid, errors: "Invalid synced_folder `config' (hash values must be strings)"
         
     | 
| 
      
 105 
     | 
    
         
            +
                  end
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                def config_summary(config)
         
     | 
| 
      
 109 
     | 
    
         
            +
                  if config.is_a? Hash and config.any?
         
     | 
| 
      
 110 
     | 
    
         
            +
                    "(#{config.map { |k, v| "#{k}=#{v.inspect}" }.join(', ')})"
         
     | 
| 
      
 111 
     | 
    
         
            +
                  end
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
       75 
113 
     | 
    
         
             
              end
         
     | 
| 
       76 
114 
     | 
    
         
             
            end
         
     | 
    
        data/lib/vagrant-lxd/version.rb
    CHANGED
    
    
    
        data/templates/locales/en.yml
    CHANGED
    
    | 
         @@ -110,6 +110,20 @@ en: 
     | 
|
| 
       110 
110 
     | 
    
         | 
| 
       111 
111 
     | 
    
         
             
                    The LXD logs may contain more information about the cause of this failure.
         
     | 
| 
       112 
112 
     | 
    
         | 
| 
      
 113 
     | 
    
         
            +
                  lxd_disk_mount_failure: |-
         
     | 
| 
      
 114 
     | 
    
         
            +
                    The provider was unable to mount a disk device at %{guestpath} for the '%{machine_name}' VM.
         
     | 
| 
      
 115 
     | 
    
         
            +
                    
         
     | 
| 
      
 116 
     | 
    
         
            +
                    The underlying error message was: %{reason}
         
     | 
| 
      
 117 
     | 
    
         
            +
                    
         
     | 
| 
      
 118 
     | 
    
         
            +
                    The LXD logs may contain more information about the cause of this failure.
         
     | 
| 
      
 119 
     | 
    
         
            +
                    
         
     | 
| 
      
 120 
     | 
    
         
            +
                  lxd_disk_unmount_failure: |-
         
     | 
| 
      
 121 
     | 
    
         
            +
                    The provider was unable to unmount a disk device at %{guestpath} for the '%{machine_name}' VM.
         
     | 
| 
      
 122 
     | 
    
         
            +
                    
         
     | 
| 
      
 123 
     | 
    
         
            +
                    The underlying error message was: %{reason}
         
     | 
| 
      
 124 
     | 
    
         
            +
                    
         
     | 
| 
      
 125 
     | 
    
         
            +
                    The LXD logs may contain more information about the cause of this failure.
         
     | 
| 
      
 126 
     | 
    
         
            +
                    
         
     | 
| 
       113 
127 
     | 
    
         
             
                  lxd_image_creation_failure: |-
         
     | 
| 
       114 
128 
     | 
    
         
             
                    The provider was unable to create an LXD image for the '%{machine_name}' VM.
         
     | 
| 
       115 
129 
     | 
    
         |