Class: Fog::Ecloud::MockDataClasses::MockVirtualMachine
- Inherits:
-
Base
- Object
- Hash
- Base
- Fog::Ecloud::MockDataClasses::MockVirtualMachine
show all
- Defined in:
- lib/rackspace-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!
Instance Method Details
#cpus ⇒ Object
485
486
487
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 485
def cpus
self[:cpus] || 1
end
|
#disks ⇒ Object
493
494
495
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 493
def disks
@disks ||= MockVirtualMachineDisks.new(self)
end
|
#href(purpose = :base) ⇒ Object
529
530
531
532
533
534
535
536
537
538
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 529
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
|
#ip ⇒ Object
481
482
483
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 481
def ip
self[:ip]
end
|
#memory ⇒ Object
489
490
491
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 489
def memory
self[:memory] || 1024
end
|
#name ⇒ Object
477
478
479
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 477
def name
self[:name]
end
|
#network_ip ⇒ Object
513
514
515
516
517
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 513
def network_ip
if network = _parent.networks.detect {|n| n.ip_collection.items[ip] }
network.ip_collection.items[ip]
end
end
|
#power_off! ⇒ Object
501
502
503
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 501
def power_off!
self[:status] = 2
end
|
#power_on! ⇒ Object
505
506
507
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 505
def power_on!
self[:status] = 4
end
|
#size ⇒ Object
509
510
511
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 509
def size
disks.inject(0) {|s, d| s + d.vcloud_size }
end
|
#status ⇒ Object
497
498
499
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 497
def status
self[:status] || 2
end
|
from fog ecloud server’s _compose_vapp_data
520
521
522
523
524
525
526
527
|
# File 'lib/rackspace-fog/ecloud/mock_data_classes.rb', line 520
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
|