vagrant-linode 0.1.3 → 0.2.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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.rspec +4 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +164 -0
- data/Gemfile +9 -6
- data/README.md +21 -9
- data/Rakefile +21 -1
- data/Vagrantfile.multi +18 -0
- data/box/linode-debian-7.5.box +0 -0
- data/box/linode.box +0 -0
- data/box/metadata-debian-7.5.json +12 -0
- data/box/metadata.json +2 -2
- data/features/provision.feature +34 -0
- data/features/steps/sdk_steps.rb +13 -0
- data/features/steps/server_steps.rb +25 -0
- data/features/support/env.rb +34 -0
- data/features/support/fog_mock.rb +16 -0
- data/features/vagrant-linode.feature +68 -0
- data/lib/vagrant-linode.rb +44 -5
- data/lib/vagrant-linode/actions.rb +201 -87
- data/lib/vagrant-linode/actions/connect_linode.rb +36 -0
- data/lib/vagrant-linode/actions/create.rb +9 -9
- data/lib/vagrant-linode/actions/create_image.rb +23 -0
- data/lib/vagrant-linode/actions/destroy.rb +1 -3
- data/lib/vagrant-linode/actions/halt.rb +29 -0
- data/lib/vagrant-linode/actions/is_created.rb +16 -0
- data/lib/vagrant-linode/actions/is_stopped.rb +17 -0
- data/lib/vagrant-linode/actions/list_datacenters.rb +20 -0
- data/lib/vagrant-linode/actions/list_distributions.rb +20 -0
- data/lib/vagrant-linode/actions/list_images.rb +20 -0
- data/lib/vagrant-linode/actions/list_plans.rb +20 -0
- data/lib/vagrant-linode/actions/list_servers.rb +20 -0
- data/lib/vagrant-linode/actions/message_already_active.rb +16 -0
- data/lib/vagrant-linode/actions/message_already_off.rb +16 -0
- data/lib/vagrant-linode/actions/message_not_created.rb +16 -0
- data/lib/vagrant-linode/actions/message_off.rb +16 -0
- data/lib/vagrant-linode/actions/power_off.rb +4 -3
- data/lib/vagrant-linode/actions/power_on.rb +3 -2
- data/lib/vagrant-linode/actions/read_ssh_info.rb +48 -0
- data/lib/vagrant-linode/actions/read_state.rb +38 -0
- data/lib/vagrant-linode/actions/rebuild.rb +3 -2
- data/lib/vagrant-linode/actions/reload.rb +3 -2
- data/lib/vagrant-linode/commands/create_image.rb +21 -0
- data/lib/vagrant-linode/commands/datacenters.rb +21 -0
- data/lib/vagrant-linode/commands/distributions.rb +21 -0
- data/lib/vagrant-linode/commands/images.rb +59 -0
- data/lib/vagrant-linode/commands/list_images.rb +21 -0
- data/lib/vagrant-linode/commands/networks.rb +21 -0
- data/lib/vagrant-linode/commands/plans.rb +21 -0
- data/lib/vagrant-linode/commands/root.rb +81 -0
- data/lib/vagrant-linode/commands/servers.rb +21 -0
- data/lib/vagrant-linode/config.rb +11 -3
- data/lib/vagrant-linode/helpers/client.rb +21 -79
- data/lib/vagrant-linode/helpers/waiter.rb +21 -0
- data/lib/vagrant-linode/plugin.rb +20 -0
- data/lib/vagrant-linode/provider.rb +27 -32
- data/lib/vagrant-linode/version.rb +1 -1
- data/locales/en.yml +17 -1
- data/spec/spec_helper.rb +20 -0
- data/spec/vagrant-linode/actions/list_distributions_spec.rb +47 -0
- data/spec/vagrant-linode/actions/list_plans_spec.rb +47 -0
- data/spec/vagrant-linode/config_spec.rb +189 -0
- data/test/Vagrantfile +4 -9
- data/vagrant-linode.gemspec +1 -1
- metadata +70 -20
- data/lib/vagrant-linode/actions/check_state.rb +0 -19
- data/lib/vagrant-linode/actions/setup_key.rb +0 -52
    
        data/test/Vagrantfile
    CHANGED
    
    | @@ -1,12 +1,7 @@ | |
| 1 1 | 
             
            # -*- mode: ruby -*-
         | 
