vagrant-openstack-provider 0.10.0 → 0.11.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/.rubocop.yml +1 -1
 - data/CHANGELOG.md +20 -1
 - data/lib/vagrant-openstack-provider/action/create_server.rb +21 -2
 - data/lib/vagrant-openstack-provider/action/read_ssh_info.rb +3 -1
 - data/lib/vagrant-openstack-provider/client/nova.rb +14 -1
 - data/lib/vagrant-openstack-provider/client/rest_utils.rb +6 -3
 - data/lib/vagrant-openstack-provider/config.rb +26 -4
 - data/lib/vagrant-openstack-provider/config_resolver.rb +7 -0
 - data/lib/vagrant-openstack-provider/version.rb +1 -1
 - data/locales/en.yml +2 -0
 - data/spec/vagrant-openstack-provider/action/create_server_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/action/read_ssh_info_spec.rb +11 -0
 - data/spec/vagrant-openstack-provider/client/cinder_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/client/glance_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/client/heat_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/client/keystone_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/client/neutron_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/client/nova_spec.rb +2 -0
 - data/spec/vagrant-openstack-provider/config_resolver_spec.rb +19 -0
 - data/spec/vagrant-openstack-provider/config_spec.rb +14 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 4ec695cee7421bdd2633f9e39de360d75183671c
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 2281efcfe75b63a318220e301c84fbdbd58ac0dd
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8dd4123bdabf397a9f566b12cbf5a7111b3540b5c79d113566f8ae9c60e9d723e430abed459af0896e7b3b5f9d564de9e45efd29d0fffd1badcb8e964309fe22
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 649d676242e35f639e9932c525647e1d5c25ec41fd08ea6b04fb5d43fbe93329b15f54d1c6f6256d6c8cc9aef88c2412a6efdfa95b02e2497045c3a85bfacd12
         
     | 
    
        data/.rubocop.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,4 +1,23 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # 0. 
     | 
| 
      
 1 
     | 
    
         
            +
            # 0.11.0 (August 5, 2017)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            IMPROVEMENTS:
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              - Implement a test suite running all samples #331
         
     | 
| 
      
 6 
     | 
    
         
            +
              - Add test for config.ssh.insert_key = false #332
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            FEATURES:
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              - Add "ssl_verify_peer" in config for self-signed certs #85 #320
         
     | 
| 
      
 11 
     | 
    
         
            +
              - Add "ssl_ca_file" in config for self-signed certs #329
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            BUG FIXES:
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              - Handling of asynchronous floating IP assignment #324
         
     | 
| 
      
 16 
     | 
    
         
            +
              - Fix floating IP assignement #330
         
     | 
| 
      
 17 
     | 
    
         
            +
              - Respect config.ssh.insert_key #328
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            # 0.10.0 (April 11, 2017)
         
     | 
| 
       2 
21 
     | 
    
         | 
| 
       3 
22 
     | 
    
         
             
            IMPROVEMENTS:
         
     | 
| 
       4 
23 
     | 
    
         | 
| 
         @@ -50,6 +50,7 @@ module VagrantPlugins 
     | 
|
| 
       50 
50 
     | 
    
         | 
| 
       51 
51 
     | 
    
         
             
                      waiting_for_server_to_be_built(env, server_id)
         
     | 
| 
       52 
52 
     | 
    
         
             
                      assign_floating_ip(env, server_id)
         
     | 
| 
      
 53 
     | 
    
         
            +
                      waiting_for_floating_ip_to_be_assigned(env, server_id)
         
     | 
| 
       53 
54 
     | 
    
         
             
                      attach_volumes(env, server_id, options[:volumes]) unless options[:volumes].empty?
         
     | 
| 
       54 
55 
     | 
    
         | 
| 
       55 
56 
     | 
    
         
             
                      @app.call(env)
         
     | 
| 
         @@ -72,7 +73,7 @@ module VagrantPlugins 
     | 
|
| 
       72 
73 
     | 
    
         
             
                        env[:ui].info(" -- ImageRef        : #{options[:image].id}")
         
     | 
| 
       73 
74 
     | 
    
         
             
                      end
         
     | 
| 
       74 
75 
     | 
    
         
             
                      env[:ui].info(" -- Boot volume     : #{options[:volume_boot][:id]} (#{options[:volume_boot][:device]})") unless options[:volume_boot].nil?
         
     | 
| 
       75 
     | 
    
         
            -
                      env[:ui].info(" -- KeyPair         : #{options[:keypair_name]}")
         
     | 
| 
      
 76 
     | 
    
         
            +
                      env[:ui].info(" -- KeyPair         : #{options[:keypair_name]}") unless options[:keypair_name].nil?
         
     | 
| 
       76 
77 
     | 
    
         | 
| 
       77 
78 
     | 
    
         
             
                      unless options[:networks].empty?
         
     | 
| 
       78 
79 
     | 
    
         
             
                        formated_networks = ' -- '
         
     | 
| 
         @@ -104,7 +105,9 @@ module VagrantPlugins 
     | 
|
| 
       104 
105 
     | 
    
         
             
                      unless options[:image].nil?
         
     | 
| 
       105 
106 
     | 
    
         
             
                        log << "image '#{options[:image].name}' (#{options[:image].id}) "
         
     | 
