Sha256: fb5a47931a8e20855153dd0be44bb7a2fbf08cb5cda09503f66851ea297b750f

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

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

        attribute :name,              :aliases => :Name
        attribute :type,              :aliases => :Type
        attribute :other_links,       :aliases => :Links, :squash => :Link
        attribute :address,           :aliases => :Address
        attribute :network_type,      :aliases => :NetworkType
        attribute :broadcast_address, :aliases => :BroadcastAddress
        attribute :gateway_address,   :aliases => :GatewayAddress
        attribute :rnat_address,      :aliases => :RnatAddress

        def rnats
          @rnats ||= Fog::Compute::Ecloud::Rnats.new(:service => service, :href => "#{service.base_path}/rnats/networks/#{id}")
        end

        def ips
          @ips ||= Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => href)
        end

        def edit_rnat_association(options)
          options[:uri] = href
          data = service.rnat_associations_edit_network(options).body
          task = Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
        end

        def id
          href.scan(/\d+/)[0]
        end

        def environment
          reload if other_links.nil?
          environment_href = other_links.find { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href]
          self.service.environments.get(environment_href)
        end

        def location
          environment.id
        end

        def reload
          @rnats = nil
          @ips = nil
          super
        end
      end
    end
  end
end

Version data entries

7 entries across 5 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/models/network.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/models/network.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/models/network.rb
fog-ecloud-0.3.0 lib/fog/compute/ecloud/models/network.rb
fog-ecloud-0.2.0 lib/fog/compute/ecloud/models/network.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/models/network.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/models/network.rb