Sha256: f46ab18aa796f7d287eed45810eb1f17dda5ca44762191e033844ed59e7c7f03

Contents?: true

Size: 1.26 KB

Versions: 10

Compression:

Stored size: 1.26 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.json'
          )
        end
      end
    end # class OpenStack
  end # module Compute
end # module Fog

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
fog-openstack-0.1.21 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.20 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.19 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.18 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.17 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.15 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.14 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.13 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.12 lib/fog/compute/openstack/requests/boot_from_snapshot.rb
fog-openstack-0.1.11 lib/fog/compute/openstack/requests/boot_from_snapshot.rb