File: block_device_mapping_v2.rb

package info (click to toggle)
ruby-fog-openstack 1.0.8-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 5,132 kB
  • sloc: ruby: 36,411; makefile: 5; sh: 4
file content (30 lines) | stat: -rw-r--r-- 807 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# OpenStack Compute (Nova) Example

require 'fog/openstack'

auth_url = "https://example.net/v2.0/tokens"
username = 'admin@example.net'
password = 'secret'
tenant   = 'My Compute Tenant' # String

compute_client ||= ::Fog::OpenStack::Compute.new(
  :openstack_api_key  => password,
  :openstack_username => username,
  :openstack_auth_url => auth_url,
  :openstack_tenant   => tenant
)

_vm = compute_client.servers.create(
  :name                    => name,
  :flavor_ref              => flavor,
  :block_device_mapping_v2 => [
    {
      :boot_index            => 0,
      :device_name           => "vda",
      :source_type           => "volume", # Or "snapshot"
      :destination_type      => "volume",
      :delete_on_termination => false,
      :uuid                  => cinder_uddi,
    }
  ]
)