Class: VSphereCloud::PersistentDisk
- Inherits:
-
Object
- Object
- VSphereCloud::PersistentDisk
- Defined in:
- lib/cloud/vsphere/resources/disk/persistent_disk.rb
Instance Method Summary collapse
- #create_spec(datacenter_name, host_info, controller_key, copy_disks) ⇒ Object
-
#initialize(disk_cid, cloud_searcher, resources, client, logger) ⇒ PersistentDisk
constructor
A new instance of PersistentDisk.
Constructor Details
#initialize(disk_cid, cloud_searcher, resources, client, logger) ⇒ PersistentDisk
Returns a new instance of PersistentDisk.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cloud/vsphere/resources/disk/persistent_disk.rb', line 5 def initialize(disk_cid, cloud_searcher, resources, client, logger) @model = Models::Disk.first(uuid: disk_cid) raise "Disk not found: #{disk_cid}" if @model.nil? @disk_size = @model.size.to_i @cloud_searcher = cloud_searcher @resources = resources @client = client @logger = logger end |
Instance Method Details
#create_spec(datacenter_name, host_info, controller_key, copy_disks) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/cloud/vsphere/resources/disk/persistent_disk.rb', line 17 def create_spec(datacenter_name, host_info, controller_key, copy_disks) need_to_create_disk = !disk_exists? destination_datacenter = @resources.datacenters[datacenter_name] if disk_exists? if disk_in_correct_datacenter?(destination_datacenter.name, host_info) @logger.info("Disk already in the right datastore #{destination_datacenter.name} #{@model.datastore}") persistent_datastore = @resources.persistent_datastore(@model.datacenter, host_info['cluster'], @model.datastore) else @logger.info("Disk needs to move from #{@model.datacenter} to #{destination_datacenter.name}") persistent_datastore = find_datastore(destination_datacenter, host_info) move_disk(persistent_datastore, destination_datacenter, copy_disks) update(persistent_datastore, destination_datacenter) end else @logger.info('Need to create disk') persistent_datastore = find_datastore(destination_datacenter, host_info) create_parent_folder(persistent_datastore.name, destination_datacenter) update(persistent_datastore, destination_datacenter) end DiskConfig.new(persistent_datastore, filename, controller_key, @disk_size). spec(independent: true, create: need_to_create_disk) end |