Sha256: 018f773d7ce90dc6829260831fc968b7d778084b14488014259342ca7d997357

Contents?: true

Size: 1.73 KB

Versions: 20

Compression:

Stored size: 1.73 KB

Contents

require 'fog/openstack'
require 'pp'

#
# Creates a share network and a share
#
# Needs to be in an environment where keystone v3 is available
#
# You will need to source OpenStack credentials since the script
# reads the following envionment variables:
#
#  OS_AUTH_URL
#  OS_PASSWORD
#  OS_USERNAME
#  OS_USER_DOMAIN_NAME
#  OS_PROJECT_NAME
#  OS_REGION_NAME
#
#  optionally disable SSL verification
#  SSL_VERIFY=false

auth_options = {
  :openstack_auth_url     => "#{ENV['OS_AUTH_URL']}/auth/tokens",
  :openstack_api_key      => ENV['OS_PASSWORD'],
  :openstack_username     => ENV['OS_USERNAME'],
  :openstack_domain_name  => ENV['OS_USER_DOMAIN_NAME'],
  :openstack_project_name => ENV['OS_PROJECT_NAME'],
  :openstack_region       => ENV['OS_REGION_NAME'],
  :connection_options     => {:ssl_verify_peer => ENV['SSL_VERIFY'] != 'false'}
}

network_service = Fog::OpenStack::Network.new(auth_options)
share_service   = Fog::OpenStack::SharedFileSystem.new(auth_options)

net = network_service.networks.first
raise 'no network exists' if net.nil?

puts "Create share network in #{net.name}"
share_network = share_service.networks.create(
  :neutron_net_id    => net.id,
  :neutron_subnet_id => net.subnets.first.id,
  :name              => 'fog_share_net'
)

pp share_network

puts 'Create share'
example_share = share_service.shares.create(
  :share_proto      => 'NFS',
  :size             => 1,
  :name             => 'fog_share',
  :share_network_id => share_network.id
)

pp example_share

puts 'Create snapshot'
example_snap = share_service.snapshots.create(
  :share_id => example_share.id,
  :name     => 'fog_share_snapshot'
)

pp example_snap

puts 'Removing snapshot, share and share network'
example_snap.destroy
example_share.destroy
share_network.destroy

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
fog-openstack-1.1.3 examples/shared_file_system/basics.rb
fog-openstack-1.1.2 examples/shared_file_system/basics.rb
fog-openstack-fork-99 examples/shared_file_system/basics.rb
fog-openstack-1.1.0 examples/shared_file_system/basics.rb
fog-openstack-1.1.0.pre examples/shared_file_system/basics.rb
fog-openstack-apibank-1.0.102 examples/shared_file_system/basics.rb
fog-openstack-1.0.11 examples/shared_file_system/basics.rb
fog-openstack-apibank-1.0.101 examples/shared_file_system/basics.rb
fog-openstack-1.0.10 examples/shared_file_system/basics.rb
fog-openstack-1.0.9 examples/shared_file_system/basics.rb
fog-openstack-1.0.8 examples/shared_file_system/basics.rb
fog-openstack-1.0.7 examples/shared_file_system/basics.rb
fog-openstack-1.0.6 examples/shared_file_system/basics.rb
fog-openstack-1.0.5 examples/shared_file_system/basics.rb
fog-openstack-1.0.4 examples/shared_file_system/basics.rb
fog-openstack-1.0.3 examples/shared_file_system/basics.rb
fog-openstack-1.0.2 examples/shared_file_system/basics.rb
fog-openstack-1.0.1 examples/shared_file_system/basics.rb
fog-openstack-1.0.0 examples/shared_file_system/basics.rb
fog-openstack-0.3.1 examples/shared_file_system/basics.rb