| 
       106 
107 
     | 
    
         
             
                      end
         
     | 
| 
       107 
     | 
    
         
            -
                       
     | 
| 
      
 108 
     | 
    
         
            +
                      unless options[:keypair_name].nil?
         
     | 
| 
      
 109 
     | 
    
         
            +
                        log << "and keypair '#{options[:keypair_name]}'"
         
     | 
| 
      
 110 
     | 
    
         
            +
                      end
         
     | 
| 
       108 
111 
     | 
    
         | 
| 
       109 
112 
     | 
    
         
             
                      @logger.info(log)
         
     | 
| 
       110 
113 
     | 
    
         | 
| 
         @@ -152,6 +155,22 @@ module VagrantPlugins 
     | 
|
| 
       152 
155 
     | 
    
         
             
                      @logger.info 'Vagrant was unable to resolve FloatingIP, continue assuming it is not necessary'
         
     | 
| 
       153 
156 
     | 
    
         
             
                    end
         
     | 
| 
       154 
157 
     | 
    
         | 
| 
      
 158 
     | 
    
         
            +
                    def waiting_for_floating_ip_to_be_assigned(env, server_id, retry_interval = 3)
         
     | 
| 
      
 159 
     | 
    
         
            +
                      floating_ip = @resolver.resolve_floating_ip(env)
         
     | 
| 
      
 160 
     | 
    
         
            +
                      return if !floating_ip || floating_ip.empty?
         
     | 
| 
      
 161 
     | 
    
         
            +
                      @logger.info "Waiting for floating IP #{floating_ip} to be assigned"
         
     | 
| 
      
 162 
     | 
    
         
            +
                      env[:ui].info(I18n.t('vagrant_openstack.waiting_for_floating_ip', floating_ip: floating_ip))
         
     | 
| 
      
 163 
     | 
    
         
            +
                      config = env[:machine].provider_config
         
     | 
| 
      
 164 
     | 
    
         
            +
                      Timeout.timeout(config.floating_ip_assign_timeout, Errors::Timeout) do
         
     | 
| 
      
 165 
     | 
    
         
            +
                        until env[:openstack_client].nova.check_assigned_floating_ip(env, server_id, floating_ip)
         
     | 
| 
      
 166 
     | 
    
         
            +
                          sleep retry_interval
         
     | 
| 
      
 167 
     | 
    
         
            +
                        end
         
     | 
| 
      
 168 
     | 
    
         
            +
                        return
         
     | 
| 
      
 169 
     | 
    
         
            +
                      end
         
     | 
| 
      
 170 
     | 
    
         
            +
                    rescue Errors::UnableToResolveFloatingIP
         
     | 
| 
      
 171 
     | 
    
         
            +
                      @logger.info 'Vagrant was unable to resolve FloatingIP, not waiting for assignment'
         
     | 
| 
      
 172 
     | 
    
         
            +
                    end
         
     | 
| 
      
 173 
     | 
    
         
            +
             
     | 
| 
       155 
174 
     | 
    
         
             
                    def attach_volumes(env, server_id, volumes)
         
     | 
| 
       156 
175 
     | 
    
         
             
                      @logger.info("Attaching volumes #{volumes} to server #{server_id}")
         
     | 
| 
       157 
176 
     | 
    
         
             
                      volumes.each do |volume|
         
     | 
| 
         @@ -40,7 +40,9 @@ module VagrantPlugins 
     | 
|
| 
       40 
40 
     | 
    
         
             
                        port: @resolver.resolve_ssh_port(env),
         
     | 
| 
       41 
41 
     | 
    
         
             
                        username: @resolver.resolve_ssh_username(env)
         
     | 
| 
       42 
42 
     | 
    
         
             
                      }
         
     | 
| 
       43 
     | 
    
         
            -
                       
     | 
| 
      
 43 
     | 
    
         
            +
                      if env[:machine].config.ssh.insert_key
         
     | 
| 
      
 44 
     | 
    
         
            +
                        hash[:private_key_path] = "#{env[:machine].data_dir}/#{get_keypair_name(env)}" unless config.keypair_name || config.public_key_path
         
     | 
| 
      
 45 
     | 
    
         
            +
                      end
         
     | 
| 
       44 
46 
     | 
    
         
             
                      # Should work silently when https://github.com/mitchellh/vagrant/issues/4637 is fixed
         
     | 
| 
       45 
47 
     | 
    
         
             
                      hash[:log_level] = 'ERROR'
         
     | 
| 
       46 
48 
     | 
    
         
             
                      hash
         
     | 
| 
         @@ -86,7 +86,7 @@ module VagrantPlugins 
     | 
|
| 
       86 
86 
     | 
    
         
             
                        s['imageRef'] = options[:image_ref]
         
     | 
| 
       87 
87 
     | 
    
         
             
                      end
         
     | 
| 
       88 
88 
     | 
    
         
             
                      s['flavorRef'] = options[:flavor_ref]
         
     | 
| 
       89 
     | 
    
         
            -
                      s['key_name'] = options[:keypair]
         
     | 
| 
      
 89 
     | 
    
         
            +
                      s['key_name'] = options[:keypair] unless options[:keypair].nil?
         
     | 
| 
       90 
90 
     | 
    
         
             
                      s['availability_zone'] = options[:availability_zone] unless options[:availability_zone].nil?
         
     | 