| 2 2 | 
             
            # vi: set ft=ruby :
         | 
| 3 3 |  | 
| 4 | 
            -
            Vagrant.require_plugin('vagrant-linode')
         | 
| 5 | 
            -
            Vagrant.require_plugin('vagrant-omnibus')
         | 
| 6 | 
            -
             | 
| 7 4 | 
             
            Vagrant.configure('2') do |config|
         | 
| 8 | 
            -
              config.omnibus.chef_version = :latest
         | 
| 9 | 
            -
             | 
| 10 5 | 
             
              config.ssh.username = 'tester'
         | 
| 11 6 | 
             
              config.ssh.private_key_path = './test_id_rsa'
         | 
| 12 7 |  | 
| @@ -15,9 +10,9 @@ Vagrant.configure('2') do |config| | |
| 15 10 | 
             
              config.vm.provider :linode do |provider, override|
         | 
| 16 11 | 
             
                override.vm.box = 'linode'
         | 
| 17 12 | 
             
                override.vm.box_url = 'https://github.com/displague/vagrant-linode/raw/master/box/linode.box'
         | 
| 18 | 
            -
                provider. | 
| 13 | 
            +
                provider.api_key = ENV['LINODE_API_KEY']
         | 
| 19 14 | 
             
                provider.ssh_key_name = 'Test Key'
         | 
| 20 | 
            -
                provider.distribution = ' | 
| 15 | 
            +
                provider.distribution = 'Debian 8'
         | 
| 21 16 | 
             
                provider.datacenter = 'newark'
         | 
| 22 17 | 
             
                provider.plan = '1024'
         | 
| 23 18 | 
             
                provider.label = 'vagrant-'+Time.new.strftime("%F%T").gsub(/[^0-9]/,'')
         | 
| @@ -26,7 +21,7 @@ Vagrant.configure('2') do |config| | |
| 26 21 |  | 
| 27 22 | 
             
                # Main Disk Image Size
         | 
| 28 23 | 
             
                # [str] ( Full Allocation - Swap ) if nil
         | 
| 29 | 
            -
                provider.xvda_size = ' | 
| 24 | 
            +
                provider.xvda_size = '2048'
         | 
| 30 25 |  | 
| 31 26 | 
             
                # Swap Image Size
         | 
| 32 27 | 
             
                # [str] 256 if nil
         | 
| @@ -41,7 +36,7 @@ Vagrant.configure('2') do |config| | |
| 41 36 |  | 
| 42 37 | 
             
                # Enable private networking
         | 
| 43 38 | 
             
                # [boolean] disabled if nil
         | 
| 44 | 
            -
                #provider.private_networking = true
         | 
| 39 | 
            +
                # provider.private_networking = true
         | 
| 45 40 | 
             
              end
         | 
| 46 41 |  | 
| 47 42 | 
             
              config.vm.provision :shell, path: 'scripts/provision.sh'
         | 
    
        data/vagrant-linode.gemspec
    CHANGED
    
    | @@ -22,7 +22,7 @@ Gem::Specification.new do |gem| | |
| 22 22 | 
             
              gem.add_development_dependency 'aruba', '~> 0.5.4'
         | 
| 23 23 |  | 
| 24 24 | 
             
              gem.files         = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
         | 
| 25 | 
            -
              gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
         | 
| 25 | 
            +
              gem.executables   = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
         | 
| 26 26 | 
             
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 27 27 | 
             
              gem.require_paths = ['lib']
         | 
| 28 28 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: vagrant-linode
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Marques Johansson
         | 
| @@ -9,90 +9,90 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2015- | 
| 12 | 
            +
            date: 2015-07-14 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: linodeapi
         | 
| 16 16 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 17 | 
             
                requirements:
         | 
| 18 | 
            -
                - -  | 
| 18 | 
            +
                - - ~>
         | 
| 19 19 | 
             
                  - !ruby/object:Gem::Version
         | 
| 20 20 | 
             
                    version: 0.1.1
         | 
| 21 21 | 
             
              type: :runtime
         | 
| 22 22 | 
             
              prerelease: false
         | 
| 23 23 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 24 24 | 
             
                requirements:
         | 
| 25 | 
            -
                - -  | 
| 25 | 
            +
                - - ~>
         | 
| 26 26 | 
             
                  - !ruby/object:Gem::Version
         | 
