Sha256: 12e644a990eaf6ab9d02af0aa89d9063fd7fdbe94cd30d7a6f3459cd03330ad3

Contents?: true

Size: 2 KB

Versions: 32

Compression:

Stored size: 2 KB

Contents

module Fog
  module Compute
    class Ecloud
      class Network < Fog::Ecloud::Model

        identity :href

        ignore_attributes :xmlns, :xmlns_xsi, :xmlns_xsd, :xmlns_i, :Configuration, :Id

        attribute :name, :aliases => :Name
        #attribute :id, :aliases => :Id
        attribute :features, :aliases => :Features, :type => :array
        attribute :links, :aliases => :Link, :type => :array
        attribute :type
        attribute :gateway, :aliases => :GatewayAddress
        attribute :broadcast, :aliases => :BroadcastAddress
        attribute :address, :aliases => :Address
        attribute :rnat, :aliases => :RnatAddress
        attribute :extension_href, :aliases => :Href
        attribute :network_type, :aliases => :NetworkType
        attribute :vlan, :aliases => :Vlan
        attribute :friendly_name, :aliases => :FriendlyName

        def ips
          load_unless_loaded!
          connection.ips.new
          Fog::Compute::Ecloud::Ips.new(
            :connection => connection,
            :href => links.detect { |link| link[:name] == "IP Addresses" }[:href]
          )
        end

        def rnat=(new_rnat)
          attributes[:rnat] = new_rnat
          @changed = true
        end

        def save
          if @changed
            connection.configure_network( extension_href, _compose_network_data )
          end
          true
        end

        def reload
          super
          merge_attributes(extension_data.body)
          self
        end

        private

        def extension_data
          connection.get_network_extensions( extensions_link[:href] )
        end

        def extensions_link
          links.detect { |link| link[:name] == name }
        end

        def _compose_network_data
          {
            :id => id,
            :href => extension_href,
            :name => name,
            :rnat => rnat,
            :address => address,
            :broadcast => broadcast,
            :gateway => gateway
          }
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 8 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
michiels-fog-1.3.1 lib/fog/ecloud/models/compute/network.rb
ftl-0.2.0 vendor/bundle/gems/fog-1.3.1/lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.18.0 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
fog-1.3.1 lib/fog/ecloud/models/compute/network.rb
fog-1.3.0 lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.17.5 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
fog-1.2.0 lib/fog/ecloud/models/compute/network.rb
ktheory-fog-1.1.2 lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.17.4 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.17.3 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.17.2 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.17.1 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.17.0 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
fog-1.1.2 lib/fog/ecloud/models/compute/network.rb
fog_tractical-1.1.4 lib/fog/ecloud/models/compute/network.rb
fog_tractical-1.1.3 lib/fog/ecloud/models/compute/network.rb
brightbox-cli-0.16.0 lib/brightbox-cli/vendor/fog/lib/fog/ecloud/models/compute/network.rb
fog-1.1.1 lib/fog/ecloud/models/compute/network.rb
fog-1.1.0 lib/fog/ecloud/models/compute/network.rb