Sha256: 96dfa90ce7a7f726052d05f340eec8157938041525caadd3b2a879d0ece65401

Contents?: true

Size: 1.54 KB

Versions: 43

Compression:

Stored size: 1.54 KB

Contents

require 'fog/core/model'

module Fog
  module Compute
    class VcloudDirector
      class Disk < Model # there is no lazy_load in disks
        identity  :id

        attribute :address
        attribute :description
        attribute :name
        attribute :resource_sub_type
        attribute :resource_type
        attribute :address_on_parent
        attribute :parent
        attribute :capacity
        attribute :bus_sub_type
        attribute :bus_type

        # TODO Virtual machine disk sizes may only be increased, not decreased.
        def capacity=(new_capacity)
          has_changed = ( capacity != new_capacity.to_i )
          not_first_set = !capacity.nil?
          attributes[:capacity] = new_capacity.to_i
          if not_first_set && has_changed
            data = Fog::Generators::Compute::VcloudDirector::Disks.new(all_disks)
            num_disk = name.scan(/\d+/).first.to_i
            data.modify_hard_disk_size(num_disk, new_capacity)
            response = service.put_disks(attributes[:vm].id, data.disks)
            service.process_task(response.body)
          end
        end

        def all_disks
          attributes[:all_disks] # this is passed at instantiation time
        end

        def destroy
          num_disk = name.scan(/\d+/).first.to_i
          data = Fog::Generators::Compute::VcloudDirector::Disks.new(all_disks)
          data.delete_hard_disk(num_disk)
          response = service.put_disks(attributes[:vm].id, data.disks)
          service.process_task(response.body)
        end
      end
    end
  end
end

Version data entries

43 entries across 41 versions & 6 rubygems

Version Path
fog-2.3.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-ifeel-2.2.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-2.2.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-2.1.0 lib/fog/vcloud_director/models/compute/disk.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/vcloud_director/models/compute/disk.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/vcloud_director/models/compute/disk.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/vcloud_director/models/compute/disk.rb
fog-1.42.1 lib/fog/vcloud_director/models/compute/disk.rb
fog-2.0.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.42.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.41.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.40.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.39.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.38.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.37.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.36.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.35.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-2.0.0.pre.0 lib/fog/vcloud_director/models/compute/disk.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/vcloud_director/models/compute/disk.rb
fog-1.34.0 lib/fog/vcloud_director/models/compute/disk.rb