Sha256: d2d2f02fa6fb8abb2006b603507f050a40e985e31b84c020d9d8609d5bc24c75

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 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)
          @connection = attributes[:connection]
          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(connection.create_flavor(self.attributes).body['flavor'])
          self
        end

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

Version data entries

5 entries across 5 versions & 4 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/openstack/models/compute/flavor.rb
fog-nirvanix-1.8.1 lib/fog/openstack/models/compute/flavor.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/openstack/models/compute/flavor.rb
fog-sgonyea-1.8.1 lib/fog/openstack/models/compute/flavor.rb
fog-1.8.0 lib/fog/openstack/models/compute/flavor.rb