| 27 27 | 
             
                    version: 0.1.1
         | 
| 28 28 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 29 29 | 
             
              name: json
         | 
| 30 30 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 31 31 | 
             
                requirements:
         | 
| 32 | 
            -
                - -  | 
| 32 | 
            +
                - - ~>
         | 
| 33 33 | 
             
                  - !ruby/object:Gem::Version
         | 
| 34 34 | 
             
                    version: 1.8.3
         | 
| 35 35 | 
             
              type: :runtime
         | 
| 36 36 | 
             
              prerelease: false
         | 
| 37 37 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 38 38 | 
             
                requirements:
         | 
| 39 | 
            -
                - -  | 
| 39 | 
            +
                - - ~>
         | 
| 40 40 | 
             
                  - !ruby/object:Gem::Version
         | 
| 41 41 | 
             
                    version: 1.8.3
         | 
| 42 42 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 43 43 | 
             
              name: log4r
         | 
| 44 44 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 45 45 | 
             
                requirements:
         | 
| 46 | 
            -
                - -  | 
| 46 | 
            +
                - - ~>
         | 
| 47 47 | 
             
                  - !ruby/object:Gem::Version
         | 
| 48 48 | 
             
                    version: 1.1.10
         | 
| 49 49 | 
             
              type: :runtime
         | 
| 50 50 | 
             
              prerelease: false
         | 
| 51 51 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 52 52 | 
             
                requirements:
         | 
| 53 | 
            -
                - -  | 
| 53 | 
            +
                - - ~>
         | 
| 54 54 | 
             
                  - !ruby/object:Gem::Version
         | 
| 55 55 | 
             
                    version: 1.1.10
         | 
| 56 56 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 57 57 | 
             
              name: rake
         | 
| 58 58 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 59 | 
             
                requirements:
         | 
| 60 | 
            -
                - -  | 
| 60 | 
            +
                - - ~>
         | 
| 61 61 | 
             
                  - !ruby/object:Gem::Version
         | 
| 62 62 | 
             
                    version: 10.4.2
         | 
| 63 63 | 
             
              type: :development
         | 
| 64 64 | 
             
              prerelease: false
         | 
| 65 65 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 66 66 | 
             
                requirements:
         | 
| 67 | 
            -
                - -  | 
| 67 | 
            +
                - - ~>
         | 
| 68 68 | 
             
                  - !ruby/object:Gem::Version
         | 
| 69 69 | 
             
                    version: 10.4.2
         | 
| 70 70 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 71 71 | 
             
              name: rspec
         | 
| 72 72 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 73 73 | 
             
                requirements:
         | 
| 74 | 
            -
                - -  | 
| 74 | 
            +
                - - ~>
         | 
| 75 75 | 
             
                  - !ruby/object:Gem::Version
         | 
| 76 76 | 
             
                    version: 2.14.0
         | 
| 77 77 | 
             
              type: :development
         | 
| 78 78 | 
             
              prerelease: false
         | 
| 79 79 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 80 80 | 
             
                requirements:
         | 
| 81 | 
            -
                - -  | 
| 81 | 
            +
                - - ~>
         | 
| 82 82 | 
             
                  - !ruby/object:Gem::Version
         | 
| 83 83 | 
             
                    version: 2.14.0
         | 
| 84 84 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 85 85 | 
             
              name: aruba
         | 
| 86 86 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 87 87 | 
             
                requirements:
         | 
| 88 | 
            -
                - -  | 
| 88 | 
            +
                - - ~>
         | 
| 89 89 | 
             
                  - !ruby/object:Gem::Version
         | 
| 90 90 | 
             
                    version: 0.5.4
         | 
| 91 91 | 
             
              type: :development
         | 
| 92 92 | 
             
              prerelease: false
         | 
| 93 93 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 94 94 | 
             
                requirements:
         | 
| 95 | 
            -
                - -  | 
| 95 | 
            +
                - - ~>
         | 
| 96 96 | 
             
                  - !ruby/object:Gem::Version
         | 
| 97 97 | 
             
                    version: 0.5.4
         | 
| 98 98 | 
             
            description: Enables Vagrant to manage Linode linodes
         | 
| @@ -103,39 +103,79 @@ executables: [] | |
| 103 103 | 
             
            extensions: []
         | 
