Sha256: 21e6d2b4b9e7e6c43f41370865af651d6b51906b4cd9a81d72e6349f9e678923

Contents?: true

Size: 1.73 KB

Versions: 34

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::Network::OpenStack.new(auth_options)
share_service   = Fog::SharedFileSystem::OpenStack.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

34 entries across 32 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 examples/shared_file_system/basics.rb
fog-openstack-0.3.10 examples/shared_file_system/basics.rb
fog-openstack-0.1.30 examples/shared_file_system/basics.rb
fog-openstack-0.1.29 examples/shared_file_system/basics.rb
fog-openstack-0.3.9 examples/shared_file_system/basics.rb
fog-openstack-0.1.28 examples/shared_file_system/basics.rb
fog-openstack-0.3.8 examples/shared_file_system/basics.rb
fog-openstack-0.3.7 examples/shared_file_system/basics.rb
fog-openstack-0.3.6 examples/shared_file_system/basics.rb
fog-openstack-0.3.5 examples/shared_file_system/basics.rb
fog-openstack-0.3.4 examples/shared_file_system/basics.rb
fog-openstack-0.3.3 examples/shared_file_system/basics.rb
fog-openstack-0.3.2 examples/shared_file_system/basics.rb
fog-openstack-0.3.0 examples/shared_file_system/basics.rb
fog-openstack-0.2.4 examples/shared_file_system/basics.rb
fog-openstack-0.2.3 examples/shared_file_system/basics.rb
fog-openstack-0.2.2 examples/shared_file_system/basics.rb
fog-openstack-0.2.1 examples/shared_file_system/basics.rb
fog-openstack-0.2.0 examples/shared_file_system/basics.rb
fog-zj-0.1.28 examples/shared_file_system/basics.rb