Sha256: 5ff264950799f4732d63407b0cb2467faecb4852223484e9d8a108a73c0eb11b

Contents?: true

Size: 1.83 KB

Versions: 8

Compression:

Stored size: 1.83 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class Brightbox

      class CloudIp < Fog::Model

        identity :id
        attribute :url
        attribute :resource_type

        attribute :name
        attribute :status
        attribute :description

        attribute :reverse_dns
        attribute :public_ip

        # Links - to be replaced
        attribute :account_id, :aliases => "account", :squash => "id"
        attribute :interface_id, :aliases => "interface", :squash => "id"
        attribute :server_id, :aliases => "server", :squash => "id"
        attribute :load_balancer, :alias => "load_balancer", :squash => "id"
        attribute :server_group, :alias => "server_group", :squash => "id"
        attribute :database_server, :alias => "database_server", :squash => "id"
        attribute :port_translators
        attribute :name

        # Attempt to map or point the Cloud IP to the destination resource.
        #
        # @param [Object] destination
        #
        def map(destination)
          requires :identity
          if destination.respond_to?(:mapping_identity)
            final_destination = destination.mapping_identity
          elsif destination.respond_to?(:identity)
            final_destination = destination.identity
          else
            final_destination = destination
          end
          service.map_cloud_ip(identity, :destination => final_destination)
        end

        def mapped?
          status == "mapped"
        end

        def unmap
          requires :identity
          service.unmap_cloud_ip(identity)
        end

        def destroy
          requires :identity
          service.destroy_cloud_ip(identity)
        end

        def destination_id
          server_id || load_balancer || server_group || database_server || interface_id
        end

      end

    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
fog-brightbox-0.1.0.dev2 lib/fog/brightbox/models/compute/cloud_ip.rb
fog-brightbox-0.1.0.dev1 lib/fog/brightbox/models/compute/cloud_ip.rb
fog-brightbox-0.0.2 lib/fog/brightbox/models/compute/cloud_ip.rb
fog-1.21.0 providers/brightbox/lib/fog/brightbox/models/compute/cloud_ip.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/brightbox/models/compute/cloud_ip.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/brightbox/models/compute/cloud_ip.rb
fog-brightbox-0.0.1 lib/fog/brightbox/models/compute/cloud_ip.rb
fog-1.20.0 lib/fog/brightbox/models/compute/cloud_ip.rb