Sha256: cfdddd3eeaa3a3028cd7a6e2737a66300ee3474d5cbfcae6c7f53b77973be0e2

Contents?: true

Size: 773 Bytes

Versions: 3

Compression:

Stored size: 773 Bytes

Contents

module Yao::Resources
  class Tenant < Base
    friendly_attributes :id, :name, :description, :enabled

    self.service        = "identity"
    self.resource_name  = "tenant"
    self.resources_name = "tenants"
    self.admin          = true
    self.return_single_on_querying = true

    def servers
      @servers ||= Yao::Server.list(all_tenants: 1).select{|s| s.tenant_id == id }
    end

    def meters
      @meters ||= Yao::Meter.list({'q.field' => 'project_id', 'q.op' => 'eq', 'q.value' => id})
    end

    def ports
      @ports ||= Yao::Port.list(tenant_id: id)
    end

    def meters_by_name(meter_name)
      meters.select{|m| m.name == meter_name}
    end

    class << self
      def accessible
        as_member { self.list }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yao-0.9.1 lib/yao/resources/tenant.rb
yao-0.9.0 lib/yao/resources/tenant.rb
yao-0.8.0 lib/yao/resources/tenant.rb