2012-02-22 09:40:32 -05:00
|
|
|
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
|
2012-12-22 18:24:36 -05:00
|
|
|
load(service.list_tenants.body['tenants'])
|
2012-02-22 09:40:32 -05:00
|
|
|
end
|
2012-02-26 03:09:22 -05:00
|
|
|
|
|
|
|
def find_by_id(id)
|
2012-10-02 01:52:45 -04:00
|
|
|
cached_tenant = self.find {|tenant| tenant.id == id}
|
|
|
|
return cached_tenant if cached_tenant
|
2012-12-22 18:24:36 -05:00
|
|
|
tenant_hash = service.get_tenant(id).body['tenant']
|
2012-10-02 01:52:45 -04:00
|
|
|
Fog::Identity::OpenStack::Tenant.new(
|
2012-12-22 18:24:36 -05:00
|
|
|
tenant_hash.merge(:service => service))
|
2012-02-26 03:09:22 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy(id)
|
|
|
|
tenant = self.find_by_id(id)
|
|
|
|
tenant.destroy
|
|
|
|
end
|
2012-02-22 09:40:32 -05:00
|
|
|
end # class Tenants
|
|
|
|
end # class OpenStack
|
|
|
|
end # module Compute
|
|
|
|
end # module Fog
|