| 
       91 
91 
     | 
    
         
             
                      s['security_groups'] = options[:security_groups] unless options[:security_groups].nil?
         
     | 
| 
       92 
92 
     | 
    
         
             
                      s['user_data'] = Base64.encode64(options[:user_data]) unless options[:user_data].nil?
         
     | 
| 
         @@ -145,6 +145,19 @@ module VagrantPlugins 
     | 
|
| 
       145 
145 
     | 
    
         
             
                    end
         
     | 
| 
       146 
146 
     | 
    
         
             
                  end
         
     | 
| 
       147 
147 
     | 
    
         | 
| 
      
 148 
     | 
    
         
            +
                  def check_assigned_floating_ip(env, server_id, floating_ip)
         
     | 
| 
      
 149 
     | 
    
         
            +
                    instance_exists do
         
     | 
| 
      
 150 
     | 
    
         
            +
                      addresses = get_server_details(env, server_id)['addresses']
         
     | 
| 
      
 151 
     | 
    
         
            +
                      addresses.each do |_, network|
         
     | 
| 
      
 152 
     | 
    
         
            +
                        network.each do |network_detail|
         
     | 
| 
      
 153 
     | 
    
         
            +
                          return true if network_detail['addr'] == floating_ip
         
     | 
| 
      
 154 
     | 
    
         
            +
                        end
         
     | 
| 
      
 155 
     | 
    
         
            +
                      end
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                      return false
         
     | 
| 
      
 158 
     | 
    
         
            +
                    end
         
     | 
| 
      
 159 
     | 
    
         
            +
                  end
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
       148 
161 
     | 
    
         
             
                  def import_keypair(env, public_key)
         
     | 
| 
       149 
162 
     | 
    
         
             
                    keyname = "vagrant-generated-#{Kernel.rand(36**8).to_s(36)}"
         
     | 
| 
       150 
163 
     | 
    
         | 
| 
         @@ -6,19 +6,22 @@ module VagrantPlugins 
     | 
|
| 
       6 
6 
     | 
    
         
             
                  def self.get(env, url, headers = {}, &block)
         
     | 
| 
       7 
7 
     | 
    
         
             
                    config = env[:machine].provider_config
         
     | 
| 
       8 