| 104 104 | 
             
            extra_rdoc_files: []
         | 
| 105 105 | 
             
            files:
         | 
| 106 | 
            -
            -  | 
| 106 | 
            +
            - .gitignore
         | 
| 107 | 
            +
            - .rspec
         | 
| 108 | 
            +
            - .rubocop.yml
         | 
| 109 | 
            +
            - .rubocop_todo.yml
         | 
| 107 110 | 
             
            - CHANGELOG.md
         | 
| 108 111 | 
             
            - Gemfile
         | 
| 109 112 | 
             
            - LICENSE.txt
         | 
| 110 113 | 
             
            - README.md
         | 
| 111 114 | 
             
            - Rakefile
         | 
| 115 | 
            +
            - Vagrantfile.multi
         | 
| 112 116 | 
             
            - box/README.md
         | 
| 117 | 
            +
            - box/linode-debian-7.5.box
         | 
| 113 118 | 
             
            - box/linode.box
         | 
| 119 | 
            +
            - box/metadata-debian-7.5.json
         | 
| 114 120 | 
             
            - box/metadata.json
         | 
| 121 | 
            +
            - features/provision.feature
         | 
| 122 | 
            +
            - features/steps/sdk_steps.rb
         | 
| 123 | 
            +
            - features/steps/server_steps.rb
         | 
| 124 | 
            +
            - features/support/env.rb
         | 
| 125 | 
            +
            - features/support/fog_mock.rb
         | 
| 126 | 
            +
            - features/vagrant-linode.feature
         | 
| 115 127 | 
             
            - lib/vagrant-linode.rb
         | 
| 116 128 | 
             
            - lib/vagrant-linode/actions.rb
         | 
| 117 | 
            -
            - lib/vagrant-linode/actions/ | 
| 129 | 
            +
            - lib/vagrant-linode/actions/connect_linode.rb
         | 
| 118 130 | 
             
            - lib/vagrant-linode/actions/create.rb
         | 
| 131 | 
            +
            - lib/vagrant-linode/actions/create_image.rb
         | 
| 119 132 | 
             
            - lib/vagrant-linode/actions/destroy.rb
         | 
| 133 | 
            +
            - lib/vagrant-linode/actions/halt.rb
         | 
| 134 | 
            +
            - lib/vagrant-linode/actions/is_created.rb
         | 
| 135 | 
            +
            - lib/vagrant-linode/actions/is_stopped.rb
         | 
| 136 | 
            +
            - lib/vagrant-linode/actions/list_datacenters.rb
         | 
| 137 | 
            +
            - lib/vagrant-linode/actions/list_distributions.rb
         | 
| 138 | 
            +
            - lib/vagrant-linode/actions/list_images.rb
         | 
| 139 | 
            +
            - lib/vagrant-linode/actions/list_plans.rb
         | 
| 140 | 
            +
            - lib/vagrant-linode/actions/list_servers.rb
         | 
| 141 | 
            +
            - lib/vagrant-linode/actions/message_already_active.rb
         | 
| 142 | 
            +
            - lib/vagrant-linode/actions/message_already_off.rb
         | 
| 143 | 
            +
            - lib/vagrant-linode/actions/message_not_created.rb
         | 
| 144 | 
            +
            - lib/vagrant-linode/actions/message_off.rb
         | 
| 120 145 | 
             
            - lib/vagrant-linode/actions/modify_provision_path.rb
         | 
| 121 146 | 
             
            - lib/vagrant-linode/actions/power_off.rb
         | 
| 122 147 | 
             
            - lib/vagrant-linode/actions/power_on.rb
         | 
| 148 | 
            +
            - lib/vagrant-linode/actions/read_ssh_info.rb
         | 
| 149 | 
            +
            - lib/vagrant-linode/actions/read_state.rb
         | 
| 123 150 | 
             
            - lib/vagrant-linode/actions/rebuild.rb
         | 
| 124 151 | 
             
            - lib/vagrant-linode/actions/reload.rb
         | 
| 125 152 | 
             
            - lib/vagrant-linode/actions/setup_hostname.rb
         | 
| 126 | 
            -
            - lib/vagrant-linode/actions/setup_key.rb
         | 
| 127 153 | 
             
            - lib/vagrant-linode/actions/setup_sudo.rb
         | 
| 128 154 | 
             
            - lib/vagrant-linode/actions/setup_user.rb
         | 
