Sha256: e9500a5788c901138efd2665fe8f896b7872554b7f2d683da6c110683ca5a8f3

Contents?: true

Size: 1.26 KB

Versions: 91

Compression:

Stored size: 1.26 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class OpenStack
      class Flavor < Fog::Model
        identity :id

        attribute :name
        attribute :ram
        attribute :disk
        attribute :vcpus
        attribute :links
        attribute :swap
        attribute :rxtx_factor
        attribute :ephemeral, :aliases => 'OS-FLV-EXT-DATA:ephemeral'
        attribute :is_public, :aliases => 'os-flavor-access:is_public'
        attribute :disabled, :aliases => 'OS-FLV-DISABLED:disabled'

        def initialize(attributes)
          # Old 'connection' is renamed as service and should be used instead
          prepare_service_value(attributes)
          super
        end

        def save
          requires :name, :ram, :vcpus, :disk
          attributes[:ephemeral] = self.ephemeral || 0
          attributes[:is_public] = self.is_public || false
          attributes[:disabled] = self.disabled || false
          attributes[:swap] = self.swap || 0
          attributes[:rxtx_factor] = self.rxtx_factor || 1.0
          merge_attributes(service.create_flavor(self.attributes).body['flavor'])
          self
        end

        def destroy
          requires :id
          service.delete_flavor(self.id)
          true
        end
      end
    end
  end
end

Version data entries

91 entries across 91 versions & 10 rubygems

Version Path
fog-1.10.1 lib/fog/openstack/models/compute/flavor.rb
fog-test-me-1.10.0 lib/fog/openstack/models/compute/flavor.rb
cifrado-0.1.3 vendor/fog/lib/fog/openstack/models/compute/flavor.rb
fog-1.10.0 lib/fog/openstack/models/compute/flavor.rb
cifrado-0.1.2 vendor/fog/lib/fog/openstack/models/compute/flavor.rb
cifrado-0.1.1 vendor/fog/lib/fog/openstack/models/compute/flavor.rb
cifrado-0.1 vendor/fog/lib/fog/openstack/models/compute/flavor.rb
fog-1.9.0 lib/fog/openstack/models/compute/flavor.rb
fog-maestrodev-1.8.0.20130114204828 lib/fog/openstack/models/compute/flavor.rb
fog-maestrodev-1.8.0.20130111070250 lib/fog/openstack/models/compute/flavor.rb
fog-maestrodev-1.8.0.20130109172219 lib/fog/openstack/models/compute/flavor.rb