8 
     | 
    
         
             
                    RestClient::Request.execute(method: :get, url: url, headers: headers,
         
     | 
| 
       9 
     | 
    
         
            -
                                                timeout: config.http.read_timeout, open_timeout: config.http.open_timeout, 
     | 
| 
      
 9 
     | 
    
         
            +
                                                timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
         
     | 
| 
      
 10 
     | 
    
         
            +
                                                ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
         
     | 
| 
       10 
11 
     | 
    
         
             
                  end
         
     | 
| 
       11 
12 
     | 
    
         | 
| 
       12 
13 
     | 
    
         
             
                  def self.post(env, url, payload, headers = {}, &block)
         
     | 
| 
       13 
14 
     | 
    
         
             
                    config = env[:machine].provider_config
         
     | 
| 
       14 
15 
     | 
    
         
             
                    RestClient::Request.execute(method: :post, url: url, payload: payload, headers: headers,
         
     | 
| 
       15 
     | 
    
         
            -
                                                timeout: config.http.read_timeout, open_timeout: config.http.open_timeout, 
     | 
| 
      
 16 
     | 
    
         
            +
                                                timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
         
     | 
| 
      
 17 
     | 
    
         
            +
                                                ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
         
     | 
| 
       16 
18 
     | 
    
         
             
                  end
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
       18 
20 
     | 
    
         
             
                  def self.delete(env, url, headers = {}, &block)
         
     | 
| 
       19 
21 
     | 
    
         
             
                    config = env[:machine].provider_config
         
     | 
| 
       20 
22 
     | 
    
         
             
                    RestClient::Request.execute(method: :delete, url: url, headers: headers,
         
     | 
| 
       21 
     | 
    
         
            -
                                                timeout: config.http.read_timeout, open_timeout: config.http.open_timeout, 
     | 
| 
      
 23 
     | 
    
         
            +
                                                timeout: config.http.read_timeout, open_timeout: config.http.open_timeout,
         
     | 
| 
      
 24 
     | 
    
         
            +
                                                ssl_ca_file: config.ssl_ca_file, verify_ssl: config.ssl_verify_peer, &block)
         
     | 
| 
       22 
25 
     | 
    
         
             
                  end
         
     | 
| 
       23 
26 
     | 
    
         
             
                end
         
     | 
| 
       24 
27 
     | 
    
         
             
              end
         
     | 
| 
         @@ -217,6 +217,10 @@ module VagrantPlugins 
     | 
|
| 
       217 
217 
     | 
    
         
             
                  # @return [Integer]
         
     | 
| 
       218 
218 
     | 
    
         
             
                  attr_accessor :stack_delete_timeout
         
     | 
| 
       219 
219 
     | 
    
         | 
| 
      
 220 
     | 
    
         
            +
                  #
         
     | 
| 
      
 221 
     | 
    
         
            +
                  # @return [Integer]
         
     | 
| 
      
 222 
     | 
    
         
            +
                  attr_accessor :floating_ip_assign_timeout
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
       220 
224 
     | 
    
         
             
                  #
         
     | 
| 
       221 
225 
     | 
    
         
             
                  # @return [HttpConfig]
         
     | 
| 
       222 
226 
     | 
    
         
             
                  attr_accessor :http
         
     | 
| 
         @@ -239,6 +243,16 @@ module VagrantPlugins 
     | 
|
| 
       239 
243 
     | 
    
         
             
                  # @return [Boolean]
         
     | 
| 
       240 
244 
     | 
    
         
             
                  attr_accessor :use_legacy_synced_folders
         
     | 
| 
       241 
245 
     | 
    
         | 
| 
      
 246 
     | 
    
         
            +
                  # Specify the certificate to use.
         
     | 
| 
      
 247 
     | 
    
         
            +
                  #
         
     | 
| 
      
 248 
     | 
    
         
            +
                  # @return [String]
         
     | 
| 
      
 249 
     | 
    
         
            +
                  attr_accessor :ssl_ca_file
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
                  # Verify ssl peer certificate when connecting. Set to false (! unsecure) to disable
         
     | 
| 
      
 252 
     | 
    
         
            +
                  #
         
     | 
| 
      
 253 
     | 
    
         
            +
                  # @return [Boolean]
         
     | 
| 
      
 254 
     | 
    
         
            +
                  attr_accessor :ssl_verify_peer
         
     | 
| 
      
 255 
     | 
    
         
            +
             
     | 
| 
       242 
256 
     | 
    
         
             
                  def initialize
         
     | 
| 
       243 
257 
     | 
    
         
             
                    @password = UNSET_VALUE
         
     | 
| 
       244 
258 
     | 
    
         
             
                    @openstack_compute_url = UNSET_VALUE
         
     | 
| 
         @@ -282,9 +296,12 @@ module VagrantPlugins 
     | 
|
| 
       282 
296 
     | 
    
         
             
                    @server_delete_timeout = UNSET_VALUE
         
     | 
| 
       283 
297 
     | 
    
         
             
                    @stack_create_timeout = UNSET_VALUE
         
     | 
| 
       284 
298 
     | 
    
         
             
                    @stack_delete_timeout = UNSET_VALUE
         
     | 
| 
      
 299 
     | 
    
         
            +
                    @floating_ip_assign_timeout = UNSET_VALUE
         
     | 
| 
       285 
300 
     | 
    
         
             
                    @meta_args_support = UNSET_VALUE
         
     | 
| 
       286 
301 
     | 
    
         
             
                    @http = HttpConfig.new
         
     | 
| 
       287 
302 
     | 
    
         
             
                    @use_legacy_synced_folders = UNSET_VALUE
         
     | 
| 
      
 303 
     | 
    
         
            +
                    @ssl_ca_file = UNSET_VALUE
         
     | 
| 
      
 304 
     | 
    
         
            +
                    @ssl_verify_peer = UNSET_VALUE
         
     | 
| 
       288 
305 
     | 
    
         
             
                  end
         
     | 
| 
       289 
306 
     | 
    
         | 
| 
       290 
307 
     | 
    
         
             
                  def merge(other)
         
     | 
| 
         @@ -390,11 +407,14 @@ module VagrantPlugins 
     | 
|
| 
       390 
407 
     | 
    
         
             
                    @server_delete_timeout = 200 if @server_delete_timeout == UNSET_VALUE
         
     | 
| 
       391 
408 
     | 
    
         
             
                    @stack_create_timeout = 200 if @stack_create_timeout == UNSET_VALUE
         
     | 
| 
       392 
409 
     | 
    
         
             
                    @stack_delete_timeout = 200 if @stack_delete_timeout == UNSET_VALUE
         
     | 
| 
      
 410 
     | 
    
         
            +
                    @floating_ip_assign_timeout = 200 if @floating_ip_assign_timeout == UNSET_VALUE
         
     | 
| 
       393 
411 
     | 
    
         
             
                    @meta_args_support = false if @meta_args_support == UNSET_VALUE
         
     | 
| 
       394 
412 
     | 
    
         
             
                    @networks = nil if @networks.empty?
         
     | 
| 
       395 
413 
     | 
    
         
             
                    @volumes = nil if @volumes.empty?
         
     | 
| 
       396 
414 
     | 
    
         
             
                    @stacks = nil if @stacks.empty?
         
     | 
| 
       397 
415 
     | 
    
         
             
                    @http.finalize!
         
     | 
| 
      
 416 
     | 
    
         
            +
                    @ssl_ca_file = nil if @ssl_ca_file == UNSET_VALUE
         
     | 
| 
      
 417 
     | 
    
         
            +
                    @ssl_verify_peer = true if @ssl_verify_peer == UNSET_VALUE
         
     | 
| 
       398 
418 
     | 
    
         
             
                  end
         
     | 
| 
       399 
419 
     | 
    
         
             
                  # rubocop:enable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
         
     | 
| 
       400 
420 
     | 
    
         | 
| 
         @@ -416,10 +436,12 @@ module VagrantPlugins 
     | 
|
| 
       416 
436 
     | 
    
         
             
                    validate_stack_config(errors)
         
     | 
| 
       417 
437 
     | 
    
         
             
                    validate_ssh_timeout(errors)
         
     | 
| 
       418 
438 
     | 
    
         | 
| 
       419 
     | 
    
         
            -
                    if machine.config.ssh. 
     | 
| 
       420 
     | 
    
         
            -
                       
     | 
| 
       421 
     | 
    
         
            -
             
     | 
| 
       422 
     | 
    
         
            -
                       
     | 
| 
      
 439 
     | 
    
         
            +
                    if machine.config.ssh.insert_key
         
     | 
| 
      
 440 
     | 
    
         
            +
                      if machine.config.ssh.private_key_path
         
     | 
| 
      
 441 
     | 
    
         
            +
                        puts I18n.t('vagrant_openstack.config.keypair_name_required').yellow unless @keypair_name || @public_key_path
         
     | 
| 
      
 442 
     | 
    
         
            +
                      else
         
     | 
| 
      
 443 
     | 
    
         
            +
                        errors << I18n.t('vagrant_openstack.config.private_key_missing') if @keypair_name || @public_key_path
         
     | 
| 
      
 444 
     | 
    
         
            +
                      end
         
     | 
| 
       423 
445 
     | 
    
         
             
                    end
         
     | 
| 
       424 
446 
     | 
    
         | 
| 
       425 
447 
     | 
    
         
             
                    {
         
     | 
| 
         @@ -37,18 +37,25 @@ module VagrantPlugins 
     | 
|
| 
       37 
37 
     | 
    
         
             
                    config = env[:machine].provider_config
         
     | 
| 
       38 
38 
     | 
    
         
             
                    nova = env[:openstack_client].nova
         
     | 
| 
       39 
39 
     | 
    
         
             
                    return config.floating_ip if config.floating_ip
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
       40 
41 
     | 
    
         
             
                    fail Errors::UnableToResolveFloatingIP if config.floating_ip_pool.nil? || config.floating_ip_pool.empty?
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
       41 
43 
     | 
    
         
             
                    @logger.debug 'Searching for available ips'
         
     | 
| 
       42 
44 
     | 
    
         
             
                    free_ip = search_free_ip(config, nova, env)
         
     | 
| 
      
 45 
     | 
    
         
            +
                    config.floating_ip = free_ip
         
     | 
| 
       43 
46 
     | 
    
         
             
                    return free_ip unless free_ip.nil?
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       44 
48 
     | 
    
         
             
                    @logger.debug 'Allocate new ip anyway'
         
     | 
| 
       45 
49 
     | 
    
         
             
                    allocated_ip = allocate_ip(config, nova, env)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    config.floating_ip = allocated_ip
         
     | 
| 
       46 
51 
     | 
    
         
             
                    return allocated_ip unless allocated_ip.nil?
         
     | 
| 
       47 
52 
     | 
    
         
             
                  end
         
     | 
| 
       48 
53 
     | 
    
         | 
| 
       49 
54 
     | 
    
         
             
                  def resolve_keypair(env)
         
     | 
| 
       50 
55 
     | 
    
         
             
                    config = env[:machine].provider_config
         
     | 
| 
      
 56 
     | 
    
         
            +
                    machine_config = env[:machine].config
         
     | 
| 
       51 
57 
     | 
    
         
             
                    nova = env[:openstack_client].nova
         
     | 
| 
      
 58 
     | 
    
         
            +
                    return nil unless machine_config.ssh.insert_key
         
     | 
| 
       52 
59 
     | 
    
         
             
                    return config.keypair_name if config.keypair_name
         
     | 
| 
       53 
60 
     | 
    
         
             
                    return nova.import_keypair_from_file(env, config.public_key_path) if config.public_key_path
         
     | 
| 
       54 
61 
     | 
    
         
             
                    generate_keypair(env)
         
     | 
    
        data/locales/en.yml
    CHANGED
    
    | 
         @@ -69,6 +69,8 @@ en: 
     | 
|
| 
       69 
69 
     | 
    
         
             
                  Rsyncing folder: %{hostpath} => %{guestpath}
         
     | 
| 
       70 
70 
     | 
    
         
             
                using_floating_ip: |-
         
     | 
| 
       71 
71 
     | 
    
         
             
                  Using floating IP %{floating_ip}
         
     | 
| 
      
 72 
     | 
    
         
            +
                waiting_for_floating_ip: |-
         
     | 
| 
      
 73 
     | 
    
         
            +
                  Waiting for floating IP %{floating_ip} to be assigned...
         
     | 
| 
       72 
74 
     | 
    
         
             
                waiting_for_build: |-
         
     | 
| 
       73 
75 
     | 
    
         
             
                  Waiting for the server to be built...
         
     | 
| 
       74 
76 
     | 
    
         
             
                waiting_for_ssh: |-
         
     | 
| 
         @@ -109,10 +109,12 @@ describe VagrantPlugins::Openstack::Action::CreateServer do 
     | 
|
| 
       109 
109 
     | 
    
         
             
                    allow(@action).to receive(:waiting_for_server_to_be_built)
         
     | 
| 
       110 
110 
     | 
    
         
             
                    allow(@action).to receive(:attach_volumes)
         
     | 
| 
       111 
111 
     | 
    
         
             
                    allow(@action).to receive(:waiting_for_server_to_be_reachable)
         
     | 
| 
      
 112 
     | 
    
         
            +
                    allow(@action).to receive(:waiting_for_floating_ip_to_be_assigned)
         
     | 
| 
       112 
113 
     | 
    
         | 
| 
       113 
114 
     | 
    
         
             
                    expect(@action).to receive(:waiting_for_server_to_be_built).with(env, '45678')
         
     | 
| 
       114 
115 
     | 
    
         
             
                    expect(@action).to receive(:assign_floating_ip).with(env, '45678').and_return('1.2.3.4')
         
     | 
| 
       115 
116 
     | 
    
         
             
                    expect(@action).to receive(:attach_volumes).with(env, '45678', [{ id: 'vol-01', device: nil }])
         
     | 
| 
      
 117 
     | 
    
         
            +
                    expect(@action).to receive(:waiting_for_floating_ip_to_be_assigned).with(env, '45678')
         
     | 
| 
       116 
118 
     | 
    
         | 
| 
       117 
119 
     | 
    
         
             
                    @action.call(env)
         
     | 
| 
       118 
120 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -43,6 +43,7 @@ describe VagrantPlugins::Openstack::Action::ReadSSHInfo do 
     | 
|
| 
       43 
43 
     | 
    
         
             
                double('ssh_config').tap do |config|
         
     | 
| 
       44 
44 
     | 
    
         
             
                  config.stub(:username) { 'sshuser' }
         
     | 
| 
       45 
45 
     | 
    
         
             
                  config.stub(:port) { nil }
         
     | 
| 
      
 46 
     | 
    
         
            +
                  config.stub(:insert_key) { true }
         
     | 
| 
       46 
47 
     | 
    
         
             
                end
         
     | 
| 
       47 
48 
     | 
    
         
             
              end
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
         @@ -166,6 +167,16 @@ describe VagrantPlugins::Openstack::Action::ReadSSHInfo do 
     | 
|
| 
       166 
167 
     | 
    
         
             
                        log_level: 'ERROR')
         
     | 
| 
       167 
168 
     | 
    
         
             
                    end
         
     | 
| 
       168 
169 
     | 
    
         
             
                  end
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
                  context 'with neither keypair_name nor public_key_path specified and ssh.insert_key is false' do
         
     | 
| 
      
 172 
     | 
    
         
            +
                    it 'does not return private_key_path' do
         
     | 
| 
      
 173 
     | 
    
         
            +
                      ssh_config.stub(:insert_key) { false }
         
     | 
| 
      
 174 
     | 
    
         
            +
                      config.stub(:floating_ip) { '80.80.80.80' }
         
     | 
| 
      
 175 
     | 
    
         
            +
                      config.stub(:keypair_name) { nil }
         
     | 
| 
      
 176 
     | 
    
         
            +
                      config.stub(:public_key_path) { nil }
         
     | 
| 
      
 177 
     | 
    
         
            +
                      @action.read_ssh_info(env).should eq(host: '80.80.80.80', port: 22, username: 'sshuser', log_level: 'ERROR')
         
     | 
| 
      
 178 
     | 
    
         
            +
                    end
         
     | 
| 
      
 179 
     | 
    
         
            +
                  end
         
     | 
| 
       169 
180 
     | 
    
         
             
                end
         
     | 
| 
       170 
181 
     | 
    
         | 
| 
       171 
182 
     | 
    
         
             
                context 'without config.floating_ip specified' do
         
     | 
| 
         @@ -20,6 +20,8 @@ describe VagrantPlugins::Openstack::KeystoneClient do 
     | 
|
| 
       20 
20 
     | 
    
         
             
                  config.stub(:interface_type) { 'public' }
         
     | 
| 
       21 
21 
     | 
    
         
             
                  config.stub(:identity_api_version) { '2' }
         
     | 
| 
       22 
22 
     | 
    
         
             
                  config.stub(:project_name) { 'testTenant' }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  config.stub(:ssl_ca_file) { nil }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  config.stub(:ssl_verify_peer) { true }
         
     | 
| 
       23 
25 
     | 
    
         
             
                end
         
     | 
| 
       24 
26 
     | 
    
         
             
              end
         
     | 
| 
       25 
27 
     | 
    
         | 
| 
         @@ -93,6 +93,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       93 
93 
     | 
    
         
             
                double('ssh_config').tap do |config|
         
     | 
| 
       94 
94 
     | 
    
         
             
                  config.stub(:username) { nil }
         
     | 
| 
       95 
95 
     | 
    
         
             
                  config.stub(:port) { nil }
         
     | 
| 
      
 96 
     | 
    
         
            +
                  config.stub(:insert_key) { true }
         
     | 
| 
       96 
97 
     | 
    
         
             
                end
         
     | 
| 
       97 
98 
     | 
    
         
             
              end
         
     | 
| 
       98 
99 
     | 
    
         | 
| 
         @@ -249,6 +250,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       249 
250 
     | 
    
         
             
                          FloatingIP.new('80.81.82.85', 'pool-1', nil)
         
     | 
| 
       250 
251 
     | 
    
         
             
                        end
         
     | 
| 
       251 
252 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { ['pool-1'] }
         
     | 
| 
      
 253 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       252 
254 
     | 
    
         
             
                        @action.resolve_floating_ip(env).should eq('80.81.82.85')
         
     | 
| 
       253 
255 
     | 
    
         
             
                      end
         
     | 
| 
       254 
256 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -261,6 +263,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       261 
263 
     | 
    
         
             
                           FloatingIP.new('80.81.82.83', 'pool-1', nil)]
         
     | 
| 
       262 
264 
     | 
    
         
             
                        end
         
     | 
| 
       263 
265 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { ['pool-1'] }
         
     | 
| 
      
 266 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       264 
267 
     | 
    
         
             
                        @action.resolve_floating_ip(env).should eq('80.81.82.83')
         
     | 
| 
       265 
268 
     | 
    
         
             
                      end
         
     | 
| 
       266 
269 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -275,6 +278,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       275 
278 
     | 
    
         
             
                        FloatingIP.new('80.81.82.84', 'pool-1', nil)
         
     | 
| 
       276 
279 
     | 
    
         
             
                      end
         
     | 
| 
       277 
280 
     | 
    
         
             
                      config.stub(:floating_ip_pool) { ['pool-1'] }
         
     | 
| 
      
 281 
     | 
    
         
            +
                      config.stub(:floating_ip=) { nil }
         
     | 
| 
       278 
282 
     | 
    
         
             
                      @action.resolve_floating_ip(env).should eq('80.81.82.84')
         
     | 
| 
       279 
283 
     | 
    
         
             
                    end
         
     | 
| 
       280 
284 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -294,6 +298,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       294 
298 
     | 
    
         
             
                          FloatingIP.new('80.81.82.85', 'pool-1', nil)
         
     | 
| 
       295 
299 
     | 
    
         
             
                        end
         
     | 
| 
       296 
300 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { %w(pool-1 pool-2) }
         
     | 
| 
      
 301 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       297 
302 
     | 
    
         
             
                        @action.resolve_floating_ip(env).should eq('80.81.82.85')
         
     | 
| 
       298 
303 
     | 
    
         
             
                      end
         
     | 
| 
       299 
304 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -306,6 +311,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       306 
311 
     | 
    
         
             
                           FloatingIP.new('80.81.82.83', 'pool-2', nil)]
         
     | 
