Sha256: 24cd799145f855bdc7672d6e00eb1e40c442f47bad24899f1c02ee2415ef9692

Contents?: true

Size: 1.74 KB

Versions: 44

Compression:

Stored size: 1.74 KB

Contents

require 'fog/openstack/models/model'

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

        attribute :name
        attribute :ram
        attribute :disk
        attribute :vcpus
        attribute :links
        attribute :swap
        attribute :rxtx_factor
        attribute :metadata
        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 save
          requires :name, :ram, :vcpus, :disk
          attributes[:ephemeral] = ephemeral || 0
          attributes[:is_public] = is_public || false
          attributes[:disabled] = disabled || false
          attributes[:swap] = swap || 0
          attributes[:rxtx_factor] = rxtx_factor || 1.0
          merge_attributes(service.create_flavor(attributes).body['flavor'])
          self
        end

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

        def metadata
          service.get_flavor_metadata(id).body['extra_specs']
        rescue Fog::Compute::OpenStack::NotFound
          nil
        end

        def create_metadata(metadata)
          service.create_flavor_metadata(id, metadata)
        rescue Fog::Compute::OpenStack::NotFound
          nil
        end

        def update_metadata(key, value)
          service.update_flavor_metadata(id, key, value)
        rescue Fog::Compute::OpenStack::NotFound
          nil
        end

        def delete_metadata(key)
          service.delete_flavor_metadata(id, key)
        rescue Fog::Compute::OpenStack::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

44 entries across 42 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.10 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.30 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.29 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.9 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.28 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.8 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.7 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.6 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.5 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.4 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.3 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.2 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.3.0 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.2.4 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.2.3 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.2.2 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.2.1 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.2.0 lib/fog/compute/openstack/models/flavor.rb
fog-zj-0.1.28 lib/fog/compute/openstack/models/flavor.rb