Sha256: 9a4fa66207e489aeaa7ad5e7842ed413b00aa2ea399a8517f727203f860e8c11

Contents?: true

Size: 886 Bytes

Versions: 19

Compression:

Stored size: 886 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_detail(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 get_by_name(name)
        self.list(name: name)
      end
      alias find_by_name get_by_name

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

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
yao-0.6.3 lib/yao/resources/tenant.rb
yao-0.6.2 lib/yao/resources/tenant.rb
yao-0.6.1 lib/yao/resources/tenant.rb
yao-0.6.0 lib/yao/resources/tenant.rb
yao-0.5.0 lib/yao/resources/tenant.rb
yao-0.4.3 lib/yao/resources/tenant.rb
yao-0.4.2 lib/yao/resources/tenant.rb
yao-0.4.1 lib/yao/resources/tenant.rb
yao-0.4.0 lib/yao/resources/tenant.rb
yao-0.3.8 lib/yao/resources/tenant.rb
yao-0.3.7 lib/yao/resources/tenant.rb
yao-0.3.6 lib/yao/resources/tenant.rb
yao-0.3.5 lib/yao/resources/tenant.rb
yao-0.3.4 lib/yao/resources/tenant.rb
yao-0.3.3 lib/yao/resources/tenant.rb
yao-0.3.2 lib/yao/resources/tenant.rb
yao-0.3.1 lib/yao/resources/tenant.rb
yao-0.3.0 lib/yao/resources/tenant.rb
yao-0.2.13 lib/yao/resources/tenant.rb