| 
       307 
312 
     | 
    
         
             
                        end
         
     | 
| 
       308 
313 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { %w(pool-1 pool-2) }
         
     | 
| 
      
 314 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       309 
315 
     | 
    
         
             
                        @action.resolve_floating_ip(env).should eq('80.81.82.83')
         
     | 
| 
       310 
316 
     | 
    
         
             
                      end
         
     | 
| 
       311 
317 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -322,6 +328,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       322 
328 
     | 
    
         
             
                          FloatingIP.new('80.81.82.84', 'pool-1', nil)
         
     | 
| 
       323 
329 
     | 
    
         
             
                        end
         
     | 
| 
       324 
330 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { %w(pool-1 pool-2) }
         
     | 
| 
      
 331 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       325 
332 
     | 
    
         
             
                        @action.resolve_floating_ip(env).should eq('80.81.82.84')
         
     | 
| 
       326 
333 
     | 
    
         
             
                      end
         
     | 
| 
       327 
334 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -337,6 +344,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       337 
344 
     | 
    
         
             
                          FloatingIP.new('80.81.82.84', 'pool-2', nil)
         
     | 
| 
       338 
345 
     | 
    
         
             
                        end
         
     | 
| 
       339 
346 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { %w(pool-1 pool-2) }
         
     | 
