Sha256: 5f0387a42bcd94428cc8f8b7ea349586c1e9b6042e065919df580c6684463342

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 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

    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

1 entries across 1 versions & 1 rubygems

Version Path
yao-0.18.0 lib/yao/resources/floating_ip.rb