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

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/compute/ecloud.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::Ecloud::MockDataClasses::Base

Instance Method Details

#cpusObject



516
517
518
# File 'lib/fog/compute/ecloud.rb', line 516

def cpus
  self[:cpus] || 1
end

#disksObject



524
525
526
# File 'lib/fog/compute/ecloud.rb', line 524

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

#href(purpose = :base) ⇒ Object



560
561
562
563
564
565
566
567
568
569
# File 'lib/fog/compute/ecloud.rb', line 560

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



512
513
514
# File 'lib/fog/compute/ecloud.rb', line 512

def ip
  self[:ip]
end

#memoryObject



520
521
522
# File 'lib/fog/compute/ecloud.rb', line 520

def memory
  self[:memory] || 1024
end

#nameObject



508
509
510
# File 'lib/fog/compute/ecloud.rb', line 508

def name
  self[:name]
end

#network_ipObject



544
545
546
547
548
# File 'lib/fog/compute/ecloud.rb', line 544

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

#power_off!Object



532
533
534
# File 'lib/fog/compute/ecloud.rb', line 532

def power_off!
  self[:status] = 2
end

#power_on!Object



536
537
538
# File 'lib/fog/compute/ecloud.rb', line 536

def power_on!
  self[:status] = 4
end

#sizeObject



540
541
542
# File 'lib/fog/compute/ecloud.rb', line 540

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

#statusObject



528
529
530
# File 'lib/fog/compute/ecloud.rb', line 528

def status
  self[:status] || 2
end

#to_configure_vapp_hashObject

from fog ecloud server’s _compose_vapp_data



551
552
553
554
555
556
557
558
# File 'lib/fog/compute/ecloud.rb', line 551

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