| 
      
 347 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       340 
348 
     | 
    
         
             
                        @action.resolve_floating_ip(env).should eq('80.81.82.84')
         
     | 
| 
       341 
349 
     | 
    
         
             
                      end
         
     | 
| 
       342 
350 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -350,6 +358,7 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       350 
358 
     | 
    
         
             
                        nova.stub(:allocate_floating_ip).with(env, 'pool-1').and_raise Errors::VagrantOpenstackError, message: 'error', code: 404
         
     | 
| 
       351 
359 
     | 
    
         
             
                        nova.stub(:allocate_floating_ip).with(env, 'pool-2').and_raise Errors::VagrantOpenstackError, message: 'error', code: 404
         
     | 
| 
       352 
360 
     | 
    
         
             
                        config.stub(:floating_ip_pool) { %w(pool-1 pool-2) }
         
     | 
| 
      
 361 
     | 
    
         
            +
                        config.stub(:floating_ip=) { nil }
         
     | 
| 
       353 
362 
     | 
    
         
             
                        expect { @action.resolve_floating_ip(env) }.to raise_error(Errors::VagrantOpenstackError)
         
     | 
| 
       354 
363 
     | 
    
         
             
                      end
         
     | 
| 
       355 
364 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -397,6 +406,16 @@ describe VagrantPlugins::Openstack::ConfigResolver do 
     | 
