1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/openstack
Paul Thornthwaite 7961ad6508 [core] Deprecates 'connection' accessor
The 'connection' accessor in collections and models actually refered to
a subclassed instance of Fog::Service which creates confusion in the
code.

References to 'connection' could have meant the service or the
Fog::Connection held within that service.

This deprecates the connection accessor and replaces it with `#service`
as a read only value. When a collection or model is initalised then
service should be passed.

This commit also updates all the changes to @connection made by
providers in model initialisers since these depending on the presence of
the 'connection' key. The key is still accepted by outputs a warning.
2013-01-07 20:53:24 +00:00
..
models [core] Deprecates 'connection' accessor 2013-01-07 20:53:24 +00:00
requests [openstack|image] Fixes #1383 2012-12-18 11:58:09 +01:00
compute.rb OpenStack auth updates to select by service name. 2012-12-10 07:55:54 -05:00
identity.rb OpenStack auth updates to select by service name. 2012-12-10 07:55:54 -05:00
image.rb Added multi-region support for OpenStack Image service 2012-12-21 12:54:53 -07:00
network.rb OpenStack auth updates to select by service name. 2012-12-10 07:55:54 -05:00
README.identity.md
volume.rb OpenStack auth updates to select by service name. 2012-12-10 07:55:54 -05:00

OpenStack Identity Service (Keystone) Example

require 'fog'
require 'pp'

auth_url = "https://example.net/v2.0/tokens"
username = 'admin@example.net'
password = 'secret'

keystone = Fog::Identity.new :provider           => 'OpenStack',
                             :openstack_auth_url => auth_url,
                             :openstack_username => username,
                             :openstack_api_key  => password
                             # Optional, self-signed certs
                             #:connection_options => { :ssl_verify_peer => false }

#
# Listing keystone tenants
#
keystone.tenants.each do |tenant|
  # <Fog::Identity::OpenStack::Tenant
  #   id="46b4ab...",
  #   description=nil,
  #   enabled=1,
  #   name="admin@example.net"
  # >
  #pp tenant
end

#
# List users
#
keystone.users.each do |user|
  # <Fog::Identity::OpenStack::User
  #   id="c975f...",
  #   email="quantum@example.net",
  #   enabled=true,
  #   name="quantum",
  #   tenant_id="00928...",
  #   password=nil
  # >
  # ...
  #pp user
end

#
# Create a new tenant
#
tenant = keystone.tenants.create :name        => 'rubiojr@example.net',
                                 :description => 'My foo tenant'

#
# Create a new user
#
user = keystone.users.create :name      => 'rubiojr@example.net',
                             :tenant_id => tenant.id,
                             :password  => 'rubiojr@example.net',
                             :email     => 'rubiojr@example.net'


# Find the recently created tenant
tenant = keystone.tenants.find { |t| t.name == 'rubiojr@example.net' }
# Destroy the tenant
tenant.destroy

# Find the recently created user 
user = keystone.users.find { |u| u.name == 'rubiojr@example.net' }
# Destroy the user
user.destroy