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.27 lib/fog/compute/openstack/models/flavor.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-openstack-0.1.26/lib/fog/compute/openstack/models/flavor.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-openstack-0.1.26/lib/fog/compute/openstack/models/flavor.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-openstack-0.1.26/lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.26 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.25 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.24 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.23 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.22 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.21 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.20 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.19 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.18 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.17 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.15 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.14 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.13 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.12 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.11 lib/fog/compute/openstack/models/flavor.rb
fog-openstack-0.1.10 lib/fog/openstack/models/compute/flavor.rb