Sha256: 2e1166e3c37a1bf11e5758abf29d4fcb6f47d365fcdf12eda8b2586a99ed546c

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

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

        identity :href, :aliases => :Href

        ignore_attributes :xmlns, :xmlns_i

        attribute :ip_address, :aliases => :IpAddress
        attribute :description, :aliases => :Description
        attribute :name, :aliases => :Name
        attribute :port, :aliases => :Port
        attribute :enabled, :aliases => :Enabled
        attribute :id, :aliases => :Id

        def delete
          requires :href

          connection.delete_node( href )
        end

        def save
          if new_record?
            result = connection.add_node( collection.href, _compose_node_data )
            merge_attributes(result.body)
          else
            connection.configure_node( href, _compose_node_data )
          end
        end

        private

        def _compose_node_data
          node_data = {}
          self.class.attributes.select{ |attribute| !send(attribute).nil? }.each { |attribute| node_data[attribute] = send(attribute).to_s }
          node_data
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fog-0.8.2 lib/fog/compute/models/ecloud/node.rb
fog-0.8.1 lib/fog/compute/models/ecloud/node.rb
fog-0.8.0 lib/fog/compute/models/ecloud/node.rb
fog-0.7.2 lib/fog/compute/models/ecloud/node.rb
fog-0.7.1 lib/fog/compute/models/ecloud/node.rb
fog-0.7.0 lib/fog/compute/models/ecloud/node.rb
fog-0.6.0 lib/fog/compute/models/ecloud/node.rb