|
| 
       397 
406 
     | 
    
         
             
                    @action.resolve_keypair(env).should eq('my-keypair-imported')
         
     | 
| 
       398 
407 
     | 
    
         
             
                  end
         
     | 
| 
       399 
408 
     | 
    
         
             
                end
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
                context 'with insert_key false' do
         
     | 
| 
      
 411 
     | 
    
         
            +
                  it 'does nothing and return nil' do
         
     | 
| 
      
 412 
     | 
    
         
            +
                    config.stub(:keypair_name) { 'my-keypair' }
         
     | 
| 
      
 413 
     | 
    
         
            +
                    ssh_config.stub(:insert_key) { false }
         
     | 
| 
      
 414 
     | 
    
         
            +
                    nova.should_not_receive(:import_keypair_from_file)
         
     | 
| 
      
 415 
     | 
    
         
            +
                    @action.should_not_receive(:generate_keypair)
         
     | 
| 
      
 416 
     | 
    
         
            +
                    @action.resolve_keypair(env).should be_nil
         
     | 
| 
      
 417 
     | 
    
         
            +
                  end
         
     | 
| 
      
 418 
     | 
    
         
            +
                end
         
     | 
| 
       400 
419 
     | 
    
         
             
              end
         
     | 
| 
       401 
420 
     | 
    
         | 
