Class: Fog::Ecloud::MockDataClasses::MockVirtualMachine

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

Instance Method Summary collapse

Methods inherited from Base

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

Methods inherited from Hash

#symbolize_keys!

Constructor Details

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

Instance Method Details

#cpusObject



483
484
485
# File 'lib/fog/ecloud/mock_data_classes.rb', line 483

def cpus
  self[:cpus] || 1
end

#disksObject



491
492
493
# File 'lib/fog/ecloud/mock_data_classes.rb', line 491

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

#href(purpose = :base) ⇒ Object



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

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



479
480
481
# File 'lib/fog/ecloud/mock_data_classes.rb', line 479

def ip
  self[:ip]
end

#memoryObject



487
488
489
# File 'lib/fog/ecloud/mock_data_classes.rb', line 487

def memory
  self[:memory] || 1024
end

#nameObject



475
476
477
# File 'lib/fog/ecloud/mock_data_classes.rb', line 475

def name
  self[:name]
end

#network_ipObject



511
512
513
514
515
# File 'lib/fog/ecloud/mock_data_classes.rb', line 511

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

#power_off!Object



499
500
501
# File 'lib/fog/ecloud/mock_data_classes.rb', line 499

def power_off!
  self[:status] = 2
end

#power_on!Object



503
504
505
# File 'lib/fog/ecloud/mock_data_classes.rb', line 503

def power_on!
  self[:status] = 4
end

#sizeObject



507
508
509
# File 'lib/fog/ecloud/mock_data_classes.rb', line 507

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

#statusObject



495
496
497
# File 'lib/fog/ecloud/mock_data_classes.rb', line 495

def status
  self[:status] || 2
end

#to_configure_vapp_hashObject

from fog ecloud server’s _compose_vapp_data



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

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