Sha256: 601fedaaa1ec77af36dbafefce14a51adb082f86f985a6bc97c1bf7fd96a1159

Contents?: true

Size: 1.54 KB

Versions: 39

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

39 entries across 39 versions & 2 rubygems

Version Path
fog-1.22.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.21.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.20.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/vcloud_director/models/compute/disk.rb
fog-1.19.0 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/vcloud_director/models/compute/disk.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/vcloud_director/models/compute/disk.rb