| 
       402 
421 
     | 
    
         
             
              describe 'generate_keypair' do
         
     | 
| 
         @@ -29,6 +29,7 @@ describe VagrantPlugins::Openstack::Config do 
     | 
|
| 
       29 
29 
     | 
    
         
             
                its(:security_groups) { should be_nil }
         
     | 
| 
       30 
30 
     | 
    
         
             
                its(:user_data) { should be_nil }
         
     | 
| 
       31 
31 
     | 
    
         
             
                its(:metadata) { should be_nil }
         
     | 
| 
      
 32 
     | 
    
         
            +
                its(:ssl_ca_file) { should eq nil }
         
     | 
| 
       32 
33 
     | 
    
         
             
              end
         
     | 
| 
       33 
34 
     | 
    
         | 
| 
       34 
35 
     | 
    
         
             
              describe 'overriding defaults' do
         
     | 
| 
         @@ -50,7 +51,8 @@ describe VagrantPlugins::Openstack::Config do 
     | 
|
| 
       50 
51 
     | 
    
         
             
                  :user_data,
         
     | 
| 
       51 
52 
     | 
    
         
             
                  :metadata,
         
     | 
| 
       52 
53 
     | 
    
         
             
                  :availability_zone,
         
     | 
| 
       53 
     | 
    
         
            -
                  :public_key_path 
     | 
| 
      
 54 
     | 
    
         
            +
                  :public_key_path,
         
     | 
| 
      
 55 
     | 
    
         
            +
                  :ssl_ca_file].each do |attribute|
         
     | 
| 
       54 
56 
     | 
    
         
             
                  it "should not default #{attribute} if overridden" do
         
     | 
| 
       55 
57 
     | 
    
         
             
                    subject.send("#{attribute}=".to_sym, 'foo')
         
     | 
| 
       56 
58 
     | 
    
         
             
                    subject.finalize!
         
     | 
| 
         @@ -270,6 +272,7 @@ describe VagrantPlugins::Openstack::Config do 
     | 
|
| 
       270 
272 
     | 
    
         
             
                  machine.stub_chain(:env, :root_path).and_return '/'
         
     | 
| 
       271 
273 
     | 
    
         
             
                  ssh.stub(:private_key_path) { 'private key path' }
         
     | 
| 
       272 
274 
     | 
    
         
             
                  ssh.stub(:username) { 'ssh username' }
         
     | 
| 
      
 275 
     | 
    
         
            +
                  ssh.stub(:insert_key) { true }
         
     | 
| 
       273 
276 
     | 
    
         
             
                  config.stub(:ssh) { ssh }
         
     | 
| 
       274 
277 
     | 
    
         
             
                  machine.stub(:config) { config }
         
     | 
| 
       275 
278 
     | 
    
         
             
                  subject.username = 'foo'
         
     | 
| 
         @@ -348,6 +351,16 @@ describe VagrantPlugins::Openstack::Config do 
     | 
|
| 
       348 
351 
     | 
    
         
             
                      validation_errors.first.should == error_message
         
     | 
| 
       349 
352 
     | 
    
         
             
                    end
         
     | 
| 
       350 
353 
     | 
    
         
             
                  end
         
     | 
| 
      
 354 
     | 
    
         
            +
             
     | 
| 
      
 355 
     | 
    
         
            +
                  context 'keypair_name or public_key_path is set and ssh.insert_key is false' do
         
     | 
| 
      
 356 
     | 
    
         
            +
                    it 'should not error' do
         
     | 
| 
      
 357 
     | 
    
         
            +
                      ssh.stub(:private_key_path) { nil }
         
     | 
| 
      
 358 
     | 
    
         
            +
                      ssh.stub(:insert_key) { false }
         
     | 
| 
      
 359 
     | 
    
         
            +
                      subject.public_key_path = 'public_key'
         
     | 
| 
      
 360 
     | 
    
         
            +
                      I18n.should_not_receive(:t)
         
     | 
| 
      
 361 
     | 
    
         
            +
                      validation_errors.should be_empty
         
     | 
| 
      
 362 
     | 
    
         
            +
                    end
         
     | 
| 
      
 363 
     | 
    
         
            +
                  end
         
     | 
| 
       351 
364 
     | 
    
         
             
                end
         
     | 
| 
       352 
365 
     | 
    
         | 
| 
       353 
366 
     | 
    
         
             
                context 'the password' do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: vagrant-openstack-provider
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.11.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Guillaume Giamarchi
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2017-08-05 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: json
         
     |