Sha256: bd7b5b0520ef6cebf88834c77a0a8417107087424cd5d4916b7ba8bc2c7aeb1f

Contents?: true

Size: 1.98 KB

Versions: 12

Compression:

Stored size: 1.98 KB

Contents

# 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

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
cifrado-0.2.1 vendor/fog/lib/fog/openstack/README.identity.md
cifrado-0.2.0 vendor/fog/lib/fog/openstack/README.identity.md
hpfog-0.0.20 lib/fog/openstack/README.identity.md
cifrado-0.1.3 vendor/fog/lib/fog/openstack/README.identity.md
fog-1.10.0 lib/fog/openstack/README.identity.md
cifrado-0.1.2 vendor/fog/lib/fog/openstack/README.identity.md
cifrado-0.1.1 vendor/fog/lib/fog/openstack/README.identity.md
cifrado-0.1 vendor/fog/lib/fog/openstack/README.identity.md
fog-1.9.0 lib/fog/openstack/README.identity.md
fog-maestrodev-1.8.0.20130114204828 lib/fog/openstack/README.identity.md
fog-maestrodev-1.8.0.20130111070250 lib/fog/openstack/README.identity.md
fog-maestrodev-1.8.0.20130109172219 lib/fog/openstack/README.identity.md