| 129 155 | 
             
            - lib/vagrant-linode/actions/sync_folders.rb
         | 
| 156 | 
            +
            - lib/vagrant-linode/commands/create_image.rb
         | 
| 157 | 
            +
            - lib/vagrant-linode/commands/datacenters.rb
         | 
| 158 | 
            +
            - lib/vagrant-linode/commands/distributions.rb
         | 
| 159 | 
            +
            - lib/vagrant-linode/commands/images.rb
         | 
| 160 | 
            +
            - lib/vagrant-linode/commands/list_images.rb
         | 
| 161 | 
            +
            - lib/vagrant-linode/commands/networks.rb
         | 
| 162 | 
            +
            - lib/vagrant-linode/commands/plans.rb
         | 
| 130 163 | 
             
            - lib/vagrant-linode/commands/rebuild.rb
         | 
| 164 | 
            +
            - lib/vagrant-linode/commands/root.rb
         | 
| 165 | 
            +
            - lib/vagrant-linode/commands/servers.rb
         | 
| 131 166 | 
             
            - lib/vagrant-linode/config.rb
         | 
| 132 167 | 
             
            - lib/vagrant-linode/errors.rb
         | 
| 133 168 | 
             
            - lib/vagrant-linode/helpers/client.rb
         | 
| 134 169 | 
             
            - lib/vagrant-linode/helpers/result.rb
         | 
| 170 | 
            +
            - lib/vagrant-linode/helpers/waiter.rb
         | 
| 135 171 | 
             
            - lib/vagrant-linode/plugin.rb
         | 
| 136 172 | 
             
            - lib/vagrant-linode/provider.rb
         | 
| 137 173 | 
             
            - lib/vagrant-linode/version.rb
         | 
| 138 174 | 
             
            - locales/en.yml
         | 
| 175 | 
            +
            - spec/spec_helper.rb
         | 
| 176 | 
            +
            - spec/vagrant-linode/actions/list_distributions_spec.rb
         | 
| 177 | 
            +
            - spec/vagrant-linode/actions/list_plans_spec.rb
         | 
| 178 | 
            +
            - spec/vagrant-linode/config_spec.rb
         | 
| 139 179 | 
             
            - test/Vagrantfile
         | 
| 140 180 | 
             
            - test/cookbooks/test/recipes/default.rb
         | 
| 141 181 | 
             
            - test/scripts/provision.sh
         | 
| @@ -153,21 +193,31 @@ require_paths: | |
| 153 193 | 
             
            - lib
         | 
| 154 194 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 155 195 | 
             
              requirements:
         | 
| 156 | 
            -
              - -  | 
| 196 | 
            +
              - - '>='
         | 
| 157 197 | 
             
                - !ruby/object:Gem::Version
         | 
| 158 198 | 
             
                  version: '0'
         | 
| 159 199 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 160 200 | 
             
              requirements:
         | 
| 161 | 
            -
              - -  | 
| 201 | 
            +
              - - '>='
         | 
| 162 202 | 
             
                - !ruby/object:Gem::Version
         | 
| 163 203 | 
             
                  version: '0'
         | 
| 164 204 | 
             
            requirements: []
         | 
| 165 205 | 
             
            rubyforge_project: 
         | 
| 166 | 
            -
            rubygems_version: 2. | 
| 206 | 
            +
            rubygems_version: 2.0.14
         | 
| 167 207 | 
             
            signing_key: 
         | 
| 168 208 | 
             
            specification_version: 4
         | 
| 169 209 | 
             
            summary: Enables Vagrant to manage Linode linodes
         | 
| 170 210 | 
             
            test_files:
         | 
| 211 | 
            +
            - features/provision.feature
         | 
| 212 | 
            +
            - features/steps/sdk_steps.rb
         | 
| 213 | 
            +
            - features/steps/server_steps.rb
         | 
| 214 | 
            +
            - features/support/env.rb
         | 
| 215 | 
            +
            - features/support/fog_mock.rb
         | 
| 216 | 
            +
            - features/vagrant-linode.feature
         | 
| 217 | 
            +
            - spec/spec_helper.rb
         | 
| 218 | 
            +
            - spec/vagrant-linode/actions/list_distributions_spec.rb
         | 
| 219 | 
            +
            - spec/vagrant-linode/actions/list_plans_spec.rb
         | 
