Sha256: 2ce94da6fcf0ed6208190307df712217abb583d04317382176ba6410d3e05d8e

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

require 'date'

module Yao::Resources
  class LoadBalancer < Base
    friendly_attributes :provider, :description, :admin_state_up, :provisioning_status,
                        :pools, :vip_address,
                        :operationg_status, :name

    def created_at
      Date.parse(self["created_at"])
    end

    def updated_at
      Date.parse(self["updated_at"])
    end

    def project
      Yao::Tenant.find self["project_id"]
    end

    def vip_network
      Yao::Network.find self["vip_network_id"]
    end

    def vip_port
      Yao::Port.find self["vip_port_id"]
    end

    def vip_subnet
      Yao::Subnet.find self["vip_subnet_id"]
    end

    def listeners
      self["listeners"].map do |listener|
        Yao::LoadBalancerListener.find listener["id"]
      end
    end

    def pools
      self["pools"].map do |pool|
        Yao::LoadBalancerPool.find pool["id"]
      end
    end

    self.service        = "load-balancer"
    self.api_version    = "v2.0"
    self.resource_name  = "loadbalancer"
    self.resources_name = "loadbalancers"
    self.resources_path = "lbaas/loadbalancers"

    class << self
      alias :delete :destroy
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.3.6 lib/yao/resources/loadbalancer.rb