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
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/openstack/models/compute/flavor.rb
fog-1.30.0 lib/fog/openstack/models/compute/flavor.rb
fog-1.29.0 lib/fog/openstack/models/compute/flavor.rb
fog-1.28.0 lib/fog/openstack/models/compute/flavor.rb
fog-1.27.0 lib/fog/openstack/models/compute/flavor.rb
fog-1.26.0 lib/fog/openstack/models/compute/flavor.rb
fog-1.25.0 lib/fog/openstack/models/compute/flavor.rb
nsidc-fog-1.24.1 lib/fog/openstack/models/compute/flavor.rb
fog-1.24.0 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.11 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.10 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.9 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.8 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.7 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.6 lib/fog/openstack/models/compute/flavor.rb
fog-1.23.0 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.4 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.3 lib/fog/openstack/models/compute/flavor.rb
ns-fog-1.22.2 lib/fog/openstack/models/compute/flavor.rb
fog-1.22.1 lib/fog/openstack/models/compute/flavor.rb