| 220 | 
            +
            - spec/vagrant-linode/config_spec.rb
         | 
| 171 221 | 
             
            - test/Vagrantfile
         | 
| 172 222 | 
             
            - test/cookbooks/test/recipes/default.rb
         | 
| 173 223 | 
             
            - test/scripts/provision.sh
         | 
| @@ -1,19 +0,0 @@ | |
| 1 | 
            -
            module VagrantPlugins
         | 
| 2 | 
            -
              module Linode
         | 
| 3 | 
            -
                module Actions
         | 
| 4 | 
            -
                  class CheckState
         | 
| 5 | 
            -
                    def initialize(app, env)
         | 
| 6 | 
            -
                      @app = app
         | 
| 7 | 
            -
                      @machine = env[:machine]
         | 
| 8 | 
            -
                      @logger = Log4r::Logger.new('vagrant::linode::check_state')
         | 
| 9 | 
            -
                    end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                    def call(env)
         | 
| 12 | 
            -
                      env[:machine_state] = @machine.state.id
         | 
| 13 | 
            -
                      @logger.info "Machine state is '#{@machine.state.id}'"
         | 
| 14 | 
            -
                      @app.call(env)
         | 
| 15 | 
            -
                    end
         | 
| 16 | 
            -
                  end
         | 
| 17 | 
            -
                end
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
            end
         | 
| @@ -1,52 +0,0 @@ | |
| 1 | 
            -
            require 'vagrant-linode/helpers/client'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            module VagrantPlugins
         | 
| 4 | 
            -
              module Linode
         | 
| 5 | 
            -
                module Actions
         | 
| 6 | 
            -
                  class SetupKey
         | 
| 7 | 
            -
                    include Helpers::Client
         | 
| 8 | 
            -
             | 
| 9 | 
            -
                    def initialize(app, env)
         | 
| 10 | 
            -
                      @app = app
         | 
| 11 | 
            -
                      @machine = env[:machine]
         | 
| 12 | 
            -
                      @client = client
         | 
| 13 | 
            -
                      @logger = Log4r::Logger.new('vagrant::linode::setup_key')
         | 
| 14 | 
            -
                    end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                    # TODO check the content of the key to see if it has changed
         | 
| 17 | 
            -
                    def call(env)
         | 
| 18 | 
            -
                      ssh_key_name = @machine.provider_config.ssh_key_name
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                      begin
         | 
| 21 | 
            -
                        # assigns existing ssh key id to env for use by other commands
         | 
| 22 | 
            -
                        env[:ssh_key_id] = @client
         | 
| 23 | 
            -
                          .request('/v2/account/keys')
         | 
| 24 | 
            -
                          .find_id(:ssh_keys, name: ssh_key_name)
         | 
| 25 | 
            -
             | 
| 26 | 
            -
                        env[:ui].info I18n.t('vagrant_linode.info.using_key', name: ssh_key_name)
         | 
| 27 | 
            -
                      rescue Errors::ResultMatchError
         | 
| 28 | 
            -
                        env[:ssh_key_id] = create_ssh_key(ssh_key_name, env)
         | 
| 29 | 
            -
                      end
         | 
| 30 | 
            -
             | 
| 31 | 
            -
                      @app.call(env)
         | 
| 32 | 
            -
                    end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
                    private
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                    def create_ssh_key(name, env)
         | 
| 37 | 
            -
                      # assumes public key exists on the same path as private key with .pub ext
         | 
| 38 | 
            -
                      path = @machine.config.ssh.private_key_path
         | 
| 39 | 
            -
                      path = path[0] if path.is_a?(Array)
         | 
| 40 | 
            -
                      path = File.expand_path(path, @machine.env.root_path)
         | 
| 41 | 
            -
                      pub_key = Linode.public_key(path)
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                      env[:ui].info I18n.t('vagrant_linode.info.creating_key', name: name)
         | 
| 44 | 
            -
             | 
| 45 | 
            -
                      result = @client.post('/v2/account/keys', name: name,
         | 
| 46 | 
            -
                                                                public_key: pub_key)
         | 
| 47 | 
            -
                      result['ssh_key']['id']
         | 
| 48 | 
            -
                    end
         | 
| 49 | 
            -
                  end
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
              end
         | 
| 52 | 
            -
            end
         |