Sha256: 02d84bfb0c1b8e94b208721e06abdd04757b47aad7852b9aa1d04ffeb799629d

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

module Fog
  module Compute
    class Ecloud
      class IpAddress < Fog::Ecloud::Model
        identity :href

        attribute :name, :aliases => :Name
        attribute :type, :aliases => :Type
        attribute :other_links, :aliases => :Links, :squash => :Link
        attribute :host, :aliases => :Host
        attribute :detected_on, :aliases => :DetectedOn
        attribute :rnat, :aliases => :RnatAddress
        attribute :reserved, :aliases => :Reserved, :type => :boolean

        def status
          (detected_on || host) ? "Assigned" : "Available"
        end

        def id
          href.match(/((\d+{1,3}\.){3}(\d+{1,3}))$/)[1]
        end

        def server
          @server ||= begin
                        reload unless other_links
                        server_link = other_links.find{|l| l[:type] == "application/vnd.tmrk.cloud.virtualMachine"}
                        self.connection.servers.get(server_link[:href])
                      end
        end

        def network
          reload if other_links.nil?
          network_href = other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.network" }[:href]
          network      = self.connection.networks.get(network_href)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
fog-maestrodev-1.8.0.20130114204828 lib/fog/ecloud/models/compute/ip_address.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/ecloud/models/compute/ip_address.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/ecloud/models/compute/ip_address.rb