Sha256: cffbe6918161c031362ffca68504c74ed6d3deeb0eb6c0a4ac322e64cd0c87de

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

module Yao::Resources
  class FloatingIP < Base

    include PortAssociationable
    include ProjectAssociationable

    friendly_attributes :router_id, :description, :dns_domain, :dns_name,
                        :revision_number,
                        :floating_network_id, :fixed_ip_address,
                        :floating_ip_address,
                        :status, :port_details, :tags, :port_forwardings

    map_attributes_to_time :created_at, :updated_at
    alias :created :created_at
    alias :updated :updated_at

    self.service        = "network"
    self.resource_name  = "floatingip"
    self.resources_name = "floatingips"

    # @return [Yao::Resources::Router]
    def router
      @router ||= Yao::Router.get(router_id)
    end

    # @param [Yao::Resources::Port]
    # @return [Yao::Resources::FloatingIP]
    def associate_port(port)
      self.class.associate_port(id, port.id)
    end

    # @return [Yao::Resources::FloatingIP]
    def disassociate_port
      self.class.disassociate_port(id)
    end

    class << self

      # @param id [String] ID of floating_ip
      # @param port_id [String] ID of port
      # @return [Yao::Resources::FloatingIP]
      def associate_port(id, port_id)
        update(id, port_id: port_id)
      end

      # @param id [String] ID of floating_ip
      # @return [Yao::Resources::FloatingIP]
      def disassociate_port(id)
        update(id, port_id: nil)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yao-0.21.0 lib/yao/resources/floating_ip.rb
yao-0.20.0 lib/yao/resources/floating_ip.rb
yao-0.19.0 lib/yao/resources/floating_ip.rb