Class: Fog::Vcloud::MockDataClasses::MockVirtualMachine

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/vcloud/mock_data_classes.rb

Instance Method Summary collapse

Methods inherited from Base

#_parent, base_url, #base_url, base_url=, #first, #initialize, #inspect, #last

Constructor Details

This class inherits a constructor from Fog::Vcloud::MockDataClasses::Base

Instance Method Details

#cpusObject



484
485
486
# File 'lib/fog/vcloud/mock_data_classes.rb', line 484

def cpus
  self[:cpus] || 1
end

#disksObject



492
493
494
# File 'lib/fog/vcloud/mock_data_classes.rb', line 492

def disks
  @disks ||= MockVirtualMachineDisks.new(self)
end

#href(purpose = :base) ⇒ Object



528
529
530
531
532
533
534
535
536
537
# File 'lib/fog/vcloud/mock_data_classes.rb', line 528

def href(purpose = :base)
  case purpose
  when :base
    super()
  when :power_on
    super() + "/power/action/powerOn"
  when :power_off
    super() + "/power/action/powerOff"
  end
end

#ipObject



480
481
482
# File 'lib/fog/vcloud/mock_data_classes.rb', line 480

def ip
  self[:ip]
end

#memoryObject



488
489
490
# File 'lib/fog/vcloud/mock_data_classes.rb', line 488

def memory
  self[:memory] || 1024
end

#nameObject



476
477
478
# File 'lib/fog/vcloud/mock_data_classes.rb', line 476

def name
  self[:name]
end

#network_ipObject



512
513
514
515
516
# File 'lib/fog/vcloud/mock_data_classes.rb', line 512

def network_ip
  if network = _parent.networks.detect {|n| n.ip_collection.items[ip] }
    network.ip_collection.items[ip]
  end
end

#power_off!Object



500
501
502
# File 'lib/fog/vcloud/mock_data_classes.rb', line 500

def power_off!
  self[:status] = 2
end

#power_on!Object



504
505
506
# File 'lib/fog/vcloud/mock_data_classes.rb', line 504

def power_on!
  self[:status] = 4
end

#sizeObject



508
509
510
# File 'lib/fog/vcloud/mock_data_classes.rb', line 508

def size
  disks.inject(0) {|s, d| s + d.vcloud_size }
end

#statusObject



496
497
498
# File 'lib/fog/vcloud/mock_data_classes.rb', line 496

def status
  self[:status] || 2
end

#to_configure_vapp_hashObject

from fog ecloud server’s _compose_vapp_data



519
520
521
522
523
524
525
526
# File 'lib/fog/vcloud/mock_data_classes.rb', line 519

def to_configure_vapp_hash
  {
    :name   => name,
    :cpus   => cpus,
    :memory => memory,
    :disks  => disks.map {|d| { :number => d.address.to_s, :size => d.vcloud_size, :resource => d.vcloud_size.to_s } }
  }
end