Sha256: 65f6ffec2e0040597a6899494ad35740c5ab4e286fa10593c0bc1b27e1087e66

Contents?: true

Size: 812 Bytes

Versions: 7

Compression:

Stored size: 812 Bytes

Contents

require 'fog/core/collection'
require 'fog/openstack/models/identity/tenant'

module Fog
  module Identity
    class OpenStack
      class Tenants < Fog::Collection
        model Fog::Identity::OpenStack::Tenant

        def all
          load(connection.list_tenants.body['tenants'])
        end

        def find_by_id(id)
          cached_tenant = self.find {|tenant| tenant.id == id}
          return cached_tenant if cached_tenant
          tenant_hash = connection.get_tenant(id).body['tenant']
          Fog::Identity::OpenStack::Tenant.new(
            tenant_hash.merge(:connection => connection))
        end

        def destroy(id)
          tenant = self.find_by_id(id)
          tenant.destroy
        end
      end # class Tenants
    end # class OpenStack
  end # module Compute
end # module Fog

Version data entries

7 entries across 7 versions & 5 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/openstack/models/identity/tenants.rb
fog-nirvanix-1.8.1 lib/fog/openstack/models/identity/tenants.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/openstack/models/identity/tenants.rb
fog-sgonyea-1.8.1 lib/fog/openstack/models/identity/tenants.rb
fog-1.8.0 lib/fog/openstack/models/identity/tenants.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/openstack/models/identity/tenants.rb
fog-1.7.0 lib/fog/openstack/models/identity/tenants.rb