Sha256: 2d98a85505df3a964ddb6e713ac197dfb483584e204b075a230d193d6d6a5af7

Contents?: true

Size: 1.43 KB

Versions: 65

Compression:

Stored size: 1.43 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class IBM
      class Address < Fog::Model

        STATES = {
          0 => 'New',
          1 => 'Allocating',
          2 => 'Free',
          3 => 'Attached',
          4 => 'Releasing',
          5 => 'Released',
          6 => 'Failed',
          7 => 'Release pending',
        }

        identity :id

        attribute :type
        attribute :location
        attribute :ip
        attribute :state
        attribute :instance_id, :aliases => 'instanceId'
        attribute :offering_id, :aliases => 'offeringId'
        attribute :vlan_id, :aliases => 'vlanId'
        attribute :hostname
        attribute :mode
        attribute :owner

        def initialize(new_attributes={})
          super(new_attributes)
          self.offering_id ||= '20001223'
          self.location ||= '82'
        end

        def save
          requires :offering_id, :location
          data = service.create_address(location, offering_id,
                                           :vlan_id => vlan_id,
                                           :ip => ip)
          merge_attributes(data.body)
          true
        end

        def state
          STATES[attributes[:state]]
        end

        def ready?
          state == 'Free' || state == 'Released'
        end

        def destroy
          requires :id
          service.delete_address(id).body['success']
        end
      end
    end
  end
end

Version data entries

65 entries across 65 versions & 6 rubygems

Version Path
fog-1.22.0 lib/fog/ibm/models/compute/address.rb
fog-1.21.0 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/ibm/models/compute/address.rb
fog-1.20.0 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/ibm/models/compute/address.rb
fog-1.19.0 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/ibm/models/compute/address.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/ibm/models/compute/address.rb