Sha256: ec0fb713c2a4e85c12ee772e928139ddca5d80eca3b721480bb724f3728a3497

Contents?: true

Size: 1.21 KB

Versions: 25

Compression:

Stored size: 1.21 KB

Contents

module Fog
  module Compute
    class OpenStack
      class Real
        def boot_from_snapshot(name, image_ref, flavor_ref, options = {})
          data = {
            'server' => {
              'flavorRef' => flavor_ref,
              'imageRef'  => image_ref,
              'name'      => name
            }
          }

          vanilla_options = ['metadata', 'accessIPv4', 'accessIPv6',
                             'availability_zone', 'user_data', 'block_device_mapping',
                             'key_name', 'security_groups']
          vanilla_options.select { |o| options[o] }.each do |key|
            data['server'][key] = options[key]
          end

          if options['personality']
            data['server']['personality'] = []
            options['personality'].each do |file|
              data['server']['personality'] << {
                'contents' => Base64.encode64(file['contents']),
                'path'     => file['path']
              }
            end
          end

          request(
            :body    => Fog::JSON.encode(data),
            :expects => [200, 202],
            :method  => 'POST',
            :path    => '/os-volumes_boot'
          )
        end
      end
    end
  end
end

Version data entries

25 entries across 23 versions & 3 rubygems

Version Path
fog-openstack-0.1.27 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-openstack-0.1.26/lib/fog/compute/openstack/requests/boot_from_snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-openstack-0.1.26/lib/fog/compute/openstack/requests/boot_from_snapshot.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-openstack-0.1.26/lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.26 lib/fog/compute/openstack/requests/boot_from_snapshot.rb